From 489a965500d4101b147a4a106fdbef051f97dcc7 Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Thu, 2 Aug 2007 09:13:40 +0000 Subject: [PATCH] MDL-10336, upgrading YUI to 2.3.0 --- lib/yui/animation/README | 18 + lib/yui/animation/animation-debug.js | 62 +- lib/yui/animation/animation-min.js | 21 +- lib/yui/animation/animation.js | 62 +- lib/yui/assets/skins/sam/autocomplete.css | 7 + lib/yui/assets/skins/sam/blankimage.png | Bin 0 -> 2314 bytes lib/yui/assets/skins/sam/button.css | 7 + lib/yui/assets/skins/sam/calendar.css | 7 + lib/yui/assets/skins/sam/colorpicker.css | 7 + lib/yui/assets/skins/sam/container.css | 7 + lib/yui/assets/skins/sam/datatable.css | 7 + lib/yui/assets/skins/sam/dt-arrow-dn.png | Bin 0 -> 111 bytes lib/yui/assets/skins/sam/dt-arrow-up.png | Bin 0 -> 111 bytes lib/yui/assets/skins/sam/editor-knob.gif | Bin 0 -> 138 bytes .../assets/skins/sam/editor-sprite-active.gif | Bin 0 -> 5298 bytes lib/yui/assets/skins/sam/editor-sprite.gif | Bin 0 -> 5324 bytes lib/yui/assets/skins/sam/editor.css | 7 + lib/yui/assets/skins/sam/hue_bg.png | Bin 0 -> 1120 bytes lib/yui/assets/skins/sam/logger.css | 7 + .../skins/sam/menu-button-arrow-disabled.png | Bin 0 -> 173 bytes .../assets/skins/sam/menu-button-arrow.png | Bin 0 -> 173 bytes lib/yui/assets/skins/sam/menu.css | 7 + lib/yui/assets/skins/sam/picker_mask.png | Bin 0 -> 12174 bytes lib/yui/assets/skins/sam/skin.css | 18 + .../skins/sam/split-button-arrow-active.png | Bin 0 -> 280 bytes .../skins/sam/split-button-arrow-disabled.png | Bin 0 -> 185 bytes .../skins/sam/split-button-arrow-focus.png | Bin 0 -> 185 bytes .../skins/sam/split-button-arrow-hover.png | Bin 0 -> 185 bytes .../assets/skins/sam/split-button-arrow.png | Bin 0 -> 185 bytes lib/yui/assets/skins/sam/sprite.png | Bin 0 -> 3123 bytes lib/yui/assets/skins/sam/tabview.css | 7 + lib/yui/assets/skins/sam/treeview-loading.gif | Bin 0 -> 2673 bytes lib/yui/assets/skins/sam/treeview-sprite.gif | Bin 0 -> 3900 bytes lib/yui/assets/skins/sam/treeview.css | 7 + lib/yui/assets/skins/sam/yuitest.css | 7 + lib/yui/autocomplete/README | 51 + .../autocomplete/assets/autocomplete-core.css | 7 + .../assets/skins/sam/autocomplete-skin.css | 50 + .../assets/skins/sam/autocomplete.css | 7 + lib/yui/autocomplete/autocomplete-debug.js | 6342 +++--- lib/yui/autocomplete/autocomplete-min.js | 366 +- lib/yui/autocomplete/autocomplete.js | 6247 +++--- lib/yui/base/README | 5 + lib/yui/base/base-min.css | 7 + lib/yui/base/base.css | 76 + lib/yui/button/README | 272 + lib/yui/button/assets/background.png | Bin 0 -> 129 bytes lib/yui/button/assets/button-core.css | 6 + lib/yui/button/assets/button.css | 215 + lib/yui/button/assets/menuarrow.gif | Bin 0 -> 67 bytes .../button/assets/skins/sam/button-skin.css | 245 + lib/yui/button/assets/skins/sam/button.css | 7 + .../skins/sam/menu-button-arrow-disabled.png | Bin 0 -> 173 bytes .../assets/skins/sam/menu-button-arrow.png | Bin 0 -> 173 bytes .../skins/sam/split-button-arrow-active.png | Bin 0 -> 280 bytes .../skins/sam/split-button-arrow-disabled.png | Bin 0 -> 185 bytes .../skins/sam/split-button-arrow-focus.png | Bin 0 -> 185 bytes .../skins/sam/split-button-arrow-hover.png | Bin 0 -> 185 bytes .../assets/skins/sam/split-button-arrow.png | Bin 0 -> 185 bytes lib/yui/button/assets/splitarrow.gif | Bin 0 -> 145 bytes lib/yui/button/assets/splitarrow_active.gif | Bin 0 -> 145 bytes lib/yui/button/button-beta-debug.js | 4554 +++++ lib/yui/button/button-beta-min.js | 162 + lib/yui/button/button-beta.js | 4477 +++++ lib/yui/calendar/README | 33 + lib/yui/calendar/assets/calendar-core.css | 88 + lib/yui/calendar/assets/calendar.css | 36 +- .../assets/skins/sam/calendar-skin.css | 231 + .../calendar/assets/skins/sam/calendar.css | 7 + lib/yui/calendar/calendar-debug.js | 2638 ++- lib/yui/calendar/calendar-min.js | 153 +- lib/yui/calendar/calendar.js | 2599 ++- lib/yui/colorpicker/README | 4 + .../colorpicker/assets/colorpicker_core.css | 6 + lib/yui/colorpicker/assets/hue_thumb.png | Bin 0 -> 195 bytes lib/yui/colorpicker/assets/picker_mask.png | Bin 0 -> 12174 bytes lib/yui/colorpicker/assets/picker_thumb.png | Bin 0 -> 192 bytes .../assets/skins/sam/colorpicker-skin.css | 105 + .../assets/skins/sam/colorpicker.css | 7 + .../colorpicker/assets/skins/sam/hue_bg.png | Bin 0 -> 1120 bytes .../assets/skins/sam/picker_mask.png | Bin 0 -> 12174 bytes lib/yui/colorpicker/colorpicker-beta-debug.js | 1745 ++ lib/yui/colorpicker/colorpicker-beta-min.js | 33 + lib/yui/colorpicker/colorpicker-beta.js | 1725 ++ lib/yui/connection/README | 77 + lib/yui/connection/connection-debug.js | 594 +- lib/yui/connection/connection-min.js | 124 +- lib/yui/connection/connection.js | 674 +- lib/yui/container/README | 665 +- lib/yui/container/assets/container-core.css | 176 + lib/yui/container/assets/container.css | 243 +- .../assets/skins/sam/container-skin.css | 302 + .../container/assets/skins/sam/container.css | 7 + lib/yui/container/container-debug.js | 12923 ++++++++----- lib/yui/container/container-min.js | 362 +- lib/yui/container/container.js | 12864 +++++++----- lib/yui/container/container_core-debug.js | 7436 ++++--- lib/yui/container/container_core-min.js | 206 +- lib/yui/container/container_core.js | 7408 ++++--- lib/yui/datasource/README | 47 + lib/yui/datasource/datasource-beta-debug.js | 1430 ++ lib/yui/datasource/datasource-beta-min.js | 102 + lib/yui/datasource/datasource-beta.js | 1365 ++ lib/yui/datatable/README | 211 + lib/yui/datatable/assets/datatable-core.css | 48 + lib/yui/datatable/assets/datatable.css | 49 + .../assets/skins/sam/datatable-skin.css | 193 + .../datatable/assets/skins/sam/datatable.css | 7 + .../assets/skins/sam/dt-arrow-dn.png | Bin 0 -> 111 bytes .../assets/skins/sam/dt-arrow-up.png | Bin 0 -> 111 bytes lib/yui/datatable/datatable-beta-debug.js | 9117 +++++++++ lib/yui/datatable/datatable-beta-min.js | 486 + lib/yui/datatable/datatable-beta.js | 8943 +++++++++ lib/yui/dom/README | 28 + lib/yui/dom/dom-debug.js | 689 +- lib/yui/dom/dom-min.js | 103 +- lib/yui/dom/dom.js | 624 +- lib/yui/dragdrop/README | 35 + lib/yui/dragdrop/dragdrop-debug.js | 4603 ++--- lib/yui/dragdrop/dragdrop-min.js | 121 +- lib/yui/dragdrop/dragdrop.js | 4345 +++-- lib/yui/editor/README | 68 + lib/yui/editor/assets/editor-core.css | 633 + .../editor/assets/skins/sam/blankimage.png | Bin 0 -> 2314 bytes .../editor/assets/skins/sam/editor-knob.gif | Bin 0 -> 138 bytes .../editor/assets/skins/sam/editor-skin.css | 534 + .../assets/skins/sam/editor-sprite-active.gif | Bin 0 -> 5298 bytes .../editor/assets/skins/sam/editor-sprite.gif | Bin 0 -> 5324 bytes lib/yui/editor/assets/skins/sam/editor.css | 7 + lib/yui/editor/editor-beta-debug.js | 5205 +++++ lib/yui/editor/editor-beta-min.js | 302 + lib/yui/editor/editor-beta.js | 5164 +++++ lib/yui/element/README | 20 + lib/yui/element/element-beta-debug.js | 957 + lib/yui/element/element-beta-min.js | 36 + lib/yui/element/element-beta.js | 943 + lib/yui/event/README | 62 + lib/yui/event/event-debug.js | 865 +- lib/yui/event/event-min.js | 88 +- lib/yui/event/event.js | 849 +- lib/yui/fonts/README | 16 + lib/yui/fonts/fonts-min.css | 8 +- lib/yui/fonts/fonts.css | 25 +- lib/yui/grids/README | 11 + lib/yui/grids/grids-min.css | 8 +- lib/yui/grids/grids.css | 149 +- lib/yui/history/README | 35 + lib/yui/history/assets/blank.html | 1 + lib/yui/history/history-beta-debug.js | 768 + lib/yui/history/history-beta-min.js | 45 + lib/yui/history/history-beta.js | 768 + lib/yui/imageloader/README | 4 + .../imageloader-experimental-debug.js | 442 + .../imageloader-experimental-min.js | 21 + .../imageloader/imageloader-experimental.js | 442 + lib/yui/logger/README | 40 +- lib/yui/logger/assets/logger-core.css | 7 + lib/yui/logger/assets/logger.css | 57 +- .../logger/assets/skins/sam/logger-skin.css | 55 + lib/yui/logger/assets/skins/sam/logger.css | 7 + lib/yui/logger/logger-debug.js | 3500 ++-- lib/yui/logger/logger-min.js | 119 +- lib/yui/logger/logger.js | 3500 ++-- lib/yui/menu/README | 527 +- lib/yui/menu/assets/map.gif | Bin 0 -> 236 bytes lib/yui/menu/assets/menu-core.css | 142 + lib/yui/menu/assets/menu.css | 315 +- lib/yui/menu/assets/skins/sam/menu-skin.css | 418 + lib/yui/menu/assets/skins/sam/menu.css | 7 + lib/yui/menu/menu-debug.js | 16099 +++++++++------- lib/yui/menu/menu-min.js | 388 +- lib/yui/menu/menu.js | 15781 ++++++++------- lib/yui/reset-fonts-grids/README | 8 + .../reset-fonts-grids/reset-fonts-grids.css | 12 +- lib/yui/reset/README | 17 +- lib/yui/reset/reset-min.css | 8 +- lib/yui/reset/reset.css | 16 +- lib/yui/slider/README | 18 +- lib/yui/slider/slider-debug.js | 48 +- lib/yui/slider/slider-min.js | 16 +- lib/yui/slider/slider.js | 54 +- lib/yui/tabview/README | 22 + lib/yui/tabview/assets/border_tabs.css | 6 + lib/yui/tabview/assets/loading.gif | Bin 0 -> 729 bytes lib/yui/tabview/assets/skin-sam.css | 77 + .../tabview/assets/skins/sam/tabview-skin.css | 187 + lib/yui/tabview/assets/skins/sam/tabview.css | 7 + lib/yui/tabview/assets/tabview-core.css | 113 + lib/yui/tabview/assets/tabview.css | 75 + lib/yui/tabview/tabview-debug.js | 1833 +- lib/yui/tabview/tabview-min.js | 64 +- lib/yui/tabview/tabview.js | 1818 +- lib/yui/treeview/README | 31 + .../assets/skins/sam/treeview-loading.gif | Bin 0 -> 2673 bytes .../assets/skins/sam/treeview-skin.css | 104 + .../assets/skins/sam/treeview-sprite.gif | Bin 0 -> 3900 bytes .../treeview/assets/skins/sam/treeview.css | 7 + lib/yui/treeview/assets/sprite-orig.gif | Bin 0 -> 3289 bytes lib/yui/treeview/assets/treeview-core.css | 6 + lib/yui/treeview/assets/treeview-loading.gif | Bin 0 -> 2673 bytes lib/yui/treeview/assets/treeview.css | 103 + lib/yui/treeview/treeview-debug.js | 192 +- lib/yui/treeview/treeview-min.js | 29 +- lib/yui/treeview/treeview.js | 190 +- lib/yui/utilities/README | 17 +- lib/yui/utilities/utilities.js | 506 +- lib/yui/yahoo-dom-event/yahoo-dom-event.js | 225 +- lib/yui/yahoo/README | 38 + lib/yui/yahoo/yahoo-debug.js | 828 +- lib/yui/yahoo/yahoo-min.js | 42 +- lib/yui/yahoo/yahoo.js | 827 +- lib/yui/yuiloader/README | 4 + lib/yui/yuiloader/yuiloader-beta-debug.js | 1408 ++ lib/yui/yuiloader/yuiloader-beta-min.js | 51 + lib/yui/yuiloader/yuiloader-beta.js | 1408 ++ lib/yui/yuitest/README | 4 + .../yuitest/assets/skins/sam/yuitest-skin.css | 7 + lib/yui/yuitest/assets/skins/sam/yuitest.css | 7 + lib/yui/yuitest/assets/testlogger.css | 33 + lib/yui/yuitest/assets/yuitest-core.css | 7 + lib/yui/yuitest/yuitest-beta-debug.js | 2669 +++ lib/yui/yuitest/yuitest-beta-min.js | 73 + lib/yui/yuitest/yuitest-beta.js | 2669 +++ 223 files changed, 134459 insertions(+), 50241 deletions(-) create mode 100755 lib/yui/assets/skins/sam/autocomplete.css create mode 100755 lib/yui/assets/skins/sam/blankimage.png create mode 100755 lib/yui/assets/skins/sam/button.css create mode 100755 lib/yui/assets/skins/sam/calendar.css create mode 100755 lib/yui/assets/skins/sam/colorpicker.css create mode 100755 lib/yui/assets/skins/sam/container.css create mode 100755 lib/yui/assets/skins/sam/datatable.css create mode 100755 lib/yui/assets/skins/sam/dt-arrow-dn.png create mode 100755 lib/yui/assets/skins/sam/dt-arrow-up.png create mode 100755 lib/yui/assets/skins/sam/editor-knob.gif create mode 100755 lib/yui/assets/skins/sam/editor-sprite-active.gif create mode 100755 lib/yui/assets/skins/sam/editor-sprite.gif create mode 100755 lib/yui/assets/skins/sam/editor.css create mode 100755 lib/yui/assets/skins/sam/hue_bg.png create mode 100755 lib/yui/assets/skins/sam/logger.css create mode 100755 lib/yui/assets/skins/sam/menu-button-arrow-disabled.png create mode 100755 lib/yui/assets/skins/sam/menu-button-arrow.png create mode 100755 lib/yui/assets/skins/sam/menu.css create mode 100755 lib/yui/assets/skins/sam/picker_mask.png create mode 100755 lib/yui/assets/skins/sam/skin.css create mode 100755 lib/yui/assets/skins/sam/split-button-arrow-active.png create mode 100755 lib/yui/assets/skins/sam/split-button-arrow-disabled.png create mode 100755 lib/yui/assets/skins/sam/split-button-arrow-focus.png create mode 100755 lib/yui/assets/skins/sam/split-button-arrow-hover.png create mode 100755 lib/yui/assets/skins/sam/split-button-arrow.png create mode 100755 lib/yui/assets/skins/sam/sprite.png create mode 100755 lib/yui/assets/skins/sam/tabview.css create mode 100755 lib/yui/assets/skins/sam/treeview-loading.gif create mode 100755 lib/yui/assets/skins/sam/treeview-sprite.gif create mode 100755 lib/yui/assets/skins/sam/treeview.css create mode 100755 lib/yui/assets/skins/sam/yuitest.css create mode 100755 lib/yui/autocomplete/assets/autocomplete-core.css create mode 100755 lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css create mode 100755 lib/yui/autocomplete/assets/skins/sam/autocomplete.css create mode 100755 lib/yui/base/README create mode 100755 lib/yui/base/base-min.css create mode 100755 lib/yui/base/base.css create mode 100755 lib/yui/button/README create mode 100755 lib/yui/button/assets/background.png create mode 100755 lib/yui/button/assets/button-core.css create mode 100755 lib/yui/button/assets/button.css create mode 100755 lib/yui/button/assets/menuarrow.gif create mode 100755 lib/yui/button/assets/skins/sam/button-skin.css create mode 100755 lib/yui/button/assets/skins/sam/button.css create mode 100755 lib/yui/button/assets/skins/sam/menu-button-arrow-disabled.png create mode 100755 lib/yui/button/assets/skins/sam/menu-button-arrow.png create mode 100755 lib/yui/button/assets/skins/sam/split-button-arrow-active.png create mode 100755 lib/yui/button/assets/skins/sam/split-button-arrow-disabled.png create mode 100755 lib/yui/button/assets/skins/sam/split-button-arrow-focus.png create mode 100755 lib/yui/button/assets/skins/sam/split-button-arrow-hover.png create mode 100755 lib/yui/button/assets/skins/sam/split-button-arrow.png create mode 100755 lib/yui/button/assets/splitarrow.gif create mode 100755 lib/yui/button/assets/splitarrow_active.gif create mode 100755 lib/yui/button/button-beta-debug.js create mode 100755 lib/yui/button/button-beta-min.js create mode 100755 lib/yui/button/button-beta.js create mode 100755 lib/yui/calendar/assets/calendar-core.css create mode 100755 lib/yui/calendar/assets/skins/sam/calendar-skin.css create mode 100755 lib/yui/calendar/assets/skins/sam/calendar.css create mode 100755 lib/yui/colorpicker/README create mode 100755 lib/yui/colorpicker/assets/colorpicker_core.css create mode 100755 lib/yui/colorpicker/assets/hue_thumb.png create mode 100755 lib/yui/colorpicker/assets/picker_mask.png create mode 100755 lib/yui/colorpicker/assets/picker_thumb.png create mode 100755 lib/yui/colorpicker/assets/skins/sam/colorpicker-skin.css create mode 100755 lib/yui/colorpicker/assets/skins/sam/colorpicker.css create mode 100755 lib/yui/colorpicker/assets/skins/sam/hue_bg.png create mode 100755 lib/yui/colorpicker/assets/skins/sam/picker_mask.png create mode 100755 lib/yui/colorpicker/colorpicker-beta-debug.js create mode 100755 lib/yui/colorpicker/colorpicker-beta-min.js create mode 100755 lib/yui/colorpicker/colorpicker-beta.js create mode 100755 lib/yui/container/assets/container-core.css create mode 100755 lib/yui/container/assets/skins/sam/container-skin.css create mode 100755 lib/yui/container/assets/skins/sam/container.css create mode 100755 lib/yui/datasource/README create mode 100755 lib/yui/datasource/datasource-beta-debug.js create mode 100755 lib/yui/datasource/datasource-beta-min.js create mode 100755 lib/yui/datasource/datasource-beta.js create mode 100755 lib/yui/datatable/README create mode 100755 lib/yui/datatable/assets/datatable-core.css create mode 100755 lib/yui/datatable/assets/datatable.css create mode 100755 lib/yui/datatable/assets/skins/sam/datatable-skin.css create mode 100755 lib/yui/datatable/assets/skins/sam/datatable.css create mode 100755 lib/yui/datatable/assets/skins/sam/dt-arrow-dn.png create mode 100755 lib/yui/datatable/assets/skins/sam/dt-arrow-up.png create mode 100755 lib/yui/datatable/datatable-beta-debug.js create mode 100755 lib/yui/datatable/datatable-beta-min.js create mode 100755 lib/yui/datatable/datatable-beta.js create mode 100755 lib/yui/editor/README create mode 100755 lib/yui/editor/assets/editor-core.css create mode 100755 lib/yui/editor/assets/skins/sam/blankimage.png create mode 100755 lib/yui/editor/assets/skins/sam/editor-knob.gif create mode 100755 lib/yui/editor/assets/skins/sam/editor-skin.css create mode 100755 lib/yui/editor/assets/skins/sam/editor-sprite-active.gif create mode 100755 lib/yui/editor/assets/skins/sam/editor-sprite.gif create mode 100755 lib/yui/editor/assets/skins/sam/editor.css create mode 100755 lib/yui/editor/editor-beta-debug.js create mode 100755 lib/yui/editor/editor-beta-min.js create mode 100755 lib/yui/editor/editor-beta.js create mode 100755 lib/yui/element/README create mode 100755 lib/yui/element/element-beta-debug.js create mode 100755 lib/yui/element/element-beta-min.js create mode 100755 lib/yui/element/element-beta.js create mode 100755 lib/yui/history/README create mode 100755 lib/yui/history/assets/blank.html create mode 100755 lib/yui/history/history-beta-debug.js create mode 100755 lib/yui/history/history-beta-min.js create mode 100755 lib/yui/history/history-beta.js create mode 100755 lib/yui/imageloader/README create mode 100755 lib/yui/imageloader/imageloader-experimental-debug.js create mode 100755 lib/yui/imageloader/imageloader-experimental-min.js create mode 100755 lib/yui/imageloader/imageloader-experimental.js create mode 100755 lib/yui/logger/assets/logger-core.css create mode 100755 lib/yui/logger/assets/skins/sam/logger-skin.css create mode 100755 lib/yui/logger/assets/skins/sam/logger.css create mode 100755 lib/yui/menu/assets/map.gif create mode 100755 lib/yui/menu/assets/menu-core.css create mode 100755 lib/yui/menu/assets/skins/sam/menu-skin.css create mode 100755 lib/yui/menu/assets/skins/sam/menu.css create mode 100755 lib/yui/tabview/assets/loading.gif create mode 100755 lib/yui/tabview/assets/skin-sam.css create mode 100755 lib/yui/tabview/assets/skins/sam/tabview-skin.css create mode 100755 lib/yui/tabview/assets/skins/sam/tabview.css create mode 100755 lib/yui/tabview/assets/tabview-core.css create mode 100644 lib/yui/tabview/assets/tabview.css create mode 100755 lib/yui/treeview/assets/skins/sam/treeview-loading.gif create mode 100755 lib/yui/treeview/assets/skins/sam/treeview-skin.css create mode 100755 lib/yui/treeview/assets/skins/sam/treeview-sprite.gif create mode 100755 lib/yui/treeview/assets/skins/sam/treeview.css create mode 100755 lib/yui/treeview/assets/sprite-orig.gif create mode 100755 lib/yui/treeview/assets/treeview-core.css create mode 100755 lib/yui/treeview/assets/treeview-loading.gif create mode 100755 lib/yui/treeview/assets/treeview.css create mode 100755 lib/yui/yuiloader/README create mode 100755 lib/yui/yuiloader/yuiloader-beta-debug.js create mode 100755 lib/yui/yuiloader/yuiloader-beta-min.js create mode 100755 lib/yui/yuiloader/yuiloader-beta.js create mode 100755 lib/yui/yuitest/README create mode 100755 lib/yui/yuitest/assets/skins/sam/yuitest-skin.css create mode 100755 lib/yui/yuitest/assets/skins/sam/yuitest.css create mode 100755 lib/yui/yuitest/assets/testlogger.css create mode 100755 lib/yui/yuitest/assets/yuitest-core.css create mode 100755 lib/yui/yuitest/yuitest-beta-debug.js create mode 100755 lib/yui/yuitest/yuitest-beta-min.js create mode 100755 lib/yui/yuitest/yuitest-beta.js diff --git a/lib/yui/animation/README b/lib/yui/animation/README index d6ea69a4be..f5dc0bda21 100755 --- a/lib/yui/animation/README +++ b/lib/yui/animation/README @@ -1,5 +1,23 @@ Animation Release Notes +*** version 2.3.0 *** + +* duration of zero now executes 1 frame animation +* added setEl() method to enable reuse +* fixed stop() for multiple animations + +*** version 2.2.2 ** + +* no change + +*** version 2.2.1 ** + +* no change + +*** version 2.2.0 ** + +* Fixed AnimMgr.stop() when called without tween + *** version 0.12.2 *** * raised AnimMgr.fps to 1000 diff --git a/lib/yui/animation/animation-debug.js b/lib/yui/animation/animation-debug.js index 7745b235b7..4980ffadb3 100755 --- a/lib/yui/animation/animation-debug.js +++ b/lib/yui/animation/animation-debug.js @@ -1,9 +1,15 @@ /* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 */ + /** * The animation module provides allows effects to be added to HTMLElements. * @module animation @@ -32,9 +38,10 @@ version: 0.12.2 */ YAHOO.util.Anim = function(el, attributes, duration, method) { - if (el) { - this.init(el, attributes, duration, method); + if (!el) { + YAHOO.log('element required to create Anim instance', 'error', 'Anim'); } + this.init(el, attributes, duration, method); }; YAHOO.util.Anim.prototype = { @@ -45,7 +52,7 @@ YAHOO.util.Anim.prototype = { */ toString: function() { var el = this.getEl(); - var id = el.id || el.tagName; + var id = el.id || el.tagName || el; return ("Anim " + id); }, @@ -155,10 +162,10 @@ YAHOO.util.Anim.prototype = { if (start.constructor == Array) { end = []; for (var i = 0, len = start.length; i < len; ++i) { - end[i] = start[i] + attributes[attr]['by'][i]; + end[i] = start[i] + attributes[attr]['by'][i] * 1; // times 1 to cast "by" } } else { - end = start + attributes[attr]['by']; + end = start + attributes[attr]['by'] * 1; } } @@ -166,7 +173,9 @@ YAHOO.util.Anim.prototype = { this.runtimeAttributes[attr].end = end; // set units if needed - this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr); + this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? + attributes[attr]['unit'] : this.getDefaultUnit(attr); + return true; }, /** @@ -230,7 +239,7 @@ YAHOO.util.Anim.prototype = { * @property duration * @type Number */ - this.duration = duration || 1; + this.duration = !YAHOO.lang.isUndefined(duration) ? duration : 1; /** * The method that will provide values to the attribute(s) during the animation. @@ -264,6 +273,13 @@ YAHOO.util.Anim.prototype = { */ this.totalFrames = YAHOO.util.AnimMgr.fps; + /** + * Changes the animated element + * @method setEl + */ + this.setEl = function(element) { + el = YAHOO.util.Dom.get(element); + }; /** * Returns a reference to the animated element. @@ -310,7 +326,11 @@ YAHOO.util.Anim.prototype = { this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration; + if (this.duration === 0 && this.useSeconds) { + this.totalFrames = 1; // jump to last frame if no duration + } YAHOO.util.AnimMgr.registerElement(this); + return true; }; /** @@ -506,10 +526,18 @@ YAHOO.util.AnimMgr = new function() { this.unRegister = function(tween, index) { tween._onComplete.fire(); index = index || getIndex(tween); - if (index != -1) { queue.splice(index, 1); } + if (index == -1) { + return false; + } + queue.splice(index, 1); + tweenCount -= 1; - if (tweenCount <= 0) { this.stop(); } + if (tweenCount <= 0) { + this.stop(); + } + + return true; }; /** @@ -518,7 +546,9 @@ YAHOO.util.AnimMgr = new function() { * @method start */ this.start = function() { - if (thread === null) { thread = setInterval(this.run, this.delay); } + if (thread === null) { + thread = setInterval(this.run, this.delay); + } }; /** @@ -530,11 +560,13 @@ YAHOO.util.AnimMgr = new function() { 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); + if ( queue[0].isAnimated() ) { + this.unRegister(queue[0], 0); } } + queue = []; thread = null; tweenCount = 0; @@ -774,7 +806,8 @@ YAHOO.util.Bezier = new function() { this.runtimeAttributes[attr].end = end; } }; -})();/* +})(); +/* TERMS OF USE - EASING EQUATIONS Open source under the BSD License. Copyright 2001 Robert Penner All rights reserved. @@ -1343,3 +1376,4 @@ YAHOO.util.Easing = { } }; })(); +YAHOO.register("animation", YAHOO.util.Anim, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/animation/animation-min.js b/lib/yui/animation/animation-min.js index 9e1291f510..284ff25f75 100755 --- a/lib/yui/animation/animation-min.js +++ b/lib/yui/animation/animation-min.js @@ -1,22 +1,25 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 +version: 2.3.0 */ -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.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||el;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 parseFloat(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;i0){this.runtimeAttributes 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');};})();(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=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);}};})(); \ No newline at end of file +return val;};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);}};})();YAHOO.register("animation",YAHOO.util.Anim,{version:"2.3.0",build:"442"}); \ No newline at end of file diff --git a/lib/yui/animation/animation.js b/lib/yui/animation/animation.js index 3b34cf4af3..236d338353 100755 --- a/lib/yui/animation/animation.js +++ b/lib/yui/animation/animation.js @@ -1,9 +1,15 @@ /* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 */ + /** * The animation module provides allows effects to be added to HTMLElements. * @module animation @@ -32,9 +38,9 @@ version: 0.12.2 */ YAHOO.util.Anim = function(el, attributes, duration, method) { - if (el) { - this.init(el, attributes, duration, method); + if (!el) { } + this.init(el, attributes, duration, method); }; YAHOO.util.Anim.prototype = { @@ -45,7 +51,7 @@ YAHOO.util.Anim.prototype = { */ toString: function() { var el = this.getEl(); - var id = el.id || el.tagName; + var id = el.id || el.tagName || el; return ("Anim " + id); }, @@ -155,10 +161,10 @@ YAHOO.util.Anim.prototype = { if (start.constructor == Array) { end = []; for (var i = 0, len = start.length; i < len; ++i) { - end[i] = start[i] + attributes[attr]['by'][i]; + end[i] = start[i] + attributes[attr]['by'][i] * 1; // times 1 to cast "by" } } else { - end = start + attributes[attr]['by']; + end = start + attributes[attr]['by'] * 1; } } @@ -166,7 +172,9 @@ YAHOO.util.Anim.prototype = { this.runtimeAttributes[attr].end = end; // set units if needed - this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr); + this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? + attributes[attr]['unit'] : this.getDefaultUnit(attr); + return true; }, /** @@ -230,7 +238,7 @@ YAHOO.util.Anim.prototype = { * @property duration * @type Number */ - this.duration = duration || 1; + this.duration = !YAHOO.lang.isUndefined(duration) ? duration : 1; /** * The method that will provide values to the attribute(s) during the animation. @@ -264,6 +272,13 @@ YAHOO.util.Anim.prototype = { */ this.totalFrames = YAHOO.util.AnimMgr.fps; + /** + * Changes the animated element + * @method setEl + */ + this.setEl = function(element) { + el = YAHOO.util.Dom.get(element); + }; /** * Returns a reference to the animated element. @@ -307,7 +322,11 @@ YAHOO.util.Anim.prototype = { this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration; + if (this.duration === 0 && this.useSeconds) { + this.totalFrames = 1; // jump to last frame if no duration + } YAHOO.util.AnimMgr.registerElement(this); + return true; }; /** @@ -503,10 +522,18 @@ YAHOO.util.AnimMgr = new function() { this.unRegister = function(tween, index) { tween._onComplete.fire(); index = index || getIndex(tween); - if (index != -1) { queue.splice(index, 1); } + if (index == -1) { + return false; + } + queue.splice(index, 1); + tweenCount -= 1; - if (tweenCount <= 0) { this.stop(); } + if (tweenCount <= 0) { + this.stop(); + } + + return true; }; /** @@ -515,7 +542,9 @@ YAHOO.util.AnimMgr = new function() { * @method start */ this.start = function() { - if (thread === null) { thread = setInterval(this.run, this.delay); } + if (thread === null) { + thread = setInterval(this.run, this.delay); + } }; /** @@ -527,11 +556,13 @@ YAHOO.util.AnimMgr = new function() { 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); + if ( queue[0].isAnimated() ) { + this.unRegister(queue[0], 0); } } + queue = []; thread = null; tweenCount = 0; @@ -771,7 +802,8 @@ YAHOO.util.Bezier = new function() { this.runtimeAttributes[attr].end = end; } }; -})();/* +})(); +/* TERMS OF USE - EASING EQUATIONS Open source under the BSD License. Copyright 2001 Robert Penner All rights reserved. @@ -999,6 +1031,7 @@ YAHOO.util.Easing = { Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; }, + /** * Backtracks slightly, then reverses direction and moves to end. * @method backIn @@ -1339,3 +1372,4 @@ YAHOO.util.Easing = { } }; })(); +YAHOO.register("animation", YAHOO.util.Anim, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/assets/skins/sam/autocomplete.css b/lib/yui/assets/skins/sam/autocomplete.css new file mode 100755 index 0000000000..98b473e26a --- /dev/null +++ b/lib/yui/assets/skins/sam/autocomplete.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-skin-sam .yui-ac{position:relative;font-family:arial;font-size:100%;}.yui-skin-sam .yui-ac-input{position:absolute;width:100%;}.yui-skin-sam .yui-ac-container{position:absolute;top:1.6em;width:100%;}.yui-skin-sam .yui-ac-content{position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;}.yui-skin-sam .yui-ac-shadow{position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity:0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;}.yui-skin-sam .yui-ac-content ul{margin:0;padding:0;width:100%;}.yui-skin-sam .yui-ac-content li{margin:0;padding:2px 5px;cursor:default;white-space:nowrap;}.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight{background:#B3D4FF;}.yui-skin-sam .yui-ac-content li.yui-ac-highlight{background:#426FD9;color:#FFF;} diff --git a/lib/yui/assets/skins/sam/blankimage.png b/lib/yui/assets/skins/sam/blankimage.png new file mode 100755 index 0000000000000000000000000000000000000000..b87bb2485015d12369549a8f88b4b4e6918da8a7 GIT binary patch literal 2314 zcmV+l3HA1gP)002t}0{{R350Hx300004XF*Lt007q5 z)K6G40000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBUzfKW_SMepzL z*?5)vnXr^-@mq~v#Is<_TJv!tH9IQe$@Xx30Dl4m?CIp{=H9&7-_qpj z@$&Na_V>}=-P_s8t;X5r<>9oxu=V))t;fI5&dBfV=di}q&Ctl)z^}#1!s6l2^YQNR z_4fPy{pIZK+vn}2t)%$)_toO#;n%^Nt);HK#<#b(?d|Q^-PrN-^x)*+!OF_W$Hdm! z)7aL|?e6dH@9^Q?*SNj5^z`$uytMfH`|DE_v7Q^$@+uYl) zwyn<6!SC?!+19@4>g)FN@VIM;P5=N05J^NqRCwC#*lSzbSQiFhNFotI4oL6_;vuC{b=qK$I+Xz#Vv+gl@7g<|P-q!D?T7b6AA7YNE^pUbd+%Us zvHiGMY?dFDpVm+7|H0xQ7NY(A7RQyM(T<>!bm{vn3=x8=(rL;Q{SFI3)s8?qX$u8u zH@N?3nH4ckx}#Azn*N_G4oMxo<@6I6%H5fJK~aq=_stfD8jQ*iH3XfEFQlfX+!}Qx ze4~YjL@+!_3T(FWE&nOEIN%yOC)PU~H4MJ1yg;_~-0+z22Q16&6NVKzRfjwP1ed_zA3i zg*8U*O1&IMRBp?=xVZQmEHTY-U$r_!L!g-&bz+X`4t(d)WtnwhDFsip&8{Fwn?C$Y-BAJXOA#XK`_RhKI zdKm{RiY;3Snxy>@I2z;yA7(lgGa&E3x|;RV@bB*M9w! z+hA1ns)v#B*^{x*P0SkNT`$lbbO1 zME0ERVyeQj0n}Jv{oq}t;(WYbiBc-f4zs z%YX#}iTOaK;&}X+uf*nSwGJ!E(%mmvP#Eld++;eN$nw9l&R$elfpTnqJ`jt=_)zHh zEEWjIGmI!o&9${JSS8e?pJ6B}4r^%JRure>NuS5FsBIQf4$MD%o3GdOr9Z`r)$Fow z_7)3VDR7fVlvd3Kp3iKn%Jc0jXMc6DrhK_F|4%-@l8@I9{bf-Uea+=ztJ|c9(jI1G zjt{S#Wi`}ip(Oz5kGJ*uO1}QgL#nr|KKb+-)^Zv0xdlz4EyieCK9N;l&1@?$nkRkI zSpY%x{7TzHPCj@rJzbDxabu|&{B_W>aAuQjDtG_l{MF3NbN(t6a;hq(proTr9lj3V zFq0r5Yr-dqvS?jj9=41o8G*_@Oz2l1W@es%^_*o@Cx4b`zeP~{jbE9ZeqdyJV#4Q> zcK=@cLS3bf(PX@q&t4#FW;+xLIh6BCDV)h*M_W5O-6I^ zL?8rB&V;tNuN?bn1f}hMwYen95?IsymMq;u*q~)LN$27Z%ZlT}hgTuT?)!Qs9B$j` zgJRKfeJYExuV7lxqE&?1e{`%aFGmI}i`gU@j)%|Al&f{!0waQoXeKxtSzcSc=lJLY zYXVg^ZH!*rXx>|0jYJ~1;VRVWv$_`xBA>}7|7fET?R99Lt{%b>#H8%gO_B=Uv2 zEZr;OVLH8+?g$J?!XH~++cT_UbLr`l3|9xAPn1NT3|sX&7z{>cA%k_9O)_L-@4W|< zR;$G@Dz;|L6tAUISrR2!1W~qb$W})LQ?s{UYyQtI+$4M+`FW=0_tP{y=53kUUc{s# zj)J%$iGRI26*pvgbU}c}Bv|dpn337yda&vH^B^dlvL7Yi z@mSG(V{GAdZNNf>0fr$@qv3(QOWMNm!`ZQ3CJP5+#k*3l*t}Kjy}A=0vY@brM-Tu) zpX+wmyQJ-?{;c0BBEdO{9*y-|@c|18>k#HI2%TyNO^>vt!|h)Na{HGz1Fvj_hb{D5 zJ%*wsV*087z%uTCq5yIDOd+dU>g5^AA;fan9>~#P zUFIDp*E^prm1K-f+YNrkz>AFelrhp8wtB(G0M676;-~cnG0H;6K!E*vgTNlL6VXu? z+HC^fZvPTp7aBxoqy?Xu1lqCx9<&{!C2rKcXsJrvG#yNhy03)|QoT{41~uw_oBM|R k{QsPv*4L~bm;VVc0HT!-jb!e$TmS$707*qoM6N<$g7zKgCjbBd literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/button.css b/lib/yui/assets/skins/sam/button.css new file mode 100755 index 0000000000..c1e05f48a2 --- /dev/null +++ b/lib/yui/assets/skins/sam/button.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-skin-sam .yui-button{display:-moz-inline-box;display:inline-block;border-width:1px 0;border-style:solid;border-color:#808080;background:url(sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{display:block;*display:inline-block;border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;*position:relative;*left:-1px;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a{display:block;*display:inline-block;padding:0 10px;border:none;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button button{*overflow:visible;background-color:transparent;cursor:pointer;cursor:hand;}.yui-skin-sam .yui-button a{text-decoration:none;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-focus button,.yui-skin-sam .yui-button-focus a{color:#000;}.yui-skin-sam .yui-split-button-focus button{background-image:url(split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-hover button,.yui-skin-sam .yui-button-hover a{color:#000;}.yui-skin-sam .yui-split-button-hover button{background-image:url(split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-button-active button,.yui-skin-sam .yui-button-active a{color:#000;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(split-button-arrow-disabled.png);} diff --git a/lib/yui/assets/skins/sam/calendar.css b/lib/yui/assets/skins/sam/calendar.css new file mode 100755 index 0000000000..18e466b658 --- /dev/null +++ b/lib/yui/assets/skins/sam/calendar.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0px;top:0px;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;}.yui-calendar .calnavright{position:absolute;z-index:1;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(sprite.png) repeat-x 0 0;border-bottom:1px solid #cccccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding-right:2px;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding-left:2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #cccccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#0066cc;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#cccccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#ccff99;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#99ccff;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#ffcccc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#ccff99;} diff --git a/lib/yui/assets/skins/sam/colorpicker.css b/lib/yui/assets/skins/sam/colorpicker.css new file mode 100755 index 0000000000..f07aa5140b --- /dev/null +++ b/lib/yui/assets/skins/sam/colorpicker.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-picker-panel{background:#e3e3e3;border-color:#888;}.yui-picker-panel .hd{background-color:#ccc;font-size:100%;line-height:100%;border:1px solid #e3e3e3;font-weight:bold;overflow:hidden;padding:6px;color:#000;}.yui-picker-panel .bd{background:#e8e8e8;margin:1px;height:200px;}.yui-picker-panel .ft{background:#e8e8e8;margin:1px;padding:1px;}.yui-picker{position:relative;}.yui-picker-hue-thumb{cursor:default;width:18px;height:18px;top:-8px;left:-2px;z-index:9;position:absolute;}.yui-picker-hue-bg{-moz-outline:none;outline:0px none;position:absolute;left:200px;height:183px;width:14px;background:url(hue_bg.png) no-repeat;top:4px;}.yui-picker-bg{-moz-outline:none;outline:0px none;position:absolute;top:4px;left:4px;height:182px;width:182px;background-color:#F00;background-image:url(picker_mask.png);}*html .yui-picker-bg{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../build/colorpicker/assets/picker_mask.png',sizingMethod='scale');}.yui-picker-mask{position:absolute;z-index:1;top:0px;left:0px;}.yui-picker-thumb{cursor:default;width:11px;height:11px;z-index:9;position:absolute;top:-4px;left:-4px;}.yui-picker-swatch{position:absolute;left:240px;top:4px;height:60px;width:55px;border:1px solid #888;}.yui-picker-websafe-swatch{position:absolute;left:304px;top:4px;height:24px;width:24px;border:1px solid #888;}.yui-picker-controls{position:absolute;top:72px;left:226px;font:1em monospace;}.yui-picker-controls .hd{background:transparent;border-width:0px !important;}.yui-picker-controls .bd{height:100px;border-width:0px !important;}.yui-picker-controls ul{float:left;list-style:none;padding:0 2px 0 0;margin:0}.yui-picker-controls li{padding:2px;margin:0}.yui-picker-controls input{font-size:0.85em;width:2.4em;}.yui-picker-hex-controls{clear:both;padding:2px;}.yui-picker-hex-controls input{width:4.6em;}.yui-picker-controls a{font:1em arial,helvetica,clean,sans-serif;display:block;*display:inline-block;padding:0;color:#000;} diff --git a/lib/yui/assets/skins/sam/container.css b/lib/yui/assets/skins/sam/container.css new file mode 100755 index 0000000000..39eb8f52f8 --- /dev/null +++ b/lib/yui/assets/skins/sam/container.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-overlay,.yui-panel-container{visibility:hidden;position:absolute;z-index:1;}yui-panel-container form{margin:0;}.masked .yui-panel-container{z-index:2;}.mask{z-index:1;display:none;position:absolute;top:0;left:0;right:0;bottom:0;overflow:auto;}.masked select,.drag select,.hide-select select{_visibility:hidden;}.yui-panel-container select{_visibility:inherit;}.hide-scrollbars,.hide-scrollbars *{overflow:hidden;}.hide-scrollbars select{display:none;}.show-scrollbars{overflow:auto;}.yui-panel-container.show-scrollbars,.yui-tt.show-scrollbars{overflow:visible;}.yui-panel-container.show-scrollbars .underlay,.yui-tt.show-scrollbars .yui-tt-shadow{overflow:auto;}.yui-tt-shadow{position:absolute;}.yui-skin-sam .mask{background-color:#000;opacity:.25;*filter:alpha(opacity=25);}.yui-skin-sam .yui-panel-container{padding:0 1px;*padding:2px 3px;}.yui-skin-sam .yui-panel{position:relative;*zoom:1;left:0;top:0;border-style:solid;border-width:1px 0;border-color:#808080;z-index:1;}.yui-skin-sam .yui-panel .hd,.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{*zoom:1;*position:relative;border-style:solid;border-width:0 1px;border-color:#808080;margin:0 -1px;}.yui-skin-sam .yui-panel .hd{border-bottom:solid 1px #ccc;}.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{background-color:#F2F2F2;}.yui-skin-sam .yui-panel .hd{padding:0 10px;font-size:93%;line-height:2;*line-height:1.9;font-weight:bold;color:#000;background:url(sprite.png) repeat-x 0 -200px;}.yui-skin-sam .yui-panel .bd{padding:10px;}.yui-skin-sam .yui-panel .ft{border-top:solid 1px #808080;padding:5px 10px;font-size:77%;}.yui-skin-sam .yui-panel-container.focused .yui-panel .hd{}.yui-skin-sam .container-close{position:absolute;top:5px;right:6px;width:25px;height:15px;background:url(sprite.png) no-repeat 0 -300px;}.yui-skin-sam .yui-panel-container .underlay{right:-1px;left:-1px;}.yui-skin-sam .yui-panel-container.matte{padding:9px 10px;background-color:#fff;}.yui-skin-sam .yui-panel-container.shadow{_padding:2px 5px 0 3px;}.yui-skin-sam .yui-panel-container.shadow .underlay{position:absolute;top:2px;right:-3px;bottom:-3px;left:-3px;*top:3px;*left:-1px;*right:-1px;*bottom:-1px;_top:0;_right:0;_bottom:0;_left:0;_margin-top:3px;_margin-left:-1px;background-color:#000;opacity:.12;*filter:alpha(opacity=12);}.yui-skin-sam .yui-dialog .ft{border-top:none;padding:0 10px 10px 10px;font-size:100%;}.yui-skin-sam .yui-dialog .ft .button-group{display:block;text-align:right;}.yui-skin-sam .yui-dialog .ft .default{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-dialog .ft .default .first-child{border-color:#304369;}.yui-skin-sam .yui-dialog .ft .default button{color:#fff;}.yui-skin-sam .yui-simple-dialog .bd .yui-icon{background:url(sprite.png) no-repeat 0 0;width:16px;height:16px;margin-right:10px;float:left;}.yui-skin-sam .yui-simple-dialog .bd span.blckicon{background-position:0 -1100px;}.yui-skin-sam .yui-simple-dialog .bd span.alrticon{background-position:0 -1050px;}.yui-skin-sam .yui-simple-dialog .bd span.hlpicon{background-position:0 -1150px;}.yui-skin-sam .yui-simple-dialog .bd span.infoicon{background-position:0 -1200px;}.yui-skin-sam .yui-simple-dialog .bd span.warnicon{background-position:0 -1900px;}.yui-skin-sam .yui-simple-dialog .bd span.tipicon{background-position:0 -1250px;}.yui-skin-sam .yui-tt .bd{position:relative;top:0;left:0;z-index:1;color:#000;padding:2px 5px;border-color:#D4C237 #A6982B #A6982B #A6982B;border-width:1px;border-style:solid;background-color:#FFEE69;}.yui-skin-sam .yui-tt.show-scrollbars .bd{overflow:auto;}.yui-skin-sam .yui-tt-shadow{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;}.yui-skin-sam .yui-tt-shadow-visible{opacity:.12;*filter:alpha(opacity=12);} diff --git a/lib/yui/assets/skins/sam/datatable.css b/lib/yui/assets/skins/sam/datatable.css new file mode 100755 index 0000000000..bff0dbf339 --- /dev/null +++ b/lib/yui/assets/skins/sam/datatable.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-dt-table th,.yui-dt-table td{overflow:hidden;}th .yui-dt-header{position:relative;}th .yui-dt-label{position:relative;}th .yui-dt-resizer{position:absolute;margin-right:-6px;right:0;bottom:0;width:6px;height:100%;cursor:w-resize;cursor:col-resize;}.yui-dt-scrollable{*overflow-y:auto;}.yui-dt-scrollable thead{display:block;}.yui-dt-scrollable thead tr{position:relative;}.yui-dt-scrollbody{display:block;overflow:auto;}.yui-dt-editor{position:absolute;z-index:9000;}.yui-skin-sam .yui-dt-table{margin:0;padding:0;font-family:arial;font-size:inherit;border-collapse:collapse;border:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-table caption{padding-bottom:1em;text-align:left;}.yui-skin-sam .yui-dt-table th{background:url(sprite.png) repeat-x 0 0;}.yui-skin-sam .yui-dt-table th,.yui-skin-sam .yui-dt-table th a{font-weight:normal;text-decoration:none;color:#000;vertical-align:bottom;}.yui-skin-sam .yui-dt-table th,.yui-skin-sam .yui-dt-table td{padding:4px 10px 4px 10px;border-right:1px solid #CBCBCB;}.yui-skin-sam .yui-dt-table td{white-space:nowrap;text-align:left;}.yui-skin-sam .yui-dt-table th.yui-dt-last,.yui-skin-sam .yui-dt-table td.yui-dt-last{border-right:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-list td{border-right:none;}.yui-skin-sam .yui-dt-table thead{border:1px solid #989898;}.yui-skin-sam .yui-dt-table tbody{border-left:1px solid #7F7F7F;border-right:1px solid #7F7F7F;border-bottom:1px solid #7F7F7F;}.yui-skin-sam .yui-dt-loading{background-color:#FFF;}.yui-skin-sam .yui-dt-loading{background-color:#FFF;}.yui-skin-sam .yui-dt-sortable{cursor:pointer;}.yui-skin-sam th.yui-dt-sortable{padding-right:5px;}.yui-skin-sam th.yui-dt-sortable .yui-dt-label{margin-right:15px;}.yui-skin-sam th.yui-dt-asc,.yui-skin-sam th.yui-dt-desc{background:url(sprite.png) repeat-x 0 -100px;}.yui-skin-sam th.yui-dt-asc .yui-dt-header{background:url(dt-arrow-up.png) no-repeat right;}.yui-skin-sam th.yui-dt-desc .yui-dt-header{background:url(dt-arrow-dn.png) no-repeat right;}.yui-dt-editable{cursor:pointer;}.yui-dt-editor{text-align:left;background-color:#F2F2F2;border:1px solid #808080;padding:6px;}.yui-dt-editor label{padding-left:4px;padding-right:6px;}.yui-dt-editor .yui-dt-button{padding-top:6px;text-align:right;}.yui-dt-editor .yui-dt-button button{background:url(sprite.png) repeat-x 0 0;border:1px solid #999;width:4em;height:1.8em;margin-left:6px;}.yui-dt-editor .yui-dt-button button.yui-dt-default{background:url(sprite.png) repeat-x 0 -1400px;background-color:#5584E0;border:1px solid #304369;color:#FFF}.yui-dt-editor .yui-dt-button button:hover{background:url(sprite.png) repeat-x 0 -1300px;color:#000;}.yui-dt-editor .yui-dt-button button:active{background:url(sprite.png) repeat-x 0 -1700px;color:#000;}.yui-skin-sam tr.yui-dt-even{background-color:#FFF;}.yui-skin-sam tr.yui-dt-odd{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-even td.yui-dt-asc,.yui-skin-sam tr.yui-dt-even td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-odd td.yui-dt-asc,.yui-skin-sam tr.yui-dt-odd td.yui-dt-desc{background-color:#DBEAFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even{background-color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-odd{background-color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-desc{background-color:#EDF5FF;}.yui-skin-sam tr.yui-dt-highlighted,.yui-skin-sam tr.yui-dt-highlighted td.yui-dt-asc,.yui-skin-sam tr.yui-dt-highlighted td.yui-dt-desc,.yui-skin-sam tr.yui-dt-even td.yui-dt-highlighted,.yui-skin-sam tr.yui-dt-odd td.yui-dt-highlighted{cursor:pointer;background-color:#B2D2FF;}.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted,.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-highlighted td.yui-dt-desc,.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-highlighted,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-highlighted{cursor:pointer;background-color:#B2D2FF;}.yui-skin-sam tr.yui-dt-selected td,.yui-skin-sam tr.yui-dt-selected td.yui-dt-asc,.yui-skin-sam tr.yui-dt-selected td.yui-dt-desc{background-color:#426FD9;color:#FFF;}.yui-skin-sam tr.yui-dt-even td.yui-dt-selected,.yui-skin-sam tr.yui-dt-odd td.yui-dt-selected{background-color:#446CD7;color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-selected td,.yui-skin-sam .yui-dt-list tr.yui-dt-selected td.yui-dt-asc,.yui-skin-sam .yui-dt-list tr.yui-dt-selected td.yui-dt-desc{background-color:#426FD9;color:#FFF;}.yui-skin-sam .yui-dt-list tr.yui-dt-even td.yui-dt-selected,.yui-skin-sam .yui-dt-list tr.yui-dt-odd td.yui-dt-selected{background-color:#446CD7;color:#FFF;}.yui-skin-sam .yui-dt-paginator{display:block;margin:6px 0;white-space:nowrap;}.yui-skin-sam .yui-dt-paginator .yui-dt-first,.yui-skin-sam .yui-dt-paginator .yui-dt-last,.yui-skin-sam .yui-dt-paginator .yui-dt-selected{padding:2px 6px;}.yui-skin-sam .yui-dt-paginator a.yui-dt-first,.yui-skin-sam .yui-dt-paginator a.yui-dt-last{text-decoration:none;}.yui-skin-sam .yui-dt-paginator .yui-dt-previous,.yui-skin-sam .yui-dt-paginator .yui-dt-next{display:none;}.yui-skin-sam a.yui-dt-page{border:1px solid #CBCBCB;padding:2px 6px;text-decoration:none;} diff --git a/lib/yui/assets/skins/sam/dt-arrow-dn.png b/lib/yui/assets/skins/sam/dt-arrow-dn.png new file mode 100755 index 0000000000000000000000000000000000000000..2178f11e327167c25acfb35264b03dd87b9486b4 GIT binary patch literal 111 zcmeAS@N?(olHy`uVBq!ia0vp^96-#%#0(_QEuNMPq&Ne7LR^6~5JW~sygPna1;}D7 z3GxeOaCmkj4agDkba4!+xRpFZ>evFQg9m0FIBSN|8>1!OUn z1o;IsI6S+N2IPo%x;TbZ+)7T!N_gOt5YU@2LyC=odofdpX;srLkUmdWKbLh*2~7a` CVH-^V literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/editor-knob.gif b/lib/yui/assets/skins/sam/editor-knob.gif new file mode 100755 index 0000000000000000000000000000000000000000..03feab3b00f83ce8bcf2e9b22454e701083ad732 GIT binary patch literal 138 zcmZ?wbhEHbRAdljSj5Wk>C>mi#>Q#WroDds`uzFx3^1VhlZBCift5iABmh#&!0aEf z>&{2rQ#+d!lrGr5WpF;$+r>U-p%#pf7j6C(;=#aR4FLK*IpF{R literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/editor-sprite-active.gif b/lib/yui/assets/skins/sam/editor-sprite-active.gif new file mode 100755 index 0000000000000000000000000000000000000000..04ac4e46ad1f810705cf7af74a94532126e96549 GIT binary patch literal 5298 zcmWlbX*^U71I6#XvoFk*>|`w2V-yjpu_Rj>TV+Y3MHDqjMWQiwsV2#qj7W$YWO+(8 z_BDpAC5A-B^E4zxnYZ`+&ZqPFoZtEHx3@Lj<+lk?MXiVcBog^vN8)GA!S(g^Uso-5 zKO1@3Iyf--qd0t9Mh|^Co$};))6eCVU$f7D4!@ib2<%D`3x&H5KJvSGIefTMJ81Z~ zaSrUJj;r83&lGBPW$q5%0atg|qy2HG@eBO@E zEp?o$%x3)j;1PT-r0eC2T}9p9m5KT~x}wBrr5o7gZ~iM^?wy?XYQAd`9h*Edv$`_d z7I-H3ZDHtERkhS$AV+Dl&Do*?Q`c=N{7-@ge-PyK!*X9`A ze|>4j&F%2&>P3c?BoJHWzZ3s+DEV{6%~i&s`$00bk75nebUL%7)!DV2L`D(!)%s|} z)8~wtTJrSQr8rl~F(>5ml;^{|2R~gU!Xjc)Qt#jYu-F}H4czM*<+&bka$a8?`8P>% zc`UDEX!b=Fw`Th1iIb=2=jT5MAd`Ff0}oBVH5|KhM1xztTkcAB*^_c1JMhD&g~^$3 z^p{Xe*QIaShdy!LM29^3#)Xafc73gn1w&8X8d4l*xC7g(4BKclVyz zFJCggi(lu13xlV%^$bj{ABuv2_8G3JIaNVPd3qZ4X6kMK+((6^Z3mrc#eyI4@4g4M zPyOu94}8X5`Mt66XQ|XfL*h)b+i}{L*ZI_crkz|4@3TLcT5)qr!Isb_)$$$kdv@v{ zKJ0ln_vq87j$~HRlrMIY7cn{U%_&{Mnxi+mu(s0WeQQYQ_FB-(@9pLHPc$V>bmsjS zy65cW@Pl__{GN42smZCUXW#OQ8+mUS=guGN-P<?+lJ?&6gr78#x%NonbW@Dg(X5~`hOy36bgXySAan7WhVR5urOU$k!0_N{kTRm4vnbMXDMY0Fj}ZApVoE~FmI z&MtJk6O%Y*r&W^Y2|r!4>*sOHKh!clb>=$OKK=MI?8mo{UA509-dx`ro(XKV&90H> zq?JNeC5;MGoTa`Fb}L%q>Dc?#Q@o1CsFyWMC%V`@sj??NY$>1Gl^^}2K+bm8i!;tn z@tAW<7cVi51QWa%g0gdc-NL8#yK03$2-3OT=#(H_GR%J#bynmN%~JA9_wYnniR>fU zolk|L%WRY4In0{+9O0ay)N2x_$T45MEOqOi2CaGrizGxIrlZTT5 z)MiyawaE_yawg*yUHxGVa(trwUNxQ5Q%PDy#Z$?8HSNRVTV7S~+jrijoiAS1%zj{6 zKwTi|USv=UsD|7{l9UK|sHSI>#+sy7*=T=GbMM*C7a#k5!a=IqNqGC>o0ER95^k{) zu|4Z#Mblo@`Nb|p{Z{SS`=LXDr|;X2u+f`C>rf~uTlLr^5V=k0n1T+cTXPU!tx)Ll zq>O|ekY6PS>lj4mgFV1@2dUt2N`kf7cpWo;>bY?;^$DHdW);X5!PZ2DZkCpn`8-8e zDoeeBrcvv$(4>P8=YFF)W-b<5dh>SC9FA`Zb=T-grhBli_&@o#X6*9IDb9KA&H!(k z(>LkI4_KY-;=-Ehrjj>>o&1XO*QK*&Sy8*wQfq&i?>&= zn5pW)Bg?6TdL#bxLEnhZy*q;z91Af=V@rz0(}NZ}v}8;gI%6&SC}c(QNgF96&59Ao zBaJmq-BK6QETKs2>oq^jXOCLej*^`v<=QD|C`!xSaf{t*0gCdA%xhM~-n3%vz1r+& zBYrI)(%X_t=U_ISj1|~H({<7D=Mm*oR)}lU2apouDWZ3A36K)IgR~$tB+1f+pPJ<< zBaZ5NMS2qAT66&?QFgicQ)|y!ic8b1sS{|U4u++6_6X}hdxF#wGhPKlC+N53wcEQrST|Oc3)_tL>y(pO@ekeJo_M>d6eeUIPThe4D_U{p+u@tPRY*lwC$S#0s zu?I{xRtHGzFO8DuRFG>dV1*-^#_KQKHsn#Yx0|+EY-dNSc7I~v1UaZ=Au8fC8F4ot zn`j2c%Ws~7zh)v;oHg0|*dREgV67=S10?NFoRns3S?MS~1`o6ShzEF}Ivzxlk$@t0 zwXw&DAFE1*P+BnJ>pa(@O)M5CCu=h&%*XB{lckbOKTyYLv4LO2m1hI2bgcOGEZIge zCmwn?buxap*E8}{tffrh{#VxWHi%S4+;W}FYX`5zRIMhK#zz)Ps+fv7LbucWlaB!D zAQ~@sO1pvzyjQWgSENqWJ-b3WQW=t7UG+#WaKED-dwY7FMWO)?aPq~!Q`Ry4tp9e= zK{lZBUhC!}gESD~(_fk1$R=D}P&0-AO7-%TdYpCbuZUJ=F{yo{fV?7n;5`=I)( z=G3bRrP7FJ4&(Fq>G~ltE;AYr)G-i%i$sveFLM~6PrZ4ykKuz)mN~8-Bg?ph1kQ2j zk!CWlMF11)yKhV^+Ufb`8p8I}Xky*8s*GY$X@Z;{EFTp1x}ch3=<3A2vwE6G72kf; zh&rwME?B>r$Mr7deQbJur6GSXEpJnviS0HK%W@%f+*g3RHZ)GH5ywE^N`n$)@fr-X@ufJP;l?`wfR%-LMC-+twu5^`6wlELHIivD(d1#k|A6g`-~Q+Ra735Grvyi;gkBt#B~q?Hh76y|`$0qq2bX zMzq>;O#J(LflT&%+}iM)sOxDW<%u?yVM;V=`H4ujjq!&1pMdo1-NZ&4pXe+gRdTP- zW<GPmLW7VA2QcSkke2l529Ed^StL>m_GLu9B7@Gt z=n0r8Eo4d4SRw{%6Nlx@5y!#A1^~3cf*VY%#ut*AX{=c$aFY>xQy62ZMRXd8b#9M! zSS96CqTFSps9JINdAJ%nL7N}vyBenrL>@PdZ@B=V8Aikki5@Dn9s;ZKz=JUMA`^_Y z^0ya|lIX}a9(ex_94bU^@Q%vDm~a7vQ-LG}q;($jhzIJ4s07>vq%9js0#H!`k~agd zN`}Z6ku(Yz3Sb2Zpez^V4s6flfjv}|A`mrD2~Gjq{k0&6yVxu)DFYyAo`wS{;5rj@ z1b_<+lu0!FlmZ?Uip#qab_fxVLSPR7dqF_56_9oUTktNZoj{@jK)6&46L?So8|iNo zKVugv$wj=jLMd5ms|yL2@8X_wk>x*wn@wc?z7>?UJIdMm2V<-2E5xL?Ig_vF%=3hXpj}5s@qAm&VkmXWUI_`*ocnw_qeDk%{;#>Rs zZ;52t`sCY7#UYs{mvu{S8;aiD7OfIwh2hWXc%=3r{^eUXo`-+c-PZqg>j{OhT|2Di zQrdhSs+xOOmO^+byz5-zGt5XOg~Q6UxD9G5df}b~3`#N5rQr1EHtDrA@Dzu2=Igx; zM*2-o^o3pN8-nQltE?-Y@G;N0+`wiX=*YDAoay%KmPhzKYDbo?ChSuJYg6N*17U4idVnYRL_1T0pML%;vcmpv zo*^HWgSZ1-9mN{7=Mo8P^?H9YkXdF#)1H=npH^MBHEc4g(3+_L+XnIxCntr?pB zPp(E4VkZ^K0UdV(gbY%eo3X`|^ZrNV?vWV7FAwN} zc@uIEV(c?5G;`n1O81mx-6(k|ke1nYHP;|JcPzYMK|ONd^n)*Q@lx^+)dMI0(ul}WQ>zOF!&KMQ1M=lKy zn4adE_#zsynjaq?5HXx!{^S{e}Q{nG3PbU>@*{F@C7%Go&~g z77|e)Rwn}Ohtj1$))XXzgD?>Or3Lmwd zidEG`9Oa`F&%&t`^S&P_3KM;A=rP67%hvWJ-tXjo5v2-adD4iBSf3_N@j#<>J5^q? zEKmLo4P~-!Cr=}Ilg0OP0ag`Y?+x4ddnoV-fn=N`x%%S|k~{-hzDPKti>v2VJD6iu zjcQJ3Gs4qKc_dm7cTR^a=cZQCgKou&#t7X@uQV(ih2)U%#{m*D#!_N9=n( zkrg!B4jJ7=c~`;(uo|EmfQbg{nP4gzs?Wh)3OEn-RU;~Z9 zv|T)^pazoxLK#5tSBDh%H|<0hUTtAxB-xlxs<18adSsE5)~JzT0;keYbB+joinJkx zP__>qj`-*I+-^0mIB4OGyDSgVi$ePF1Xp<2G9Id%2hH{^Gt{IGGA{pKxY^GTtG8i})VvDm+%MryENCN9K*5doSC7KNLD6J=b zTK$PcXrb{;eQVI~MrZ+GD7J-Iw2_3Zq1W0NL2Y49ZCC5tLdM>tyQ35vRl1+}#}I*U ze=%27uM$@ehsC#_x7@+B=tvuTbECVRxX{i{c>(a-gC{%gDRw@z=xig%gr&C=E_86N z!P#Xh#ZH}E#jZ#%+-6$WW*UwVjd{kf%yt0l*zi3eevl6^*d;-XE^IW$nh*FeN|g9u z5Czxq8!}^5WaHoVUxQ2eU{*5nD)2UlhQwNS^;!^{c<3NHI*kq2QNbX3&(|>|A)4Sy z?{Q^=L()egUMJt2Vn8hLU#4vCY+G%3Rum4Gj_q0rsKw}Ghew*w#7 XB06eDh)(%90t!die?|n7Fkt>aSK4zI literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/editor-sprite.gif b/lib/yui/assets/skins/sam/editor-sprite.gif new file mode 100755 index 0000000000000000000000000000000000000000..dd36c3ee7d74e085b2b353e751b79cdae780dd09 GIT binary patch literal 5324 zcmWlbi9geig;nn^O+wJ+7-6m#DtgTK?M;z=OghJtu=R02n8~5Eywz0AqkCyA~VS@Ceh2MVV zsUc%yV@BJydw6)hYOT)aSN|OC4iAr*8?>#ft&6tTXC@|8o>M+`D&(g~H2*SkW@cu- z=gh)8m$p0MSFc<(DS!F>ev0a4?4RkAU%yT)PTlaI@pzVPw({-yosyEQtZSNT>J1q- zTXgjR06<-oxEV|-C@6e?hcH_ouyoz#`}o-E{KV2y_#6HkfYlIcCA%=3esU+iFhqfS zC(AHfw>M8gBje%naLm_6wJ{#;*YrfPlkD9Gj1Pz5KSK8fC+Wg>bHI%kaWS#0b0a^} zRR4_T{QBJA_+{a1Ae{c1|8=BHN=j?|JP|wS*lUZKiScXh zS|58k^vBS%?nufO1ILI9-}Bx5JP!QSGguLxUwHeNd++XcI_>CX2uGa1u+L`S_I%#g-h)&N>W6_2 zlU>G+G)LiJ{lNnVU7TJ0{ZDR;E(m3Wf?lyZcNm>HeP+*YbG=PEhY!)f;H*#Qq>mnT zcXf6NI2mBLm7>0p{7E3ldMgr(fvKsf@$s)YKc(XN;IE;8?g_3q1TeNPNlQ(g9RK{~ z3wmAJmj8r(K~G;bH#g5reX1RO+5i2+rGcMxx^Jc6_wa7=pWXtU8l5A@X>~rjhdlO6 zpGv2;d}(~xc>DJ4YxP$HgH8nm1gUUTCMPEa?*@f*{GOc#pWB$^#PaJ!-UXQ_gJS~j z-gP)|bDcFue|&s=R@lAx!ZTx7R8?73TY2ZwrAtSi3V8qVM*h1j8p;{{wepL{p6RUN z=3V&RS6;VWB`PxNW1h{;8#i)ua&xM8MLbh~`}VC^EdKfPr`j?M0)QCM|KC)A|91kw ziUBcB)sD+)OTxWra6b@@1MUDWbdY|!8`eL=cl~eUfROI)&VY5ldo^xXP z!0DMb`}@zu*8U$k>6+6)54K`2_b86K$xaeUMWo1Z){dn-_T>Ue{Wa|dC;mV zX6}VWRV9!{5Yw_S@DBU~l)PBy_hEgr^G+Q`DpIW8Y-iUXEnQSzf15>iGpg5I98r>~ zizsEk)^{!2rT~}!9boBKmwpx&Mhpi{7Dc{VzKl<4rrUVs>1bG6IXhEnhSfYK+fC$bL z)EaWY`d6A-at=FjZ zKrmu9`{e*?r-UkvDEX&4seMZmm11vk%Z@7*jESvi*R$5ASSt`}Ifzb4;drJTwU!IW z^2l(S_FAPQi#TsLw{QV{t|VPWDzFW};jU;r$MGcR?eW*<#eJ6$D}PjmJhJ8|MP{}> z!>l_RS==S#*TI{&ka7&O*_Gp!V7&nnj2|Rw-DM|BmcA3g8Yo1F)z*qu#{l|XJZs~s z$u{N}%rCq zHFoc4s(`tND3tND1C)q#bTrW)bt0UJ`g3lcXPk#+tIn2E{}=3cwx*Ab>~cI)aj$A`{l>2vwEZuvQ~} z;2!;MNj8PG>F;L}%5FXO*3s5@iZ94udz0tLsc8D~_3!jjl`c`Qd`uh1+3{eM{&h1$ z%4g*_%{IjO%A%x@B+!-XLwrE9W4-60S{(^Xy|z93J?1=V-Tq!2IwboAz!N{0T7&_B zP6t)3L{m!+225F{_p>2-*%P0Z{qC>QZ`Q*f^lfnto*Q8Nn%(g&=awDfb9vb<&X@K4 z*!He6zjGR~`-mYy_u{E)O8r;bwo8{B^w!<3)`+bz?y^7Ri7hRhk_$L$*KtV3d#*@y zCBQp7jOFsb@4G$4(zXG`_>2+akstn>e5Qg9$4twfz~H8KEtF&zbPHvxBe8n>iXklh z4jF%L(px2;m9kGxro_%}-!de3u|%jv{>szKw#2K@cid4|2{bJ*!vh*Ec{+U z;Fb!kpY4V|cud_f{eA?QGBmZ%A^LU99?c4{k6>A_@}^+rcL{KC+Uf@+mty4%YbBgA zD~o0olmhbAQ?T7?6?B6Btjv8#*FD)|AXX@+rm;}vvv{hfN+sg@i2M>%)T&)4{N)*Ra9ahN)|qf9mE+i~Ch{dvPTZXcJ|Id=4g z$BpF$t@DyU0)O|ql!5!#VSdJJ8y8(%FFgl6Hc&ssR>% z>7_t@o%_~Z%^-NQ(EkbfkijfFNmb78*h0B8S(m*{!ob?YWQMtZ|Nms90WcYMCqH1b za}~FNCYr@!RFp$E+&GuEjx^E%XrZ};bTWoh7RLXd9Sy?D( z=`c0e&$i~$)_;@qi|l-~r=d*Zdb)eJm4UP?;ok4n%z3x``YL3>>!jrLDNj%1a&4o# zH%_~LvFae#&z`=P%{kpnd%Sg2d$IBQ)sN$t9I~|3F24cqGm4p5N^kDorw!&G<2nk4 zGGehhm~A)WACDFFDlJqFZBZHWS^bPmI@DEsn0+s$`d<0z1o<+{OH4#qv(TA%(N7}ZUx1H;O+Z>4J z61%MioPRP|o570Yt8z~m`=90S%}+cK_;cp$QCG{^;wQgL-u__hO3fu$D0ZUON~1oR zy1T>EF+{>YzT2(8@(S zu;W)3NpqXxJVihpjnG14V!Go$Ponnlm@PCZxhd4jCd7pw`;ZDc&=UT#3CgrYWdSLY zm#{_!$<6RrHqgQ*kSIwcW}>cAlCe?}P9U*+N@C{{X?-QZ%9v%N!?GB`j^?o5<|K;w z*vnjO9UrenNv@zJySgPm&q?-(RBfh#Cs@e3HhezU5dQ{7I3$>jsiy0M?L)0Gu-gP1 zgL9E(KD@>Vtfonpup!(VI8Q(-7vbwUL{%;xS1dWh#y=21vI5c_F$XuqhnpG5m;hR& z!=?1tY7YJmhgfvUxtE7eJP|wG58e}{K_Dzolhmc)rvYp^6Dp#GVGO}MHolsQ+fS2} z=LSTcBP~IdU~62bU^v z>gA{Bs6#~@a5I3dVZhJMpHD)x!X_sPZlhj8a~fN>x?`RsP6Q7Fqe)k>*3mondI{Ona-0 z#oWwq%^5$Y4!zS-{AHXere&_@;3mZ*AvIK-L)W>uiL2BWkL@NIJA*P*nE2JDNDZTG z-L&hrn+axB*+Oke_2n#V0>fZFYr$Z$v8s#u;uh|6-;(BQEH?%9*6*#`EJe)7400<&2?na^x5S}x~`Shcbl7BMorUNBEX7na9m5&a^hr8z} zlM7(!{LxJXI-@!Ns9IY$(+sup(%ti}M&*7s&eU};OpYp)lE~vPA4=sw>Hu~kCuV>K zyh;JEOm?VCtb1C)koW?|m;)Gdi9J-}sWj|8TG7NL=?n)r$pJC}iFP1I!zosuj+%%f zq9b!qj;B{{5^-ln1tEgMvNV?Qg08yemE8g=U%j`Lpe_HXywi|$!7 z-){YEx&3eXwrA8?Xg>#&UfR&kk(!nWuS&2oz4Oz)cza;+&guh#s+@-QVvQ=!a8TZw zQdEz9cG~8WD^(>Ybu$A^^K?v0w0cS+s_7R6STegJY8rcyiJW6sEKwxF0YHge;d%s# zPX{d#_=H#lnTWuR0K{ihLiG}4CU}ZhX+ei9M5xS1U<|SoN~mx`-~v;0Wp7nxz6AtA z<_K_t4n3tpN2t(K4%R{h5g7aHPGO~J*knr0!|0l1E&I ze;ea)1EulA;|EPVsm&CEtN`?1eR$@3pe&PcF1Rt^v40b}DPy=%qSzm%HYNl&8P)jv z*GOJ0KkLb9wkHvBdYh;YA*z-zIsW4Ik1baivXZ zg$GhmV+cT21;(f-kP!<>x9{M=jb6e1JBR=eQu+HG*h}Fyt>ZsP7_lJ(XCxE@4G_3bTM1I0u{QMySrKM zyU+*hJH?E^4cCH)FCv#`)WSsFSm~Y&qT=PC36@xJj9%fDfh#fS86BI{*%%3{L%9?9LF1Xb;}+Q1kC;q^x0R9 literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/editor.css b/lib/yui/assets/skins/sam/editor.css new file mode 100755 index 0000000000..950a2a69d4 --- /dev/null +++ b/lib/yui/assets/skins/sam/editor.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-toolbar-container .yui-toolbar-subcont{padding:.25em 0;zoom:1;}.yui-toolbar-container .yui-toolbar-subcont:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-container span.yui-toolbar-draghandle{cursor:move;border-left:1px solid #999;border-right:1px solid #999;overflow:hidden;text-indent:77777px;width:2px;height:20px;display:block;clear:none;float:left;margin:0 0 0 .2em;}.yui-toolbar-container .yui-toolbar-titlebar.draggable{cursor:move;}.yui-toolbar-container .yui-toolbar-titlebar{position:relative;}.yui-toolbar-container .yui-toolbar-titlebar h2{font-weight:bold;border:none;color:#000;margin:0;padding:.2em;}.yui-toolbar-container.yui-toolbar-grouped span.yui-toolbar-draghandle{height:40px;}.yui-toolbar-container .yui-toolbar-group{float:left;zoom:1;}.yui-toolbar-container .yui-toolbar-group:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-container .yui-toolbar-group h3{font-size:75%;color:#999;padding-left:.25em;}.yui-toolbar-container span.yui-toolbar-separator{border-left:1px solid #999;overflow:hidden;text-indent:77777px;width:2px;height:18px;margin:.2em 0 .2em .1em;display:block;clear:none;float:left;}.yui-toolbar-container.yui-toolbar-grouped span.yui-toolbar-separator{height:35px;}.yui-toolbar-container.yui-toolbar-grouped .yui-toolbar-group span.yui-toolbar-separator{height:18px;}.yui-toolbar-container ul li{margin:0;float:left;}.yui-toolbar-container .yui-button{border:1px solid #999999;background:none;padding:0;cursor:pointer;height:20px;width:30px;overflow:hidden;display:block;float:left;margin:0 1px;position:relative;filter:none;}.yui-toolbar-container .yui-button .first-child,.yui-toolbar-container .yui-button .first-child a{margin:0;border:0;display:block;text-indent:50px !important;width:200px;overflow:hidden;}.yui-toolbar-container .yui-button-disabled{opacity:.5;filter:alpha(opacity=50);cursor:default;}.yui-toolbar-container .yui-button a{padding:0;}.yui-toolbar-container .yui-button.ie6.hover{background-color:#98D5FC !important;}.yui-toolbar-container .yui-toolbar-select{height:20px;width:auto;}.yui-toolbar-container .yui-toolbar-select a{border:none;background-color:transparent;height:19px;width:100%;text-align:left;cursor:pointer;opacity:1;filter:none;}.yui-toolbar-container .yui-toolbar-select .first-child{width:100% !important;}.yui-toolbar-container .yui-toolbar-select .first-child a{text-indent:3px !important;width:100% !important;}.yui-toolbar-container .yui-toolbar-select.yui-button-disabled a{cursor:default;opacity:1;filter:none;display:block;}.yui-toolbar-container .yui-toolbar-fontname{width:125px;}.yui-toolbar-container .yui-toolbar-heading{width:80px;}.yui-toolbar-fontname-arial{font-family:Arial;}.yui-toolbar-fontname-arial-black{font-family:Arial Black;}.yui-toolbar-fontname-comic-sans-ms{font-family:Comic Sans MS;}.yui-toolbar-fontname-courier-new{font-family:Courier New;}.yui-toolbar-fontname-times-new-roman{font-family:Times New Roman;}.yui-toolbar-fontname-verdana{font-family:Verdana;}.yui-toolbar-fontname-impact{font-family:Impact;}.yui-toolbar-fontname-lucida-console{font-family:Lucida Console;}.yui-toolbar-fontname-tahoma{font-family:Tahoma;}.yui-toolbar-fontname-trebuchet-ms{font-family:Trebuchet MS;}.yui-toolbar-container .yui-push-button-focus{border:1px dotted #999;}.yui-toolbar-container .yui-toolbar-spinbutton{position:relative;width:35px;}.yui-toolbar-container .yui-toolbar-spinbutton .first-child{width:35px;}.yui-toolbar-container .yui-toolbar-spinbutton .first-child a{border:none;background-color:transparent;background-image:none;background-repeat:no-repeat;width:28px;height:20px;text-align:left;text-indent:2px !important;z-index:0;opacity:1;filter:none;}.yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.up,.yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.down{position:absolute;display:block right:0;cursor:pointer;text-indent:999px;overflow:hidden;z-index:1;border:none;}.yui-toolbar-container .yui-overlay{position:absolute;}.yui-toolbar-container .yui-overlay ul li{float:none;}.yui-toolbar-colors{width:133px;zoom:1;display:none;z-index:100;overflow:hidden;}.yui-toolbar-colors:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-colors a{height:9px;width:9px;float:left;display:block;overflow:hidden;text-indent:999px;margin:0;cursor:pointer;border:1px solid #F6F7EE;}.yui-toolbar-colors a:hover{border:1px solid black;}.yui-color-button-menu{overflow:hidden;background-color:transparent;}.yui-toolbar-colors span{position:relative;display:block;padding:3px;overflow:hidden;float:left;width:100%;zoom:1;}.yui-toolbar-colors span:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-toolbar-colors span em{height:35px;width:30px;float:left;display:block;overflow:hidden;text-indent:999px;margin:0.75px;border:1px solid black;}.yui-toolbar-colors span strong{font-weight:normal;padding-left:3px;display:block;font-size:85%;float:left;width:65%;}.yui-toolbar-container{z-index:1;}.yui-editor-container .yui-editor-editable-container{position:relative;z-index:0;}.yui-editor-container .yui-editor-masked{background-color:#CCC;}.yui-editor-container iframe{border:0px;padding:0;margin:0;}.yui-editor-container .yui-editor-editable{padding:0;margin:0;}.yui-editor-container .dompath{height:1em;padding:0.25em;font-size:85%;}.yui-editor-panel .hd{text-align:left;position:relative;}.yui-editor-panel .hd h3{font-weight:bold;padding:0.25em 0pt 0.25em 0.25em;}.yui-editor-panel .bd{width:100%;zoom:1;position:relative;}.yui-editor-panel .bd div.yui-editor-body-cont{padding:.25em .1em;zoom:1;}.yui-editor-panel .bd div.yui-editor-body-cont:after{display:block;clear:both;visibility:hidden;content:'.';height:0;}.yui-editor-panel .ft{text-align:right;width:99%;float:left;clear:both;}.yui-editor-panel .ft span.tip{display:block;position:relative;padding-left:23px;text-align:left;margin:.5em;zoom:1;}.yui-editor-panel label{clear:both;float:left;padding:0;overflow:auto;width:100%;zoom:1;text-align:left;}.yui-editor-panel label strong{float:left;width:6em;}.yui-editor-panel .removeLink{width:80%;text-align:right;}.yui-editor-panel label input{margin-left:.25em;float:left;}.yui-editor-panel .yui-toolbar-group-padding{width:100px;}.yui-editor-panel .yui-toolbar-group-border{width:175px;*width:190px;}.yui-editor-panel .yui-toolbar-group-textflow{width:150px;*width:180px;}.yui-editor-panel .height-width{float:left;width:68%;}.yui-editor-panel .height-width h3{padding-right:11px;}.yui-editor-panel .height-width span{font-style:italic;display:block;float:left;overflow:auto;}.yui-editor-panel .height-width span.info{font-size:70%;}.yui-editor-panel .yui-toolbar-bordersize,.yui-editor-panel .yui-toolbar-bordertype{width:50px;font-size:75%;}.yui-editor-panel .yui-toolbar-container span.yui-toolbar-separator{border:none;}.yui-editor-panel .yui-toolbar-container div.yuimenu li.yuimenuitem a{float:none;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-solid{border-bottom:1px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-dotted{border-bottom:1px dotted black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordertype span a span.yui-toolbar-bordertype-dashed{border-bottom:1px dashed black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-1{border-bottom:1px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-2{border-bottom:2px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-3{border-bottom:3px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-4{border-bottom:4px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-editor-panel .yui-toolbar-bordersize span a span.yui-toolbar-bordersize-5{border-bottom:5px solid black;text-indent:777px;overflow:hidden;display:block;width:22px;height:8px;position:absolute;left:2px;}.yui-toolbar-container .yui-toolbar-bordersize-menu{width:30px;}.yui-toolbar-bordersize-menu .yuimenuitemlabel,.yui-toolbar-bordertype-menu .yuimenuitemlabel{display:block;width:50px;color:#ffffff;position:relative;margin-left:20px;padding:0;}.yui-toolbar-bordersize-menu .yuimenuitemlabel .checkedindicator,.yui-toolbar-bordertype-menu .yuimenuitemlabel .checkedindicator{position:absolute;left:-14px;}.yui-toolbar-bordersize-menu .yuimenuitem a.selected,.yui-toolbar-bordertype-menu .yuimenuitem a.selected{color:#B3D4FF;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-0 a{color:#000;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-0 a.selected{color:#fff;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-1 a{border-bottom:1px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-2 a{border-bottom:2px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-3 a{border-bottom:3px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-4 a{border-bottom:4px solid black;}div.yuimenu.yui-toolbar-bordersize-menu li.yui-toolbar-bordersize-5 a{border-bottom:5px solid black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-solid a{border-bottom:1px solid black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-dashed a{border-bottom:1px dashed black;}div.yuimenu.yui-toolbar-bordertype-menu li.yui-toolbar-bordertype-dotted a{border-bottom:1px dotted black;}h2.yui-editor-skipheader,h3.yui-editor-skipheader{height:0;margin:0;padding:0;border:none;width:0;overflow:hidden;position:absolute;}.yui-skin-sam .yui-toolbar-container{border:1px solid #808080;zoom:1;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar{background:url(sprite.png) repeat-x 0 -200px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar h2{color:#000000;font-weight:bold;margin:0;padding:0.3em 1em;font-size:100%;text-align:left;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-group h3{color:#808080;font-size:75%;margin:1em 0 0.25em;padding-bottom:0;padding-left:0.25em;text-align:left;}.yui-toolbar-container span.yui-toolbar-separator{border:none;}.yui-skin-sam .yui-toolbar-container{background-color:#F2F2F2;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-subcont{padding:0 1em 0.35em;}.yui-skin-sam .yui-editor-container .visible .yui-menu-shadow,.yui-skin-sam .yui-editor-panel .visible .yui-menu-shadow{display:none;}.yui-skin-sam .yui-editor-container ul{list-style-type:none;margin:0;padding:0;}.yui-skin-sam .yui-editor-container ul li{margin:0;padding:0;}.yui-skin-sam .yui-editor-container .yui-editor-editable-container{border:1px solid #808080;border-top:none;}.yui-skin-sam .yui-editor-container .dompath{background-color:#F2F2F2;border:1px solid #808080;border-top:none;color:#999;text-align:left;}.yui-skin-sam .yui-toolbar-container .collapse{background:url(sprite.png) no-repeat 0 -400px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-titlebar span.collapse{cursor:pointer;position:absolute;top:2px;right:2px;display:block;overflow:hidden;height:15px;width:15px;text-indent:9999px;}.yui-toolbar-container .yui-toolbar-select .first-child a{padding-top:0;}.yui-skin-sam .yui-toolbar-container .yui-button{background:url(sprite.png) repeat-x 0 0;border:1px solid #808080;cursor:pointer;height:22px;margin:0;overflow:hidden;position:relative;display:block;}.yui-skin-sam .yui-toolbar-container .yui-button-hover{background:url(sprite.png) repeat-x 0 -1300px;border-color:#808080;}.yui-skin-sam .yui-toolbar-container .yui-button-selected{background:url(sprite.png) no-repeat 0 -1700px;border-color:#808080;}.yui-skin-sam .yui-toolbar-container .yui-button span.yui-toolbar-icon{display:block;position:absolute;top:2px;height:18px;width:18px;overflow:hidden;background-image:url( editor-sprite.gif );background-repeat:no-repeat;background-position:30px 30px;}.yui-skin-sam .yui-toolbar-container .yui-button-selected span.yui-toolbar-icon,.yui-skin-sam .yui-toolbar-container .yui-button-hover span.yui-toolbar-icon{background-image:url(editor-sprite-active.gif);}.yui-skin-sam .visible .yuimenuitemlabel{text-align:left;}.yui-skin-sam .yui-button-menu{background-color:#ffffff;}.yui-skin-sam div.yuimenu li.selected{background-color:#B3D4FF;}.yui-skin-sam div.yuimenu li.selected a.selected{color:#000;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-bold span.yui-toolbar-icon{background-position:0 0;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-italic span.yui-toolbar-icon{background-position:0 -36px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-underline span.yui-toolbar-icon{background-position:0 -72px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-subscript span.yui-toolbar-icon{background-position:0 -180px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-superscript span.yui-toolbar-icon{background-position:0 -144px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-forecolor span.yui-toolbar-icon{background-position:0 -216px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-backcolor span.yui-toolbar-icon{background-position:0 -288px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyleft span.yui-toolbar-icon{background-position:0 -324px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifycenter span.yui-toolbar-icon{background-position:0 -360px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyright span.yui-toolbar-icon{background-position:0 -396px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyfull span.yui-toolbar-icon{background-position:0 -432px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-indent span.yui-toolbar-icon{background-position:0 -720px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-outdent span.yui-toolbar-icon{background-position:0 -684px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-createlink span.yui-toolbar-icon{background-position:0 -792px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertimage span.yui-toolbar-icon{background-position:1px -756px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-left span.yui-toolbar-icon{background-position:0 -972px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-right span.yui-toolbar-icon{background-position:0 -936px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-inline span.yui-toolbar-icon{background-position:0 -900px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-block span.yui-toolbar-icon{background-position:0 -864px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordercolor span.yui-toolbar-icon{background-position:0 -252px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-removeformat span.yui-toolbar-icon{background-position:0 -1080px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-hiddenelements span.yui-toolbar-icon{background-position:0 -1044px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertunorderedlist span.yui-toolbar-icon{background-position:0 -468px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertorderedlist span.yui-toolbar-icon{background-position:0 -504px;left:5px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-fontname,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bold,.yui-skin-sam .yui-toolbar-container .yui-toolbar-italic,.yui-skin-sam .yui-toolbar-container .yui-toolbar-subscript,.yui-skin-sam .yui-toolbar-container .yui-toolbar-forecolor,.yui-skin-sam .yui-toolbar-container .yui-toolbar-removeformat,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyleft,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifycenter,.yui-skin-sam .yui-toolbar-container .yui-toolbar-justifyright,.yui-skin-sam .yui-toolbar-container .yui-toolbar-indent,.yui-skin-sam .yui-toolbar-container .yui-toolbar-outdent,.yui-skin-sam .yui-toolbar-container .yui-toolbar-insertunorderedlist,.yui-skin-sam .yui-toolbar-container .yui-toolbar-createlink,.yui-skin-sam .yui-toolbar-container .yui-toolbar-left,.yui-skin-sam .yui-toolbar-container .yui-toolbar-inline,.yui-skin-sam .yui-toolbar-container .yui-toolbar-block,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordersize,.yui-skin-sam .yui-toolbar-container .yui-toolbar-bordertype{border-right:none;}.yui-skin-sam .yui-toolbar-container .yui-button .first-child,.yui-skin-sam .yui-toolbar-container .yui-button .first-child a{width:500px;position:absolute;_position:static;top:-1px;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select .first-child,.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton .first-child{position:static;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select .first-child a,.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton .first-child a{height:19px;left:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton span.yui-toolbar-icon{display:none;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.up{top:0;right:0;background-image:url( editor-sprite.gif );background-position:0 -1221px;overflow:hidden;height:8px;width:8px;min-height:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-spinbutton.yui-button a.down{bottom:0;right:0;background-image:url( editor-sprite.gif );background-position:0 -1187px;overflow:hidden;height:8px;width:8px;min-height:0;}.yui-skin-sam .yui-toolbar-container .yui-toolbar-select span.yui-toolbar-icon{background-image:url( editor-sprite.gif );background-position:0px -1144px;overflow:hidden;right:-2px;top:0px;height:20px;}.yui-skin-sam .yui-editor-panel .yui-color-button-menu .bd{background-color:transparent;border:none;width:135px;}.yui-skin-sam .yui-color-button-menu .yui-toolbar-colors{border:1px solid #808080;}.yui-editor-panel label input.warning{background-color:#FFEE69;}.yui-skin-sam .yui-editor-panel .yui-panel{padding:0;margin:0;border:none;background-color:transparent;overflow:visible;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group-border{width:190px;*width:195px;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group-textflow{width:185px;}.yui-skin-sam .yui-editor-panel .hd{margin:13px 0 0;padding:0;border:none;}.yui-skin-sam .yui-editor-panel .hd h3{color:#000;border:1px solid #808080;background:url(sprite.png) repeat-x 0 -200px;width:99%;position:relative;margin:0;padding:0;font-size:93%;text-indent:5px;height:20px;}.yui-skin-sam .yui-editor-panel .bd{background-color:#F2F2F2;border-left:1px solid #808080;border-right:1px solid #808080;width:99%;margin:0;*margin-left:-1px;padding:0;overflow:visible;}.yui-skin-sam .yui-editor-panel ul{list-style-type:none;margin:0;padding:0;}.yui-skin-sam .yui-editor-panel ul li{margin:0;padding:0;}.yui-skin-sam .yui-editor-panel label strong{font-weight:normal;font-size:93%;}.yui-skin-sam .yui-editor-panel .hd{background:none;}.yui-skin-sam .yui-editor-panel .ft{background-color:#F2F2F2;border:1px solid #808080;border-top:none;padding:0;margin:0;z-index:-1;}.yui-skin-sam .yui-editor-panel .hd span.close{background:url(sprite.png) no-repeat 0 -300px;cursor:pointer;display:block;height:16px;overflow:hidden;position:absolute;right:5px;text-indent:500px;top:2px;width:26px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon{background-image:url( editor-sprite.gif );background-position:0 -1260px;display:block;height:20px;left:0;position:absolute;top:0;width:20px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon-info{background-position:2px -1260px;}.yui-skin-sam .yui-editor-panel .ft span.tip span.icon-warn{background-position:2px -1296px;}.yui-skin-sam .yui-editor-panel .hd span.knob{position:absolute;height:10px;width:28px;top:-10px;left:25px;text-indent:9999px;overflow:hidden;background-image:url( editor-knob.gif );background-repeat:no-repeat;}.yui-skin-sam .yui-editor-panel .yui-toolbar-container{float:left;width:100%;background-image:none;border:none;}.yui-skin-sam .yui-editor-panel .yui-toolbar-container .bd{background-color:#ffffff;border-bottom:1px solid #808080;}.yui-skin-sam .yui-editor-panel .yui-toolbar-group h3{color:#000;float:left;padding-top:5px;}.yui-editor-blankimage{background-image:url( blankimage.png );} diff --git a/lib/yui/assets/skins/sam/hue_bg.png b/lib/yui/assets/skins/sam/hue_bg.png new file mode 100755 index 0000000000000000000000000000000000000000..d9bcdeb5c49910d5c32c9ebbb134200bf138b7b4 GIT binary patch literal 1120 zcmWkuZA?>V6h6*nD|EKy_G>T#efd;-TcIEZRG=3KG$^eF2Q{FAMV4*KY}f{qh`QSV zerz}DmTbC_Y|fEr#w0P0=t#CW_qsTZ+oCcxM!nmzgkYx0y)F9Qv+IxZJb6w|&dGC5 zaz;Z<^@~z7QUPF5prJObvq_J$hJ`xXo5wcl^n8zhtsmg}%|C)|K3%8x)wT6C_ipWb zw=>oa{%CJkw=1x%v!^@U-5DL&ajAP1z;mggH7#{nz-rJ$faL=7qA45La$rShQh@N! zu%sTCvXE1t{K=eCf%*<$g}~m_lTbYf%#DuhOcn)}oyL+UY!^T)N0SIlg&q}p70^Bg z#v`A*ftBD@6%H#L*N*0!pas#aR&fdVH33r!@M?%V4H}RB^=Q5i+Cy}fVbYD}B4EjH z?P{0x>Acg883%Oa|AzJ?B#N%FVmw`fKNY;g=C3&BXB;Z@Kam~dpydSE;!)KoPs+}MGZ#35TL&dgu1t8ZJCOzunMR5)=3wB`6<04>Wd>fEGNt=fUO7S z2UdorB;0d<%}W2%DB8|}rj&7Bd@G600GiIAl}DfA(T~fGjEtPSpMM-+!RdW!t0gq&tGw>1(Ck!bL+QCwfHM zFSfg6C%J1(_sXrL%2?h=Gs#tB`jY5~^n-B4=5yiEV7#4=o|0Az*Nu@}Ih_Oz$pHOG zC`&0{EO(L#V`PcEmKepS-spt1Gd{>irzEF%o|nyJB4uhF{YR*@P1evnVor$^%6<|| znF`WIVUCMc(=ZuIiR8<#kjLU}uWTnbQf7F06KORJtfO9XHgzgQe;2kI(+lL6NRM$K zObK})t}2X5(vY~u9{XN8DGugG$E0mSB^Mi(>V!GlYlD8E#--~|}G|8JkdYdiH90fD-v+HZu-d;bSJ8}W_+ literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/logger.css b/lib/yui/assets/skins/sam/logger.css new file mode 100755 index 0000000000..5b8077f184 --- /dev/null +++ b/lib/yui/assets/skins/sam/logger.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-skin-sam .yui-log{padding:1em;width:31em;background-color:#AAA;color:#000;border:1px solid black;font-family:monospace;font-size:77%;text-align:left;z-index:9000;}.yui-skin-sam .yui-log-container{position:absolute;top:1em;right:1em;}.yui-skin-sam .yui-log input{margin:0;padding:0;font-family:arial;font-size:100%;font-weight:normal;}.yui-skin-sam .yui-log .yui-log-btns{position:relative;float:right;bottom:.25em;}.yui-skin-sam .yui-log .yui-log-hd{margin-top:1em;padding:.5em;background-color:#575757;}.yui-skin-sam .yui-log .yui-log-hd h4{margin:0;padding:0;font-size:108%;font-weight:bold;color:#FFF;}.yui-skin-sam .yui-log .yui-log-bd{width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}.yui-skin-sam .yui-log p{margin:1px;padding:.1em;}.yui-skin-sam .yui-log pre{margin:0;padding:0;}.yui-skin-sam .yui-log pre.yui-log-verbose{white-space:pre-wrap;white-space:-moz-pre-wrap !important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;}.yui-skin-sam .yui-log .yui-log-ft{margin-top:.5em;}.yui-skin-sam .yui-log .yui-log-ft .yui-log-categoryfilters{}.yui-skin-sam .yui-log .yui-log-ft .yui-log-sourcefilters{width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}.yui-skin-sam .yui-log .yui-log-filtergrp{margin-right:.5em;}.yui-skin-sam .yui-log .info{background-color:#A7CC25;}.yui-skin-sam .yui-log .warn{background-color:#F58516;}.yui-skin-sam .yui-log .error{background-color:#E32F0B;}.yui-skin-sam .yui-log .time{background-color:#A6C9D7;}.yui-skin-sam .yui-log .window{background-color:#F2E886;} diff --git a/lib/yui/assets/skins/sam/menu-button-arrow-disabled.png b/lib/yui/assets/skins/sam/menu-button-arrow-disabled.png new file mode 100755 index 0000000000000000000000000000000000000000..8cef2abb31170a370c7062c839ea9d5e9de18948 GIT binary patch literal 173 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~d!3-ofWcl9%anc=q9T^y|-MHc(VFct$mbgZg z1m~xflqVLYGB~E>C#5QQ<|d}62BjvZR2H60wE-$(3-AeXt*@{D|Np;u@pDC#5QQ<|d}62BjvZR2H60wE-$(3-AeX1=9cj|6h7@{#_u8sU*lR z_&>wb?FL>zp1h}vV@SoVq=W_rH;IG.bd>ul:after{content:".";display:block;clear:both;visibility:hidden;height:0;line-height:0;}.yui-skin-sam .yuimenubaritem{float:left;}.yui-skin-sam .yuimenubarnav .yuimenubaritem{border-right:solid 1px #ccc;}.yui-skin-sam .yuimenubaritemlabel{display:block;*display:inline-block;font-size:93%;line-height:2;*line-height:1.9;padding:0 10px;color:#000;text-decoration:none;outline:none;cursor:default;border-style:solid;border-color:#808080;border-width:1px 0;position:relative;margin:-1px 0;}.yui-skin-sam .yuimenubarnav .yuimenubaritemlabel{padding-right:20px;}.yui-skin-sam .yuimenubaritemlabel .submenuindicator{width:1px;height:1px;top:0;left:0;}.yui-skin-sam .yuimenubarnav .yuimenubaritemlabel .submenuindicator{top:50%;right:8px;left:auto;margin-top:-3px;height:4px;width:7px;text-indent:8px;background-position:-16px -856px;}.yui-skin-sam .yuimenubaritem a.selected{background:url(sprite.png) repeat-x 0 -1700px;border-color:#7D98B8;}.yui-skin-sam .yuimenubarnav .yuimenubaritem a.selected{border-left-width:1px;margin-left:-1px;*left:-1px;}.yui-skin-sam .yuimenubar a.selected .submenuindicator{background:transparent;}.yui-skin-sam .yuimenubarnav a.selected .submenuindicator{background:url(sprite.png) repeat-x -16px -856px;}.yui-skin-sam .yuimenubaritem a.disabled{cursor:default;color:#A6A6A6;}.yui-skin-sam .yuimenubarnav .yuimenubaritem a.disabled .submenuindicator{background-position:-16px -881px;}.yui-skin-sam .yuimenu .bd{position:relative;top:0;left:0;border:solid 1px #808080;background-color:#fff;z-index:1;}.yui-skin-sam .yuimenu ul{padding:3px 0;border-width:1px 0 0 0;border-color:#ccc;border-style:solid;}.yui-skin-sam .yuimenu ul.first-of-type{border-width:0;}.yui-skin-sam .yuimenu h6{font-size:93%;font-weight:bold;line-height:1.5;*line-height:1.45;border-style:solid;border-color:#ccc;border-width:1px 0 0 0;color:#a4a4a4;padding:3px 10px 0 10px;}.yui-skin-sam .yuimenu ul.hastitle,.yui-skin-sam .yuimenu h6.first-of-type{border-width:0;}.yui-skin-sam .yuimenu .topscrollbar,.yui-skin-sam .yuimenu .bottomscrollbar{position:relative;height:16px;border:solid 1px #808080;background:#fff url(sprite.png) no-repeat 0 0;}.yui-skin-sam .yuimenu .topscrollbar{z-index:2;border-bottom-color:#ccc;margin-bottom:-1px;background-position:center -950px;}.yui-skin-sam .yuimenu .topscrollbar_disabled{background-position:center -975px;}.yui-skin-sam .yuimenu .bottomscrollbar{z-index:3;border-top-color:#ccc;margin-top:-1px;background-position:center -850px;}.yui-skin-sam .yuimenu .bottomscrollbar_disabled{background-position:center -875px;}.yui-skin-sam .yuimenuitemlabel{font-size:93%;line-height:1.5;*line-height:1.45;padding:0 20px;display:block;color:#000;text-decoration:none;outline:none;position:relative;cursor:default;}.yui-skin-sam .yuimenuitemlabel .helptext{font-style:normal;margin:0 0 0 40px;}.yui-skin-sam .yuimenuitemlabel .submenuindicator,.yui-skin-sam .yuimenuitemlabel .checkedindicator,.yui-skin-sam .yuimenubaritemlabel .submenuindicator{position:absolute;overflow:hidden;background:url(sprite.png) no-repeat;}.yui-skin-sam .yuimenuitemlabel .submenuindicator{top:50%;right:8px;margin-top:-3px;height:7px;width:4px;text-indent:5px;background-position:0 -906px;}.yui-skin-sam .yuimenuitemlabel .checkedindicator{top:50%;left:8px;margin-top:-3px;height:7px;width:7px;text-indent:8px;background-position:0 -1006px;}.yui-skin-sam .yui-menu-shadow-visible{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;opacity:.12;*filter:alpha(opacity=12);visibility:visible;}.yui-skin-sam .visible .bd,.yui-skin-sam .visible .yuimenuitem{_zoom:1;}.yui-skin-sam .visible .yuimenuitemlabel{*zoom:1;}.yui-skin-sam .visible .yuimenuitemlabel .helptext{float:right;width:100%;text-align:right;margin:-1.5em 0 0 0;*margin:-1.45em 0 0 0;}.yui-skin-sam .yuimenuitem a.selected{background:#B3D4FF;}.yui-skin-sam .yuimenubar .yuimenuitem a.selected .submenuindicator{background:url(sprite.png) no-repeat 0 -906px;}.yui-skin-sam .yuimenubarnav .yuimenuitem a.selected{border-width:0;margin:0;*left:0;}.yui-skin-sam .yuimenuitem a.disabled{cursor:default;color:#A6A6A6;}.yui-skin-sam .yuimenuitem a.disabled .submenuindicator{background-position:0 -931px;}.yui-skin-sam .yuimenuitem a.disabled .checkedindicator{background-position:0 -1031px;} diff --git a/lib/yui/assets/skins/sam/picker_mask.png b/lib/yui/assets/skins/sam/picker_mask.png new file mode 100755 index 0000000000000000000000000000000000000000..f8d91932b376af76ccfac030c12eb9fec7ee4c63 GIT binary patch literal 12174 zcmV;9FLBU`P)_6|b&%Dfjpyv}j54LBIXFZqhE-_t{2r7|?ya1%Cs>h{sswI&ir4|Fh z$jAgxe*E!Arq9Rc<1hC3+xpMn|Ni&&sREphKX2dqw+!rCg4fvHA{v>|sAOH9VUq1Wx=i{&V_yqRn;}h7QkI%<-7fW_4(VkZ}j!+ z*W3A4Q2+7AAN1S*{zm`&=RfJ^|M;1H`st@nDf0RFlp-IAiA&;HZ{w3b`^>wEDMb|H zcWo7$YKZ}V2ee&$PJPY#JEPa?S+a1^5~E@1g&W3xW#A&D$3t?w{=G7DSsA*r_4-%Y z`s|z_E&o@}NSYWQ_Q@Xg&3d|Ou zW&0J1V(Gn21@Ok$tl7ApUjkd|>Gf{~b_Mkc=*rd-*uVe&`%Pc}`s=SZK(DV?u$Q+4 zw*GP77{rl7z$bi8N=|4%dgnzQK{K@X9=v7^ctch^o|!a57b!8M)R5bd+^DZB*f)2h zXi(pP{pA7dU4m@DUcq}~?BDNws-MON*}ARvB9}^yYkUl^^T(x&iy;x&pXVP)oMH zG4>x1DYCNm`n+yi_f;$KX~32?&=bL&3KR!`?Ad)hXq&kbL*FF~DPi6Lgmfs6L(D+0 zND0vbo2}RNnI*FeDS>21aabAxyE61@^}W7lp{p^l|7WGkjF52;svSZcA8su7jAYiZ3LweO3*sn5! zSD>!n=?3mEUmKmhK6d%BxhCszn^Za-*h3D(8SY6kiNgaaXQX90(eY3K$c_zH0Bie! zBHJ2UyB-p(7Bef5YbLIag?2iM6)3&}lecGR>8-$C0bN;o1$K2uG_Y5@@20Q6ep|mt z*;#x0tH7=ryq?1awzczFEUg2jL1spUI~;shFFVJMWT3#Y2!p-uSjIu7V%f`fjs-Ap z^O>)I7X@&(g2WB97X@e*&x;21dj4(4t<5d)+aC4x2CzHGU+%zOzu(5F>;Cn4UV*tj zZ$V@8yjpp$fL&R8ZO0o+m)B>04HkLJJo2A^{CRu7ZvXb}emug@Fk>GfXvJPL@_-^q z01_^oksZ=)$m(QUUX;~R(;!CYEsBZDLoIZEb1~!wBOR^fg#bCy%lortW+6TF_FY@w z&6w46@B~bZ!ZnoFU!@$z>E}`k{^oUMnFB{O&3px81f^O z51QS()3a{J?CEH!+pUC&YHNa5>Eykw2XY`qJYY8f?~*Z#9Wbu!EB)#UYzgYy^IbES z3h4T`vT|kq^`Z574Oq_r_AIDJ0c{44L7>OU1PLbsz#Hu@vK`wj512a*;t0UHoeBa? zk6L-sMY|p{s1$`s7O*7~*BX(c{b~v9`g)Thw{{({Us@kq|5b2nV9S~lBm$l;MJBR- zSsN}46ctdtgi9+$xa(0`+j0;b5@@3(htB#Thl4>@u&CE;xE$KTV_CN$*;#_wksf7p zH>9;!8MRBwYyjM)2y#PKP>c6P+kZ7HSsw`0kDr;x8GBY&%c%cEP&e$K0;+W$c6Ga3 z-f4l|(a#9Tgjm>eL6n{@$mNioz>^;m>!~orEy~tWx3~ zOIPqpfCGkR(H?r%tE(Zjv@CMcj9p#<%|dfa05{ue+I>B?x*{YBs9Lr@sIdpzjet7C z(j3YXHqYbA7G>{gy$rQE(#f8iq4wzn3QC-$G_@y1j3806bjQvT*z2!Z!CPeq$}$Qt zKiFGHksaJG`+EfLE_ox5tq+;W^uV3*u}1^OjK^IhVL9wdjz0DhDyAkTJeq`!B#Pcg zhP)_7_7G+P^?uQ&deV!Q8k_%Iz3u(DO+Od8Pl9$mZo9rWlUfCjjYrK(<6~b$ZT0S1 zS3O;Ux%tu+)a&a-3?R6yAif2U*Sn8h->)oR%UIXfo6X1d@8#Re{rTQ*_p!In<@$MS zi0rd9cH9YgPHQJ6i50k+-%kgas7Aw(CeRhp9mnRTLOFML>EN7Z(g?zUW!g!Hg9HcE;V1EAh^ef|OhyG~Aswq6=s?q4)8Rd863y;SWj zSY7I8OIMc~2-fXFMwH5^wNOOZdAr8m>OGbX*q5qptG2GXdan<;-u3UQn|Fkfk?i04PcV*!JYNDjCSSa=A`)xBsyFVf!o zcEj3Z$<&e+vLHr0ak9iY3#aPde)nR zA-C1eupV=%_1K$crutm{Xra05zTK<7Zd!fooV!f@ zjN&Brbhe|X^)|DOW?&^TSXpb-J8|rPncYZ6g>MN)cr9$&910<@S`i zkQl{aQy;-2thth!_d8NT%MNOLaRo zCuFG|O0cz;&U9i--BvN-HZ`yK2WHwUjV^zvpBugv*x@U8x z({-K67HqPx8;i~;!e{od_khhIU{6k}7aYNF7KD;K_3|HlOG;X68|WyQts~R_Ey{93p$q#vLD)BBQJf!DrZ2nhQiG*TS=m|!i=sNPks~sAWNwo((+QeE z#&&JLOxr|mJq#Wvwe^U!h^q1|mxGNOYb!WJG9t^^ z7DMZKI!Lj#PN|b)?X9WqMFoppm0nG~SG!I#I0zVZ`DqtCYId&sD^t_0?Sst)+mcAN zUvx@c>}O&7-Gj-m-xe7Z%Keh9Wq_!IMZnTSjO}I%4>EJ4jWgw@5p#Q)LYiP`6fiQd z^$Ve27n-UX6~u~jBf+k#TtGMMS9dA;lIYZHi)4l30jO7QF&T(%QhouWT^ zynfVSX2S`ZnZPko&ykt#z}4MKa~F_k(OQ~~0%y}dDP!_F!}v#hlq(gM^>trIkoxdHpiniE-2)#zvMuOXYZ z@JTauPGdhoUrzx&2nsFzYz-P9uOq1X=#HU5Icmr1+m7`=TI)3+i)$@z)KfDUFrb|e zMgs?s-Dk1u&Z5gh$7`mpZ50a_t)I09Z_Y2;>j48bSd6fih|8uJJL^RwJv?I9MOj1S zdLU4vQqm5rNLt8_pn<5I7Sa+!IUbUAt>rFsNh$%|eUVd;2@Sq8wo0jAKq5vm`3kt3 z=3N~Rsk>_m9Wl3@TSRJXnS>Dm>Ye59TAeks*WX>pFw%@&JCaPu7;eaM#?H163Yxqm ziO1X{Y;1uY1)XquF~r!S{e#6HD+K5cU}@)0U+V%VRlwA-9$@K^y(J@8pB$}LpzaKz z#@63&zauQRhE`R26msV$Z^{OZT{Yqz~|MKp5@rfxL0c0%O-=ufe>>^uw{kcP3JqOoTg z+bjHcEIkgV+Xd`yFtrAF15DLXpaVjTJA-wc7@{Rz2CcE1z_Vdg<2a#%A@fTHRary$ zx^qPy{_{TkOX+1&?B6kR^}s#nLpfB<^+cJ+!)2=@cHV%N&a^i{jchr@!b(pU4J^^d zO17|ADFAxZ`eGm^1_e)qtT@Ery0EFfmaLv(=|+cN8%Rh$tyRdxLGaieqrB*@ zL#S!P*wWof-%8)Qb4e_g_L$k4z#SDq0S(+`G&PH>PTX|r+7{K~Ti3eID{{XsPtw=} z0bxo@dr1_)!UUvA#=f(B>9TP$k}MsN5fF`Yl1{Sda#ZD%T;wD_* zrR(uRL+ilL+JnOY9wm9-+$udbbEn?0(LOj>$r_hai=7gPtL*qQi|ZPXQR$29gp zkeHn=VZ^I8vx(Xr3C^*P2@HVj>StOa=0bwJ{*liQX>WaLOu?0&v$0Jsj zZGj8Z3^mjKv_3!Zt()Tzw)7pqx@$jMW2a1WYelRebzTA;ZOaH?FNSYztt>#^x{9&}1iB)CrBSv~c-4}XJO4VNu`kuHu8xMR`H+r@WMy3&f@(oD zV-IQUBfyT>ItFjOyTqV&0>y3{a4&QaiC7u|8A%bSB@^2+!6JcGyO0!VK!4kJZHk>1 znNk-3?ybKKaCMsmp|tx{qUMoqf7#pY9YA&lk%ZZwrPU|5J9327sG0NZzDc%Dr%025 zqCIwz@d$Rqv$k9j0=G{sMPM7F99180rOMfIOX{5lSZj~hBGDq+p)@>{DBd>D(nB2@ zz1GjEM9YEo=n!M0*-1Ij*Dw%_*w@JncJ0>&i~KC^eP`rF2U)|W{@J)VA!A!|1Qar* z*jjIw0i|Z_ef0$;GbCeMEUibRZ?mK78J{kaZ6ym=Hg~jl6AQ>=HEZjAwYpG94|(1j zW6N|q-Bz=DfN-cDdxU)xSwru&TsGqlj#fXTK+$96&LKfghSJ8J%i;Ld466Ic7^EwK zuHB7AWfjo^qGj`m7f~6w&sVL%jGPcDOR5_pYDq3q8i?$oc2L&4#06v<775i>3x}i}tq++VK{F93+C@%G zValBBMTkrmmI0*)W{`~}Bamck?hjo=AIT2H;zr=Ov-i5ctc-b|dO^D>y);olB4TMB zC|XiP28;VR$Cqm(8I)rp>kC5c^snH_B6o0E;XOGDq4mJAaYlw*nfA;o{!0X+V9n+`Q=20nuSDlk0 zdgAwJ=+@w{od%FmxoH4qYj6Ry<_6@487vZ>V-HCY_L4Ek;gHVAHhozyMcV2<0vW}W z{7{x50y!yd{Q&F2azst1q4hSTulr-+Tp`h%A*?MwAJ_+zEJ?ObOB4spn(@)R)X>2& zf=kQ!usm=ppk%N<3>mc_`qq7y4os*fgh3{fE%yV-ALNecQ9724spY3iR-n%;mLmd6 zE873Ja6=*qeEPg1Cyb7X=BtLlGg9Z#Gl5!Z*j^VXfzjv;q(@hx2?D~5Jdw7U_P2|X zXdzX>N67uq%&cTd!^|?#(m5pyv#$2jQbRr?MwiJL*{)@0>KMC94OKA3K#t72B8eGQ zho%5VV9w47VpMu*-A$wNL!A%GiU-iw7fW|M05Jh}mf1p5fbI&HM3Gac!nzy#;7ldzS7-AeZ2l+khNtzzZzBJg{dp zb~=mbyw7Y0_M9bK!fawT={_?Rk|qSC2C5A~wb;**BF6L!W`$oc0wS#Y$YvKE zd17j5OQIOlnsscaN0*DLL$AtD>*~b_1WCz@B5FbwppQe4OMr?AbDH21$qb#P1Oo$h z`Jrt*5Px-YLqh0lp~&%y-E2wy05*1A5Qnk%VHvfhCyH zC=hpY#SvhGb9KOVK)%&Y^RnGaB(p=7)*V4_v-Gn7YcXoCFRC_(RZ!S6b8Cfqwbxbv zIj6A?%91d9Xt1|+Of}XTw3;!B44<0% znWwtB|2&P4+P1NSp^2?K9QLkzeJ!ClT9SHNtqA8<27~p{mMh}O4{Na_#LV9CBRDWv z0#Jih47q~#9>@&J3tPNlQHDPawRfPgO~%%`y0s}74Z!7ym6a4BPiw1+ygEt-x+0)F zb#IHD5sR_Ifd)sVNL0&_vGT}Xc+?%csAYn*+Q^s#o56yZ9IR5MSuC&vo8!1&Bi#ab zqlFVvgjB+%|65pFi}1B2Pjo6A6*5T>N(ltKX>(B|m0NHnM|lj~Jr~#sRwic^FJ1-T`NnK`Sm1G_Iw#v}#|WQK-WlSrb8+AYnEC!}nrHzOofG;mq1M+5E# zF0gem)7`OLLSQ3s1BPWaokAx|WSl1)5O_Z6ba(|#QZlH~GNb{nI{^wDZ8k5vpDICX zWG18F@zH)Vr5-va5qopI{6+-mtjzF^x9ma0=x8jY25H&De=xXL-ukp$GA4EJ?nEl- zQ?{Ut(U?OkHjw~DK_d!wv%y_+E+_VTv|H%tHi!TN=lLhqd)(n^$wIw5XbX}6n z`wVcC!1m9<6ftn4w>5(+5MMNCf!6LiiE4Whw^Y6wQ<}v(+fAE42iREv2fEtS=E3Z# z5uh!P+mj_oiZsVqH6tECPhe|8cAs!~*a#jwEAVkGN;B?DgH?WY8pQ;Rv=0J-zk#a?d`U!O06|i&_pC0~% zs`H#tCai{-F-YNecP#Zgvjn-m4!WXHOEei+>hHL2yn0o89qjDD)2se_dhnP@n|qag zq7K&uG4;zpyE+``=ZwZifMAQ|GqM9DW;}m7&*Dql$%OnMBsqMELWGhrj(%q3(o|;F zm3fVvSr`q@)mGl(=b*|dsgt6oOp6bR~u`cPXan(Y?Gyewo|O!dC`^>(LOeEI&2wo%g8#w=7X*X=dws6C9Z=RM)P&R>XeWcW*}*S9|dBO z#E4vw6hn)0PQ$k*rB~U=N_Ki%gBgJqonHde7}bdbG3X-bM%8BGh!5%`glVkCChN}~g3BW$M}kFK2>ONsVtFvIPh8-j|! zP`X_o->~@7R1I1~_EP)g01;!(lkT_dq{zVuDO3BhOrBuw4xoebW0}oV0S%e1I!G@ zS(<=GAhvWhk}V>&+|*Y)b=L0-?9AW-BY4bAxj;rqE3At~Ky}WW0=SHa2iUo(K{h79 zoT?DC0FAa;NfwZ-@hm`!>^_u$QRi@h3rq?mNydOZGE=G{H&Tn{xCKvROl{R@LvI^( zB**_YItF)xh#kMXDH{M%hCO)$0MF=nR&EvuhTU2bMl1Q!wJQMKqreW=pfU8fHKC=;%8?Wy zW7a2QbPj5(!NIjz>u$oivp7#D1d0NoTZEjF9$;1MK(IMCCG zx#4mA491Rzkwx{-qhlU*CEw$JHpIZDM;^H+`-KBjpLq;>6vPe?U29I&lkB=&7dC0T zkL-zu_B9&G9&wIzIR`R>lTzb(!J|=U9R-`&X&KV;#bWceXp7Ay_biXxa!>Y)!Gw|^ zRzPXZRpL4+;23w5y4e9ilxJLLJ(vJZZMK~=hmp~M@T|Zw#n?zU2c03D=h^@)oM4jt zsnM*VVdlh?mfl95dUI}PN`okEK2kL0v3MjOvN9u+K?D|Fd;ZM@K@!6VE-4WpdRjVS z`e9&)&ImiJgbn!Hp)7H-n8gVs%>dH{es0F7IG{|}g8|!fpqD#of!gVkQq&1hX3_GZ z_3_C-5c<`Ii&6%I$Pr){sa-I;}6YGm*O`nF^QD6H`R=aiQ0s=u4 zTza2}Kqg;X`>lWu)lt7?a43FWI*YMWGq5^yjaX|lW+X^@MFS{LxLd9dEvFY2K>Mgp?OA;_w>u?86cFL0 zl^u|i`zRqxP>`3><7&bkb1pweD>LXk79h=KJ3K9)2o~)&cO%)=1g}F zezt&oXXmE4tL+eryM}%D`&caP0o?<5GC3n&x1^uY*oC}O)4&Ny&lDB0x4RvToOh&) zr$x!r&{le0YierKcvjGr`MhwQN2@c|(vL0gU66c2WH&Pd(};GS(b>6m9(kOx2U$5v z@|0jSjm6$YCkMz`nb*JIW&u`KPe-hr@wz*AM^1+0bSRGYKYlwV;Do^T4dXIFHa6J1 z)5oZS&(qlha)lDCehAo6iE0Y?R>0YuTY#ACrKQ=>*;xRyl>~C^y1g2X{k0@ro$W{? zwvM-s$pDz_i65J#OcG%Bz!;8vLC%YD?so%r2z*0VV~N1-I_u_z2H-X|cn0LCMglSM zk_53Mlgw>~!{KUf$8{>kWIt>;QEu|Y(%7QI@3#!A20N#nd+-LJ&->U1fju>|lm~u` zMVtiAa2v1VIPJr2mhANV{@gxO%YTY*rpumms_z`G6*Nz z@vOfDix06fV0>$B$utX(vNk(w-AuBv%gzxK2aX60xFRL6_ufZ}bZ!6>Cu>P8z_~%E zH<=FdoV||Vfm~{K063R%M}Vz=BS&@=XYTJbm>oS$PO`<-#+Jr*?hJ)Bt`PObM)kSZ8H|g?k<=*@;I^`DUND+wP){p6|2G-|G5*}WiV*^B=KId- z;G@Tf8k-jmEBQtPM31$T_1&(cVlBrp3fd&t$w|wntNq&V-IN5&It_E4@Imd|Kl?!< zfuUTc3zAHObCRvo`Z^&~rld%Ai4Mrxfz*f=J2kV1&iOMk#tIN2lVtAiQla>BXSp(9++bG|?7bP^y}FKW_JBeC3hEjw3ZfkQ=ooGj?Ibj8S#saVB*- z(a3wWYzYE&Mi#gdr2U=EcHfQNhXCmfHXuAzgA3lI-REUKqmoum9Ai$?F!CHEmD0~z zqF9XWl^>uxWn#1olpsOM+>$6(x}0oQrzmhdPl^o4kuac)((nmM5;-1}WlGssZT7om z&`$%t(;*_@Mk^abP-k3?V4{ACM!F=WN2VN=j44B&BSj(rM^iD32B1+VaO%L_i|*Y4 zY*t?&sLqff4*OA7!ZgPku1D6@utwCJ{WyPAO_H%kf$k=8h&W*C==PQYs~c!Wj2#U! zFn*)-F|TRRDm+6Dq3p;2+49V@!K-(?{xPPPoF1to z$x0H=yC}mJp~L3**vIz?8MOj$Qro8;i>#|LTTB(5kG`YF^a7^fmu>C|j@F))CsXdp z2*c0Hi~~%Z-PZrVI2D6HRvrQW5r+0;$An*<4jfMfb~Hxr6qu(0VIU{6XB%fdUt+7GKM$ZQ7d z+*G-q^3AhAkG6UGeKe43wk=Z~@{qi^8g4~a7kh3;^x0=fpYx@Ed05BU<|1?Y@y9GNH9cw6|*ydMtC~bu#Ur zW^%V9`U#e%tuqzfu>F?#-9|w@YT*rZk~0~*#cRn2ktxkSAW3Ed%?xnei<~%b>YUvy zQB0iuZb_Yd#{V~D+^D7_lR5mbj7|2~MWfx0!AN^YIy$^?2|Zp0fzVvE@~A_$*cnVA zMw#g)ypCq2vdiFXhx6E0)LqSNUxhI zVW-W=i}3ha-8{;~vjY#ZReptXbC!%U_7TS<<#h*49XcddFz8&+VQpzLHIvtFG}ukc ztmOZTJf~!aiH*rPc@pR;9nD7=JCGdVDq<116>`I1b5xT@tC-Dp5?2cO>`Zi$Oc?Cc z(=Nq~W}cBGvz~W!9>~};tnKM?az?r*E|O;jW_03+7UVQwICongNlHz~C-}PvCLZYw zR_qcowKa`$hP?y!^;8FkQe+UQgE~86O1M%&)(VWI%!rlfG4Y`wbreh^=ZP%0M8brg z;dU5oO-Jt}hg^{e*c8v~l#?WMUt?_~z?@+B^hF06nQ2~sj#!{Wam0bn8hwA4g(GPp zre)|l%aSOn8U*|Kj6IRW895IgvD0rHxqx+pbT_1PaWqhU>-R^eY8dPASqqQe_aWKy zbYM@gdG;KmUU;{SlVCmuzzWeg767aWXd_QWP{P+&9)h)*5Dlk z!wjP}|BcZa_lfvoG{C0G|7UodwcV@AJHfqqjue^oy9ceoY@nI}^Q?wH6;v~TLW`Kr zXy79tKO?#FmJgG$lhVOuZE*2ZjE(?$gwY2R3`cIyVJA+KNNfEK$gcDqZHkf0VMdOe zm>Iv^1hyK8I~oYO9l-Us@yB|M4gsFj<5}h%0zYagcd)ZD(q&^V&IE^>F~$_5al^!k4%1 zJn&9?;+~W-ewCt^;T`NeM?jwi+M(lXmEnk#nsGM*Cu2AujAFmD9g=3^cRpazg{)2P zn8^slCiA+?NR(!+NuZ1{S-MkuZF%6gv9{}!d*XLgzfH?4N!?6zAmK9F0seNx-8fs1 zXDviP*JZL(3;|+<;j`Pb3|s~}q7~H5vaL6j*f~=voG(jG12zp0Lhxjb*#NQD5r-zc z8>nBrJig*G4d%vKNVex5w1@9RM?K}U<_D?ky?<0-r@?(R`7p`ot`?H2s#>^rZ4^=FlN|z7;uANn-1>IN}N2Cr3Zk`BP^T*Bp+h=GXQ?n zq4@~xH~`i&0DT(!&VYJ`-9wFiKyS}TnG}0}0I747b%*zVRH^Xn>CK)NJe~mTrv#t_ zcabwXLIlFM0P-}L$AMa&#=dX$_}d`x3eTZ?RLY=?o8@$7*!k>srvp9PW)jSU?U;_9 z^Qe?K+IdESZGby%u+M1qd$#NeEItDAvw?m9$ftmLQX9{>7*l{gdPf)rHlFHin8at8 zf231nfja`;X`qjQ{TPtT2$-J+=#L;%GCuZM%zFe-GoTq|EqXG0J-rjFA!)YD@D%G+(%jVtWGl1QAU{d2%u&<<*Zbo86f4@e+txxnf@rS&tmU0L4FkI zvtVzu0H1hQIRnIJ0C_feJe#F6_kc5iO=q3M`0__VKFhGvjLYYO_Y5XJ1jJ{7c^Yep zHW&J!52nA`qtNH$?S3o4*oSLk&tTSPNrW?X?<5;9naK^$U}fVxx$Ap|$u2f@bg3gWkxHK%Fp4+8RMf$}i0&g=*$e&(C#qxaD0ZvpHl zv+I6`Mm!BUmxWOUFGBaUp^pXA9e5eL-vl3cNcl?@AS6vgTG5D@?CMq zTi=Sx2mN33JO2+a9~-FUJu&myl|RHap8Fr(82g7GfB2M~pO3%P.bd>ul:after{content:".";display:block;clear:both;visibility:hidden;height:0;line-height:0;}.yui-skin-sam .yuimenubaritem{float:left;}.yui-skin-sam .yuimenubarnav .yuimenubaritem{border-right:solid 1px #ccc;}.yui-skin-sam .yuimenubaritemlabel{display:block;*display:inline-block;font-size:93%;line-height:2;*line-height:1.9;padding:0 10px;color:#000;text-decoration:none;outline:none;cursor:default;border-style:solid;border-color:#808080;border-width:1px 0;position:relative;margin:-1px 0;}.yui-skin-sam .yuimenubarnav .yuimenubaritemlabel{padding-right:20px;}.yui-skin-sam .yuimenubaritemlabel .submenuindicator{width:1px;height:1px;top:0;left:0;}.yui-skin-sam .yuimenubarnav .yuimenubaritemlabel .submenuindicator{top:50%;right:8px;left:auto;margin-top:-3px;height:4px;width:7px;text-indent:8px;background-position:-16px -856px;}.yui-skin-sam .yuimenubaritem a.selected{background:url(sprite.png) repeat-x 0 -1700px;border-color:#7D98B8;}.yui-skin-sam .yuimenubarnav .yuimenubaritem a.selected{border-left-width:1px;margin-left:-1px;*left:-1px;}.yui-skin-sam .yuimenubar a.selected .submenuindicator{background:transparent;}.yui-skin-sam .yuimenubarnav a.selected .submenuindicator{background:url(sprite.png) repeat-x -16px -856px;}.yui-skin-sam .yuimenubaritem a.disabled{cursor:default;color:#A6A6A6;}.yui-skin-sam .yuimenubarnav .yuimenubaritem a.disabled .submenuindicator{background-position:-16px -881px;}.yui-skin-sam .yuimenu .bd{position:relative;top:0;left:0;border:solid 1px #808080;background-color:#fff;z-index:1;}.yui-skin-sam .yuimenu ul{padding:3px 0;border-width:1px 0 0 0;border-color:#ccc;border-style:solid;}.yui-skin-sam .yuimenu ul.first-of-type{border-width:0;}.yui-skin-sam .yuimenu h6{font-size:93%;font-weight:bold;line-height:1.5;*line-height:1.45;border-style:solid;border-color:#ccc;border-width:1px 0 0 0;color:#a4a4a4;padding:3px 10px 0 10px;}.yui-skin-sam .yuimenu ul.hastitle,.yui-skin-sam .yuimenu h6.first-of-type{border-width:0;}.yui-skin-sam .yuimenu .topscrollbar,.yui-skin-sam .yuimenu .bottomscrollbar{position:relative;height:16px;border:solid 1px #808080;background:#fff url(sprite.png) no-repeat 0 0;}.yui-skin-sam .yuimenu .topscrollbar{z-index:2;border-bottom-color:#ccc;margin-bottom:-1px;background-position:center -950px;}.yui-skin-sam .yuimenu .topscrollbar_disabled{background-position:center -975px;}.yui-skin-sam .yuimenu .bottomscrollbar{z-index:3;border-top-color:#ccc;margin-top:-1px;background-position:center -850px;}.yui-skin-sam .yuimenu .bottomscrollbar_disabled{background-position:center -875px;}.yui-skin-sam .yuimenuitemlabel{font-size:93%;line-height:1.5;*line-height:1.45;padding:0 20px;display:block;color:#000;text-decoration:none;outline:none;position:relative;cursor:default;}.yui-skin-sam .yuimenuitemlabel .helptext{font-style:normal;margin:0 0 0 40px;}.yui-skin-sam .yuimenuitemlabel .submenuindicator,.yui-skin-sam .yuimenuitemlabel .checkedindicator,.yui-skin-sam .yuimenubaritemlabel .submenuindicator{position:absolute;overflow:hidden;background:url(sprite.png) no-repeat;}.yui-skin-sam .yuimenuitemlabel .submenuindicator{top:50%;right:8px;margin-top:-3px;height:7px;width:4px;text-indent:5px;background-position:0 -906px;}.yui-skin-sam .yuimenuitemlabel .checkedindicator{top:50%;left:8px;margin-top:-3px;height:7px;width:7px;text-indent:8px;background-position:0 -1006px;}.yui-skin-sam .yui-menu-shadow-visible{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;opacity:.12;*filter:alpha(opacity=12);visibility:visible;}.yui-skin-sam .visible .bd,.yui-skin-sam .visible .yuimenuitem{_zoom:1;}.yui-skin-sam .visible .yuimenuitemlabel{*zoom:1;}.yui-skin-sam .visible .yuimenuitemlabel .helptext{float:right;width:100%;text-align:right;margin:-1.5em 0 0 0;*margin:-1.45em 0 0 0;}.yui-skin-sam .yuimenuitem a.selected{background:#B3D4FF;}.yui-skin-sam .yuimenubar .yuimenuitem a.selected .submenuindicator{background:url(sprite.png) no-repeat 0 -906px;}.yui-skin-sam .yuimenubarnav .yuimenuitem a.selected{border-width:0;margin:0;*left:0;}.yui-skin-sam .yuimenuitem a.disabled{cursor:default;color:#A6A6A6;}.yui-skin-sam .yuimenuitem a.disabled .submenuindicator{background-position:0 -931px;}.yui-skin-sam .yuimenuitem a.disabled .checkedindicator{background-position:0 -1031px;} +.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{margin:0 0.5em 0 0;}.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{margin:0 0 0.5em;}.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{width:6em;}.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{width:auto;}.yui-navset .yui-navset-left,.yui-navset-left{padding:0 0 0 6em;}.yui-navset-right{padding:0 6em 0 0;}.yui-navset-top,.yui-navset-bottom{padding:auto;}.yui-nav,.yui-nav li{margin:0;padding:0;list-style:none;}.yui-navset li em{font-style:normal;}.yui-navset{position:relative;zoom:1;}.yui-navset .yui-content{zoom:1;}.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{display:inline-block;display:-moz-inline-stack;*display:inline;vertical-align:bottom;cursor:pointer;zoom:1;}.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{display:block;}.yui-navset .yui-nav a{Xoutline:0;}.yui-navset .yui-nav a{Xposition:relative;}.yui-navset .yui-nav li a,.yui-navset-top .yui-nav li a,.yui-navset-bottom .yui-nav li a{display:block;display:inline-block;vertical-align:bottom;zoom:1;}.yui-navset-left .yui-nav li a,.yui-navset-right .yui-nav li a{display:block;}.yui-navset-bottom .yui-nav li a{vertical-align:text-top;}.yui-navset .yui-nav li a em,.yui-navset-top .yui-nav li a em,.yui-navset-bottom .yui-nav li a em{display:block;}.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{position:absolute;z-index:1;}.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{position:static;}.yui-navset .yui-navset-left .yui-nav,.yui-navset-left .yui-nav{left:0;right:auto;}.yui-navset .yui-navset-right .yui-nav,.yui-navset-right .yui-nav{right:0;left:auto;}.yui-skin-sam .yui-navset .yui-nav,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav{border:solid #2647a0;border-width:0 0 5px;Xposition:relative;zoom:1;}.yui-skin-sam .yui-navset .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav li{margin:0 0.16em 0 0;padding:1px 0 0;zoom:1;}.yui-skin-sam .yui-navset .yui-nav .selected,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav .selected{margin:0 0.16em -1px 0;}.yui-skin-sam .yui-navset .yui-nav a,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a{background:#d8d8d8 url(sprite.png) repeat-x;border:solid #a3a3a3;border-width:0 1px;color:#000;position:relative;text-decoration:none;}.yui-skin-sam .yui-navset .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a em{border:solid #a3a3a3;border-width:1px 0 0;cursor:hand;padding:0.25em .75em;left:0;right:0;bottom:0;top:-1px;position:relative;}.yui-skin-sam .yui-navset .yui-nav .selected a,.yui-skin-sam .yui-navset .yui-nav .selected a:focus,.yui-skin-sam .yui-navset .yui-nav .selected a:hover{background:#2647a0 url(sprite.png) repeat-x left -1400px;color:#fff;}.yui-skin-sam .yui-navset .yui-nav a:hover,.yui-skin-sam .yui-navset .yui-nav a:focus{background:#bfdaff url(sprite.png) repeat-x left -1300px;outline:0;}.yui-skin-sam .yui-navset .yui-nav .selected a em{padding:0.35em 0.75em;}.yui-skin-sam .yui-navset .yui-nav .selected a,.yui-skin-sam .yui-navset .yui-nav .selected a em{border-color:#243356;}.yui-skin-sam .yui-navset .yui-content{background:#edf5ff;}.yui-skin-sam .yui-navset .yui-content,.yui-skin-sam .yui-navset .yui-navset-top .yui-content{border:1px solid #808080;border-top-color:#243356;padding:0.25em 0.5em;}.yui-skin-sam .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 5px 0 0;Xposition:absolute;top:0;bottom:0;}.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 0 0 5px;}.yui-skin-sam .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset-right .yui-nav li{margin:0 0 0.16em;padding:0 0 0 1px;}.yui-skin-sam .yui-navset-right .yui-nav li{padding:0 1px 0 0;}.yui-skin-sam .yui-navset-left .yui-nav .selected,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav .selected{margin:0 -1px 0.16em 0;}.yui-skin-sam .yui-navset-right .yui-nav .selected{margin:0 0 0.16em -1px;}.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav a{border-width:1px 0;}.yui-skin-sam .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 0 0 1px;padding:0.2em .75em;top:auto;left:-1px;}.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 1px 0 0;left:auto;right:-1px;}.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-left .yui-nav .selected a,.yui-skin-sam .yui-navset-left .yui-nav a:hover,.yui-skin-sam .yui-navset-right .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav .selected a,.yui-skin-sam .yui-navset-right .yui-nav a:hover,.yui-skin-sam .yui-navset-bottom .yui-nav a,.yui-skin-sam .yui-navset-bottom .yui-nav .selected a,.yui-skin-sam .yui-navset-bottom .yui-nav a:hover{background-image:none;}.yui-skin-sam .yui-navset-left .yui-content{border:1px solid #808080;border-left-color:#243356;}.yui-skin-sam .yui-navset-bottom .yui-nav,.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav{border-width:5px 0 0;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav .selected,.yui-skin-sam .yui-navset-bottom .yui-nav .selected{margin:-1px 0.16em 0 0;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li,.yui-skin-sam .yui-navset-bottom .yui-nav li{padding:0 0 1px 0;vertical-align:top;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li a,.yui-skin-sam .yui-navset-bottom .yui-nav li a{}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav a em,.yui-skin-sam .yui-navset-bottom .yui-nav a em{border-width:0 0 1px;top:auto;bottom:-1px;}.yui-skin-sam .yui-navset-bottom .yui-content,.yui-skin-sam .yui-navset .yui-navset-bottom .yui-content{border:1px solid #808080;border-bottom-color:#243356;} +.ygtvtn{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -5600px no-repeat;}.ygtvtm{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -4000px no-repeat;}.ygtvtmh{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -4800px no-repeat;}.ygtvtp{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -6400px no-repeat;}.ygtvtph{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -7200px no-repeat;}.ygtvln{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -1600px no-repeat;}.ygtvlm{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 0px no-repeat;}.ygtvlmh{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -800px no-repeat;}.ygtvlp{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -2400px no-repeat;}.ygtvlph{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -3200px no-repeat;}.ygtvloading{width:18px;height:22px;background:url(treeview-loading.gif) 0 0 no-repeat;}.ygtvdepthcell{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -8000px no-repeat;}.ygtvblankdepthcell{width:18px;height:22px;}.ygtvitem{}.ygtvchildren{*zoom:1;}.ygtvlabel,.ygtvlabel:link,.ygtvlabel:visited,.ygtvlabel:hover{margin-left:2px;text-decoration:none;background-color:white;}.ygtvspacer{height:22px;width:18px;} + diff --git a/lib/yui/assets/skins/sam/split-button-arrow-active.png b/lib/yui/assets/skins/sam/split-button-arrow-active.png new file mode 100755 index 0000000000000000000000000000000000000000..fa58c5030e76082c84e38342cf6722c723ad2fd2 GIT binary patch literal 280 zcmV+z0q6dSP)N~-|K;%i-0c73 z@c-iO|KRQa-|hd~QeFE1003M`L_t(|+U&?l5`sVg1i`WZK}Epr|6dhmytLs92=mel z9uoULP6;mwyM%qhIpHzkHQ|(SNO(*5TD8?y@wq9xG<+26t_AN^`$=39HtEMPCOjwP e%l`;(0R{kdKn;SADLBOd00006$Gh9E#3p9{H-P6S}q~camLV^=3&tj%#_Xa_x2_Xl57U&w-9pX85Q9;Im dv4Me^VIeE)+1pK9I)PdkJYD@<);T3K0RYcxInw|D literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/split-button-arrow-focus.png b/lib/yui/assets/skins/sam/split-button-arrow-focus.png new file mode 100755 index 0000000000000000000000000000000000000000..167d71eb721ba9b85c6601f9077d5c39faa4ebd2 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_Tx)0S05bpo|DSu#^)isf zToU9L{Qp10^;5h+0~ypkT^vIyZY3ooII;39W@>hC5M-JVa^Poyu7TYlo?{mkWE>b9 b7?>Frva+7N-L$0>sD;7P)z4*}Q$iB}D9ShR literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/split-button-arrow-hover.png b/lib/yui/assets/skins/sam/split-button-arrow-hover.png new file mode 100755 index 0000000000000000000000000000000000000000..167d71eb721ba9b85c6601f9077d5c39faa4ebd2 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_Tx)0S05bpo|DSu#^)isf zToU9L{Qp10^;5h+0~ypkT^vIyZY3ooII;39W@>hC5M-JVa^Poyu7TYlo?{mkWE>b9 b7?>Frva+7N-L$0>sD;7P)z4*}Q$iB}D9ShR literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/split-button-arrow.png b/lib/yui/assets/skins/sam/split-button-arrow.png new file mode 100755 index 0000000000000000000000000000000000000000..b33a93ff2dc2039bd24e4ea3b75ecf4bb3295f84 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_TpJo1fXx5@|JyBHuocK+ zE(!7r{{Nrh`YB$Zfeh-NE{-7;w~`VPoLG4lGc~(62r^9wIqgTe~DWM4f1sXSq literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/sprite.png b/lib/yui/assets/skins/sam/sprite.png new file mode 100755 index 0000000000000000000000000000000000000000..afd65e05aaabc820fc2e6bba0740818773fcd599 GIT binary patch literal 3123 zcmYk8dpy(oAIHCQkKB(`L$fBLgHFmdwpy8rlp;APT_~3%jD%5a64_7ZI7gvht{voB zq}Rs{e+ z-3^62FY9IipggQ1FFWB*a!LR|9`HPK;e=Ew6|)+qskFuJ!wbzOg3pDl>|;V3o3~i# z`tXaj0DoRRu4F)JL)Jb=jRW`t43mpchf5=Me6i8o#fm`-snmC%q*)6 zJgNd(gTc%WKBv*>DY!0|;4d??v#YMIuOl^Bbq+b@J!^V;tP02V`Tid*LMGi6m@o8J z>n?7vsmweV&J*x_@zJ^43P|62cAM>?RX)HYWfgYv33mp7&V*j_k zr;FY`!nnAYsOL0axw(G#J+K(}+dVMze>t6NSZK5pfBZ-#M00ZvkjE)oTU%XST@s08 zV`F1|eO)9H&9hjuvvVt4?&|95vG8w9o|HJNT<)x=rgOULRl#DJn7_; zlr%4$=S#)n^-okOi_M-{mM$(X&2pu4OeU2^Utizg@%UtxY(TuYv^2++eql-nW~4*2 z(%va4l_M32#FPaojU(j?1e}!>#9cB5gMmV!e7;~+C>$gX&$HN-)iqo$Pgdgf_4clA zLjQo{tpWRh-sW+sP$+_jj4p9Fqogs*^EKAq?^!Ii{f*B@gNRd8)RmPLfvi?ndq4Jl zXlb*(+P$>IVa~I-TrP*RLMD&PRO{b2&do95p(J?N7?004J5y@mQ9+LZ^F}U-TU)=M zcU>JgQ(Ie0pI^zz$@xxn3JwltQo4AgATm~o#bRw>Fsrl-Nkq(0BW`nLX3PmfUzQdW zeJQS(;EScpS^F78^ak0Jt*Z9D$ZOYg#G$I^Ibcb`?Z0$G=NrJcNi1P~MLj@({5d zsvVS_mCSev5ra_93fY+CowAqzmGCIUr}cf>e9l{bb)!QU)&jq8fjS0h+5;0MF?t|k zbCk1M_6B?e$ku#x(@Le|8to%Q(l58xQ_+H0!}**|`k&HC9Ma~xYkcjMN1DoLr;U4% z;=~lC40=+>!JDbOH|0w`4`;T3ITXQYd8qR@d(Pl;Am;nsYeB<$^sqtj)S}aD`h(YH ziOmAy@5j~}acOD$L<+QV`#q`!5iF6ZsUYjV)tMRM2MJLni-|<$0sG?RP~LXNy6_jR zPI*9Dnn&X{h+7b-0Ikt!ZxE@`d2oBCIDU$oyZJlOc<}p%2<|9ftrA{zSZI*65Iv~Y zBq4GS0NUE7N!#)OrDK=utc_iLSPsAdW!B|^0s6*?STL`RsMh5CGC~dlJ>`>_#zsSI z)t9+vQE8Ld-yxx_&@}zN$-G!I9i#L(6z+>?-*RTk-iJj-Ujs(TQvWy2YDFEomvHAA z_o1;p6*rcBM(LchwrAhkS+Q#;qSw;RK9(PN7Iy}Bkh<7nuCtsW(`dQzE~)`}w6Mny za6sPu{FOcca!6U@QSU*a9>9VPXbr5Ba!z^U^*x5?pr=;2T$(M=n-9!9190{BKCB_Ubo6m%pJlk` zo+jnYkRu{iP1!fQ;tUP>M6$Pm!BiiDEWG^o5C2byEeCDwbNwG6E-oDgETXx~HA6F( zf$?8|lLq%??27pXOdfQx?m#N5*p4Me~` zXe0%J($efe#bduFjmvI6<^otj7iI;2M{ehcGUl+-_NK!iRt0d~N&$7x5QsIQm7|tY z0iJ16&JGU%iTow8d+)H$72O1MI|xY-Ol#kMQuV~ykqQ)g#r1x2m5;}E;?x^`7{v&i zs=dz6yJ?3MoI^jfK~2>Qy=;ESm<66;-e@tqa?MPzk0J~@d765($9CHJ>yMoqc0@sZ z)Q4=fN=6ZT{L~!q71(+3?QFuJjcpq==w{#;DgU)JWSQNpKBq$>-4c+aV=C@H`7X?i zx^;_$&8)1bU*}XEnAjO8sHm)~BWs~!q_3~u`t@{1fG?(FDz`hME+f&=@BGxup1l-WW?H>uxOYN=74bD6rp2ZP|wr6^JdS3;J)tAmOBxjhsDD*gT~ou=?|imcHPq&zs-};~KOpC*M?~AFgpC7LD!BTfmbOeJQg9%D zYMLbDb;Eu~tDTi?4b!?y{DS$(Xwp{umiD4{)~AQvwcE%1XL*Blfe$V;_1)QEH;z4Y zdcR1n7>=B&>kW9A@YbB@bidRvPJf?9%U1CYgM{F-_nsdAuu6IUy6ne@*z2LJXq5@_ z)kC|L+NL=g6S2M_jFs}T5_=bdGP(2sw-eOsc5=x`}1k$`0ZoRES{4#givEdzuB zc)c3in3=*ImpF+v4ggcV0aKV46UZ z=xxgwFL{ZHHka&C+#Pe<`X3hxERD5Gs0*9#9PY$eq0q^U&A+g?2SlHrp;gR;g9w_4 z`(RYT|Jjy@G}b<<`!yuEbnjH%i)Y~A98iF;Bt$>F|458i@D9HY0qM*^?5Af{?+;K* z{bvh8|nVnE*~rBj@x@! zof9&_7rsV}YBXM9tX-~Pu&$Heqjpz t#6&}WQC_v4-qAr9E!idrg%(C}T>`R7sV<66EZOD*xSjAoRvo+c=s&g>bp!wa literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/tabview.css b/lib/yui/assets/skins/sam/tabview.css new file mode 100755 index 0000000000..247414abb6 --- /dev/null +++ b/lib/yui/assets/skins/sam/tabview.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{margin:0 0.5em 0 0;}.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{margin:0 0 0.5em;}.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{width:6em;}.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{width:auto;}.yui-navset .yui-navset-left,.yui-navset-left{padding:0 0 0 6em;}.yui-navset-right{padding:0 6em 0 0;}.yui-navset-top,.yui-navset-bottom{padding:auto;}.yui-nav,.yui-nav li{margin:0;padding:0;list-style:none;}.yui-navset li em{font-style:normal;}.yui-navset{position:relative;zoom:1;}.yui-navset .yui-content{zoom:1;}.yui-navset .yui-nav li,.yui-navset .yui-navset-top .yui-nav li,.yui-navset .yui-navset-bottom .yui-nav li{display:inline-block;display:-moz-inline-stack;*display:inline;vertical-align:bottom;cursor:pointer;zoom:1;}.yui-navset-left .yui-nav li,.yui-navset-right .yui-nav li{display:block;}.yui-navset .yui-nav a{Xoutline:0;}.yui-navset .yui-nav a{Xposition:relative;}.yui-navset .yui-nav li a,.yui-navset-top .yui-nav li a,.yui-navset-bottom .yui-nav li a{display:block;display:inline-block;vertical-align:bottom;zoom:1;}.yui-navset-left .yui-nav li a,.yui-navset-right .yui-nav li a{display:block;}.yui-navset-bottom .yui-nav li a{vertical-align:text-top;}.yui-navset .yui-nav li a em,.yui-navset-top .yui-nav li a em,.yui-navset-bottom .yui-nav li a em{display:block;}.yui-navset .yui-navset-left .yui-nav,.yui-navset .yui-navset-right .yui-nav,.yui-navset-left .yui-nav,.yui-navset-right .yui-nav{position:absolute;z-index:1;}.yui-navset-top .yui-nav,.yui-navset-bottom .yui-nav{position:static;}.yui-navset .yui-navset-left .yui-nav,.yui-navset-left .yui-nav{left:0;right:auto;}.yui-navset .yui-navset-right .yui-nav,.yui-navset-right .yui-nav{right:0;left:auto;}.yui-skin-sam .yui-navset .yui-nav,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav{border:solid #2647a0;border-width:0 0 5px;Xposition:relative;zoom:1;}.yui-skin-sam .yui-navset .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav li{margin:0 0.16em 0 0;padding:1px 0 0;zoom:1;}.yui-skin-sam .yui-navset .yui-nav .selected,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav .selected{margin:0 0.16em -1px 0;}.yui-skin-sam .yui-navset .yui-nav a,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a{background:#d8d8d8 url(sprite.png) repeat-x;border:solid #a3a3a3;border-width:0 1px;color:#000;position:relative;text-decoration:none;}.yui-skin-sam .yui-navset .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-top .yui-nav a em{border:solid #a3a3a3;border-width:1px 0 0;cursor:hand;padding:0.25em .75em;left:0;right:0;bottom:0;top:-1px;position:relative;}.yui-skin-sam .yui-navset .yui-nav .selected a,.yui-skin-sam .yui-navset .yui-nav .selected a:focus,.yui-skin-sam .yui-navset .yui-nav .selected a:hover{background:#2647a0 url(sprite.png) repeat-x left -1400px;color:#fff;}.yui-skin-sam .yui-navset .yui-nav a:hover,.yui-skin-sam .yui-navset .yui-nav a:focus{background:#bfdaff url(sprite.png) repeat-x left -1300px;outline:0;}.yui-skin-sam .yui-navset .yui-nav .selected a em{padding:0.35em 0.75em;}.yui-skin-sam .yui-navset .yui-nav .selected a,.yui-skin-sam .yui-navset .yui-nav .selected a em{border-color:#243356;}.yui-skin-sam .yui-navset .yui-content{background:#edf5ff;}.yui-skin-sam .yui-navset .yui-content,.yui-skin-sam .yui-navset .yui-navset-top .yui-content{border:1px solid #808080;border-top-color:#243356;padding:0.25em 0.5em;}.yui-skin-sam .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav,.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 5px 0 0;Xposition:absolute;top:0;bottom:0;}.yui-skin-sam .yui-navset .yui-navset-right .yui-nav,.yui-skin-sam .yui-navset-right .yui-nav{border-width:0 0 0 5px;}.yui-skin-sam .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav li,.yui-skin-sam .yui-navset-right .yui-nav li{margin:0 0 0.16em;padding:0 0 0 1px;}.yui-skin-sam .yui-navset-right .yui-nav li{padding:0 1px 0 0;}.yui-skin-sam .yui-navset-left .yui-nav .selected,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav .selected{margin:0 -1px 0.16em 0;}.yui-skin-sam .yui-navset-right .yui-nav .selected{margin:0 0 0.16em -1px;}.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav a{border-width:1px 0;}.yui-skin-sam .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset .yui-navset-left .yui-nav a em,.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 0 0 1px;padding:0.2em .75em;top:auto;left:-1px;}.yui-skin-sam .yui-navset-right .yui-nav a em{border-width:0 1px 0 0;left:auto;right:-1px;}.yui-skin-sam .yui-navset-left .yui-nav a,.yui-skin-sam .yui-navset-left .yui-nav .selected a,.yui-skin-sam .yui-navset-left .yui-nav a:hover,.yui-skin-sam .yui-navset-right .yui-nav a,.yui-skin-sam .yui-navset-right .yui-nav .selected a,.yui-skin-sam .yui-navset-right .yui-nav a:hover,.yui-skin-sam .yui-navset-bottom .yui-nav a,.yui-skin-sam .yui-navset-bottom .yui-nav .selected a,.yui-skin-sam .yui-navset-bottom .yui-nav a:hover{background-image:none;}.yui-skin-sam .yui-navset-left .yui-content{border:1px solid #808080;border-left-color:#243356;}.yui-skin-sam .yui-navset-bottom .yui-nav,.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav{border-width:5px 0 0;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav .selected,.yui-skin-sam .yui-navset-bottom .yui-nav .selected{margin:-1px 0.16em 0 0;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li,.yui-skin-sam .yui-navset-bottom .yui-nav li{padding:0 0 1px 0;vertical-align:top;}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav li a,.yui-skin-sam .yui-navset-bottom .yui-nav li a{}.yui-skin-sam .yui-navset .yui-navset-bottom .yui-nav a em,.yui-skin-sam .yui-navset-bottom .yui-nav a em{border-width:0 0 1px;top:auto;bottom:-1px;}.yui-skin-sam .yui-navset-bottom .yui-content,.yui-skin-sam .yui-navset .yui-navset-bottom .yui-content{border:1px solid #808080;border-bottom-color:#243356;} diff --git a/lib/yui/assets/skins/sam/treeview-loading.gif b/lib/yui/assets/skins/sam/treeview-loading.gif new file mode 100755 index 0000000000000000000000000000000000000000..0bbf3bc0c0e5e635553e8d1bf9ceddefbc402396 GIT binary patch literal 2673 zcmchY_gj;P7RTSb83YJ1>=8y5ONL=ZcEgk+C?FydumNNz8c=c6`n&|fmMu_HHG%^w zNLVjHyfy)hAgHK_Kxkz+0Ktm5M|X*?y?g!o_3yv`{_^F^wY9YuFJ3GxEUd1s-nnz<)vH(c?%i8n zUVirM+2rIT007UQKY#e};oRKZty{MqJa}MhYina;bNBAu-+udTYHDhBcJ|n@WA*j* z-+lL;iHS*OX6D|#dm|zu!o$ON?b=mbT)bh!26uP&kdP1u2Zx!N8486$B9X?&$DclZ zdgI28>FMdk#l`#g@Bj4EPc=0)2M!!4EG!%z9?s6rzI5r**|TSdhK8)HtXf)HHgDc+ zZEek9Fk)k4xm@nHZQC3j9o^jACMG6~jg9m3^EYnX2*Yq^XJ>6~?X_#y4jnqQbLUQp zM6z$+zMp^o*}}p?p-?n8H=jOzx~Zv&N~Km+RkgLX9X@>c=FOXxm6dsUd1NvZ zX=yul?BMZua=F~p)O7py?EwJ+w{PD*dGh2hzx?v((WCP6au$mb!vmnqSpF6-9Ona(JQT#e>!KODwxYzG5#S|?M#v6eD#mgO^`=~9EL;yL&>*dd5*+XG=_`^3=CG25PbLa+LJ%N(PW_s z=_-TaM{SB!w(n7k+dMDN2G6VPqUA$u7F4m@ABAZ1D`*UMfe}E6csJU}J1Trmp#~7hZ5QSGpNvd1Uz$!Rf3q28pgSj9o zx?zwoWa8GYK@TOz^)mp#V2_VR5WfJ0W9BSSbn+cKb z7B9l9)K#s!?PSt;g%c8u;y7rd?hkP%>vq5BY=N>c=98V=+T&RSPgSu|E(FAK>B?vNN1 zPszwcbxJ?Oh|1pGd!9?gxzSWOR8o=x5!rGh+6r3hBL-14aTaAQxvJ|Y-S_m4niV2S zK@?}-9Dkhg<+w{Ny!vjyp-QmjyGmIW1DFB{k>P2=8cm~9M^_P#8?JFDumGEPaqJvf zZ{f;B#CG;H7q8a_hQ$pR6%%6So8vKM+W+cNPE_TI46^dn9q@qBr@1bUgxcPGB*b-i z3Hx_0(Esy5KKx^Y0yfgB6~}t>@!ctk>J|!vgVRhE2CPQ;AOKY2y%5nM@YF^ZMS~q}%L-n>Lpor#4w48UHYViOt={{43LMRvkIp+rkbs*s; z14}4q0y6`s8DL?uo-~*R@5tnFsC1DR#BGxT8fA20u_o?`0iDNI6lf;^$@AkR1dPTz z>XF1ZAqNjU95c@Vn59Wo;Z6b(YG+L$xy3(?j2I*vQ>PmzMEdh`yw3=)E}JYMDG|*x mDkGVJ;D)fXhxDI?kcM(ish)*oZEbC8g{gpmfWg7R(&qow=l|H~|Jv#Q-R%G0?f>H9 zFVn1?CkCD@8IqK|D@c-rT|K{=k@bU5T^7Qrf_4fAn_xbty`uh9(`v3p{ z000000000000000A^8LW000{REC2ui01^OTA^-*c;3ke_X_CUJuI!e!LoCm6IcRvU z;{$nPJ546T^I?w13+8eeW_qImb4tBfEKt$FGQE1e+0CF*0hrHb3uO>+i76B`8g6sg z?+r@h9v(Cp4S|A#eGG<&h<|+xjE#07FJR?d5um5f zpFK+im_W3sQKD@|3_Z#;sfeKvh(?_-HLBAM0itTv8lh{1t63q4h45hPSg;8a$T?Fs zXo>&{Agnd>zyVqWc=PH-0QP|2zkvOMHDJJR0mFv{lL%0NK!L}QBZDPCxw2)-SFr-! ze6zFX&!9t#9!C>oFt6t5zwd>cgW6PdRySDAyxO3~?&AYen-@t4~Q^e#vzLM@W_}8L{iC_m#oNQiEOs%=9_TFDd(JY z)@kRRc;>0+o_zM{=bwNED(Iku7Ha6Bh$gD&qKr1`=%bKED(R$@R%+>`&!l*YrkioL z7*kDs3aU|HQ6-fbQX%!}R%S%y6+QGThAZy4+ZYo z#w+i<^ww+dz4+#<@4o!@>+ipGYHA7qo2WTMi!tT^V-7&P=mQQ&ED z(6$?Dr>&FRue@zH-Q?kIp5Ey34RqXq&mDN(ezR9Niie|e_uzRmzPICjL;knmloKww z;g=(xx#Ed$+PNwIi&x&b=#P^gx#^QzjymS6Yu-BNn|mHR=${W=d(pQaoqN)|FWr07 zzds#()Wc6*eAUNaoqX2IZ{2*?&wm|#*wc?)ec9KaJ-hAOY4<<2WzT>GblU+Hm_WD1rd2GO@c^>vVaA9P;`;WtA0m5_cXv|kGGw?h53kbf`qUkm}Lx*Cqo zhNZ*d>2#R78~QMZKipvudkDlL3eku}Jfael$VArh(1}BYA`+#zL@GAXbx*`%6ty@- zE>_WtSA_oE3=ud+2A0u*SrlU$1-M26o-uT7gkT&cI7bTB(SmoxU>-HNM-KMUgMS2J zAVoMx5*E^gheTl_Rk%nNHqwQUgkdCQI7u3AQH_^mViYEln zBCECFs#d+SOB>#jfCHo@0eR^sK>HGyf)0i-2rW!Pq1713IOZ_~FaWixRha@@%bP(7 zBmOhLs7#J-RHM$^CM!kiN|M6Tq_RXQEmdkumg3T-x`Zh&W$H_s0@J3##3?a#YD}IY z)1x5;sx^g*O`>YksN6*ANR?Vrrk>QPDTV4vrP@-ezSOEQ#p+D8T2rpx)T=oK>rTbm zQ?mXPq(en(QPp}>wkFlBONDDw<@!{*M%AuU#cNgddR4w=)vsFxY*z*QRl@d8kL@U9q3Kh~n$@zCm1bo%ds)tAmYSUf?PuXQP10^ww2}R2YJ)o31)>(R zu$Am;(>mL=*0!y;eQR#xy4$(-wywXuYjE>A+`SgJugCpsas#{E!8W(B&pm8({u4Xh z#a6emu~lt$S$kc~cGt7teXVS_OIz~V*1WhyuWr@LTlV_ay}*U9aOF!}`Wn~1$i=U6 z^~+rTI@iC@1+a7lOkDz7*TC2vuY$F^VD2K=yAK9$gvHC?3Ol&L<;C!MHJn}!uh+xv z1@U`D9A6U8*TnTj@qJaCUl#Az#r=ixe`OqC8V}gU1;+7#b(~-eXV}LZ26Bgm{9z)8 z*vKPBa*36EVkW29$t#9(i>3TxD#zH$Gsbd_wR~eP=h(|T26K-uEM^Gv*vw^?@R`+| zW(t$}%|C{7kmWpNIv3f_N5*rK^}J+0H`&im26U7KJ!L{y+0a);be0wVy=6vs+0kEy zbeJVQ<~Un=&X=xprtiGzJa>A}pYF5m+(YU$yE)Wa7Im^yz3f#tyVcKrb+ltW?O9j5*4MsuwsXDh zU3a_J-~P3*$4zW<8{6E-Mz^xn&1`l%+uhKHx3uL=ZF*bV-q^;sw)M?zetX;B;0Cz3 z%T4fe7d+huUw6XWz3_K8Jl+qVcf{*G@q1T1-xuF^#{0eTe|J3KA0N2EM~-lkE8OG^ zN4djQ4sn)C+~pL9xy5CUahhw~<{Zbl$8`>Jo{PNXKtFlVQ$GIml^4C`M}K+JW4`p6 zH@)Uhzj@SiKJ}efz2{f|xzM*xbgmoS>qrN?(#6hnvOC@EP)EDe)lPM`Tixwghr8Ch zPWP|ZJ?wWMd)~{w_p|ps?SEf;;M+d)r8uhrHh<4|vK8-tvUU zyx}#Ec+M-n@t}Wv=p#S+$(O$Jr@wsaGr#)Hx4!eQ|GemDPkP#$-u9@+z3O$(dfvO< z_pk@P>}yZ_+ZR9g$KQSOd%yhOH$V8#AHMOYk9_JY-}=nQzVo#YeeO%Y`ryBQ__II$ z?U%p%=l{O=*H3=-o8SHDhrjyUPyhGVKmPZhzy0@*fBydKzyAREe*%bRltzHQW`N;_ zfC8t0A;*9|=YUxUfpRB-iARB+XMwSYfx@SO(Z_+_=Yi=5g7PPV`A35OXMzEUf&<8A z1;~O2=z^p`FfiaVX_7Ds^DqqKA`62AW?&-};{!Yb09Al7UeF^OQzRcV7a;>BB(oN9 za577xGExEnE7JfklO}oa2#K*MiL*$F zwP=aAh>5wViMz;&cld(6sDi?{iNhF-#CVLxn2f)uhswBy&gh2E_(stfO3Ubp)d-5$ zD2mxgirZ+4-H3|csEXmpisR^t-edkZm}S4q1>2d5{m8kQ2F(5!sLsS& zDTg#Elr~9}IBAqR`I9nSUG?;3{U|PG12}X3;8UflqS*0SUmDYmpWK;2r^> z7q$XWc|lNrfh>SQP=`?f&2j*TF&WYFP}8y)6m=OFg;856mR0GQR|%R~>6M*{hyQq* zQz@EVshVF&nqg_0sR^5(DVw25o1@8^r3s9vIh(o}o4v`K%($Di`J2NToW5zCz-f)g zshr7)jmznr&8dygDV@>DjniqJ)#;7bsh!ygj@#*--6@XWDW2g;j^k;bY-fY{B5qdV%PaSEk#Dy4Nw zrFUwjd5Wcbs-=C(rGM(BfeNOBDyD@>riW^#iHfF+s-}&~rjP2TkqW0h%A-F@rCl_sp_Yz>Z+{@sIMxku_~yuYOA$MsJE)C zxoW7p>Z`qqsJ|+#!K$dkYOKY|sK=_T$?B-f>a5KQsn05{(JHCaYOU2uso83zZ_2Hc z>aEwRtv9Nv+lr)1DxBSFuIb98->R6U(d>3#}JRtr?508!N6*`LSRLvaTtz KHVU#K0029HfgIHU literal 0 HcmV?d00001 diff --git a/lib/yui/assets/skins/sam/treeview.css b/lib/yui/assets/skins/sam/treeview.css new file mode 100755 index 0000000000..b82d34e6e8 --- /dev/null +++ b/lib/yui/assets/skins/sam/treeview.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.ygtvtn{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -5600px no-repeat;}.ygtvtm{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -4000px no-repeat;}.ygtvtmh{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -4800px no-repeat;}.ygtvtp{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -6400px no-repeat;}.ygtvtph{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -7200px no-repeat;}.ygtvln{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -1600px no-repeat;}.ygtvlm{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 0px no-repeat;}.ygtvlmh{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -800px no-repeat;}.ygtvlp{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -2400px no-repeat;}.ygtvlph{width:18px;height:22px;cursor:pointer;background:url(treeview-sprite.gif) 0 -3200px no-repeat;}.ygtvloading{width:18px;height:22px;background:url(treeview-loading.gif) 0 0 no-repeat;}.ygtvdepthcell{width:18px;height:22px;background:url(treeview-sprite.gif) 0 -8000px no-repeat;}.ygtvblankdepthcell{width:18px;height:22px;}.ygtvitem{}.ygtvchildren{*zoom:1;}.ygtvlabel,.ygtvlabel:link,.ygtvlabel:visited,.ygtvlabel:hover{margin-left:2px;text-decoration:none;background-color:white;}.ygtvspacer{height:22px;width:18px;} diff --git a/lib/yui/assets/skins/sam/yuitest.css b/lib/yui/assets/skins/sam/yuitest.css new file mode 100755 index 0000000000..8b4d7cdee7 --- /dev/null +++ b/lib/yui/assets/skins/sam/yuitest.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ + diff --git a/lib/yui/autocomplete/README b/lib/yui/autocomplete/README index 39c1cd89cf..89659ae9fb 100755 --- a/lib/yui/autocomplete/README +++ b/lib/yui/autocomplete/README @@ -1,5 +1,56 @@ AutoComplete Release Notes +*** version 2.3.0 *** + +* Applied new skinning model. + +* The default queryDelay value has been changed to 0.2. In low-latency +implementations (e.g., when queryDelay is set to 0 against a local +JavaScript DataSource), typeAhead functionality may experience a race condition +when retrieving the value of the textbox. To avoid this problem, implementers +are advised not to set the queryDelay value too low. + +* Fixed runtime property value validation. + +* Implemented new method doBeforeSendQuery(). + +* Implemented new method destroy(). + +* Added support for latest JSON lib http://www.json.org/json.js. + +* Fixed forceSelection issues with matched selections and multiple selections. + +* No longer create var oAnim in global scope. + +* The properties alwaysShowContainer and useShadow should not be enabled together. + +* There is a known issue in Firefox where the native browser autocomplete +attribute cannot be disabled programmatically on input boxes that are in use. + + + + + +**** version 2.2.2 *** + +* No changes. + + + +*** version 2.2.1 *** + +* Fixed form submission in Safari bug. +* Fixed broken DS_JSArray support for minQueryLength=0. +* Improved type checking with YAHOO.lang. + + + +*** version 2.2.0 *** + +* No changes. + + + *** version 0.12.2 *** * No changes. diff --git a/lib/yui/autocomplete/assets/autocomplete-core.css b/lib/yui/autocomplete/assets/autocomplete-core.css new file mode 100755 index 0000000000..921fad9617 --- /dev/null +++ b/lib/yui/autocomplete/assets/autocomplete-core.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/* This file intentionally left blank */ diff --git a/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css b/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css new file mode 100755 index 0000000000..a2d2359072 --- /dev/null +++ b/lib/yui/autocomplete/assets/skins/sam/autocomplete-skin.css @@ -0,0 +1,50 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/* styles for entire widget */ +.yui-skin-sam .yui-ac { + position:relative;font-family:arial;font-size:100%; +} + +/* styles for input field */ +.yui-skin-sam .yui-ac-input { + position:absolute;width:100%; +} + +/* styles for results container */ +.yui-skin-sam .yui-ac-container { + position:absolute;top:1.6em;width:100%; +} + +/* styles for header/body/footer wrapper within container */ +.yui-skin-sam .yui-ac-content { + position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050; +} + +/* styles for container shadow */ +.yui-skin-sam .yui-ac-shadow { + position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity: 0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049; +} + +/* styles for results list */ +.yui-skin-sam .yui-ac-content ul{ + margin:0;padding:0;width:100%; +} + +/* styles for result item */ +.yui-skin-sam .yui-ac-content li { + margin:0;padding:2px 5px;cursor:default;white-space:nowrap; +} + +/* styles for prehighlighted result item */ +.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight { + background:#B3D4FF; +} + +/* styles for highlighted result item */ +.yui-skin-sam .yui-ac-content li.yui-ac-highlight { + background:#426FD9;color:#FFF; +} diff --git a/lib/yui/autocomplete/assets/skins/sam/autocomplete.css b/lib/yui/autocomplete/assets/skins/sam/autocomplete.css new file mode 100755 index 0000000000..98b473e26a --- /dev/null +++ b/lib/yui/autocomplete/assets/skins/sam/autocomplete.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-skin-sam .yui-ac{position:relative;font-family:arial;font-size:100%;}.yui-skin-sam .yui-ac-input{position:absolute;width:100%;}.yui-skin-sam .yui-ac-container{position:absolute;top:1.6em;width:100%;}.yui-skin-sam .yui-ac-content{position:absolute;width:100%;border:1px solid #808080;background:#fff;overflow:hidden;z-index:9050;}.yui-skin-sam .yui-ac-shadow{position:absolute;margin:.3em;width:100%;background:#000;-moz-opacity:0.10;opacity:.10;filter:alpha(opacity=10);z-index:9049;}.yui-skin-sam .yui-ac-content ul{margin:0;padding:0;width:100%;}.yui-skin-sam .yui-ac-content li{margin:0;padding:2px 5px;cursor:default;white-space:nowrap;}.yui-skin-sam .yui-ac-content li.yui-ac-prehighlight{background:#B3D4FF;}.yui-skin-sam .yui-ac-content li.yui-ac-highlight{background:#426FD9;color:#FFF;} diff --git a/lib/yui/autocomplete/autocomplete-debug.js b/lib/yui/autocomplete/autocomplete-debug.js index 45dc20894d..522add11f0 100755 --- a/lib/yui/autocomplete/autocomplete-debug.js +++ b/lib/yui/autocomplete/autocomplete-debug.js @@ -1,3097 +1,3253 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 +version: 2.3.0 */ - /** - * The AutoComplete control provides the front-end logic for text-entry suggestion and - * completion functionality. - * - * @module autocomplete - * @requires yahoo, dom, event, datasource - * @optional animation, connection, json - * @namespace YAHOO.widget - * @title AutoComplete Widget - */ - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The AutoComplete class provides the customizable functionality of a plug-and-play DHTML - * auto completion widget. Some key features: - *
    - *
  • Navigate with up/down arrow keys and/or mouse to pick a selection
  • - *
  • The drop down container can "roll down" or "fly out" via configurable - * animation
  • - *
  • UI look-and-feel customizable through CSS, including container - * attributes, borders, position, fonts, etc
  • - *
- * - * @class AutoComplete - * @constructor - * @param elInput {HTMLElement} DOM element reference of an input field. - * @param elInput {String} String ID of an input field. - * @param elContainer {HTMLElement} DOM element reference of an existing DIV. - * @param elContainer {String} String ID of an existing DIV. - * @param oDataSource {Object} Instance of YAHOO.widget.DataSource for query/results. - * @param oConfigs {Object} (optional) Object literal of configuration params. - */ -YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) { - if(elInput && elContainer && oDataSource) { - // Validate DataSource - 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(elInput)) { - if(typeof elInput == "string") { - this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput; - this._oTextbox = document.getElementById(elInput); - } - else { - this._sName = (elInput.id) ? - "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput.id: - "instance" + YAHOO.widget.AutoComplete._nIndex; - this._oTextbox = elInput; - } - } - 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(elContainer)) { - if(typeof elContainer == "string") { - this._oContainer = document.getElementById(elContainer); - } - else { - this._oContainer = elContainer; - } - 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,"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); - } - YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,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 DataSource object that encapsulates the data used for auto completion. - * This object should be an inherited object from YAHOO.widget.DataSource. - * - * @property dataSource - * @type Object - */ -YAHOO.widget.AutoComplete.prototype.dataSource = null; - -/** - * Number of characters that must be entered before querying for results. A negative value - * effectively turns off the widget. A value of 0 allows queries of null or empty string - * values. - * - * @property minQueryLength - * @type Number - * @default 1 - */ -YAHOO.widget.AutoComplete.prototype.minQueryLength = 1; - -/** - * Maximum number of results to display in results container. - * - * @property maxResultsDisplayed - * @type Number - * @default 10 - */ -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. - * - * @property queryDelay - * @type Number - * @default 0.5 - */ -YAHOO.widget.AutoComplete.prototype.queryDelay = 0.5; - -/** - * Class name of a highlighted item within results container. - * - * @property highlighClassName - * @type String - * @default "yui-ac-highlight" - */ -YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight"; - -/** - * Class name of a pre-highlighted item within results container. - * - * @property prehighlightClassName - * @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. - * - * @property delimChar - * @type String | String[] - */ -YAHOO.widget.AutoComplete.prototype.delimChar = null; - -/** - * Whether or not the first item in results container should be automatically highlighted - * on expand. - * - * @property autoHighlight - * @type Boolean - * @default true - */ -YAHOO.widget.AutoComplete.prototype.autoHighlight = true; - -/** - * Whether or not the 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. - * - * @property typeAhead - * @type Boolean - * @default false - */ -YAHOO.widget.AutoComplete.prototype.typeAhead = false; - -/** - * Whether or not to animate the expansion/collapse of the results container in the - * horizontal direction. - * - * @property animHoriz - * @type Boolean - * @default false - */ -YAHOO.widget.AutoComplete.prototype.animHoriz = false; - -/** - * Whether or not to animate the expansion/collapse of the results container in the - * vertical direction. - * - * @property animVert - * @type Boolean - * @default true - */ -YAHOO.widget.AutoComplete.prototype.animVert = true; - -/** - * Speed of container expand/collapse animation, in seconds.. - * - * @property animSpeed - * @type Number - * @default 0.3 - */ -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 input field into a - * <select> field. This feature is not recommended with delimiter character(s) - * defined. - * - * @property forceSelection - * @type Boolean - * @default false - */ -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 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. - * - * @property allowBrowserAutocomplete - * @type Boolean - * @default true - */ -YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true; - -/** - * Whether or not the results container should always be displayed. - * Enabling this feature displays the container when the widget is instantiated - * and prevents the toggling of the container to a collapsed state. - * - * @property alwaysShowContainer - * @type Boolean - * @default false - */ -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 results 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). - * - * @property useIFrame - * @type Boolean - * @default false - */ -YAHOO.widget.AutoComplete.prototype.useIFrame = false; - -/** - * Whether or not the results container should have a shadow. - * - * @property useShadow - * @type Boolean - * @default false - */ -YAHOO.widget.AutoComplete.prototype.useShadow = false; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - - /** - * Public accessor to the unique name of the AutoComplete instance. - * - * @method toString - * @return {String} Unique name of the AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.toString = function() { - return "AutoComplete " + this._sName; -}; - - /** - * Returns true if container is in an expanded state, false otherwise. - * - * @method isContainerOpen - * @return {Boolean} Returns true if container is in an expanded state, false otherwise. - */ -YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() { - return this._bContainerOpen; -}; - -/** - * Public accessor to the internal array of DOM <li> elements that - * display query results within the results container. - * - * @method getListItems - * @return {HTMLElement[]} Array of <li> elements within the results container. - */ -YAHOO.widget.AutoComplete.prototype.getListItems = function() { - return this._aListItems; -}; - -/** - * Public accessor to the data held in an <li> element of the - * results container. - * - * @method getListItemData - * @return {Object | 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 results container header. This markup will be - * inserted within a <div> tag with a class of "ac_hd". - * - * @method setHeader - * @param sHeader {String} HTML markup for results 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 results container footer. This markup will be - * inserted within a <div> tag with a class of "ac_ft". - * - * @method setFooter - * @param sFooter {String} HTML markup for results 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 results container body. This markup will be - * inserted within a <div> tag with a class of "ac_bd". - * - * @method setBody - * @param sHeader {String} HTML markup for results 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. - * - * @method formatResult - * @param oResultItem {Object} Result item representing one query result. Data is held in an array. - * @param sQuery {String} 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 ""; - } -}; - -/** - * Overridable method called before container expands allows implementers to access data - * and DOM elements. - * - * @method doBeforeExpandContainer - * @return {Boolean} Return true to continue expanding container, false to cancel the expand. - */ -YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oResultItem, sQuery) { - return true; -}; - -/** - * Makes query request to the DataSource. - * - * @method sendQuery - * @param sQuery {String} Query string. - */ -YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) { - this._sendQuery(sQuery); -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public events -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Fired when the input field receives focus. - * - * @event textboxFocusEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null; - -/** - * Fired when the input field receives key input. - * - * @event textboxKeyEvent - * @param oSelf {Object} The AutoComplete instance. - * @param nKeycode {Number} The keycode number. - */ -YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null; - -/** - * Fired when the AutoComplete instance makes a query to the DataSource. - * - * @event dataRequestEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The query string. - */ -YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null; - -/** - * Fired when the AutoComplete instance receives query results from the data - * source. - * - * @event dataReturnEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The query string. - * @param aResults {Array} Results array. - */ -YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null; - -/** - * Fired when the AutoComplete instance does not receive query results from the - * DataSource due to an error. - * - * @event dataErrorEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The query string. - */ -YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null; - -/** - * Fired when the results container is expanded. - * - * @event containerExpandEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null; - -/** - * Fired when the input field has been prefilled by the type-ahead - * feature. - * - * @event typeAheadEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The query string. - * @param sPrefill {String} The prefill string. - */ -YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null; - -/** - * Fired when result item has been moused over. - * - * @event itemMouseOverEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} The <li> element item moused to. - */ -YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null; - -/** - * Fired when result item has been moused out. - * - * @event itemMouseOutEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} The <li> element item moused from. - */ -YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null; - -/** - * Fired when result item has been arrowed to. - * - * @event itemArrowToEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} The <li> element item arrowed to. - */ -YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null; - -/** - * Fired when result item has been arrowed away from. - * - * @event itemArrowFromEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} 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. - * - * @event itemSelectEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} The selected <li> element item. - * @param oData {Object} 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 a 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. - * - * @event unmatchedItemSelectEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The user-typed query string. - */ -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. - * - * @event selectionEnforceEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null; - -/** - * Fired when the results container is collapsed. - * - * @event containerCollapseEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null; - -/** - * Fired when the input field loses focus. - * - * @event textboxBlurEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple AutoComplete instances. - * - * @property _nIndex - * @type Number - * @default 0 - * @private - */ -YAHOO.widget.AutoComplete._nIndex = 0; - -/** - * Name of AutoComplete instance. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._sName = null; - -/** - * Text input field DOM element. - * - * @property _oTextbox - * @type HTMLElement - * @private - */ -YAHOO.widget.AutoComplete.prototype._oTextbox = null; - -/** - * Whether or not the input field is currently in focus. If query results come back - * but the user has already moved on, do not proceed with auto complete behavior. - * - * @property _bFocused - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._bFocused = true; - -/** - * Animation instance for container expand/collapse. - * - * @property _oAnim - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._oAnim = null; - -/** - * Container DOM element. - * - * @property _oContainer - * @type HTMLElement - * @private - */ -YAHOO.widget.AutoComplete.prototype._oContainer = null; - -/** - * Whether or not the results container is currently open. - * - * @property _bContainerOpen - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._bContainerOpen = false; - -/** - * Whether or not the mouse is currently over the results - * container. This is necessary in order to prevent clicks on container items - * from being text input field blur events. - * - * @property _bOverContainer - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._bOverContainer = false; - -/** - * Array of <li> elements references that contain query results within the - * results container. - * - * @property _aListItems - * @type Array - * @private - */ -YAHOO.widget.AutoComplete.prototype._aListItems = null; - -/** - * Number of <li> elements currently displayed in results container. - * - * @property _nDisplayedItems - * @type Number - * @private - */ -YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0; - -/** - * Internal count of <li> elements displayed and hidden in results container. - * - * @property _maxResultsDisplayed - * @type Number - * @private - */ -YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0; - -/** - * Current query string - * - * @property _sCurQuery - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._sCurQuery = null; - -/** - * Past queries this session (for saving delimited queries). - * - * @property _sSavedQuery - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._sSavedQuery = null; - -/** - * Pointer to the currently highlighted <li> element in the container. - * - * @property _oCurItem - * @type HTMLElement - * @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. - * - * @property _bItemSelected - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._bItemSelected = false; - -/** - * Key code of the last key pressed in textbox. - * - * @property _nKeyCode - * @type Number - * @private - */ -YAHOO.widget.AutoComplete.prototype._nKeyCode = null; - -/** - * Delay timeout ID. - * - * @property _nDelayID - * @type Number - * @private - */ -YAHOO.widget.AutoComplete.prototype._nDelayID = -1; - -/** - * Src to iFrame used when useIFrame = true. Supports implementations over SSL - * as well. - * - * @property _iFrameSrc - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;"; - -/** - * For users typing via certain IMEs, queries must be triggered by intervals, - * since key events yet supported across all browsers for all IMEs. - * - * @property _queryInterval - * @type Object - * @private - */ -YAHOO.widget.AutoComplete.prototype._queryInterval = null; - -/** - * Internal tracker to last known textbox value, used to determine whether or not - * to trigger a query via interval for certain IME users. - * - * @event _sLastTextboxValue - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Updates and validates latest public config properties. - * - * @method __initProps - * @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()); - } -}; - -/** - * Initializes the results container helpers if they are enabled and do - * not exist - * - * @method _initContainerHelpers - * @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%"; - oIFrame.tabIndex = -1; - this._oContainer._oIFrame = this._oContainer.appendChild(oIFrame); - } -}; - -/** - * Initializes the results container once at object creation - * - * @method _initContainer - * @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. - * - * @method _initList - * @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= 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; -}; - -/** - * Makes query request to the DataSource. - * - * @method _sendQuery - * @param sQuery {String} Query string. - * @private - */ -YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) { - // Widget has been effectively turned off - if(this.minQueryLength == -1) { - this._toggleContainer(false); - return; - } - // 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 && (sQuery.length < this.minQueryLength) || (!sQuery && this.minQueryLength > 0)) { - if (this._nDelayID != -1) { - clearTimeout(this._nDelayID); - } - this._toggleContainer(false); - 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); -}; - -/** - * 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 instance are returned to the - * AutoComplete instance. - * - * @method _populateList - * @param sQuery {String} The query string. - * @param aResults {Array} An array of query result objects from the DataSource. - * @param oSelf {Object} The AutoComplete 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 - var ok = oSelf.doBeforeExpandContainer(oSelf._oTextbox, oSelf._oContainer, sQuery, aResults); - oSelf._toggleContainer(ok); - } - else { - oSelf._toggleContainer(false); - } - oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults); -}; - -/** - * When forceSelection is true and the user attempts - * leave the text input box without selecting an item from the query results, - * the user selection is cleared. - * - * @method _clearSelection - * @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. - * - * @method _textMatchesOption - * @return {Boolean} True if user-input text matches a result, false otherwise. - * @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. - * - * @method _typeAhead - * @param oItem {HTMLElement} The <li> element item whose data populates the input field. - * @param sQuery {String} Query string. - * @private - */ -YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) { - // Don't update if turned off - if (!this.typeAhead || (this._nKeyCode == 8)) { - 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 the input field. - * - * @method _selectText - * @param oTextbox {HTMLElement} Text input box element in which to select text. - * @param nStart {Number} Starting index of text string to select. - * @param nEnd {Number} 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 results container with its helpers. - * - * @method _toggleContainerHelpers - * @param bShow {Boolean} 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(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(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. - * - * @method _toggleContainer - * @param bShow {Boolean} True if container should be expanded, false if container should be collapsed - * @private - */ -YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) { - var oContainer = this._oContainer; - - // Implementer has container always open so don't mess with it - if(this.alwaysShowContainer && this._bContainerOpen) { - return; - } - - // Clear contents of container - if(!bShow) { - 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; - } - - // 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. - * - * @method _toggleHighlight - * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior. - * @param sType {String} Type "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. - * - * @method _togglePrehighlight - * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior. - * @param sType {String} Type "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. - * - * @method _updateValue - * @param oItem {HTMLElement} 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] || this.delimChar) : 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 - * - * @method _selectItem - * @param oItem {HTMLElement} The selected <li> element item. - * @private - */ -YAHOO.widget.AutoComplete.prototype._selectItem = function(oItem) { - this._bItemSelected = true; - this._updateValue(oItem); - this._cancelIntervalDetection(this); - this.itemSelectEvent.fire(this, oItem, oItem._oResultData); - this._toggleContainer(false); -}; - -/** - * For values updated by type-ahead, the right arrow key jumps to the end - * of the textbox, otherwise the container is closed. - * - * @method _jumpSelection - * @private - */ -YAHOO.widget.AutoComplete.prototype._jumpSelection = function() { - if(!this.typeAhead) { - return; - } - else { - this._toggleContainer(false); - } -}; - -/** - * Triggered by up and down arrow keys, changes the current highlighted - * <li> element item. Scrolls container if necessary. - * - * @method _moveSelection - * @param nKeyCode {Number} 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._toggleContainer(false); - return; - } - - var oNewItem = this._aListItems[nNewItemIndex]; - - // Scroll the container if necessary - var oContent = this._oContainer._oContent; - var scrollOn = ((YAHOO.util.Dom.getStyle(oContent,"overflow") == "auto") || - (YAHOO.util.Dom.getStyle(oContent,"overflowY") == "auto")); - if(scrollOn && (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) > (oContent.scrollTop + oContent.offsetHeight)) { - // Set bottom of scroll area to bottom of selected item - oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight; - } - // Bottom of selected item is above scroll area... - else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) { - // Set top of selected item to top of scroll area - oContent.scrollTop = oNewItem.offsetTop; - - } - } - // User is keying up - else { - // Top of selected item is above scroll area - if(oNewItem.offsetTop < 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 > (oContent.scrollTop + oContent.offsetHeight)) { - // Set bottom of selected item to bottom of scroll area - this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight; - } - } - } - - this._toggleHighlight(oNewItem, "to"); - this.itemArrowToEvent.fire(this, oNewItem); - if(this.typeAhead) { - this._updateValue(oNewItem); - } - } -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private event handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Handles <li> element mouseover events in the container. - * - * @method _onItemMouseover - * @param v {HTMLEvent} The mouseover event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onItemMouseout - * @param v {HTMLEvent} The mouseout event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onItemMouseclick - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onContainerMouseover - * @param v {HTMLEvent} The mouseover event. - * @param oSelf {Object} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) { - oSelf._bOverContainer = true; -}; - -/** - * Handles container mouseout events. - * - * @method _onContainerMouseout - * @param v {HTMLEvent} The mouseout event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onContainerScroll - * @param v {HTMLEvent} The scroll event. - * @param oSelf {Object} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) { - oSelf._oTextbox.focus(); -}; - -/** - * Handles container resize events. - * - * @method _onContainerResize - * @param v {HTMLEvent} The resize event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onTextboxKeyDown - * @param v {HTMLEvent} The keydown event. - * @param oSelf {object} The AutoComplete 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._toggleContainer(false); - } - 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._toggleContainer(false); - } - break; - case 27: // esc - oSelf._toggleContainer(false); - 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. - * @method _onTextboxKeyPress - * @param v {HTMLEvent} The keypress event. - * @param oSelf {Object} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) { - var nKeyCode = v.keyCode; - - //Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337) - var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1); - if(isMac) { - switch (nKeyCode) { - case 9: // tab - if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) { - if(oSelf._bContainerOpen) { - YAHOO.util.Event.stopEvent(v); - } - } - break; - case 13: // enter - if(oSelf._nKeyCode != nKeyCode) { - if(oSelf._bContainerOpen) { - YAHOO.util.Event.stopEvent(v); - } - } - break; - case 38: // up - case 40: // down - YAHOO.util.Event.stopEvent(v); - break; - default: - break; - } - } - - //TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948) - // Korean IME detected - else if(nKeyCode == 229) { - oSelf._queryInterval = setInterval(function() { oSelf._onIMEDetected(oSelf); },500); - } -}; - -/** - * Handles textbox keyup events that trigger queries. - * - * @method _onTextboxKeyUp - * @param v {HTMLEvent} The keyup event. - * @param oSelf {Object} The AutoComplete 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 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); - } -}; - -/** - * Handles text input box receiving focus. - * - * @method _onTextboxFocus - * @param v {HTMLEvent} The focus event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onTextboxBlur - * @param v {HTMLEvent} The focus event. - * @param oSelf {Object} The AutoComplete 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._toggleContainer(false); - } - oSelf._cancelIntervalDetection(oSelf); - oSelf._bFocused = false; - oSelf.textboxBlurEvent.fire(oSelf); - } -}; - -/** - * Handles form submission event. - * - * @method _onFormSubmit - * @param v {HTMLEvent} The submit event. - * @param oSelf {Object} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) { - if(oSelf.allowBrowserAutocomplete) { - oSelf._oTextbox.setAttribute("autocomplete","on"); - } - else { - oSelf._oTextbox.setAttribute("autocomplete","off"); - } -}; -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The DataSource classes manages sending a request and returning response from a live - * database. Supported data include local JavaScript arrays and objects and databases - * accessible via XHR connections. Supported response formats include JavaScript arrays, - * JSON, XML, and flat-file textual data. - * - * @class DataSource - * @constructor - */ -YAHOO.widget.DataSource = function() { - /* abstract class */ -}; - - -///////////////////////////////////////////////////////////////////////////// -// -// Public constants -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Error message for null data responses. - * - * @property ERROR_DATANULL - * @type String - * @static - * @final - */ -YAHOO.widget.DataSource.ERROR_DATANULL = "Response data was null"; - -/** - * Error message for data responses with parsing errors. - * - * @property ERROR_DATAPARSE - * @type String - * @static - * @final - */ -YAHOO.widget.DataSource.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. - * - * @property maxCacheEntries - * @type Number - * @default 15 - */ -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. - * - * @property queryMatchContains - * @type Boolean - * @default false - */ -YAHOO.widget.DataSource.prototype.queryMatchContains = false; - -/** - * Enables 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 DataSources that return comprehensive results - * for queries with very few characters. - * - * @property queryMatchSubset - * @type Boolean - * @default false - * - */ -YAHOO.widget.DataSource.prototype.queryMatchSubset = false; - -/** - * Enables query case-sensitivity matching. If caching is on and - * queryMatchCase is true, queries will only return results for case-sensitive - * matches. - * - * @property queryMatchCase - * @type Boolean - * @default false - */ -YAHOO.widget.DataSource.prototype.queryMatchCase = false; - - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - - /** - * Public accessor to the unique name of the DataSource instance. - * - * @method toString - * @return {String} Unique name of the DataSource 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. - * - * @method getResults - * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} 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). - * - * @method doQuery - * @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} The object instance that has requested data. - */ -YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { - /* override this */ -}; - -/** - * Flushes cache. - * - * @method flushCache - */ -YAHOO.widget.DataSource.prototype.flushCache = function() { - if(this._aCache) { - this._aCache = []; - } - if(this._aCacheHelper) { - this._aCacheHelper = []; - } - this.cacheFlushEvent.fire(this); -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public events -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Fired when a query is made to the live data source. - * - * @event queryEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - */ -YAHOO.widget.DataSource.prototype.queryEvent = null; - -/** - * Fired when a query is made to the local cache. - * - * @event cacheQueryEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - */ -YAHOO.widget.DataSource.prototype.cacheQueryEvent = null; - -/** - * Fired when data is retrieved from the live data source. - * - * @event getResultsEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - * @param aResults {Object[]} Array of result objects. - */ -YAHOO.widget.DataSource.prototype.getResultsEvent = null; - -/** - * Fired when data is retrieved from the local cache. - * - * @event getCachedResultsEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - * @param aResults {Object[]} Array of result objects. - */ -YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null; - -/** - * Fired when an error is encountered with the live data source. - * - * @event dataErrorEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - * @param sMsg {String} Error message string - */ -YAHOO.widget.DataSource.prototype.dataErrorEvent = null; - -/** - * Fired when the local cache is flushed. - * - * @event cacheFlushEvent - * @param oSelf {Object} The DataSource instance - */ -YAHOO.widget.DataSource.prototype.cacheFlushEvent = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple DataSource instances. - * - * @property _nIndex - * @type Number - * @private - * @static - */ -YAHOO.widget.DataSource._nIndex = 0; - -/** - * Name of DataSource instance. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.DataSource.prototype._sName = null; - -/** - * Local cache of data result objects indexed chronologically. - * - * @property _aCache - * @type Object[] - * @private - */ -YAHOO.widget.DataSource.prototype._aCache = null; - - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Initializes DataSource instance. - * - * @method _init - * @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. - * - * @method _addCacheElem - * @param oResult {Object} Data result object, including array of results. - * @private - */ -YAHOO.widget.DataSource.prototype._addCacheElem = function(oResult) { - var aCache = this._aCache; - // Don't add if anything important is missing. - if(!aCache || !oResult || !oResult.query || !oResult.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(oResult); -}; - -/** - * 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. - * - * @method _doQueryCache - * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} The object instance that has requested data. - * @return aResults {Object[]} Array of results 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. - * - * @class DS_XHR - * @extends YAHOO.widget.DataSource - * @requires connection - * @constructor - * @param sScriptURI {String} Absolute or relative URI to script that returns query - * results as JSON, XML, or delimited flat-file data. - * @param aSchema {String[]} Data schema definition of results. - * @param oConfigs {Object} (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. - * - * @property TYPE_JSON - * @type Number - * @static - * @final - */ -YAHOO.widget.DS_XHR.TYPE_JSON = 0; - -/** - * XML data type. - * - * @property TYPE_XML - * @type Number - * @static - * @final - */ -YAHOO.widget.DS_XHR.TYPE_XML = 1; - -/** - * Flat-file data type. - * - * @property TYPE_FLAT - * @type Number - * @static - * @final - */ -YAHOO.widget.DS_XHR.TYPE_FLAT = 2; - -/** - * Error message for XHR failure. - * - * @property ERROR_DATAXHR - * @type String - * @static - * @final - */ -YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed"; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Alias to YUI Connection Manager. Allows implementers to specify their own - * subclasses of the YUI Connection Manager utility. - * - * @property connMgr - * @type Object - * @default YAHOO.util.Connect - */ -YAHOO.widget.DS_XHR.prototype.connMgr = YAHOO.util.Connect; - -/** - * 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. - * - * @property connTimeout - * @type Number - * @default 0 - */ -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 - * - * @property scriptURI - * @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 - * - * @property scriptQueryParam - * @type String - * @default "query" - */ -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> - * - * @property scriptQueryAppend - * @type String - * @default "" - */ -YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = ""; - -/** - * XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML - * and YAHOO.widget.DS_XHR.TYPE_FLAT. - * - * @property responseType - * @type String - * @default YAHOO.widget.DS_XHR.TYPE_JSON - */ -YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.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. - * - * @property responseStripAfter - * @type String - * @default "\n<!-" - */ -YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n 0) { - sUri += "&" + this.scriptQueryAppend; - } - YAHOO.log("DataSource 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, YAHOO.widget.DataSource.ERROR_DATANULL); - YAHOO.log(YAHOO.widget.DataSource.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, YAHOO.widget.DataSource.ERROR_DATANULL); - YAHOO.log(YAHOO.widget.DataSource.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, YAHOO.widget.DataSource.ERROR_DATAPARSE); - YAHOO.log(YAHOO.widget.DataSource.ERROR_DATAPARSE, "error", oSelf.toString()); - aResults = []; - } - 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, YAHOO.widget.DS_XHR.ERROR_DATAXHR); - YAHOO.log(YAHOO.widget.DS_XHR.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) { - this.connMgr.abort(this._oConn); - } - - oSelf._oConn = this.connMgr.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. - * - * @method parseResponse - * @param sQuery {String} Query string. - * @param oResponse {Object} The raw response data to parse. - * @param oParent {Object} The object instance that has requested data. - * @returns {Object[]} 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 YAHOO.widget.DS_XHR.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 { - try { - // eval is necessary here since aSchema[0] is of unknown depth - jsonList = eval("jsonObjParsed." + aSchema[0]); - } - catch(e) { - bError = true; - break; - } - } - } - 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; - } - - if(jsonList.constructor != Array) { - jsonList = [jsonList]; - } - - // 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); - } - // If schema isn't well defined, pass along the entire result object - if(aResultItem.length == 1) { - aResultItem.push(jsonResult); - } - // Capture the array of data field values in an array of results - aResults.unshift(aResultItem); - } - break; - case YAHOO.widget.DS_XHR.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 YAHOO.widget.DS_XHR.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. - * - * @property _oConn - * @type Object - * @private - */ -YAHOO.widget.DS_XHR.prototype._oConn = null; - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * Implementation of YAHOO.widget.DataSource using a native Javascript function as - * its live data source. - * - * @class DS_JSFunction - * @constructor - * @extends YAHOO.widget.DataSource - * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects. - * @param oConfigs {Object} (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. - * - * @property dataFunction - * @type HTMLFunction - */ -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. - * - * @method doQuery - * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} 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, YAHOO.widget.DataSource.ERROR_DATANULL); - YAHOO.log(YAHOO.widget.DataSource.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. - * - * @class DS_JSArray - * @constructor - * @extends YAHOO.widget.DataSource - * @param aData {String[]} In-memory Javascript array of simple string data. - * @param oConfigs {Object} (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. - * - * @property data - * @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. - * - * @method doQuery - * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} The object instance that has requested data. - */ -YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { - var aData = this.data; // the array - var aResults = []; // container for results - var bMatchFound = false; - var bMatchContains = this.queryMatchContains; - if(sQuery) { - if(!this.queryMatchCase) { - sQuery = sQuery.toLowerCase(); - } - - // Loop through each element of the array... - // which can be a string or an array of strings - for(var i = aData.length-1; i >= 0; i--) { - var aDataset = []; - - if(aData[i]) { - if(aData[i].constructor == String) { - aDataset[0] = aData[i]; - } - else if(aData[i].constructor == Array) { - aDataset = aData[i]; - } - } - - if(aDataset[0] && (aDataset[0].constructor == String)) { - 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); -}; + /** + * The AutoComplete control provides the front-end logic for text-entry suggestion and + * completion functionality. + * + * @module autocomplete + * @requires yahoo, dom, event, datasource + * @optional animation, connection + * @namespace YAHOO.widget + * @title AutoComplete Widget + */ + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +/** + * The AutoComplete class provides the customizable functionality of a plug-and-play DHTML + * auto completion widget. Some key features: + *
    + *
  • Navigate with up/down arrow keys and/or mouse to pick a selection
  • + *
  • The drop down container can "roll down" or "fly out" via configurable + * animation
  • + *
  • UI look-and-feel customizable through CSS, including container + * attributes, borders, position, fonts, etc
  • + *
+ * + * @class AutoComplete + * @constructor + * @param elInput {HTMLElement} DOM element reference of an input field. + * @param elInput {String} String ID of an input field. + * @param elContainer {HTMLElement} DOM element reference of an existing DIV. + * @param elContainer {String} String ID of an existing DIV. + * @param oDataSource {YAHOO.widget.DataSource} DataSource instance. + * @param oConfigs {Object} (optional) Object literal of configuration params. + */ +YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) { + if(elInput && elContainer && oDataSource) { + // Validate DataSource + if(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(elInput)) { + if(YAHOO.lang.isString(elInput)) { + this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput; + this._oTextbox = document.getElementById(elInput); + } + else { + this._sName = (elInput.id) ? + "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput.id: + "instance" + YAHOO.widget.AutoComplete._nIndex; + this._oTextbox = elInput; + } + YAHOO.util.Dom.addClass(this._oTextbox, "yui-ac-input"); + } + 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(elContainer)) { + if(YAHOO.lang.isString(elContainer)) { + this._oContainer = document.getElementById(elContainer); + } + else { + this._oContainer = elContainer; + } + 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()); + } + + // For skinning + var elParent = this._oContainer.parentNode; + var elTag = elParent.tagName.toLowerCase(); + while(elParent && (elParent != "document")) { + if(elTag == "div") { + YAHOO.util.Dom.addClass(elParent, "yui-ac"); + break; + } + else { + elParent = elParent.parentNode; + elTag = elParent.tagName.toLowerCase(); + } + } + if(elTag != "div") { + YAHOO.log("Could not find an appropriate parent container for skinning", "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(oConfigs && (oConfigs.constructor == 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,"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); + } + YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,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 DataSource object that encapsulates the data used for auto completion. + * This object should be an inherited object from YAHOO.widget.DataSource. + * + * @property dataSource + * @type YAHOO.widget.DataSource + */ +YAHOO.widget.AutoComplete.prototype.dataSource = null; + +/** + * Number of characters that must be entered before querying for results. A negative value + * effectively turns off the widget. A value of 0 allows queries of null or empty string + * values. + * + * @property minQueryLength + * @type Number + * @default 1 + */ +YAHOO.widget.AutoComplete.prototype.minQueryLength = 1; + +/** + * Maximum number of results to display in results container. + * + * @property maxResultsDisplayed + * @type Number + * @default 10 + */ +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. + * Implementers should take care when setting this value very low (i.e., less + * than 0.2) with low latency DataSources and the typeAhead feature enabled, as + * fast typers may see unexpected behavior. + * + * @property queryDelay + * @type Number + * @default 0.2 + */ +YAHOO.widget.AutoComplete.prototype.queryDelay = 0.2; + +/** + * Class name of a highlighted item within results container. + * + * @property highlightClassName + * @type String + * @default "yui-ac-highlight" + */ +YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight"; + +/** + * Class name of a pre-highlighted item within results container. + * + * @property prehighlightClassName + * @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. + * + * @property delimChar + * @type String | String[] + */ +YAHOO.widget.AutoComplete.prototype.delimChar = null; + +/** + * Whether or not the first item in results container should be automatically highlighted + * on expand. + * + * @property autoHighlight + * @type Boolean + * @default true + */ +YAHOO.widget.AutoComplete.prototype.autoHighlight = true; + +/** + * Whether or not the 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. + * + * @property typeAhead + * @type Boolean + * @default false + */ +YAHOO.widget.AutoComplete.prototype.typeAhead = false; + +/** + * Whether or not to animate the expansion/collapse of the results container in the + * horizontal direction. + * + * @property animHoriz + * @type Boolean + * @default false + */ +YAHOO.widget.AutoComplete.prototype.animHoriz = false; + +/** + * Whether or not to animate the expansion/collapse of the results container in the + * vertical direction. + * + * @property animVert + * @type Boolean + * @default true + */ +YAHOO.widget.AutoComplete.prototype.animVert = true; + +/** + * Speed of container expand/collapse animation, in seconds.. + * + * @property animSpeed + * @type Number + * @default 0.3 + */ +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 input field into a + * <select> field. This feature is not recommended with delimiter character(s) + * defined. + * + * @property forceSelection + * @type Boolean + * @default false + */ +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 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. + * + * @property allowBrowserAutocomplete + * @type Boolean + * @default true + */ +YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true; + +/** + * Whether or not the results container should always be displayed. + * Enabling this feature displays the container when the widget is instantiated + * and prevents the toggling of the container to a collapsed state. + * + * @property alwaysShowContainer + * @type Boolean + * @default false + */ +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 results 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). + * + * @property useIFrame + * @type Boolean + * @default false + */ +YAHOO.widget.AutoComplete.prototype.useIFrame = false; + +/** + * Whether or not the results container should have a shadow. + * + * @property useShadow + * @type Boolean + * @default false + */ +YAHOO.widget.AutoComplete.prototype.useShadow = false; + +///////////////////////////////////////////////////////////////////////////// +// +// Public methods +// +///////////////////////////////////////////////////////////////////////////// + + /** + * Public accessor to the unique name of the AutoComplete instance. + * + * @method toString + * @return {String} Unique name of the AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.toString = function() { + return "AutoComplete " + this._sName; +}; + + /** + * Returns true if container is in an expanded state, false otherwise. + * + * @method isContainerOpen + * @return {Boolean} Returns true if container is in an expanded state, false otherwise. + */ +YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() { + return this._bContainerOpen; +}; + +/** + * Public accessor to the internal array of DOM <li> elements that + * display query results within the results container. + * + * @method getListItems + * @return {HTMLElement[]} Array of <li> elements within the results container. + */ +YAHOO.widget.AutoComplete.prototype.getListItems = function() { + return this._aListItems; +}; + +/** + * Public accessor to the data held in an <li> element of the + * results container. + * + * @method getListItemData + * @return {Object | Object[]} 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 results container header. This markup will be + * inserted within a <div> tag with a class of "yui-ac-hd". + * + * @method setHeader + * @param sHeader {String} HTML markup for results 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 results container footer. This markup will be + * inserted within a <div> tag with a class of "yui-ac-ft". + * + * @method setFooter + * @param sFooter {String} HTML markup for results 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 results container body. This markup will be + * inserted within a <div> tag with a class of "yui-ac-bd". + * + * @method setBody + * @param sBody {String} HTML markup for results 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. + * + * @method formatResult + * @param oResultItem {Object} Result item representing one query result. Data is held in an array. + * @param sQuery {String} 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 ""; + } +}; + +/** + * Overridable method called before container expands allows implementers to access data + * and DOM elements. + * + * @method doBeforeExpandContainer + * @param oTextbox {HTMLElement} The text input box. + * @param oContainer {HTMLElement} The container element. + * @param sQuery {String} The query string. + * @param aResults {Object[]} An array of query results. + * @return {Boolean} Return true to continue expanding container, false to cancel the expand. + */ +YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) { + return true; +}; + +/** + * Makes query request to the DataSource. + * + * @method sendQuery + * @param sQuery {String} Query string. + */ +YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) { + this._sendQuery(sQuery); +}; + +/** + * Overridable method gives implementers access to the query before it gets sent. + * + * @method doBeforeSendQuery + * @param sQuery {String} Query string. + * @return {String} Query string. + */ +YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery = function(sQuery) { + return sQuery; +}; + +/** + * Nulls out the entire AutoComplete instance and related objects, removes attached + * event listeners, and clears out DOM elements inside the container. After + * calling this method, the instance reference should be expliclitly nulled by + * implementer, as in myDataTable = null. Use with caution! + * + * @method destroy + */ +YAHOO.widget.AutoComplete.prototype.destroy = function() { + var instanceName = this.toString(); + var elInput = this._oTextbox; + var elContainer = this._oContainer; + + // Unhook custom events + this.textboxFocusEvent.unsubscribe(); + this.textboxKeyEvent.unsubscribe(); + this.dataRequestEvent.unsubscribe(); + this.dataReturnEvent.unsubscribe(); + this.dataErrorEvent.unsubscribe(); + this.containerExpandEvent.unsubscribe(); + this.typeAheadEvent.unsubscribe(); + this.itemMouseOverEvent.unsubscribe(); + this.itemMouseOutEvent.unsubscribe(); + this.itemArrowToEvent.unsubscribe(); + this.itemArrowFromEvent.unsubscribe(); + this.itemSelectEvent.unsubscribe(); + this.unmatchedItemSelectEvent.unsubscribe(); + this.selectionEnforceEvent.unsubscribe(); + this.containerCollapseEvent.unsubscribe(); + this.textboxBlurEvent.unsubscribe(); + + // Unhook DOM events + YAHOO.util.Event.purgeElement(elInput, true); + YAHOO.util.Event.purgeElement(elContainer, true); + + // Remove DOM elements + elContainer.innerHTML = ""; + + // Null out objects + for(var key in this) { + if(this.hasOwnProperty(key)) { + this[key] = null; + } + } + + YAHOO.log("AutoComplete instance destroyed: " + instanceName); +}; + +///////////////////////////////////////////////////////////////////////////// +// +// Public events +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Fired when the input field receives focus. + * + * @event textboxFocusEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null; + +/** + * Fired when the input field receives key input. + * + * @event textboxKeyEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param nKeycode {Number} The keycode number. + */ +YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null; + +/** + * Fired when the AutoComplete instance makes a query to the DataSource. + * + * @event dataRequestEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The query string. + */ +YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null; + +/** + * Fired when the AutoComplete instance receives query results from the data + * source. + * + * @event dataReturnEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The query string. + * @param aResults {Object[]} Results array. + */ +YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null; + +/** + * Fired when the AutoComplete instance does not receive query results from the + * DataSource due to an error. + * + * @event dataErrorEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The query string. + */ +YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null; + +/** + * Fired when the results container is expanded. + * + * @event containerExpandEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null; + +/** + * Fired when the input field has been prefilled by the type-ahead + * feature. + * + * @event typeAheadEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The query string. + * @param sPrefill {String} The prefill string. + */ +YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null; + +/** + * Fired when result item has been moused over. + * + * @event itemMouseOverEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} The <li> element item moused to. + */ +YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null; + +/** + * Fired when result item has been moused out. + * + * @event itemMouseOutEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} The <li> element item moused from. + */ +YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null; + +/** + * Fired when result item has been arrowed to. + * + * @event itemArrowToEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} The <li> element item arrowed to. + */ +YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null; + +/** + * Fired when result item has been arrowed away from. + * + * @event itemArrowFromEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} 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. + * + * @event itemSelectEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} The selected <li> element item. + * @param oData {Object} 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 a 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. + * + * @event unmatchedItemSelectEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The user-typed query string. + */ +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. + * + * @event selectionEnforceEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null; + +/** + * Fired when the results container is collapsed. + * + * @event containerCollapseEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null; + +/** + * Fired when the input field loses focus. + * + * @event textboxBlurEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null; + +///////////////////////////////////////////////////////////////////////////// +// +// Private member variables +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Internal class variable to index multiple AutoComplete instances. + * + * @property _nIndex + * @type Number + * @default 0 + * @private + */ +YAHOO.widget.AutoComplete._nIndex = 0; + +/** + * Name of AutoComplete instance. + * + * @property _sName + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._sName = null; + +/** + * Text input field DOM element. + * + * @property _oTextbox + * @type HTMLElement + * @private + */ +YAHOO.widget.AutoComplete.prototype._oTextbox = null; + +/** + * Whether or not the input field is currently in focus. If query results come back + * but the user has already moved on, do not proceed with auto complete behavior. + * + * @property _bFocused + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._bFocused = true; + +/** + * Animation instance for container expand/collapse. + * + * @property _oAnim + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._oAnim = null; + +/** + * Container DOM element. + * + * @property _oContainer + * @type HTMLElement + * @private + */ +YAHOO.widget.AutoComplete.prototype._oContainer = null; + +/** + * Whether or not the results container is currently open. + * + * @property _bContainerOpen + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._bContainerOpen = false; + +/** + * Whether or not the mouse is currently over the results + * container. This is necessary in order to prevent clicks on container items + * from being text input field blur events. + * + * @property _bOverContainer + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._bOverContainer = false; + +/** + * Array of <li> elements references that contain query results within the + * results container. + * + * @property _aListItems + * @type HTMLElement[] + * @private + */ +YAHOO.widget.AutoComplete.prototype._aListItems = null; + +/** + * Number of <li> elements currently displayed in results container. + * + * @property _nDisplayedItems + * @type Number + * @private + */ +YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0; + +/** + * Internal count of <li> elements displayed and hidden in results container. + * + * @property _maxResultsDisplayed + * @type Number + * @private + */ +YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0; + +/** + * Current query string + * + * @property _sCurQuery + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._sCurQuery = null; + +/** + * Past queries this session (for saving delimited queries). + * + * @property _sSavedQuery + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._sSavedQuery = null; + +/** + * Pointer to the currently highlighted <li> element in the container. + * + * @property _oCurItem + * @type HTMLElement + * @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. + * + * @property _bItemSelected + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._bItemSelected = false; + +/** + * Key code of the last key pressed in textbox. + * + * @property _nKeyCode + * @type Number + * @private + */ +YAHOO.widget.AutoComplete.prototype._nKeyCode = null; + +/** + * Delay timeout ID. + * + * @property _nDelayID + * @type Number + * @private + */ +YAHOO.widget.AutoComplete.prototype._nDelayID = -1; + +/** + * Src to iFrame used when useIFrame = true. Supports implementations over SSL + * as well. + * + * @property _iFrameSrc + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;"; + +/** + * For users typing via certain IMEs, queries must be triggered by intervals, + * since key events yet supported across all browsers for all IMEs. + * + * @property _queryInterval + * @type Object + * @private + */ +YAHOO.widget.AutoComplete.prototype._queryInterval = null; + +/** + * Internal tracker to last known textbox value, used to determine whether or not + * to trigger a query via interval for certain IME users. + * + * @event _sLastTextboxValue + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null; + +///////////////////////////////////////////////////////////////////////////// +// +// Private methods +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Updates and validates latest public config properties. + * + * @method __initProps + * @private + */ +YAHOO.widget.AutoComplete.prototype._initProps = function() { + // Correct any invalid values + var minQueryLength = this.minQueryLength; + if(!YAHOO.lang.isNumber(minQueryLength)) { + this.minQueryLength = 1; + } + var maxResultsDisplayed = this.maxResultsDisplayed; + if(!YAHOO.lang.isNumber(maxResultsDisplayed) || (maxResultsDisplayed < 1)) { + this.maxResultsDisplayed = 10; + } + var queryDelay = this.queryDelay; + if(!YAHOO.lang.isNumber(queryDelay) || (queryDelay < 0)) { + this.queryDelay = 0.2; + } + var delimChar = this.delimChar; + if(YAHOO.lang.isString(delimChar)) { + this.delimChar = [delimChar]; + } + else if(!YAHOO.lang.isArray(delimChar)) { + this.delimChar = null; + } + var animSpeed = this.animSpeed; + if((this.animHoriz || this.animVert) && YAHOO.util.Anim) { + if(!YAHOO.lang.isNumber(animSpeed) || (animSpeed < 0)) { + this.animSpeed = 0.3; + } + if(!this._oAnim ) { + this._oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed); + } + else { + this._oAnim.duration = this.animSpeed; + } + } + if(this.forceSelection && delimChar) { + YAHOO.log("The forceSelection feature has been enabled with delimChar defined.","warn", this.toString()); + } +}; + +/** + * Initializes the results container helpers if they are enabled and do + * not exist + * + * @method _initContainerHelpers + * @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%"; + oIFrame.tabIndex = -1; + this._oContainer._oIFrame = this._oContainer.appendChild(oIFrame); + } +}; + +/** + * Initializes the results container once at object creation + * + * @method _initContainer + * @private + */ +YAHOO.widget.AutoComplete.prototype._initContainer = function() { + YAHOO.util.Dom.addClass(this._oContainer, "yui-ac-container"); + + 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. + * + * @method _initList + * @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; oldi--) { + 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= 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 >= 36 && nKeyCode <= 40) || // home,left,up, right, down + (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert + return true; + } + return false; +}; + +/** + * Makes query request to the DataSource. + * + * @method _sendQuery + * @param sQuery {String} Query string. + * @private + */ +YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) { + // Widget has been effectively turned off + if(this.minQueryLength == -1) { + this._toggleContainer(false); + YAHOO.log("Property minQueryLength is set to -1", "info", this.toString()); + return; + } + // 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 && (sQuery.length < this.minQueryLength)) || (!sQuery && this.minQueryLength > 0)) { + if(this._nDelayID != -1) { + clearTimeout(this._nDelayID); + } + this._toggleContainer(false); + YAHOO.log("Query \"" + sQuery + "\" is too short", "info", this.toString()); + return; + } + + sQuery = encodeURIComponent(sQuery); + this._nDelayID = -1; // Reset timeout ID because request has been made + sQuery = this.doBeforeSendQuery(sQuery); + this.dataRequestEvent.fire(this, sQuery); + YAHOO.log("Sending query \"" + sQuery + "\"", "info", this.toString()); + this.dataSource.getResults(this._populateList, sQuery, this); +}; + +/** + * 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 instance are returned to the + * AutoComplete instance. + * + * @method _populateList + * @param sQuery {String} The query string. + * @param aResults {Object[]} An array of query result objects from the DataSource. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, aResults, oSelf) { + if(aResults === null) { + oSelf.dataErrorEvent.fire(oSelf, sQuery); + } + if(!oSelf._bFocused || !aResults) { + YAHOO.log("Could not populate list", "info", oSelf.toString()); + 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; + } + + // Expand the container + var ok = oSelf.doBeforeExpandContainer(oSelf._oTextbox, oSelf._oContainer, sQuery, aResults); + oSelf._toggleContainer(ok); + + if(oSelf.autoHighlight) { + // Go to the first item + var oFirstItem = aItems[0]; + oSelf._toggleHighlight(oFirstItem,"to"); + oSelf.itemArrowToEvent.fire(oSelf, oFirstItem); + YAHOO.log("Arrowed to first item", "info", oSelf.toString()); + oSelf._typeAhead(oFirstItem,sQuery); + } + else { + oSelf._oCurItem = null; + } + } + else { + oSelf._toggleContainer(false); + } + oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults); + YAHOO.log("Container populated with list items", "info", oSelf.toString()); + +}; + +/** + * When forceSelection is true and the user attempts + * leave the text input box without selecting an item from the query results, + * the user selection is cleared. + * + * @method _clearSelection + * @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); + YAHOO.log("Selection enforced", "info", this.toString()); +}; + +/** + * Whether or not user-typed value in the text input box matches any of the + * query results. + * + * @method _textMatchesOption + * @return {HTMLElement} Matching list item element if user-input text matches + * a result, null otherwise. + * @private + */ +YAHOO.widget.AutoComplete.prototype._textMatchesOption = function() { + var foundMatch = null; + + 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 = oItem; + 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. + * + * @method _typeAhead + * @param oItem {HTMLElement} The <li> element item whose data populates the input field. + * @param sQuery {String} Query string. + * @private + */ +YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) { + // Don't update if turned off + if(!this.typeAhead || (this._nKeyCode == 8)) { + 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); + YAHOO.log("Typeahead occured with prefill string \"" + sPrefill + "\"", "info", this.toString()); +}; + +/** + * Selects text in the input field. + * + * @method _selectText + * @param oTextbox {HTMLElement} Text input box element in which to select text. + * @param nStart {Number} Starting index of text string to select. + * @param nEnd {Number} 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 results container with its helpers. + * + * @method _toggleContainerHelpers + * @param bShow {Boolean} 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(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(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. + * + * @method _toggleContainer + * @param bShow {Boolean} True if container should be expanded, false if container should be collapsed + * @private + */ +YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) { + var oContainer = this._oContainer; + + // Implementer has container always open so don't mess with it + if(this.alwaysShowContainer && this._bContainerOpen) { + return; + } + + // Clear contents of container + if(!bShow) { + 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; + } + + // 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); + YAHOO.log("Container expanded", "info", oSelf.toString()); + } + else { + oContainer._oContent.style.display = "none"; + oSelf.containerCollapseEvent.fire(oSelf); + YAHOO.log("Container collapsed", "info", oSelf.toString()); + } + 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); + YAHOO.log("Container expanded", "info", this.toString()); + } + else { + oContainer._oContent.style.display = "none"; + this.containerCollapseEvent.fire(this); + YAHOO.log("Container collapsed", "info", this.toString()); + } + 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. + * + * @method _toggleHighlight + * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior. + * @param sType {String} Type "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. + * + * @method _togglePrehighlight + * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior. + * @param sType {String} Type "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. + * + * @method _updateValue + * @param oItem {HTMLElement} 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] || this.delimChar) : 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 + * + * @method _selectItem + * @param oItem {HTMLElement} The selected <li> element item. + * @private + */ +YAHOO.widget.AutoComplete.prototype._selectItem = function(oItem) { + this._bItemSelected = true; + this._updateValue(oItem); + this._cancelIntervalDetection(this); + this.itemSelectEvent.fire(this, oItem, oItem._oResultData); + YAHOO.log("Item selected: " + YAHOO.lang.dump(oItem._oResultData), "info", this.toString()); + this._toggleContainer(false); +}; + +/** + * If an item is highlighted in the container, the right arrow key jumps to the + * end of the textbox and selects the highlighted item, otherwise the container + * is closed. + * + * @method _jumpSelection + * @private + */ +YAHOO.widget.AutoComplete.prototype._jumpSelection = function() { + if(this._oCurItem) { + this._selectItem(this._oCurItem); + } + else { + this._toggleContainer(false); + } +}; + +/** + * Triggered by up and down arrow keys, changes the current highlighted + * <li> element item. Scrolls container if necessary. + * + * @method _moveSelection + * @param nKeyCode {Number} 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); + YAHOO.log("Item arrowed from", "info", this.toString()); + } + 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._toggleContainer(false); + return; + } + + var oNewItem = this._aListItems[nNewItemIndex]; + + // Scroll the container if necessary + var oContent = this._oContainer._oContent; + var scrollOn = ((YAHOO.util.Dom.getStyle(oContent,"overflow") == "auto") || + (YAHOO.util.Dom.getStyle(oContent,"overflowY") == "auto")); + if(scrollOn && (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) > (oContent.scrollTop + oContent.offsetHeight)) { + // Set bottom of scroll area to bottom of selected item + oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight; + } + // Bottom of selected item is above scroll area... + else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) { + // Set top of selected item to top of scroll area + oContent.scrollTop = oNewItem.offsetTop; + + } + } + // User is keying up + else { + // Top of selected item is above scroll area + if(oNewItem.offsetTop < 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 > (oContent.scrollTop + oContent.offsetHeight)) { + // Set bottom of selected item to bottom of scroll area + this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight; + } + } + } + + this._toggleHighlight(oNewItem, "to"); + this.itemArrowToEvent.fire(this, oNewItem); + YAHOO.log("Item arrowed to", "info", this.toString()); + if(this.typeAhead) { + this._updateValue(oNewItem); + } + } +}; + +///////////////////////////////////////////////////////////////////////////// +// +// Private event handlers +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Handles <li> element mouseover events in the container. + * + * @method _onItemMouseover + * @param v {HTMLEvent} The mouseover event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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); + YAHOO.log("Item moused over", "info", oSelf.toString()); +}; + +/** + * Handles <li> element mouseout events in the container. + * + * @method _onItemMouseout + * @param v {HTMLEvent} The mouseout event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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); + YAHOO.log("Item moused out", "info", oSelf.toString()); +}; + +/** + * Handles <li> element click events in the container. + * + * @method _onItemMouseclick + * @param v {HTMLEvent} The click event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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. + * + * @method _onContainerMouseover + * @param v {HTMLEvent} The mouseover event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) { + oSelf._bOverContainer = true; +}; + +/** + * Handles container mouseout events. + * + * @method _onContainerMouseout + * @param v {HTMLEvent} The mouseout event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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. + * + * @method _onContainerScroll + * @param v {HTMLEvent} The scroll event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) { + oSelf._oTextbox.focus(); +}; + +/** + * Handles container resize events. + * + * @method _onContainerResize + * @param v {HTMLEvent} The resize event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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. + * + * @method _onTextboxKeyDown + * @param v {HTMLEvent} The keydown event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) { + var nKeyCode = v.keyCode; + + switch (nKeyCode) { + case 9: // tab + // select an item or clear out + if(oSelf._oCurItem) { + if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) { + if(oSelf._bContainerOpen) { + YAHOO.util.Event.stopEvent(v); + } + } + oSelf._selectItem(oSelf._oCurItem); + } + else { + oSelf._toggleContainer(false); + } + break; + case 13: // enter + if(oSelf._oCurItem) { + if(oSelf._nKeyCode != nKeyCode) { + if(oSelf._bContainerOpen) { + YAHOO.util.Event.stopEvent(v); + } + } + oSelf._selectItem(oSelf._oCurItem); + } + else { + oSelf._toggleContainer(false); + } + break; + case 27: // esc + oSelf._toggleContainer(false); + 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. + * @method _onTextboxKeyPress + * @param v {HTMLEvent} The keypress event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) { + var nKeyCode = v.keyCode; + + //Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337) + var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1); + if(isMac) { + switch (nKeyCode) { + case 9: // tab + if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) { + YAHOO.util.Event.stopEvent(v); + } + break; + 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; + } + } + + //TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948) + // Korean IME detected + else if(nKeyCode == 229) { + oSelf._queryInterval = setInterval(function() { oSelf._onIMEDetected(oSelf); },500); + } +}; + +/** + * Handles textbox keyup events that trigger queries. + * + * @method _onTextboxKeyUp + * @param v {HTMLEvent} The keyup event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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 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._bItemSelected = false; + YAHOO.util.Dom.removeClass(oSelf._oCurItem, oSelf.highlightClassName); + oSelf._oCurItem = null; + + oSelf.textboxKeyEvent.fire(oSelf, nKeyCode); + YAHOO.log("Textbox keyed", "info", oSelf.toString()); + } + + // 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); + } +}; + +/** + * Handles text input box receiving focus. + * + * @method _onTextboxFocus + * @param v {HTMLEvent} The focus event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) { + oSelf._oTextbox.setAttribute("autocomplete","off"); + oSelf._bFocused = true; + if(!oSelf._bItemSelected) { + oSelf.textboxFocusEvent.fire(oSelf); + YAHOO.log("Textbox focused", "info", oSelf.toString()); + } +}; + +/** + * Handles text input box losing focus. + * + * @method _onTextboxBlur + * @param v {HTMLEvent} The focus event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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) { + var oMatch = oSelf._textMatchesOption(); + if(!oSelf._bContainerOpen || (oSelf._bContainerOpen && (oMatch === null))) { + if(oSelf.forceSelection) { + oSelf._clearSelection(); + } + else { + oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery); + YAHOO.log("Unmatched item selected", "info", oSelf.toString()); + } + } + else { + oSelf._selectItem(oMatch); + } + } + + if(oSelf._bContainerOpen) { + oSelf._toggleContainer(false); + } + oSelf._cancelIntervalDetection(oSelf); + oSelf._bFocused = false; + oSelf.textboxBlurEvent.fire(oSelf); + YAHOO.log("Textbox blurred", "info", oSelf.toString()); + } +}; + +/** + * Handles form submission event. + * + * @method _onFormSubmit + * @param v {HTMLEvent} The submit event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) { + if(oSelf.allowBrowserAutocomplete) { + oSelf._oTextbox.setAttribute("autocomplete","on"); + } + else { + oSelf._oTextbox.setAttribute("autocomplete","off"); + } +}; + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +/** + * The DataSource classes manages sending a request and returning response from a live + * database. Supported data include local JavaScript arrays and objects and databases + * accessible via XHR connections. Supported response formats include JavaScript arrays, + * JSON, XML, and flat-file textual data. + * + * @class DataSource + * @constructor + */ +YAHOO.widget.DataSource = function() { + /* abstract class */ +}; + + +///////////////////////////////////////////////////////////////////////////// +// +// Public constants +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Error message for null data responses. + * + * @property ERROR_DATANULL + * @type String + * @static + * @final + */ +YAHOO.widget.DataSource.ERROR_DATANULL = "Response data was null"; + +/** + * Error message for data responses with parsing errors. + * + * @property ERROR_DATAPARSE + * @type String + * @static + * @final + */ +YAHOO.widget.DataSource.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. + * + * @property maxCacheEntries + * @type Number + * @default 15 + */ +YAHOO.widget.DataSource.prototype.maxCacheEntries = 15; + +/** + * Use this to fine-tune the matching algorithm used against JS Array types of + * DataSource and DataSource caches. If queryMatchContains is true, then the JS + * Array or cache returns results that "contain" the query string. By default, + * queryMatchContains is set to false, so that only results that "start with" + * the query string are returned. + * + * @property queryMatchContains + * @type Boolean + * @default false + */ +YAHOO.widget.DataSource.prototype.queryMatchContains = false; + +/** + * Enables 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 DataSources that return comprehensive results + * for queries with very few characters. + * + * @property queryMatchSubset + * @type Boolean + * @default false + * + */ +YAHOO.widget.DataSource.prototype.queryMatchSubset = false; + +/** + * Enables case-sensitivity in the matching algorithm used against JS Array + * types of DataSources and DataSource caches. If queryMatchCase is true, only + * case-sensitive matches will return. + * + * @property queryMatchCase + * @type Boolean + * @default false + */ +YAHOO.widget.DataSource.prototype.queryMatchCase = false; + + +///////////////////////////////////////////////////////////////////////////// +// +// Public methods +// +///////////////////////////////////////////////////////////////////////////// + + /** + * Public accessor to the unique name of the DataSource instance. + * + * @method toString + * @return {String} Unique name of the DataSource 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. + * + * @method getResults + * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} 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); + YAHOO.log("Query received \"" + sQuery, "info", this.toString()); + 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). + * + * @method doQuery + * @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} The object instance that has requested data. + */ +YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { + /* override this */ +}; + +/** + * Flushes cache. + * + * @method flushCache + */ +YAHOO.widget.DataSource.prototype.flushCache = function() { + if(this._aCache) { + this._aCache = []; + } + if(this._aCacheHelper) { + this._aCacheHelper = []; + } + this.cacheFlushEvent.fire(this); + YAHOO.log("Cache flushed", "info", this.toString()); + +}; + +///////////////////////////////////////////////////////////////////////////// +// +// Public events +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Fired when a query is made to the live data source. + * + * @event queryEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + */ +YAHOO.widget.DataSource.prototype.queryEvent = null; + +/** + * Fired when a query is made to the local cache. + * + * @event cacheQueryEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + */ +YAHOO.widget.DataSource.prototype.cacheQueryEvent = null; + +/** + * Fired when data is retrieved from the live data source. + * + * @event getResultsEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + * @param aResults {Object[]} Array of result objects. + */ +YAHOO.widget.DataSource.prototype.getResultsEvent = null; + +/** + * Fired when data is retrieved from the local cache. + * + * @event getCachedResultsEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + * @param aResults {Object[]} Array of result objects. + */ +YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null; + +/** + * Fired when an error is encountered with the live data source. + * + * @event dataErrorEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + * @param sMsg {String} Error message string + */ +YAHOO.widget.DataSource.prototype.dataErrorEvent = null; + +/** + * Fired when the local cache is flushed. + * + * @event cacheFlushEvent + * @param oSelf {Object} The DataSource instance + */ +YAHOO.widget.DataSource.prototype.cacheFlushEvent = null; + +///////////////////////////////////////////////////////////////////////////// +// +// Private member variables +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Internal class variable to index multiple DataSource instances. + * + * @property _nIndex + * @type Number + * @private + * @static + */ +YAHOO.widget.DataSource._nIndex = 0; + +/** + * Name of DataSource instance. + * + * @property _sName + * @type String + * @private + */ +YAHOO.widget.DataSource.prototype._sName = null; + +/** + * Local cache of data result objects indexed chronologically. + * + * @property _aCache + * @type Object[] + * @private + */ +YAHOO.widget.DataSource.prototype._aCache = null; + + +///////////////////////////////////////////////////////////////////////////// +// +// Private methods +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Initializes DataSource instance. + * + * @method _init + * @private + */ +YAHOO.widget.DataSource.prototype._init = function() { + // Validate and initialize public configs + var maxCacheEntries = this.maxCacheEntries; + if(!YAHOO.lang.isNumber(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. + * + * @method _addCacheElem + * @param oResult {Object} Data result object, including array of results. + * @private + */ +YAHOO.widget.DataSource.prototype._addCacheElem = function(oResult) { + var aCache = this._aCache; + // Don't add if anything important is missing. + if(!aCache || !oResult || !oResult.query || !oResult.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(oResult); +}; + +/** + * 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. + * + * @method _doQueryCache + * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} The object instance that has requested data. + * @return aResults {Object[]} Array of results 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); + YAHOO.log("Querying cache: \"" + sQuery + "\"", "info", this.toString()); + // 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); + YAHOO.log("Cached results found for query \"" + sQuery + "\": " + + YAHOO.lang.dump(aResults), "info", this.toString()); + oCallbackFn(sOrigQuery, aResults, oParent); + } + } + return aResults; +}; + + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +/** + * Implementation of YAHOO.widget.DataSource using XML HTTP requests that return + * query results. + * + * @class DS_XHR + * @extends YAHOO.widget.DataSource + * @requires connection + * @constructor + * @param sScriptURI {String} Absolute or relative URI to script that returns query + * results as JSON, XML, or delimited flat-file data. + * @param aSchema {String[]} Data schema definition of results. + * @param oConfigs {Object} (optional) Object literal of config params. + */ +YAHOO.widget.DS_XHR = function(sScriptURI, aSchema, oConfigs) { + // Set any config params passed in to override defaults + if(oConfigs && (oConfigs.constructor == Object)) { + for(var sConfig in oConfigs) { + this[sConfig] = oConfigs[sConfig]; + } + } + + // Initialization sequence + if(!YAHOO.lang.isArray(aSchema) || !YAHOO.lang.isString(sScriptURI)) { + YAHOO.log("Could not instantiate XHR DataSource due to invalid arguments", "error", this.toString()); + return; + } + + 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. + * + * @property TYPE_JSON + * @type Number + * @static + * @final + */ +YAHOO.widget.DS_XHR.TYPE_JSON = 0; + +/** + * XML data type. + * + * @property TYPE_XML + * @type Number + * @static + * @final + */ +YAHOO.widget.DS_XHR.TYPE_XML = 1; + +/** + * Flat-file data type. + * + * @property TYPE_FLAT + * @type Number + * @static + * @final + */ +YAHOO.widget.DS_XHR.TYPE_FLAT = 2; + +/** + * Error message for XHR failure. + * + * @property ERROR_DATAXHR + * @type String + * @static + * @final + */ +YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed"; + +///////////////////////////////////////////////////////////////////////////// +// +// Public member variables +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Alias to YUI Connection Manager. Allows implementers to specify their own + * subclasses of the YUI Connection Manager utility. + * + * @property connMgr + * @type Object + * @default YAHOO.util.Connect + */ +YAHOO.widget.DS_XHR.prototype.connMgr = YAHOO.util.Connect; + +/** + * 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. + * + * @property connTimeout + * @type Number + * @default 0 + */ +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 + * + * @property scriptURI + * @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 + * + * @property scriptQueryParam + * @type String + * @default "query" + */ +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> + * + * @property scriptQueryAppend + * @type String + * @default "" + */ +YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = ""; + +/** + * XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML + * and YAHOO.widget.DS_XHR.TYPE_FLAT. + * + * @property responseType + * @type String + * @default YAHOO.widget.DS_XHR.TYPE_JSON + */ +YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.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. + * + * @property responseStripAfter + * @type String + * @default "\n<!-" + */ +YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n 0) { + sUri += "&" + this.scriptQueryAppend; + } + YAHOO.log("DataSource 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, YAHOO.widget.DataSource.ERROR_DATANULL); + YAHOO.log(YAHOO.widget.DataSource.ERROR_DATANULL, "error", oSelf.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, YAHOO.widget.DataSource.ERROR_DATANULL); + YAHOO.log(YAHOO.widget.DataSource.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, YAHOO.widget.DataSource.ERROR_DATAPARSE); + YAHOO.log(YAHOO.widget.DataSource.ERROR_DATAPARSE, "error", oSelf.toString()); + aResults = []; + } + else { + oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults); + YAHOO.log("Results returned for query \"" + sQuery + "\": " + + YAHOO.lang.dump(aResults), "info", oSelf.toString()); + oSelf._addCacheElem(resultObj); + } + oCallbackFn(sQuery, aResults, oParent); + }; + + var responseFailure = function(oResp) { + oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, YAHOO.widget.DS_XHR.ERROR_DATAXHR); + YAHOO.log(YAHOO.widget.DS_XHR.ERROR_DATAXHR + ": " + oResp.statusText, "error", oSelf.toString()); + return; + }; + + var oCallback = { + success:responseSuccess, + failure:responseFailure + }; + + if(YAHOO.lang.isNumber(this.connTimeout) && (this.connTimeout > 0)) { + oCallback.timeout = this.connTimeout; + } + + if(this._oConn) { + this.connMgr.abort(this._oConn); + } + + oSelf._oConn = this.connMgr.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. + * + * @method parseResponse + * @param sQuery {String} Query string. + * @param oResponse {Object} The raw response data to parse. + * @param oParent {Object} The object instance that has requested data. + * @returns {Object[]} 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 YAHOO.widget.DS_XHR.TYPE_JSON: + var jsonList, jsonObjParsed; + // Check for JSON lib but divert KHTML clients + var isNotMac = (navigator.userAgent.toLowerCase().indexOf('khtml')== -1); + if(oResponse.parseJSON && isNotMac) { + // Use the new JSON utility if available + jsonObjParsed = oResponse.parseJSON(); + if(!jsonObjParsed) { + bError = true; + } + else { + try { + // eval is necessary here since aSchema[0] is of unknown depth + jsonList = eval("jsonObjParsed." + aSchema[0]); + } + catch(e) { + bError = true; + break; + } + } + } + else if(window.JSON && isNotMac) { + // Use older JSON lib if available + jsonObjParsed = JSON.parse(oResponse); + if(!jsonObjParsed) { + bError = true; + break; + } + else { + try { + // eval is necessary here since aSchema[0] is of unknown depth + jsonList = eval("jsonObjParsed." + aSchema[0]); + } + catch(e) { + bError = true; + break; + } + } + } + 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; + } + + if(!YAHOO.lang.isArray(jsonList)) { + jsonList = [jsonList]; + } + + // 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); + } + // If schema isn't well defined, pass along the entire result object + if(aResultItem.length == 1) { + aResultItem.push(jsonResult); + } + // Capture the array of data field values in an array of results + aResults.unshift(aResultItem); + } + break; + case YAHOO.widget.DS_XHR.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 YAHOO.widget.DS_XHR.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. + * + * @property _oConn + * @type Object + * @private + */ +YAHOO.widget.DS_XHR.prototype._oConn = null; + + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +/** + * Implementation of YAHOO.widget.DataSource using a native Javascript function as + * its live data source. + * + * @class DS_JSFunction + * @constructor + * @extends YAHOO.widget.DataSource + * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects. + * @param oConfigs {Object} (optional) Object literal of config params. + */ +YAHOO.widget.DS_JSFunction = function(oFunction, oConfigs) { + // Set any config params passed in to override defaults + if(oConfigs && (oConfigs.constructor == Object)) { + for(var sConfig in oConfigs) { + this[sConfig] = oConfigs[sConfig]; + } + } + + // Initialization sequence + if(!YAHOO.lang.isFunction(oFunction)) { + 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. + * + * @property dataFunction + * @type HTMLFunction + */ +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. + * + * @method doQuery + * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} 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, YAHOO.widget.DataSource.ERROR_DATANULL); + YAHOO.log(YAHOO.widget.DataSource.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); + YAHOO.log("Results returned for query \"" + sQuery + + "\": " + YAHOO.lang.dump(aResults), "info", this.toString()); + oCallbackFn(sQuery, aResults, oParent); + return; +}; + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +/** + * Implementation of YAHOO.widget.DataSource using a native Javascript array as + * its live data source. + * + * @class DS_JSArray + * @constructor + * @extends YAHOO.widget.DataSource + * @param aData {String[]} In-memory Javascript array of simple string data. + * @param oConfigs {Object} (optional) Object literal of config params. + */ +YAHOO.widget.DS_JSArray = function(aData, oConfigs) { + // Set any config params passed in to override defaults + if(oConfigs && (oConfigs.constructor == Object)) { + for(var sConfig in oConfigs) { + this[sConfig] = oConfigs[sConfig]; + } + } + + // Initialization sequence + if(!YAHOO.lang.isArray(aData)) { + 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. + * + * @property data + * @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. + * + * @method doQuery + * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} The object instance that has requested data. + */ +YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { + var i; + var aData = this.data; // the array + var aResults = []; // container for results + var bMatchFound = false; + var bMatchContains = this.queryMatchContains; + if(sQuery) { + if(!this.queryMatchCase) { + sQuery = sQuery.toLowerCase(); + } + + // Loop through each element of the array... + // which can be a string or an array of strings + for(i = aData.length-1; i >= 0; i--) { + var aDataset = []; + + if(YAHOO.lang.isString(aData[i])) { + aDataset[0] = aData[i]; + } + else if(YAHOO.lang.isArray(aData[i])) { + aDataset = aData[i]; + } + + if(YAHOO.lang.isString(aDataset[0])) { + 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); + } + } + } + } + else { + for(i = aData.length-1; i >= 0; i--) { + if(YAHOO.lang.isString(aData[i])) { + aResults.unshift([aData[i]]); + } + else if(YAHOO.lang.isArray(aData[i])) { + aResults.unshift(aData[i]); + } + } + } + + this.getResultsEvent.fire(this, oParent, sQuery, aResults); + YAHOO.log("Results returned for query \"" + sQuery + + "\": " + YAHOO.lang.dump(aResults), "info", this.toString()); + oCallbackFn(sQuery, aResults, oParent); +}; + +YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/autocomplete/autocomplete-min.js b/lib/yui/autocomplete/autocomplete-min.js index 91bba0312c..d877c981f5 100755 --- a/lib/yui/autocomplete/autocomplete-min.js +++ b/lib/yui/autocomplete/autocomplete-min.js @@ -1,183 +1,191 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 +version: 2.3.0 */ - -YAHOO.widget.AutoComplete=function(elInput,elContainer,oDataSource,oConfigs){if(elInput&&elContainer&&oDataSource){if(oDataSource&&(oDataSource instanceof YAHOO.widget.DataSource)){this.dataSource=oDataSource;} -else{return;} -if(YAHOO.util.Dom.inDocument(elInput)){if(typeof elInput=="string"){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput;this._oTextbox=document.getElementById(elInput);} -else{this._sName=(elInput.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=elInput;}} -else{return;} -if(YAHOO.util.Dom.inDocument(elContainer)){if(typeof elContainer=="string"){this._oContainer=document.getElementById(elContainer);} -else{this._oContainer=elContainer;} -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,"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);} -YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,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("selectionEnforce",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.useShadow=false;YAHOO.widget.AutoComplete.prototype.toString=function(){return"AutoComplete "+this._sName;};YAHOO.widget.AutoComplete.prototype.isContainerOpen=function(){return this._bContainerOpen;};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.doBeforeExpandContainer=function(oResultItem,sQuery){return true;};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){this._sendQuery(sQuery);};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.AutoComplete._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._iFrameSrc="javascript:false;";YAHOO.widget.AutoComplete.prototype._queryInterval=null;YAHOO.widget.AutoComplete.prototype._sLastTextboxValue=null;YAHOO.widget.AutoComplete.prototype._initProps=function(){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.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%";oIFrame.tabIndex=-1;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-ac-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=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._sendQuery=function(sQuery){if(this.minQueryLength==-1){this._toggleContainer(false);return;} -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&&(sQuery.length0)){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);} -this._toggleContainer(false);return;} -sQuery=encodeURIComponent(sQuery);this._nDelayID=-1;this.dataRequestEvent.fire(this,sQuery);this.dataSource.getResults(this._populateList,sQuery,this);};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;} -var ok=oSelf.doBeforeExpandContainer(oSelf._oTextbox,oSelf._oContainer,sQuery,aResults);oSelf._toggleContainer(ok);} -else{oSelf._toggleContainer(false);} -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||(this._nKeyCode==8)){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(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(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){var oContainer=this._oContainer;if(this.alwaysShowContainer&&this._bContainerOpen){return;} -if(!bShow){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;} -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]||this.delimChar):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._cancelIntervalDetection(this);this.itemSelectEvent.fire(this,oItem,oItem._oResultData);this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(!this.typeAhead){return;} -else{this._toggleContainer(false);}};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._toggleContainer(false);return;} -var oNewItem=this._aListItems[nNewItemIndex];var oContent=this._oContainer._oContent;var scrollOn=((YAHOO.util.Dom.getStyle(oContent,"overflow")=="auto")||(YAHOO.util.Dom.getStyle(oContent,"overflowY")=="auto"));if(scrollOn&&(nNewItemIndex>-1)&&(nNewItemIndex(oContent.scrollTop+oContent.offsetHeight)){oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;} -else if((oNewItem.offsetTop+oNewItem.offsetHeight)(oContent.scrollTop+oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;}}} -this._toggleHighlight(oNewItem,"to");this.itemArrowToEvent.fire(this,oNewItem);if(this.typeAhead){this._updateValue(oNewItem);}}};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._toggleContainer(false);} -break;case 13:if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}} -if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);} -else{oSelf._toggleContainer(false);} -break;case 27:oSelf._toggleContainer(false);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;var isMac=(navigator.userAgent.toLowerCase().indexOf("mac")!=-1);if(isMac){switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}} -break;case 13:if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}} -break;case 38:case 40:YAHOO.util.Event.stopEvent(v);break;default:break;}} -else if(nKeyCode==229){oSelf._queryInterval=setInterval(function(){oSelf._onIMEDetected(oSelf);},500);}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(v,oSelf){oSelf._initProps();var nKeyCode=v.keyCode;oSelf._nKeyCode=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._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._toggleContainer(false);} -oSelf._cancelIntervalDetection(oSelf);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.DataSource=function(){};YAHOO.widget.DataSource.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.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.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(oResult){var aCache=this._aCache;if(!aCache||!oResult||!oResult.query||!oResult.results){return;} -if(aCache.length>=this.maxCacheEntries){aCache.shift();} -aCache.push(oResult);};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.TYPE_JSON=0;YAHOO.widget.DS_XHR.TYPE_XML=1;YAHOO.widget.DS_XHR.TYPE_FLAT=2;YAHOO.widget.DS_XHR.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connMgr=YAHOO.util.Connect;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.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n0){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,YAHOO.widget.DataSource.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,YAHOO.widget.DataSource.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,YAHOO.widget.DataSource.ERROR_DATAPARSE);aResults=[];} -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,YAHOO.widget.DS_XHR.ERROR_DATAXHR);return;};var oCallback={success:responseSuccess,failure:responseFailure};if(!isNaN(this.connTimeout)&&this.connTimeout>0){oCallback.timeout=this.connTimeout;} -if(this._oConn){this.connMgr.abort(this._oConn);} -oSelf._oConn=this.connMgr.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 YAHOO.widget.DS_XHR.TYPE_JSON:var jsonList;if(window.JSON&&(navigator.userAgent.toLowerCase().indexOf('khtml')==-1)){var jsonObjParsed=JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;} -else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);} -catch(e){bError=true;break;}}} -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;} -if(jsonList.constructor!=Array){jsonList=[jsonList];} -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);} -if(aResultItem.length==1){aResultItem.push(jsonResult);} -aResults.unshift(aResultItem);} -break;case YAHOO.widget.DS_XHR.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 YAHOO.widget.DS_XHR.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,YAHOO.widget.DataSource.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(sQuery){if(!this.queryMatchCase){sQuery=sQuery.toLowerCase();} -for(var i=aData.length-1;i>=0;i--){var aDataset=[];if(aData[i]){if(aData[i].constructor==String){aDataset[0]=aData[i];} -else if(aData[i].constructor==Array){aDataset=aData[i];}} -if(aDataset[0]&&(aDataset[0].constructor==String)){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);}; \ No newline at end of file + +YAHOO.widget.AutoComplete=function(elInput,elContainer,oDataSource,oConfigs){if(elInput&&elContainer&&oDataSource){if(oDataSource instanceof YAHOO.widget.DataSource){this.dataSource=oDataSource;} +else{return;} +if(YAHOO.util.Dom.inDocument(elInput)){if(YAHOO.lang.isString(elInput)){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput;this._oTextbox=document.getElementById(elInput);} +else{this._sName=(elInput.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+elInput.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=elInput;} +YAHOO.util.Dom.addClass(this._oTextbox,"yui-ac-input");} +else{return;} +if(YAHOO.util.Dom.inDocument(elContainer)){if(YAHOO.lang.isString(elContainer)){this._oContainer=document.getElementById(elContainer);} +else{this._oContainer=elContainer;} +if(this._oContainer.style.display=="none"){} +var elParent=this._oContainer.parentNode;var elTag=elParent.tagName.toLowerCase();while(elParent&&(elParent!="document")){if(elTag=="div"){YAHOO.util.Dom.addClass(elParent,"yui-ac");break;} +else{elParent=elParent.parentNode;elTag=elParent.tagName.toLowerCase();}} +if(elTag!="div"){}} +else{return;} +if(oConfigs&&(oConfigs.constructor==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,"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);} +YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,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("selectionEnforce",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.2;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.useShadow=false;YAHOO.widget.AutoComplete.prototype.toString=function(){return"AutoComplete "+this._sName;};YAHOO.widget.AutoComplete.prototype.isContainerOpen=function(){return this._bContainerOpen;};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.doBeforeExpandContainer=function(oTextbox,oContainer,sQuery,aResults){return true;};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){this._sendQuery(sQuery);};YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery=function(sQuery){return sQuery;};YAHOO.widget.AutoComplete.prototype.destroy=function(){var instanceName=this.toString();var elInput=this._oTextbox;var elContainer=this._oContainer;this.textboxFocusEvent.unsubscribe();this.textboxKeyEvent.unsubscribe();this.dataRequestEvent.unsubscribe();this.dataReturnEvent.unsubscribe();this.dataErrorEvent.unsubscribe();this.containerExpandEvent.unsubscribe();this.typeAheadEvent.unsubscribe();this.itemMouseOverEvent.unsubscribe();this.itemMouseOutEvent.unsubscribe();this.itemArrowToEvent.unsubscribe();this.itemArrowFromEvent.unsubscribe();this.itemSelectEvent.unsubscribe();this.unmatchedItemSelectEvent.unsubscribe();this.selectionEnforceEvent.unsubscribe();this.containerCollapseEvent.unsubscribe();this.textboxBlurEvent.unsubscribe();YAHOO.util.Event.purgeElement(elInput,true);YAHOO.util.Event.purgeElement(elContainer,true);elContainer.innerHTML="";for(var key in this){if(this.hasOwnProperty(key)){this[key]=null;}}};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.AutoComplete._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._iFrameSrc="javascript:false;";YAHOO.widget.AutoComplete.prototype._queryInterval=null;YAHOO.widget.AutoComplete.prototype._sLastTextboxValue=null;YAHOO.widget.AutoComplete.prototype._initProps=function(){var minQueryLength=this.minQueryLength;if(!YAHOO.lang.isNumber(minQueryLength)){this.minQueryLength=1;} +var maxResultsDisplayed=this.maxResultsDisplayed;if(!YAHOO.lang.isNumber(maxResultsDisplayed)||(maxResultsDisplayed<1)){this.maxResultsDisplayed=10;} +var queryDelay=this.queryDelay;if(!YAHOO.lang.isNumber(queryDelay)||(queryDelay<0)){this.queryDelay=0.2;} +var delimChar=this.delimChar;if(YAHOO.lang.isString(delimChar)){this.delimChar=[delimChar];} +else if(!YAHOO.lang.isArray(delimChar)){this.delimChar=null;} +var animSpeed=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(!YAHOO.lang.isNumber(animSpeed)||(animSpeed<0)){this.animSpeed=0.3;} +if(!this._oAnim){this._oAnim=new YAHOO.util.Anim(this._oContainer._oContent,{},this.animSpeed);} +else{this._oAnim.duration=this.animSpeed;}} +if(this.forceSelection&&delimChar){}};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%";oIFrame.tabIndex=-1;this._oContainer._oIFrame=this._oContainer.appendChild(oIFrame);}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){YAHOO.util.Dom.addClass(this._oContainer,"yui-ac-container");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-ac-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;oldi--){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=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=40)||(nKeyCode>=44&&nKeyCode<=45)){return true;} +return false;};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){if(this.minQueryLength==-1){this._toggleContainer(false);return;} +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&&(sQuery.length0)){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);} +this._toggleContainer(false);return;} +sQuery=encodeURIComponent(sQuery);this._nDelayID=-1;sQuery=this.doBeforeSendQuery(sQuery);this.dataRequestEvent.fire(this,sQuery);this.dataSource.getResults(this._populateList,sQuery,this);};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;} +var ok=oSelf.doBeforeExpandContainer(oSelf._oTextbox,oSelf._oContainer,sQuery,aResults);oSelf._toggleContainer(ok);if(oSelf.autoHighlight){var oFirstItem=aItems[0];oSelf._toggleHighlight(oFirstItem,"to");oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);} +else{oSelf._oCurItem=null;}} +else{oSelf._toggleContainer(false);} +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=null;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=oItem;break;}} +return(foundMatch);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(oItem,sQuery){if(!this.typeAhead||(this._nKeyCode==8)){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(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(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){var oContainer=this._oContainer;if(this.alwaysShowContainer&&this._bContainerOpen){return;} +if(!bShow){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;} +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]||this.delimChar):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._cancelIntervalDetection(this);this.itemSelectEvent.fire(this,oItem,oItem._oResultData);this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(this._oCurItem){this._selectItem(this._oCurItem);} +else{this._toggleContainer(false);}};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._toggleContainer(false);return;} +var oNewItem=this._aListItems[nNewItemIndex];var oContent=this._oContainer._oContent;var scrollOn=((YAHOO.util.Dom.getStyle(oContent,"overflow")=="auto")||(YAHOO.util.Dom.getStyle(oContent,"overflowY")=="auto"));if(scrollOn&&(nNewItemIndex>-1)&&(nNewItemIndex(oContent.scrollTop+oContent.offsetHeight)){oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;} +else if((oNewItem.offsetTop+oNewItem.offsetHeight)(oContent.scrollTop+oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;}}} +this._toggleHighlight(oNewItem,"to");this.itemArrowToEvent.fire(this,oNewItem);if(this.typeAhead){this._updateValue(oNewItem);}}};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._oCurItem){if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}} +oSelf._selectItem(oSelf._oCurItem);} +else{oSelf._toggleContainer(false);} +break;case 13:if(oSelf._oCurItem){if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}} +oSelf._selectItem(oSelf._oCurItem);} +else{oSelf._toggleContainer(false);} +break;case 27:oSelf._toggleContainer(false);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;var isMac=(navigator.userAgent.toLowerCase().indexOf("mac")!=-1);if(isMac){switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){YAHOO.util.Event.stopEvent(v);} +break;case 13:if(oSelf._nKeyCode!=nKeyCode){YAHOO.util.Event.stopEvent(v);} +break;case 38:case 40:YAHOO.util.Event.stopEvent(v);break;default:break;}} +else if(nKeyCode==229){oSelf._queryInterval=setInterval(function(){oSelf._onIMEDetected(oSelf);},500);}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(v,oSelf){oSelf._initProps();var nKeyCode=v.keyCode;oSelf._nKeyCode=nKeyCode;var sText=this.value;if(oSelf._isIgnoreKey(nKeyCode)||(sText.toLowerCase()==oSelf._sCurQuery)){return;} +else{oSelf._bItemSelected=false;YAHOO.util.Dom.removeClass(oSelf._oCurItem,oSelf.highlightClassName);oSelf._oCurItem=null;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._onTextboxFocus=function(v,oSelf){oSelf._oTextbox.setAttribute("autocomplete","off");oSelf._bFocused=true;if(!oSelf._bItemSelected){oSelf.textboxFocusEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(!oSelf._bItemSelected){var oMatch=oSelf._textMatchesOption();if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&(oMatch===null))){if(oSelf.forceSelection){oSelf._clearSelection();} +else{oSelf.unmatchedItemSelectEvent.fire(oSelf,oSelf._sCurQuery);}} +else{oSelf._selectItem(oMatch);}} +if(oSelf._bContainerOpen){oSelf._toggleContainer(false);} +oSelf._cancelIntervalDetection(oSelf);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.DataSource=function(){};YAHOO.widget.DataSource.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.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.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(!YAHOO.lang.isNumber(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(oResult){var aCache=this._aCache;if(!aCache||!oResult||!oResult.query||!oResult.results){return;} +if(aCache.length>=this.maxCacheEntries){aCache.shift();} +aCache.push(oResult);};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(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}} +if(!YAHOO.lang.isArray(aSchema)||!YAHOO.lang.isString(sScriptURI)){return;} +this.schema=aSchema;this.scriptURI=sScriptURI;this._init();};YAHOO.widget.DS_XHR.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_XHR.TYPE_JSON=0;YAHOO.widget.DS_XHR.TYPE_XML=1;YAHOO.widget.DS_XHR.TYPE_FLAT=2;YAHOO.widget.DS_XHR.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connMgr=YAHOO.util.Connect;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.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n0){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,YAHOO.widget.DataSource.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,YAHOO.widget.DataSource.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,YAHOO.widget.DataSource.ERROR_DATAPARSE);aResults=[];} +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,YAHOO.widget.DS_XHR.ERROR_DATAXHR);return;};var oCallback={success:responseSuccess,failure:responseFailure};if(YAHOO.lang.isNumber(this.connTimeout)&&(this.connTimeout>0)){oCallback.timeout=this.connTimeout;} +if(this._oConn){this.connMgr.abort(this._oConn);} +oSelf._oConn=this.connMgr.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 YAHOO.widget.DS_XHR.TYPE_JSON:var jsonList,jsonObjParsed;var isNotMac=(navigator.userAgent.toLowerCase().indexOf('khtml')==-1);if(oResponse.parseJSON&&isNotMac){jsonObjParsed=oResponse.parseJSON();if(!jsonObjParsed){bError=true;} +else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);} +catch(e){bError=true;break;}}} +else if(window.JSON&&isNotMac){jsonObjParsed=JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;} +else{try{jsonList=eval("jsonObjParsed."+aSchema[0]);} +catch(e){bError=true;break;}}} +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;} +if(!YAHOO.lang.isArray(jsonList)){jsonList=[jsonList];} +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);} +if(aResultItem.length==1){aResultItem.push(jsonResult);} +aResults.unshift(aResultItem);} +break;case YAHOO.widget.DS_XHR.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 YAHOO.widget.DS_XHR.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(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}} +if(!YAHOO.lang.isFunction(oFunction)){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,YAHOO.widget.DataSource.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(oConfigs&&(oConfigs.constructor==Object)){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}} +if(!YAHOO.lang.isArray(aData)){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 i;var aData=this.data;var aResults=[];var bMatchFound=false;var bMatchContains=this.queryMatchContains;if(sQuery){if(!this.queryMatchCase){sQuery=sQuery.toLowerCase();} +for(i=aData.length-1;i>=0;i--){var aDataset=[];if(YAHOO.lang.isString(aData[i])){aDataset[0]=aData[i];} +else if(YAHOO.lang.isArray(aData[i])){aDataset=aData[i];} +if(YAHOO.lang.isString(aDataset[0])){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);}}}} +else{for(i=aData.length-1;i>=0;i--){if(YAHOO.lang.isString(aData[i])){aResults.unshift([aData[i]]);} +else if(YAHOO.lang.isArray(aData[i])){aResults.unshift(aData[i]);}}} +this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);};YAHOO.register("autocomplete",YAHOO.widget.AutoComplete,{version:"2.3.0",build:"442"}); \ No newline at end of file diff --git a/lib/yui/autocomplete/autocomplete.js b/lib/yui/autocomplete/autocomplete.js index a39a98780b..72a6772b59 100755 --- a/lib/yui/autocomplete/autocomplete.js +++ b/lib/yui/autocomplete/autocomplete.js @@ -1,3065 +1,3190 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 +version: 2.3.0 */ - /** - * The AutoComplete control provides the front-end logic for text-entry suggestion and - * completion functionality. - * - * @module autocomplete - * @requires yahoo, dom, event, datasource - * @optional animation, connection, json - * @namespace YAHOO.widget - * @title AutoComplete Widget - */ - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The AutoComplete class provides the customizable functionality of a plug-and-play DHTML - * auto completion widget. Some key features: - *
    - *
  • Navigate with up/down arrow keys and/or mouse to pick a selection
  • - *
  • The drop down container can "roll down" or "fly out" via configurable - * animation
  • - *
  • UI look-and-feel customizable through CSS, including container - * attributes, borders, position, fonts, etc
  • - *
- * - * @class AutoComplete - * @constructor - * @param elInput {HTMLElement} DOM element reference of an input field. - * @param elInput {String} String ID of an input field. - * @param elContainer {HTMLElement} DOM element reference of an existing DIV. - * @param elContainer {String} String ID of an existing DIV. - * @param oDataSource {Object} Instance of YAHOO.widget.DataSource for query/results. - * @param oConfigs {Object} (optional) Object literal of configuration params. - */ -YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) { - if(elInput && elContainer && oDataSource) { - // Validate DataSource - if (oDataSource && (oDataSource instanceof YAHOO.widget.DataSource)) { - this.dataSource = oDataSource; - } - else { - return; - } - - // Validate input element - if(YAHOO.util.Dom.inDocument(elInput)) { - if(typeof elInput == "string") { - this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput; - this._oTextbox = document.getElementById(elInput); - } - else { - this._sName = (elInput.id) ? - "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput.id: - "instance" + YAHOO.widget.AutoComplete._nIndex; - this._oTextbox = elInput; - } - } - else { - return; - } - - // Validate container element - if(YAHOO.util.Dom.inDocument(elContainer)) { - if(typeof elContainer == "string") { - this._oContainer = document.getElementById(elContainer); - } - else { - this._oContainer = elContainer; - } - 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,"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); - } - YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,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 DataSource object that encapsulates the data used for auto completion. - * This object should be an inherited object from YAHOO.widget.DataSource. - * - * @property dataSource - * @type Object - */ -YAHOO.widget.AutoComplete.prototype.dataSource = null; - -/** - * Number of characters that must be entered before querying for results. A negative value - * effectively turns off the widget. A value of 0 allows queries of null or empty string - * values. - * - * @property minQueryLength - * @type Number - * @default 1 - */ -YAHOO.widget.AutoComplete.prototype.minQueryLength = 1; - -/** - * Maximum number of results to display in results container. - * - * @property maxResultsDisplayed - * @type Number - * @default 10 - */ -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. - * - * @property queryDelay - * @type Number - * @default 0.5 - */ -YAHOO.widget.AutoComplete.prototype.queryDelay = 0.5; - -/** - * Class name of a highlighted item within results container. - * - * @property highlighClassName - * @type String - * @default "yui-ac-highlight" - */ -YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight"; - -/** - * Class name of a pre-highlighted item within results container. - * - * @property prehighlightClassName - * @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. - * - * @property delimChar - * @type String | String[] - */ -YAHOO.widget.AutoComplete.prototype.delimChar = null; - -/** - * Whether or not the first item in results container should be automatically highlighted - * on expand. - * - * @property autoHighlight - * @type Boolean - * @default true - */ -YAHOO.widget.AutoComplete.prototype.autoHighlight = true; - -/** - * Whether or not the 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. - * - * @property typeAhead - * @type Boolean - * @default false - */ -YAHOO.widget.AutoComplete.prototype.typeAhead = false; - -/** - * Whether or not to animate the expansion/collapse of the results container in the - * horizontal direction. - * - * @property animHoriz - * @type Boolean - * @default false - */ -YAHOO.widget.AutoComplete.prototype.animHoriz = false; - -/** - * Whether or not to animate the expansion/collapse of the results container in the - * vertical direction. - * - * @property animVert - * @type Boolean - * @default true - */ -YAHOO.widget.AutoComplete.prototype.animVert = true; - -/** - * Speed of container expand/collapse animation, in seconds.. - * - * @property animSpeed - * @type Number - * @default 0.3 - */ -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 input field into a - * <select> field. This feature is not recommended with delimiter character(s) - * defined. - * - * @property forceSelection - * @type Boolean - * @default false - */ -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 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. - * - * @property allowBrowserAutocomplete - * @type Boolean - * @default true - */ -YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true; - -/** - * Whether or not the results container should always be displayed. - * Enabling this feature displays the container when the widget is instantiated - * and prevents the toggling of the container to a collapsed state. - * - * @property alwaysShowContainer - * @type Boolean - * @default false - */ -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 results 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). - * - * @property useIFrame - * @type Boolean - * @default false - */ -YAHOO.widget.AutoComplete.prototype.useIFrame = false; - -/** - * Whether or not the results container should have a shadow. - * - * @property useShadow - * @type Boolean - * @default false - */ -YAHOO.widget.AutoComplete.prototype.useShadow = false; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - - /** - * Public accessor to the unique name of the AutoComplete instance. - * - * @method toString - * @return {String} Unique name of the AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.toString = function() { - return "AutoComplete " + this._sName; -}; - - /** - * Returns true if container is in an expanded state, false otherwise. - * - * @method isContainerOpen - * @return {Boolean} Returns true if container is in an expanded state, false otherwise. - */ -YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() { - return this._bContainerOpen; -}; - -/** - * Public accessor to the internal array of DOM <li> elements that - * display query results within the results container. - * - * @method getListItems - * @return {HTMLElement[]} Array of <li> elements within the results container. - */ -YAHOO.widget.AutoComplete.prototype.getListItems = function() { - return this._aListItems; -}; - -/** - * Public accessor to the data held in an <li> element of the - * results container. - * - * @method getListItemData - * @return {Object | 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 results container header. This markup will be - * inserted within a <div> tag with a class of "ac_hd". - * - * @method setHeader - * @param sHeader {String} HTML markup for results 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 results container footer. This markup will be - * inserted within a <div> tag with a class of "ac_ft". - * - * @method setFooter - * @param sFooter {String} HTML markup for results 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 results container body. This markup will be - * inserted within a <div> tag with a class of "ac_bd". - * - * @method setBody - * @param sHeader {String} HTML markup for results 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. - * - * @method formatResult - * @param oResultItem {Object} Result item representing one query result. Data is held in an array. - * @param sQuery {String} 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 ""; - } -}; - -/** - * Overridable method called before container expands allows implementers to access data - * and DOM elements. - * - * @method doBeforeExpandContainer - * @return {Boolean} Return true to continue expanding container, false to cancel the expand. - */ -YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oResultItem, sQuery) { - return true; -}; - -/** - * Makes query request to the DataSource. - * - * @method sendQuery - * @param sQuery {String} Query string. - */ -YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) { - this._sendQuery(sQuery); -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public events -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Fired when the input field receives focus. - * - * @event textboxFocusEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null; - -/** - * Fired when the input field receives key input. - * - * @event textboxKeyEvent - * @param oSelf {Object} The AutoComplete instance. - * @param nKeycode {Number} The keycode number. - */ -YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null; - -/** - * Fired when the AutoComplete instance makes a query to the DataSource. - * - * @event dataRequestEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The query string. - */ -YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null; - -/** - * Fired when the AutoComplete instance receives query results from the data - * source. - * - * @event dataReturnEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The query string. - * @param aResults {Array} Results array. - */ -YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null; - -/** - * Fired when the AutoComplete instance does not receive query results from the - * DataSource due to an error. - * - * @event dataErrorEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The query string. - */ -YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null; - -/** - * Fired when the results container is expanded. - * - * @event containerExpandEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null; - -/** - * Fired when the input field has been prefilled by the type-ahead - * feature. - * - * @event typeAheadEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The query string. - * @param sPrefill {String} The prefill string. - */ -YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null; - -/** - * Fired when result item has been moused over. - * - * @event itemMouseOverEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} The <li> element item moused to. - */ -YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null; - -/** - * Fired when result item has been moused out. - * - * @event itemMouseOutEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} The <li> element item moused from. - */ -YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null; - -/** - * Fired when result item has been arrowed to. - * - * @event itemArrowToEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} The <li> element item arrowed to. - */ -YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null; - -/** - * Fired when result item has been arrowed away from. - * - * @event itemArrowFromEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} 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. - * - * @event itemSelectEvent - * @param oSelf {Object} The AutoComplete instance. - * @param elItem {HTMLElement} The selected <li> element item. - * @param oData {Object} 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 a 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. - * - * @event unmatchedItemSelectEvent - * @param oSelf {Object} The AutoComplete instance. - * @param sQuery {String} The user-typed query string. - */ -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. - * - * @event selectionEnforceEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null; - -/** - * Fired when the results container is collapsed. - * - * @event containerCollapseEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null; - -/** - * Fired when the input field loses focus. - * - * @event textboxBlurEvent - * @param oSelf {Object} The AutoComplete instance. - */ -YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple AutoComplete instances. - * - * @property _nIndex - * @type Number - * @default 0 - * @private - */ -YAHOO.widget.AutoComplete._nIndex = 0; - -/** - * Name of AutoComplete instance. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._sName = null; - -/** - * Text input field DOM element. - * - * @property _oTextbox - * @type HTMLElement - * @private - */ -YAHOO.widget.AutoComplete.prototype._oTextbox = null; - -/** - * Whether or not the input field is currently in focus. If query results come back - * but the user has already moved on, do not proceed with auto complete behavior. - * - * @property _bFocused - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._bFocused = true; - -/** - * Animation instance for container expand/collapse. - * - * @property _oAnim - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._oAnim = null; - -/** - * Container DOM element. - * - * @property _oContainer - * @type HTMLElement - * @private - */ -YAHOO.widget.AutoComplete.prototype._oContainer = null; - -/** - * Whether or not the results container is currently open. - * - * @property _bContainerOpen - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._bContainerOpen = false; - -/** - * Whether or not the mouse is currently over the results - * container. This is necessary in order to prevent clicks on container items - * from being text input field blur events. - * - * @property _bOverContainer - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._bOverContainer = false; - -/** - * Array of <li> elements references that contain query results within the - * results container. - * - * @property _aListItems - * @type Array - * @private - */ -YAHOO.widget.AutoComplete.prototype._aListItems = null; - -/** - * Number of <li> elements currently displayed in results container. - * - * @property _nDisplayedItems - * @type Number - * @private - */ -YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0; - -/** - * Internal count of <li> elements displayed and hidden in results container. - * - * @property _maxResultsDisplayed - * @type Number - * @private - */ -YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0; - -/** - * Current query string - * - * @property _sCurQuery - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._sCurQuery = null; - -/** - * Past queries this session (for saving delimited queries). - * - * @property _sSavedQuery - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._sSavedQuery = null; - -/** - * Pointer to the currently highlighted <li> element in the container. - * - * @property _oCurItem - * @type HTMLElement - * @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. - * - * @property _bItemSelected - * @type Boolean - * @private - */ -YAHOO.widget.AutoComplete.prototype._bItemSelected = false; - -/** - * Key code of the last key pressed in textbox. - * - * @property _nKeyCode - * @type Number - * @private - */ -YAHOO.widget.AutoComplete.prototype._nKeyCode = null; - -/** - * Delay timeout ID. - * - * @property _nDelayID - * @type Number - * @private - */ -YAHOO.widget.AutoComplete.prototype._nDelayID = -1; - -/** - * Src to iFrame used when useIFrame = true. Supports implementations over SSL - * as well. - * - * @property _iFrameSrc - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;"; - -/** - * For users typing via certain IMEs, queries must be triggered by intervals, - * since key events yet supported across all browsers for all IMEs. - * - * @property _queryInterval - * @type Object - * @private - */ -YAHOO.widget.AutoComplete.prototype._queryInterval = null; - -/** - * Internal tracker to last known textbox value, used to determine whether or not - * to trigger a query via interval for certain IME users. - * - * @event _sLastTextboxValue - * @type String - * @private - */ -YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Updates and validates latest public config properties. - * - * @method __initProps - * @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) { - } -}; - -/** - * Initializes the results container helpers if they are enabled and do - * not exist - * - * @method _initContainerHelpers - * @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%"; - oIFrame.tabIndex = -1; - this._oContainer._oIFrame = this._oContainer.appendChild(oIFrame); - } -}; - -/** - * Initializes the results container once at object creation - * - * @method _initContainer - * @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. - * - * @method _initList - * @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= 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; -}; - -/** - * Makes query request to the DataSource. - * - * @method _sendQuery - * @param sQuery {String} Query string. - * @private - */ -YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) { - // Widget has been effectively turned off - if(this.minQueryLength == -1) { - this._toggleContainer(false); - return; - } - // 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 && (sQuery.length < this.minQueryLength) || (!sQuery && this.minQueryLength > 0)) { - if (this._nDelayID != -1) { - clearTimeout(this._nDelayID); - } - this._toggleContainer(false); - 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); -}; - -/** - * 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 instance are returned to the - * AutoComplete instance. - * - * @method _populateList - * @param sQuery {String} The query string. - * @param aResults {Array} An array of query result objects from the DataSource. - * @param oSelf {Object} The AutoComplete 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 - var ok = oSelf.doBeforeExpandContainer(oSelf._oTextbox, oSelf._oContainer, sQuery, aResults); - oSelf._toggleContainer(ok); - } - else { - oSelf._toggleContainer(false); - } - oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults); -}; - -/** - * When forceSelection is true and the user attempts - * leave the text input box without selecting an item from the query results, - * the user selection is cleared. - * - * @method _clearSelection - * @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. - * - * @method _textMatchesOption - * @return {Boolean} True if user-input text matches a result, false otherwise. - * @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. - * - * @method _typeAhead - * @param oItem {HTMLElement} The <li> element item whose data populates the input field. - * @param sQuery {String} Query string. - * @private - */ -YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) { - // Don't update if turned off - if (!this.typeAhead || (this._nKeyCode == 8)) { - 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 the input field. - * - * @method _selectText - * @param oTextbox {HTMLElement} Text input box element in which to select text. - * @param nStart {Number} Starting index of text string to select. - * @param nEnd {Number} 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 results container with its helpers. - * - * @method _toggleContainerHelpers - * @param bShow {Boolean} 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(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(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. - * - * @method _toggleContainer - * @param bShow {Boolean} True if container should be expanded, false if container should be collapsed - * @private - */ -YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) { - var oContainer = this._oContainer; - - // Implementer has container always open so don't mess with it - if(this.alwaysShowContainer && this._bContainerOpen) { - return; - } - - // Clear contents of container - if(!bShow) { - 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; - } - - // 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. - * - * @method _toggleHighlight - * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior. - * @param sType {String} Type "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. - * - * @method _togglePrehighlight - * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior. - * @param sType {String} Type "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. - * - * @method _updateValue - * @param oItem {HTMLElement} 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] || this.delimChar) : 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 - * - * @method _selectItem - * @param oItem {HTMLElement} The selected <li> element item. - * @private - */ -YAHOO.widget.AutoComplete.prototype._selectItem = function(oItem) { - this._bItemSelected = true; - this._updateValue(oItem); - this._cancelIntervalDetection(this); - this.itemSelectEvent.fire(this, oItem, oItem._oResultData); - this._toggleContainer(false); -}; - -/** - * For values updated by type-ahead, the right arrow key jumps to the end - * of the textbox, otherwise the container is closed. - * - * @method _jumpSelection - * @private - */ -YAHOO.widget.AutoComplete.prototype._jumpSelection = function() { - if(!this.typeAhead) { - return; - } - else { - this._toggleContainer(false); - } -}; - -/** - * Triggered by up and down arrow keys, changes the current highlighted - * <li> element item. Scrolls container if necessary. - * - * @method _moveSelection - * @param nKeyCode {Number} 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._toggleContainer(false); - return; - } - - var oNewItem = this._aListItems[nNewItemIndex]; - - // Scroll the container if necessary - var oContent = this._oContainer._oContent; - var scrollOn = ((YAHOO.util.Dom.getStyle(oContent,"overflow") == "auto") || - (YAHOO.util.Dom.getStyle(oContent,"overflowY") == "auto")); - if(scrollOn && (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) > (oContent.scrollTop + oContent.offsetHeight)) { - // Set bottom of scroll area to bottom of selected item - oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight; - } - // Bottom of selected item is above scroll area... - else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) { - // Set top of selected item to top of scroll area - oContent.scrollTop = oNewItem.offsetTop; - - } - } - // User is keying up - else { - // Top of selected item is above scroll area - if(oNewItem.offsetTop < 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 > (oContent.scrollTop + oContent.offsetHeight)) { - // Set bottom of selected item to bottom of scroll area - this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight; - } - } - } - - this._toggleHighlight(oNewItem, "to"); - this.itemArrowToEvent.fire(this, oNewItem); - if(this.typeAhead) { - this._updateValue(oNewItem); - } - } -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private event handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Handles <li> element mouseover events in the container. - * - * @method _onItemMouseover - * @param v {HTMLEvent} The mouseover event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onItemMouseout - * @param v {HTMLEvent} The mouseout event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onItemMouseclick - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onContainerMouseover - * @param v {HTMLEvent} The mouseover event. - * @param oSelf {Object} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) { - oSelf._bOverContainer = true; -}; - -/** - * Handles container mouseout events. - * - * @method _onContainerMouseout - * @param v {HTMLEvent} The mouseout event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onContainerScroll - * @param v {HTMLEvent} The scroll event. - * @param oSelf {Object} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) { - oSelf._oTextbox.focus(); -}; - -/** - * Handles container resize events. - * - * @method _onContainerResize - * @param v {HTMLEvent} The resize event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onTextboxKeyDown - * @param v {HTMLEvent} The keydown event. - * @param oSelf {object} The AutoComplete 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._toggleContainer(false); - } - 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._toggleContainer(false); - } - break; - case 27: // esc - oSelf._toggleContainer(false); - 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. - * @method _onTextboxKeyPress - * @param v {HTMLEvent} The keypress event. - * @param oSelf {Object} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) { - var nKeyCode = v.keyCode; - - //Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337) - var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1); - if(isMac) { - switch (nKeyCode) { - case 9: // tab - if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) { - if(oSelf._bContainerOpen) { - YAHOO.util.Event.stopEvent(v); - } - } - break; - case 13: // enter - if(oSelf._nKeyCode != nKeyCode) { - if(oSelf._bContainerOpen) { - YAHOO.util.Event.stopEvent(v); - } - } - break; - case 38: // up - case 40: // down - YAHOO.util.Event.stopEvent(v); - break; - default: - break; - } - } - - //TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948) - // Korean IME detected - else if(nKeyCode == 229) { - oSelf._queryInterval = setInterval(function() { oSelf._onIMEDetected(oSelf); },500); - } -}; - -/** - * Handles textbox keyup events that trigger queries. - * - * @method _onTextboxKeyUp - * @param v {HTMLEvent} The keyup event. - * @param oSelf {Object} The AutoComplete 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 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); - } -}; - -/** - * Handles text input box receiving focus. - * - * @method _onTextboxFocus - * @param v {HTMLEvent} The focus event. - * @param oSelf {Object} The AutoComplete 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. - * - * @method _onTextboxBlur - * @param v {HTMLEvent} The focus event. - * @param oSelf {Object} The AutoComplete 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._toggleContainer(false); - } - oSelf._cancelIntervalDetection(oSelf); - oSelf._bFocused = false; - oSelf.textboxBlurEvent.fire(oSelf); - } -}; - -/** - * Handles form submission event. - * - * @method _onFormSubmit - * @param v {HTMLEvent} The submit event. - * @param oSelf {Object} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) { - if(oSelf.allowBrowserAutocomplete) { - oSelf._oTextbox.setAttribute("autocomplete","on"); - } - else { - oSelf._oTextbox.setAttribute("autocomplete","off"); - } -}; -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The DataSource classes manages sending a request and returning response from a live - * database. Supported data include local JavaScript arrays and objects and databases - * accessible via XHR connections. Supported response formats include JavaScript arrays, - * JSON, XML, and flat-file textual data. - * - * @class DataSource - * @constructor - */ -YAHOO.widget.DataSource = function() { - /* abstract class */ -}; - - -///////////////////////////////////////////////////////////////////////////// -// -// Public constants -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Error message for null data responses. - * - * @property ERROR_DATANULL - * @type String - * @static - * @final - */ -YAHOO.widget.DataSource.ERROR_DATANULL = "Response data was null"; - -/** - * Error message for data responses with parsing errors. - * - * @property ERROR_DATAPARSE - * @type String - * @static - * @final - */ -YAHOO.widget.DataSource.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. - * - * @property maxCacheEntries - * @type Number - * @default 15 - */ -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. - * - * @property queryMatchContains - * @type Boolean - * @default false - */ -YAHOO.widget.DataSource.prototype.queryMatchContains = false; - -/** - * Enables 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 DataSources that return comprehensive results - * for queries with very few characters. - * - * @property queryMatchSubset - * @type Boolean - * @default false - * - */ -YAHOO.widget.DataSource.prototype.queryMatchSubset = false; - -/** - * Enables query case-sensitivity matching. If caching is on and - * queryMatchCase is true, queries will only return results for case-sensitive - * matches. - * - * @property queryMatchCase - * @type Boolean - * @default false - */ -YAHOO.widget.DataSource.prototype.queryMatchCase = false; - - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - - /** - * Public accessor to the unique name of the DataSource instance. - * - * @method toString - * @return {String} Unique name of the DataSource 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. - * - * @method getResults - * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} 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). - * - * @method doQuery - * @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} The object instance that has requested data. - */ -YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { - /* override this */ -}; - -/** - * Flushes cache. - * - * @method flushCache - */ -YAHOO.widget.DataSource.prototype.flushCache = function() { - if(this._aCache) { - this._aCache = []; - } - if(this._aCacheHelper) { - this._aCacheHelper = []; - } - this.cacheFlushEvent.fire(this); -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public events -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Fired when a query is made to the live data source. - * - * @event queryEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - */ -YAHOO.widget.DataSource.prototype.queryEvent = null; - -/** - * Fired when a query is made to the local cache. - * - * @event cacheQueryEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - */ -YAHOO.widget.DataSource.prototype.cacheQueryEvent = null; - -/** - * Fired when data is retrieved from the live data source. - * - * @event getResultsEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - * @param aResults {Object[]} Array of result objects. - */ -YAHOO.widget.DataSource.prototype.getResultsEvent = null; - -/** - * Fired when data is retrieved from the local cache. - * - * @event getCachedResultsEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - * @param aResults {Object[]} Array of result objects. - */ -YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null; - -/** - * Fired when an error is encountered with the live data source. - * - * @event dataErrorEvent - * @param oSelf {Object} The DataSource instance. - * @param oParent {Object} The requesting object. - * @param sQuery {String} The query string. - * @param sMsg {String} Error message string - */ -YAHOO.widget.DataSource.prototype.dataErrorEvent = null; - -/** - * Fired when the local cache is flushed. - * - * @event cacheFlushEvent - * @param oSelf {Object} The DataSource instance - */ -YAHOO.widget.DataSource.prototype.cacheFlushEvent = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple DataSource instances. - * - * @property _nIndex - * @type Number - * @private - * @static - */ -YAHOO.widget.DataSource._nIndex = 0; - -/** - * Name of DataSource instance. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.DataSource.prototype._sName = null; - -/** - * Local cache of data result objects indexed chronologically. - * - * @property _aCache - * @type Object[] - * @private - */ -YAHOO.widget.DataSource.prototype._aCache = null; - - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Initializes DataSource instance. - * - * @method _init - * @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. - * - * @method _addCacheElem - * @param oResult {Object} Data result object, including array of results. - * @private - */ -YAHOO.widget.DataSource.prototype._addCacheElem = function(oResult) { - var aCache = this._aCache; - // Don't add if anything important is missing. - if(!aCache || !oResult || !oResult.query || !oResult.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(oResult); -}; - -/** - * 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. - * - * @method _doQueryCache - * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} The object instance that has requested data. - * @return aResults {Object[]} Array of results 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. - * - * @class DS_XHR - * @extends YAHOO.widget.DataSource - * @requires connection - * @constructor - * @param sScriptURI {String} Absolute or relative URI to script that returns query - * results as JSON, XML, or delimited flat-file data. - * @param aSchema {String[]} Data schema definition of results. - * @param oConfigs {Object} (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. - * - * @property TYPE_JSON - * @type Number - * @static - * @final - */ -YAHOO.widget.DS_XHR.TYPE_JSON = 0; - -/** - * XML data type. - * - * @property TYPE_XML - * @type Number - * @static - * @final - */ -YAHOO.widget.DS_XHR.TYPE_XML = 1; - -/** - * Flat-file data type. - * - * @property TYPE_FLAT - * @type Number - * @static - * @final - */ -YAHOO.widget.DS_XHR.TYPE_FLAT = 2; - -/** - * Error message for XHR failure. - * - * @property ERROR_DATAXHR - * @type String - * @static - * @final - */ -YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed"; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Alias to YUI Connection Manager. Allows implementers to specify their own - * subclasses of the YUI Connection Manager utility. - * - * @property connMgr - * @type Object - * @default YAHOO.util.Connect - */ -YAHOO.widget.DS_XHR.prototype.connMgr = YAHOO.util.Connect; - -/** - * 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. - * - * @property connTimeout - * @type Number - * @default 0 - */ -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 - * - * @property scriptURI - * @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 - * - * @property scriptQueryParam - * @type String - * @default "query" - */ -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> - * - * @property scriptQueryAppend - * @type String - * @default "" - */ -YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = ""; - -/** - * XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML - * and YAHOO.widget.DS_XHR.TYPE_FLAT. - * - * @property responseType - * @type String - * @default YAHOO.widget.DS_XHR.TYPE_JSON - */ -YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.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. - * - * @property responseStripAfter - * @type String - * @default "\n<!-" - */ -YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n 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, YAHOO.widget.DataSource.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, YAHOO.widget.DataSource.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, YAHOO.widget.DataSource.ERROR_DATAPARSE); - aResults = []; - } - 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, YAHOO.widget.DS_XHR.ERROR_DATAXHR); - return; - }; - - var oCallback = { - success:responseSuccess, - failure:responseFailure - }; - - if(!isNaN(this.connTimeout) && this.connTimeout > 0) { - oCallback.timeout = this.connTimeout; - } - - if(this._oConn) { - this.connMgr.abort(this._oConn); - } - - oSelf._oConn = this.connMgr.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. - * - * @method parseResponse - * @param sQuery {String} Query string. - * @param oResponse {Object} The raw response data to parse. - * @param oParent {Object} The object instance that has requested data. - * @returns {Object[]} 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 YAHOO.widget.DS_XHR.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 { - try { - // eval is necessary here since aSchema[0] is of unknown depth - jsonList = eval("jsonObjParsed." + aSchema[0]); - } - catch(e) { - bError = true; - break; - } - } - } - 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; - } - - if(jsonList.constructor != Array) { - jsonList = [jsonList]; - } - - // 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); - } - // If schema isn't well defined, pass along the entire result object - if(aResultItem.length == 1) { - aResultItem.push(jsonResult); - } - // Capture the array of data field values in an array of results - aResults.unshift(aResultItem); - } - break; - case YAHOO.widget.DS_XHR.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 YAHOO.widget.DS_XHR.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. - * - * @property _oConn - * @type Object - * @private - */ -YAHOO.widget.DS_XHR.prototype._oConn = null; - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * Implementation of YAHOO.widget.DataSource using a native Javascript function as - * its live data source. - * - * @class DS_JSFunction - * @constructor - * @extends YAHOO.widget.DataSource - * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects. - * @param oConfigs {Object} (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. - * - * @property dataFunction - * @type HTMLFunction - */ -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. - * - * @method doQuery - * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} 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, YAHOO.widget.DataSource.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. - * - * @class DS_JSArray - * @constructor - * @extends YAHOO.widget.DataSource - * @param aData {String[]} In-memory Javascript array of simple string data. - * @param oConfigs {Object} (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. - * - * @property data - * @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. - * - * @method doQuery - * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. - * @param sQuery {String} Query string. - * @param oParent {Object} The object instance that has requested data. - */ -YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { - var aData = this.data; // the array - var aResults = []; // container for results - var bMatchFound = false; - var bMatchContains = this.queryMatchContains; - if(sQuery) { - if(!this.queryMatchCase) { - sQuery = sQuery.toLowerCase(); - } - - // Loop through each element of the array... - // which can be a string or an array of strings - for(var i = aData.length-1; i >= 0; i--) { - var aDataset = []; - - if(aData[i]) { - if(aData[i].constructor == String) { - aDataset[0] = aData[i]; - } - else if(aData[i].constructor == Array) { - aDataset = aData[i]; - } - } - - if(aDataset[0] && (aDataset[0].constructor == String)) { - 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); -}; + /** + * The AutoComplete control provides the front-end logic for text-entry suggestion and + * completion functionality. + * + * @module autocomplete + * @requires yahoo, dom, event, datasource + * @optional animation, connection + * @namespace YAHOO.widget + * @title AutoComplete Widget + */ + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +/** + * The AutoComplete class provides the customizable functionality of a plug-and-play DHTML + * auto completion widget. Some key features: + *
    + *
  • Navigate with up/down arrow keys and/or mouse to pick a selection
  • + *
  • The drop down container can "roll down" or "fly out" via configurable + * animation
  • + *
  • UI look-and-feel customizable through CSS, including container + * attributes, borders, position, fonts, etc
  • + *
+ * + * @class AutoComplete + * @constructor + * @param elInput {HTMLElement} DOM element reference of an input field. + * @param elInput {String} String ID of an input field. + * @param elContainer {HTMLElement} DOM element reference of an existing DIV. + * @param elContainer {String} String ID of an existing DIV. + * @param oDataSource {YAHOO.widget.DataSource} DataSource instance. + * @param oConfigs {Object} (optional) Object literal of configuration params. + */ +YAHOO.widget.AutoComplete = function(elInput,elContainer,oDataSource,oConfigs) { + if(elInput && elContainer && oDataSource) { + // Validate DataSource + if(oDataSource instanceof YAHOO.widget.DataSource) { + this.dataSource = oDataSource; + } + else { + return; + } + + // Validate input element + if(YAHOO.util.Dom.inDocument(elInput)) { + if(YAHOO.lang.isString(elInput)) { + this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput; + this._oTextbox = document.getElementById(elInput); + } + else { + this._sName = (elInput.id) ? + "instance" + YAHOO.widget.AutoComplete._nIndex + " " + elInput.id: + "instance" + YAHOO.widget.AutoComplete._nIndex; + this._oTextbox = elInput; + } + YAHOO.util.Dom.addClass(this._oTextbox, "yui-ac-input"); + } + else { + return; + } + + // Validate container element + if(YAHOO.util.Dom.inDocument(elContainer)) { + if(YAHOO.lang.isString(elContainer)) { + this._oContainer = document.getElementById(elContainer); + } + else { + this._oContainer = elContainer; + } + if(this._oContainer.style.display == "none") { + } + + // For skinning + var elParent = this._oContainer.parentNode; + var elTag = elParent.tagName.toLowerCase(); + while(elParent && (elParent != "document")) { + if(elTag == "div") { + YAHOO.util.Dom.addClass(elParent, "yui-ac"); + break; + } + else { + elParent = elParent.parentNode; + elTag = elParent.tagName.toLowerCase(); + } + } + if(elTag != "div") { + } + } + else { + return; + } + + // Set any config params passed in to override defaults + if(oConfigs && (oConfigs.constructor == 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,"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); + } + YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,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 DataSource object that encapsulates the data used for auto completion. + * This object should be an inherited object from YAHOO.widget.DataSource. + * + * @property dataSource + * @type YAHOO.widget.DataSource + */ +YAHOO.widget.AutoComplete.prototype.dataSource = null; + +/** + * Number of characters that must be entered before querying for results. A negative value + * effectively turns off the widget. A value of 0 allows queries of null or empty string + * values. + * + * @property minQueryLength + * @type Number + * @default 1 + */ +YAHOO.widget.AutoComplete.prototype.minQueryLength = 1; + +/** + * Maximum number of results to display in results container. + * + * @property maxResultsDisplayed + * @type Number + * @default 10 + */ +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. + * Implementers should take care when setting this value very low (i.e., less + * than 0.2) with low latency DataSources and the typeAhead feature enabled, as + * fast typers may see unexpected behavior. + * + * @property queryDelay + * @type Number + * @default 0.2 + */ +YAHOO.widget.AutoComplete.prototype.queryDelay = 0.2; + +/** + * Class name of a highlighted item within results container. + * + * @property highlightClassName + * @type String + * @default "yui-ac-highlight" + */ +YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight"; + +/** + * Class name of a pre-highlighted item within results container. + * + * @property prehighlightClassName + * @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. + * + * @property delimChar + * @type String | String[] + */ +YAHOO.widget.AutoComplete.prototype.delimChar = null; + +/** + * Whether or not the first item in results container should be automatically highlighted + * on expand. + * + * @property autoHighlight + * @type Boolean + * @default true + */ +YAHOO.widget.AutoComplete.prototype.autoHighlight = true; + +/** + * Whether or not the 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. + * + * @property typeAhead + * @type Boolean + * @default false + */ +YAHOO.widget.AutoComplete.prototype.typeAhead = false; + +/** + * Whether or not to animate the expansion/collapse of the results container in the + * horizontal direction. + * + * @property animHoriz + * @type Boolean + * @default false + */ +YAHOO.widget.AutoComplete.prototype.animHoriz = false; + +/** + * Whether or not to animate the expansion/collapse of the results container in the + * vertical direction. + * + * @property animVert + * @type Boolean + * @default true + */ +YAHOO.widget.AutoComplete.prototype.animVert = true; + +/** + * Speed of container expand/collapse animation, in seconds.. + * + * @property animSpeed + * @type Number + * @default 0.3 + */ +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 input field into a + * <select> field. This feature is not recommended with delimiter character(s) + * defined. + * + * @property forceSelection + * @type Boolean + * @default false + */ +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 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. + * + * @property allowBrowserAutocomplete + * @type Boolean + * @default true + */ +YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true; + +/** + * Whether or not the results container should always be displayed. + * Enabling this feature displays the container when the widget is instantiated + * and prevents the toggling of the container to a collapsed state. + * + * @property alwaysShowContainer + * @type Boolean + * @default false + */ +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 results 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). + * + * @property useIFrame + * @type Boolean + * @default false + */ +YAHOO.widget.AutoComplete.prototype.useIFrame = false; + +/** + * Whether or not the results container should have a shadow. + * + * @property useShadow + * @type Boolean + * @default false + */ +YAHOO.widget.AutoComplete.prototype.useShadow = false; + +///////////////////////////////////////////////////////////////////////////// +// +// Public methods +// +///////////////////////////////////////////////////////////////////////////// + + /** + * Public accessor to the unique name of the AutoComplete instance. + * + * @method toString + * @return {String} Unique name of the AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.toString = function() { + return "AutoComplete " + this._sName; +}; + + /** + * Returns true if container is in an expanded state, false otherwise. + * + * @method isContainerOpen + * @return {Boolean} Returns true if container is in an expanded state, false otherwise. + */ +YAHOO.widget.AutoComplete.prototype.isContainerOpen = function() { + return this._bContainerOpen; +}; + +/** + * Public accessor to the internal array of DOM <li> elements that + * display query results within the results container. + * + * @method getListItems + * @return {HTMLElement[]} Array of <li> elements within the results container. + */ +YAHOO.widget.AutoComplete.prototype.getListItems = function() { + return this._aListItems; +}; + +/** + * Public accessor to the data held in an <li> element of the + * results container. + * + * @method getListItemData + * @return {Object | Object[]} 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 results container header. This markup will be + * inserted within a <div> tag with a class of "yui-ac-hd". + * + * @method setHeader + * @param sHeader {String} HTML markup for results 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 results container footer. This markup will be + * inserted within a <div> tag with a class of "yui-ac-ft". + * + * @method setFooter + * @param sFooter {String} HTML markup for results 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 results container body. This markup will be + * inserted within a <div> tag with a class of "yui-ac-bd". + * + * @method setBody + * @param sBody {String} HTML markup for results 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. + * + * @method formatResult + * @param oResultItem {Object} Result item representing one query result. Data is held in an array. + * @param sQuery {String} 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 ""; + } +}; + +/** + * Overridable method called before container expands allows implementers to access data + * and DOM elements. + * + * @method doBeforeExpandContainer + * @param oTextbox {HTMLElement} The text input box. + * @param oContainer {HTMLElement} The container element. + * @param sQuery {String} The query string. + * @param aResults {Object[]} An array of query results. + * @return {Boolean} Return true to continue expanding container, false to cancel the expand. + */ +YAHOO.widget.AutoComplete.prototype.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) { + return true; +}; + +/** + * Makes query request to the DataSource. + * + * @method sendQuery + * @param sQuery {String} Query string. + */ +YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) { + this._sendQuery(sQuery); +}; + +/** + * Overridable method gives implementers access to the query before it gets sent. + * + * @method doBeforeSendQuery + * @param sQuery {String} Query string. + * @return {String} Query string. + */ +YAHOO.widget.AutoComplete.prototype.doBeforeSendQuery = function(sQuery) { + return sQuery; +}; + +/** + * Nulls out the entire AutoComplete instance and related objects, removes attached + * event listeners, and clears out DOM elements inside the container. After + * calling this method, the instance reference should be expliclitly nulled by + * implementer, as in myDataTable = null. Use with caution! + * + * @method destroy + */ +YAHOO.widget.AutoComplete.prototype.destroy = function() { + var instanceName = this.toString(); + var elInput = this._oTextbox; + var elContainer = this._oContainer; + + // Unhook custom events + this.textboxFocusEvent.unsubscribe(); + this.textboxKeyEvent.unsubscribe(); + this.dataRequestEvent.unsubscribe(); + this.dataReturnEvent.unsubscribe(); + this.dataErrorEvent.unsubscribe(); + this.containerExpandEvent.unsubscribe(); + this.typeAheadEvent.unsubscribe(); + this.itemMouseOverEvent.unsubscribe(); + this.itemMouseOutEvent.unsubscribe(); + this.itemArrowToEvent.unsubscribe(); + this.itemArrowFromEvent.unsubscribe(); + this.itemSelectEvent.unsubscribe(); + this.unmatchedItemSelectEvent.unsubscribe(); + this.selectionEnforceEvent.unsubscribe(); + this.containerCollapseEvent.unsubscribe(); + this.textboxBlurEvent.unsubscribe(); + + // Unhook DOM events + YAHOO.util.Event.purgeElement(elInput, true); + YAHOO.util.Event.purgeElement(elContainer, true); + + // Remove DOM elements + elContainer.innerHTML = ""; + + // Null out objects + for(var key in this) { + if(this.hasOwnProperty(key)) { + this[key] = null; + } + } + +}; + +///////////////////////////////////////////////////////////////////////////// +// +// Public events +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Fired when the input field receives focus. + * + * @event textboxFocusEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null; + +/** + * Fired when the input field receives key input. + * + * @event textboxKeyEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param nKeycode {Number} The keycode number. + */ +YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null; + +/** + * Fired when the AutoComplete instance makes a query to the DataSource. + * + * @event dataRequestEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The query string. + */ +YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null; + +/** + * Fired when the AutoComplete instance receives query results from the data + * source. + * + * @event dataReturnEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The query string. + * @param aResults {Object[]} Results array. + */ +YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null; + +/** + * Fired when the AutoComplete instance does not receive query results from the + * DataSource due to an error. + * + * @event dataErrorEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The query string. + */ +YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null; + +/** + * Fired when the results container is expanded. + * + * @event containerExpandEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null; + +/** + * Fired when the input field has been prefilled by the type-ahead + * feature. + * + * @event typeAheadEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The query string. + * @param sPrefill {String} The prefill string. + */ +YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null; + +/** + * Fired when result item has been moused over. + * + * @event itemMouseOverEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} The <li> element item moused to. + */ +YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null; + +/** + * Fired when result item has been moused out. + * + * @event itemMouseOutEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} The <li> element item moused from. + */ +YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null; + +/** + * Fired when result item has been arrowed to. + * + * @event itemArrowToEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} The <li> element item arrowed to. + */ +YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null; + +/** + * Fired when result item has been arrowed away from. + * + * @event itemArrowFromEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} 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. + * + * @event itemSelectEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param elItem {HTMLElement} The selected <li> element item. + * @param oData {Object} 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 a 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. + * + * @event unmatchedItemSelectEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @param sQuery {String} The user-typed query string. + */ +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. + * + * @event selectionEnforceEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null; + +/** + * Fired when the results container is collapsed. + * + * @event containerCollapseEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null; + +/** + * Fired when the input field loses focus. + * + * @event textboxBlurEvent + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + */ +YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null; + +///////////////////////////////////////////////////////////////////////////// +// +// Private member variables +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Internal class variable to index multiple AutoComplete instances. + * + * @property _nIndex + * @type Number + * @default 0 + * @private + */ +YAHOO.widget.AutoComplete._nIndex = 0; + +/** + * Name of AutoComplete instance. + * + * @property _sName + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._sName = null; + +/** + * Text input field DOM element. + * + * @property _oTextbox + * @type HTMLElement + * @private + */ +YAHOO.widget.AutoComplete.prototype._oTextbox = null; + +/** + * Whether or not the input field is currently in focus. If query results come back + * but the user has already moved on, do not proceed with auto complete behavior. + * + * @property _bFocused + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._bFocused = true; + +/** + * Animation instance for container expand/collapse. + * + * @property _oAnim + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._oAnim = null; + +/** + * Container DOM element. + * + * @property _oContainer + * @type HTMLElement + * @private + */ +YAHOO.widget.AutoComplete.prototype._oContainer = null; + +/** + * Whether or not the results container is currently open. + * + * @property _bContainerOpen + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._bContainerOpen = false; + +/** + * Whether or not the mouse is currently over the results + * container. This is necessary in order to prevent clicks on container items + * from being text input field blur events. + * + * @property _bOverContainer + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._bOverContainer = false; + +/** + * Array of <li> elements references that contain query results within the + * results container. + * + * @property _aListItems + * @type HTMLElement[] + * @private + */ +YAHOO.widget.AutoComplete.prototype._aListItems = null; + +/** + * Number of <li> elements currently displayed in results container. + * + * @property _nDisplayedItems + * @type Number + * @private + */ +YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0; + +/** + * Internal count of <li> elements displayed and hidden in results container. + * + * @property _maxResultsDisplayed + * @type Number + * @private + */ +YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0; + +/** + * Current query string + * + * @property _sCurQuery + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._sCurQuery = null; + +/** + * Past queries this session (for saving delimited queries). + * + * @property _sSavedQuery + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._sSavedQuery = null; + +/** + * Pointer to the currently highlighted <li> element in the container. + * + * @property _oCurItem + * @type HTMLElement + * @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. + * + * @property _bItemSelected + * @type Boolean + * @private + */ +YAHOO.widget.AutoComplete.prototype._bItemSelected = false; + +/** + * Key code of the last key pressed in textbox. + * + * @property _nKeyCode + * @type Number + * @private + */ +YAHOO.widget.AutoComplete.prototype._nKeyCode = null; + +/** + * Delay timeout ID. + * + * @property _nDelayID + * @type Number + * @private + */ +YAHOO.widget.AutoComplete.prototype._nDelayID = -1; + +/** + * Src to iFrame used when useIFrame = true. Supports implementations over SSL + * as well. + * + * @property _iFrameSrc + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._iFrameSrc = "javascript:false;"; + +/** + * For users typing via certain IMEs, queries must be triggered by intervals, + * since key events yet supported across all browsers for all IMEs. + * + * @property _queryInterval + * @type Object + * @private + */ +YAHOO.widget.AutoComplete.prototype._queryInterval = null; + +/** + * Internal tracker to last known textbox value, used to determine whether or not + * to trigger a query via interval for certain IME users. + * + * @event _sLastTextboxValue + * @type String + * @private + */ +YAHOO.widget.AutoComplete.prototype._sLastTextboxValue = null; + +///////////////////////////////////////////////////////////////////////////// +// +// Private methods +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Updates and validates latest public config properties. + * + * @method __initProps + * @private + */ +YAHOO.widget.AutoComplete.prototype._initProps = function() { + // Correct any invalid values + var minQueryLength = this.minQueryLength; + if(!YAHOO.lang.isNumber(minQueryLength)) { + this.minQueryLength = 1; + } + var maxResultsDisplayed = this.maxResultsDisplayed; + if(!YAHOO.lang.isNumber(maxResultsDisplayed) || (maxResultsDisplayed < 1)) { + this.maxResultsDisplayed = 10; + } + var queryDelay = this.queryDelay; + if(!YAHOO.lang.isNumber(queryDelay) || (queryDelay < 0)) { + this.queryDelay = 0.2; + } + var delimChar = this.delimChar; + if(YAHOO.lang.isString(delimChar)) { + this.delimChar = [delimChar]; + } + else if(!YAHOO.lang.isArray(delimChar)) { + this.delimChar = null; + } + var animSpeed = this.animSpeed; + if((this.animHoriz || this.animVert) && YAHOO.util.Anim) { + if(!YAHOO.lang.isNumber(animSpeed) || (animSpeed < 0)) { + this.animSpeed = 0.3; + } + if(!this._oAnim ) { + this._oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed); + } + else { + this._oAnim.duration = this.animSpeed; + } + } + if(this.forceSelection && delimChar) { + } +}; + +/** + * Initializes the results container helpers if they are enabled and do + * not exist + * + * @method _initContainerHelpers + * @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%"; + oIFrame.tabIndex = -1; + this._oContainer._oIFrame = this._oContainer.appendChild(oIFrame); + } +}; + +/** + * Initializes the results container once at object creation + * + * @method _initContainer + * @private + */ +YAHOO.widget.AutoComplete.prototype._initContainer = function() { + YAHOO.util.Dom.addClass(this._oContainer, "yui-ac-container"); + + 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. + * + * @method _initList + * @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; oldi--) { + 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= 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 >= 36 && nKeyCode <= 40) || // home,left,up, right, down + (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert + return true; + } + return false; +}; + +/** + * Makes query request to the DataSource. + * + * @method _sendQuery + * @param sQuery {String} Query string. + * @private + */ +YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) { + // Widget has been effectively turned off + if(this.minQueryLength == -1) { + this._toggleContainer(false); + return; + } + // 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 && (sQuery.length < this.minQueryLength)) || (!sQuery && this.minQueryLength > 0)) { + if(this._nDelayID != -1) { + clearTimeout(this._nDelayID); + } + this._toggleContainer(false); + return; + } + + sQuery = encodeURIComponent(sQuery); + this._nDelayID = -1; // Reset timeout ID because request has been made + sQuery = this.doBeforeSendQuery(sQuery); + this.dataRequestEvent.fire(this, sQuery); + this.dataSource.getResults(this._populateList, sQuery, this); +}; + +/** + * 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 instance are returned to the + * AutoComplete instance. + * + * @method _populateList + * @param sQuery {String} The query string. + * @param aResults {Object[]} An array of query result objects from the DataSource. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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; + } + + // Expand the container + var ok = oSelf.doBeforeExpandContainer(oSelf._oTextbox, oSelf._oContainer, sQuery, aResults); + oSelf._toggleContainer(ok); + + 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; + } + } + else { + oSelf._toggleContainer(false); + } + oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults); + +}; + +/** + * When forceSelection is true and the user attempts + * leave the text input box without selecting an item from the query results, + * the user selection is cleared. + * + * @method _clearSelection + * @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. + * + * @method _textMatchesOption + * @return {HTMLElement} Matching list item element if user-input text matches + * a result, null otherwise. + * @private + */ +YAHOO.widget.AutoComplete.prototype._textMatchesOption = function() { + var foundMatch = null; + + 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 = oItem; + 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. + * + * @method _typeAhead + * @param oItem {HTMLElement} The <li> element item whose data populates the input field. + * @param sQuery {String} Query string. + * @private + */ +YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) { + // Don't update if turned off + if(!this.typeAhead || (this._nKeyCode == 8)) { + 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 the input field. + * + * @method _selectText + * @param oTextbox {HTMLElement} Text input box element in which to select text. + * @param nStart {Number} Starting index of text string to select. + * @param nEnd {Number} 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 results container with its helpers. + * + * @method _toggleContainerHelpers + * @param bShow {Boolean} 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(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(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. + * + * @method _toggleContainer + * @param bShow {Boolean} True if container should be expanded, false if container should be collapsed + * @private + */ +YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) { + var oContainer = this._oContainer; + + // Implementer has container always open so don't mess with it + if(this.alwaysShowContainer && this._bContainerOpen) { + return; + } + + // Clear contents of container + if(!bShow) { + 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; + } + + // 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. + * + * @method _toggleHighlight + * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior. + * @param sType {String} Type "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. + * + * @method _togglePrehighlight + * @param oNewItem {HTMLElement} The <li> element item to receive highlight behavior. + * @param sType {String} Type "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. + * + * @method _updateValue + * @param oItem {HTMLElement} 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] || this.delimChar) : 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 + * + * @method _selectItem + * @param oItem {HTMLElement} The selected <li> element item. + * @private + */ +YAHOO.widget.AutoComplete.prototype._selectItem = function(oItem) { + this._bItemSelected = true; + this._updateValue(oItem); + this._cancelIntervalDetection(this); + this.itemSelectEvent.fire(this, oItem, oItem._oResultData); + this._toggleContainer(false); +}; + +/** + * If an item is highlighted in the container, the right arrow key jumps to the + * end of the textbox and selects the highlighted item, otherwise the container + * is closed. + * + * @method _jumpSelection + * @private + */ +YAHOO.widget.AutoComplete.prototype._jumpSelection = function() { + if(this._oCurItem) { + this._selectItem(this._oCurItem); + } + else { + this._toggleContainer(false); + } +}; + +/** + * Triggered by up and down arrow keys, changes the current highlighted + * <li> element item. Scrolls container if necessary. + * + * @method _moveSelection + * @param nKeyCode {Number} 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._toggleContainer(false); + return; + } + + var oNewItem = this._aListItems[nNewItemIndex]; + + // Scroll the container if necessary + var oContent = this._oContainer._oContent; + var scrollOn = ((YAHOO.util.Dom.getStyle(oContent,"overflow") == "auto") || + (YAHOO.util.Dom.getStyle(oContent,"overflowY") == "auto")); + if(scrollOn && (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) > (oContent.scrollTop + oContent.offsetHeight)) { + // Set bottom of scroll area to bottom of selected item + oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight; + } + // Bottom of selected item is above scroll area... + else if((oNewItem.offsetTop+oNewItem.offsetHeight) < oContent.scrollTop) { + // Set top of selected item to top of scroll area + oContent.scrollTop = oNewItem.offsetTop; + + } + } + // User is keying up + else { + // Top of selected item is above scroll area + if(oNewItem.offsetTop < 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 > (oContent.scrollTop + oContent.offsetHeight)) { + // Set bottom of selected item to bottom of scroll area + this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - oContent.offsetHeight; + } + } + } + + this._toggleHighlight(oNewItem, "to"); + this.itemArrowToEvent.fire(this, oNewItem); + if(this.typeAhead) { + this._updateValue(oNewItem); + } + } +}; + +///////////////////////////////////////////////////////////////////////////// +// +// Private event handlers +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Handles <li> element mouseover events in the container. + * + * @method _onItemMouseover + * @param v {HTMLEvent} The mouseover event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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. + * + * @method _onItemMouseout + * @param v {HTMLEvent} The mouseout event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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. + * + * @method _onItemMouseclick + * @param v {HTMLEvent} The click event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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. + * + * @method _onContainerMouseover + * @param v {HTMLEvent} The mouseover event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) { + oSelf._bOverContainer = true; +}; + +/** + * Handles container mouseout events. + * + * @method _onContainerMouseout + * @param v {HTMLEvent} The mouseout event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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. + * + * @method _onContainerScroll + * @param v {HTMLEvent} The scroll event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) { + oSelf._oTextbox.focus(); +}; + +/** + * Handles container resize events. + * + * @method _onContainerResize + * @param v {HTMLEvent} The resize event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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. + * + * @method _onTextboxKeyDown + * @param v {HTMLEvent} The keydown event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) { + var nKeyCode = v.keyCode; + + switch (nKeyCode) { + case 9: // tab + // select an item or clear out + if(oSelf._oCurItem) { + if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) { + if(oSelf._bContainerOpen) { + YAHOO.util.Event.stopEvent(v); + } + } + oSelf._selectItem(oSelf._oCurItem); + } + else { + oSelf._toggleContainer(false); + } + break; + case 13: // enter + if(oSelf._oCurItem) { + if(oSelf._nKeyCode != nKeyCode) { + if(oSelf._bContainerOpen) { + YAHOO.util.Event.stopEvent(v); + } + } + oSelf._selectItem(oSelf._oCurItem); + } + else { + oSelf._toggleContainer(false); + } + break; + case 27: // esc + oSelf._toggleContainer(false); + 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. + * @method _onTextboxKeyPress + * @param v {HTMLEvent} The keypress event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) { + var nKeyCode = v.keyCode; + + //Expose only to Mac browsers, where stopEvent is ineffective on keydown events (bug 790337) + var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1); + if(isMac) { + switch (nKeyCode) { + case 9: // tab + if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) { + YAHOO.util.Event.stopEvent(v); + } + break; + 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; + } + } + + //TODO: (?) limit only to non-IE, non-Mac-FF for Korean IME support (bug 811948) + // Korean IME detected + else if(nKeyCode == 229) { + oSelf._queryInterval = setInterval(function() { oSelf._onIMEDetected(oSelf); },500); + } +}; + +/** + * Handles textbox keyup events that trigger queries. + * + * @method _onTextboxKeyUp + * @param v {HTMLEvent} The keyup event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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 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._bItemSelected = false; + YAHOO.util.Dom.removeClass(oSelf._oCurItem, oSelf.highlightClassName); + oSelf._oCurItem = null; + + 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); + } +}; + +/** + * Handles text input box receiving focus. + * + * @method _onTextboxFocus + * @param v {HTMLEvent} The focus event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) { + oSelf._oTextbox.setAttribute("autocomplete","off"); + oSelf._bFocused = true; + if(!oSelf._bItemSelected) { + oSelf.textboxFocusEvent.fire(oSelf); + } +}; + +/** + * Handles text input box losing focus. + * + * @method _onTextboxBlur + * @param v {HTMLEvent} The focus event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete 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) { + var oMatch = oSelf._textMatchesOption(); + if(!oSelf._bContainerOpen || (oSelf._bContainerOpen && (oMatch === null))) { + if(oSelf.forceSelection) { + oSelf._clearSelection(); + } + else { + oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery); + } + } + else { + oSelf._selectItem(oMatch); + } + } + + if(oSelf._bContainerOpen) { + oSelf._toggleContainer(false); + } + oSelf._cancelIntervalDetection(oSelf); + oSelf._bFocused = false; + oSelf.textboxBlurEvent.fire(oSelf); + } +}; + +/** + * Handles form submission event. + * + * @method _onFormSubmit + * @param v {HTMLEvent} The submit event. + * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. + * @private + */ +YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) { + if(oSelf.allowBrowserAutocomplete) { + oSelf._oTextbox.setAttribute("autocomplete","on"); + } + else { + oSelf._oTextbox.setAttribute("autocomplete","off"); + } +}; + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +/** + * The DataSource classes manages sending a request and returning response from a live + * database. Supported data include local JavaScript arrays and objects and databases + * accessible via XHR connections. Supported response formats include JavaScript arrays, + * JSON, XML, and flat-file textual data. + * + * @class DataSource + * @constructor + */ +YAHOO.widget.DataSource = function() { + /* abstract class */ +}; + + +///////////////////////////////////////////////////////////////////////////// +// +// Public constants +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Error message for null data responses. + * + * @property ERROR_DATANULL + * @type String + * @static + * @final + */ +YAHOO.widget.DataSource.ERROR_DATANULL = "Response data was null"; + +/** + * Error message for data responses with parsing errors. + * + * @property ERROR_DATAPARSE + * @type String + * @static + * @final + */ +YAHOO.widget.DataSource.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. + * + * @property maxCacheEntries + * @type Number + * @default 15 + */ +YAHOO.widget.DataSource.prototype.maxCacheEntries = 15; + +/** + * Use this to fine-tune the matching algorithm used against JS Array types of + * DataSource and DataSource caches. If queryMatchContains is true, then the JS + * Array or cache returns results that "contain" the query string. By default, + * queryMatchContains is set to false, so that only results that "start with" + * the query string are returned. + * + * @property queryMatchContains + * @type Boolean + * @default false + */ +YAHOO.widget.DataSource.prototype.queryMatchContains = false; + +/** + * Enables 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 DataSources that return comprehensive results + * for queries with very few characters. + * + * @property queryMatchSubset + * @type Boolean + * @default false + * + */ +YAHOO.widget.DataSource.prototype.queryMatchSubset = false; + +/** + * Enables case-sensitivity in the matching algorithm used against JS Array + * types of DataSources and DataSource caches. If queryMatchCase is true, only + * case-sensitive matches will return. + * + * @property queryMatchCase + * @type Boolean + * @default false + */ +YAHOO.widget.DataSource.prototype.queryMatchCase = false; + + +///////////////////////////////////////////////////////////////////////////// +// +// Public methods +// +///////////////////////////////////////////////////////////////////////////// + + /** + * Public accessor to the unique name of the DataSource instance. + * + * @method toString + * @return {String} Unique name of the DataSource 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. + * + * @method getResults + * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} 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). + * + * @method doQuery + * @param oCallbackFn {HTMLFunction} Callback function implemented by oParent to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} The object instance that has requested data. + */ +YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { + /* override this */ +}; + +/** + * Flushes cache. + * + * @method flushCache + */ +YAHOO.widget.DataSource.prototype.flushCache = function() { + if(this._aCache) { + this._aCache = []; + } + if(this._aCacheHelper) { + this._aCacheHelper = []; + } + this.cacheFlushEvent.fire(this); + +}; + +///////////////////////////////////////////////////////////////////////////// +// +// Public events +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Fired when a query is made to the live data source. + * + * @event queryEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + */ +YAHOO.widget.DataSource.prototype.queryEvent = null; + +/** + * Fired when a query is made to the local cache. + * + * @event cacheQueryEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + */ +YAHOO.widget.DataSource.prototype.cacheQueryEvent = null; + +/** + * Fired when data is retrieved from the live data source. + * + * @event getResultsEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + * @param aResults {Object[]} Array of result objects. + */ +YAHOO.widget.DataSource.prototype.getResultsEvent = null; + +/** + * Fired when data is retrieved from the local cache. + * + * @event getCachedResultsEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + * @param aResults {Object[]} Array of result objects. + */ +YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null; + +/** + * Fired when an error is encountered with the live data source. + * + * @event dataErrorEvent + * @param oSelf {Object} The DataSource instance. + * @param oParent {Object} The requesting object. + * @param sQuery {String} The query string. + * @param sMsg {String} Error message string + */ +YAHOO.widget.DataSource.prototype.dataErrorEvent = null; + +/** + * Fired when the local cache is flushed. + * + * @event cacheFlushEvent + * @param oSelf {Object} The DataSource instance + */ +YAHOO.widget.DataSource.prototype.cacheFlushEvent = null; + +///////////////////////////////////////////////////////////////////////////// +// +// Private member variables +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Internal class variable to index multiple DataSource instances. + * + * @property _nIndex + * @type Number + * @private + * @static + */ +YAHOO.widget.DataSource._nIndex = 0; + +/** + * Name of DataSource instance. + * + * @property _sName + * @type String + * @private + */ +YAHOO.widget.DataSource.prototype._sName = null; + +/** + * Local cache of data result objects indexed chronologically. + * + * @property _aCache + * @type Object[] + * @private + */ +YAHOO.widget.DataSource.prototype._aCache = null; + + +///////////////////////////////////////////////////////////////////////////// +// +// Private methods +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Initializes DataSource instance. + * + * @method _init + * @private + */ +YAHOO.widget.DataSource.prototype._init = function() { + // Validate and initialize public configs + var maxCacheEntries = this.maxCacheEntries; + if(!YAHOO.lang.isNumber(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. + * + * @method _addCacheElem + * @param oResult {Object} Data result object, including array of results. + * @private + */ +YAHOO.widget.DataSource.prototype._addCacheElem = function(oResult) { + var aCache = this._aCache; + // Don't add if anything important is missing. + if(!aCache || !oResult || !oResult.query || !oResult.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(oResult); +}; + +/** + * 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. + * + * @method _doQueryCache + * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} The object instance that has requested data. + * @return aResults {Object[]} Array of results 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. + * + * @class DS_XHR + * @extends YAHOO.widget.DataSource + * @requires connection + * @constructor + * @param sScriptURI {String} Absolute or relative URI to script that returns query + * results as JSON, XML, or delimited flat-file data. + * @param aSchema {String[]} Data schema definition of results. + * @param oConfigs {Object} (optional) Object literal of config params. + */ +YAHOO.widget.DS_XHR = function(sScriptURI, aSchema, oConfigs) { + // Set any config params passed in to override defaults + if(oConfigs && (oConfigs.constructor == Object)) { + for(var sConfig in oConfigs) { + this[sConfig] = oConfigs[sConfig]; + } + } + + // Initialization sequence + if(!YAHOO.lang.isArray(aSchema) || !YAHOO.lang.isString(sScriptURI)) { + return; + } + + this.schema = aSchema; + this.scriptURI = sScriptURI; + + this._init(); +}; + +YAHOO.widget.DS_XHR.prototype = new YAHOO.widget.DataSource(); + +///////////////////////////////////////////////////////////////////////////// +// +// Public constants +// +///////////////////////////////////////////////////////////////////////////// + +/** + * JSON data type. + * + * @property TYPE_JSON + * @type Number + * @static + * @final + */ +YAHOO.widget.DS_XHR.TYPE_JSON = 0; + +/** + * XML data type. + * + * @property TYPE_XML + * @type Number + * @static + * @final + */ +YAHOO.widget.DS_XHR.TYPE_XML = 1; + +/** + * Flat-file data type. + * + * @property TYPE_FLAT + * @type Number + * @static + * @final + */ +YAHOO.widget.DS_XHR.TYPE_FLAT = 2; + +/** + * Error message for XHR failure. + * + * @property ERROR_DATAXHR + * @type String + * @static + * @final + */ +YAHOO.widget.DS_XHR.ERROR_DATAXHR = "XHR response failed"; + +///////////////////////////////////////////////////////////////////////////// +// +// Public member variables +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Alias to YUI Connection Manager. Allows implementers to specify their own + * subclasses of the YUI Connection Manager utility. + * + * @property connMgr + * @type Object + * @default YAHOO.util.Connect + */ +YAHOO.widget.DS_XHR.prototype.connMgr = YAHOO.util.Connect; + +/** + * 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. + * + * @property connTimeout + * @type Number + * @default 0 + */ +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 + * + * @property scriptURI + * @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 + * + * @property scriptQueryParam + * @type String + * @default "query" + */ +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> + * + * @property scriptQueryAppend + * @type String + * @default "" + */ +YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = ""; + +/** + * XHR response data type. Other types that may be defined are YAHOO.widget.DS_XHR.TYPE_XML + * and YAHOO.widget.DS_XHR.TYPE_FLAT. + * + * @property responseType + * @type String + * @default YAHOO.widget.DS_XHR.TYPE_JSON + */ +YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.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. + * + * @property responseStripAfter + * @type String + * @default "\n<!-" + */ +YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n 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, YAHOO.widget.DataSource.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, YAHOO.widget.DataSource.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, YAHOO.widget.DataSource.ERROR_DATAPARSE); + aResults = []; + } + 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, YAHOO.widget.DS_XHR.ERROR_DATAXHR); + return; + }; + + var oCallback = { + success:responseSuccess, + failure:responseFailure + }; + + if(YAHOO.lang.isNumber(this.connTimeout) && (this.connTimeout > 0)) { + oCallback.timeout = this.connTimeout; + } + + if(this._oConn) { + this.connMgr.abort(this._oConn); + } + + oSelf._oConn = this.connMgr.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. + * + * @method parseResponse + * @param sQuery {String} Query string. + * @param oResponse {Object} The raw response data to parse. + * @param oParent {Object} The object instance that has requested data. + * @returns {Object[]} 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 YAHOO.widget.DS_XHR.TYPE_JSON: + var jsonList, jsonObjParsed; + // Check for JSON lib but divert KHTML clients + var isNotMac = (navigator.userAgent.toLowerCase().indexOf('khtml')== -1); + if(oResponse.parseJSON && isNotMac) { + // Use the new JSON utility if available + jsonObjParsed = oResponse.parseJSON(); + if(!jsonObjParsed) { + bError = true; + } + else { + try { + // eval is necessary here since aSchema[0] is of unknown depth + jsonList = eval("jsonObjParsed." + aSchema[0]); + } + catch(e) { + bError = true; + break; + } + } + } + else if(window.JSON && isNotMac) { + // Use older JSON lib if available + jsonObjParsed = JSON.parse(oResponse); + if(!jsonObjParsed) { + bError = true; + break; + } + else { + try { + // eval is necessary here since aSchema[0] is of unknown depth + jsonList = eval("jsonObjParsed." + aSchema[0]); + } + catch(e) { + bError = true; + break; + } + } + } + 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; + } + + if(!YAHOO.lang.isArray(jsonList)) { + jsonList = [jsonList]; + } + + // 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); + } + // If schema isn't well defined, pass along the entire result object + if(aResultItem.length == 1) { + aResultItem.push(jsonResult); + } + // Capture the array of data field values in an array of results + aResults.unshift(aResultItem); + } + break; + case YAHOO.widget.DS_XHR.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 YAHOO.widget.DS_XHR.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. + * + * @property _oConn + * @type Object + * @private + */ +YAHOO.widget.DS_XHR.prototype._oConn = null; + + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +/** + * Implementation of YAHOO.widget.DataSource using a native Javascript function as + * its live data source. + * + * @class DS_JSFunction + * @constructor + * @extends YAHOO.widget.DataSource + * @param oFunction {HTMLFunction} In-memory Javascript function that returns query results as an array of objects. + * @param oConfigs {Object} (optional) Object literal of config params. + */ +YAHOO.widget.DS_JSFunction = function(oFunction, oConfigs) { + // Set any config params passed in to override defaults + if(oConfigs && (oConfigs.constructor == Object)) { + for(var sConfig in oConfigs) { + this[sConfig] = oConfigs[sConfig]; + } + } + + // Initialization sequence + if(!YAHOO.lang.isFunction(oFunction)) { + 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. + * + * @property dataFunction + * @type HTMLFunction + */ +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. + * + * @method doQuery + * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} 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, YAHOO.widget.DataSource.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. + * + * @class DS_JSArray + * @constructor + * @extends YAHOO.widget.DataSource + * @param aData {String[]} In-memory Javascript array of simple string data. + * @param oConfigs {Object} (optional) Object literal of config params. + */ +YAHOO.widget.DS_JSArray = function(aData, oConfigs) { + // Set any config params passed in to override defaults + if(oConfigs && (oConfigs.constructor == Object)) { + for(var sConfig in oConfigs) { + this[sConfig] = oConfigs[sConfig]; + } + } + + // Initialization sequence + if(!YAHOO.lang.isArray(aData)) { + 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. + * + * @property data + * @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. + * + * @method doQuery + * @param oCallbackFn {HTMLFunction} Callback function defined by oParent object to which to return results. + * @param sQuery {String} Query string. + * @param oParent {Object} The object instance that has requested data. + */ +YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { + var i; + var aData = this.data; // the array + var aResults = []; // container for results + var bMatchFound = false; + var bMatchContains = this.queryMatchContains; + if(sQuery) { + if(!this.queryMatchCase) { + sQuery = sQuery.toLowerCase(); + } + + // Loop through each element of the array... + // which can be a string or an array of strings + for(i = aData.length-1; i >= 0; i--) { + var aDataset = []; + + if(YAHOO.lang.isString(aData[i])) { + aDataset[0] = aData[i]; + } + else if(YAHOO.lang.isArray(aData[i])) { + aDataset = aData[i]; + } + + if(YAHOO.lang.isString(aDataset[0])) { + 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); + } + } + } + } + else { + for(i = aData.length-1; i >= 0; i--) { + if(YAHOO.lang.isString(aData[i])) { + aResults.unshift([aData[i]]); + } + else if(YAHOO.lang.isArray(aData[i])) { + aResults.unshift(aData[i]); + } + } + } + + this.getResultsEvent.fire(this, oParent, sQuery, aResults); + oCallbackFn(sQuery, aResults, oParent); +}; + +YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/base/README b/lib/yui/base/README new file mode 100755 index 0000000000..287f22ea11 --- /dev/null +++ b/lib/yui/base/README @@ -0,0 +1,5 @@ +YUI Library - Base - Release Notes + +Version 2.3.0 + + * Initial release. \ No newline at end of file diff --git a/lib/yui/base/base-min.css b/lib/yui/base/base-min.css new file mode 100755 index 0000000000..a4dcc816f6 --- /dev/null +++ b/lib/yui/base/base-min.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +h1{font-size:138.5%;}h2{font-size:123.1%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:bold;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;}em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style: decimal outside;}ul li{list-style: disc outside;}dl dd{margin-left:1em;}th,td {border:1px solid #000;padding:.5em;}th {font-weight:bold;text-align:center;}caption {margin-bottom:.5em;text-align:center;}p,fieldset,table {margin-bottom:1em;} \ No newline at end of file diff --git a/lib/yui/base/base.css b/lib/yui/base/base.css new file mode 100755 index 0000000000..85dcca7dd2 --- /dev/null +++ b/lib/yui/base/base.css @@ -0,0 +1,76 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/* base.css, part of YUI's CSS Foundation */ +h1 { + /*18px via YUI Fonts CSS foundation*/ + font-size:138.5%; +} +h2 { + /*16px via YUI Fonts CSS foundation*/ + font-size:123.1%; +} +h3 { + /*14px via YUI Fonts CSS foundation*/ + font-size:108%; +} +h1,h2,h3 { + /* top & bottom margin based on font size */ + margin:1em 0; +} +h1,h2,h3,h4,h5,h6,strong { + /*bringing boldness back to headers and the strong element*/ + font-weight:bold; +} +abbr,acronym { + /*indicating to users that more info is available */ + border-bottom:1px dotted #000; + cursor:help; +} +em { + /*bringing italics back to the em element*/ + font-style:italic; +} +blockquote,ul,ol,dl { + /*giving blockquotes and lists room to breath*/ + margin:1em; +} +ol,ul,dl { + /*bringing lists on to the page with breathing room */ + margin-left:2em; +} +ol li { + /*giving OL's LIs generated numbers*/ + list-style: decimal outside; +} +ul li { + /*giving UL's LIs generated disc markers*/ + list-style: disc outside; +} +dl dd { + /*giving UL's LIs generated numbers*/ + margin-left:1em; +} +th,td { + /*borders and padding to make the table readable*/ + border:1px solid #000; + padding:.5em; +} +th { + /*distinguishing table headers from data cells*/ + font-weight:bold; + text-align:center; +} +caption { + /*coordinated marking to match cell's padding*/ + margin-bottom:.5em; + /*centered so it doesn't blend in to other content*/ + text-align:center; +} +p,fieldset,table { + /*so things don't run into each other*/ + margin-bottom:1em; +} \ No newline at end of file diff --git a/lib/yui/button/README b/lib/yui/button/README new file mode 100755 index 0000000000..a0bcb58831 --- /dev/null +++ b/lib/yui/button/README @@ -0,0 +1,272 @@ +*** Version 2.3.0 *** + +Added the following features: +----------------------------- + ++ Added a "focusmenu" configuration attribute that controls whether or not a + Button instance's menu will automatically be focused when made visible. + ++ Added a "lazyloadmenu" configuration attribute that controls the value of + the "lazyload" configuration property of a Button's menu. + ++ Added "menuclassname" configuration attribute that defines a CSS class name + to be applied to the root HTML element of a button's menu. + + +Fixed the following bugs: +------------------------- + ++ Setting the "label" attribute of a Button of type "link" to a string with + a "www." prefix will no longer result in the value of the "href" property + being used for the "label" in IE. + ++ Disabling a Button when its menu is visible will now result in the menu + being hidden. + ++ Hidden field(s) created by a Button instance are now removed if the + submission of its parent form is cancelled. + ++ If a Button instance is preceeded by another enabled HTML submit button + ( or + - + - ... TEXT/HTML ... + - ... ... + - ... ... + ++ The id of a Button instance can now match that of its source element. + ++ CSS changes: + + 1) All Buttons have a "yui-" prefix as opposed to "yui": + + 2.2.2 | 2.3 + ------------------------- + .yuibutton | .yui-button + + + 2) Each Button type has its own class name with a "yui-" prefix and + "-button" suffix IN ADDITION TO the default "yui-button" class name: + + 2.2.2 | 2.3 + ------------------------------------------ + .yuibutton.splitbutton | .yui-split-button + .yuibutton.menubutton | .yui-menu-button + + * Allows for the definition of generic styles that apply to all buttons, + while providing a means for uniquely styling buttons of a specific type. + + + 3) For states that are common to all Buttons, two classes are applied: a + generic class name (i.e. yui-button-[state]) and a type-specific state class + name (yui-[type]-button-[state]): + + 2.2.2 | 2.3 + ------------------------------------------- + .yuibutton.focus | .yui-button-focus + .yuibutton.radio.focus | .yui-radio-button-focus + + * States common to all Button types are: + + focus + + hover + + active + + disabled + + ** Allows for the definition of generic styles that apply to all states of + all buttons, while providing a means for uniquely styling states for + buttons of a specific type. + + + 4) Buttons of type "radio" and "checkbox" have two classes applied to + represent their "checked" state: a generic class name + (i.e. yui-button-checked) and a type-specific class + name (yui-[type]-button-checked): + + 2.2.2 | 2.3 + ------------------------------------------- + .yuibutton.checked | .yui-button-checked + .yuibutton.radio.checked | .yui-radio-button-checked + .yuibutton.checkbox.checked | .yui-checkbox-button-checked + + ** This allows for the definition of a universal style for all Buttons that + have a "checked" state or the ability to define a type-specific style for + the "checked" state. + + + 5) States that are specific to a particular type only get a type-specific + state class name. Currently this only applies to the "splitbutton" type: + + 2.2.2 | 2.3 + ------------------------------------------- + .yuibutton.activeoption | .yui-split-button-activeoption + + + 6) The "ie6" class name is removed. + + +*** Version 2.2.2 *** + ++ No changes + + +*** Version 2.2.1 *** + +Added the following features: +----------------------------- + ++ Added "getHiddenField" method to YAHOO.widget.Button. + + +Fixed the following bugs: +------------------------- + ++ Removed built-in use of the Event utility's "onAvailable" method from the + constructor of Button and ButtonGroup as it was preventing the addition of + event listeners on instances created from existing markup. Going forward + Button and ButtonGroup instances created from existing markup can only be + instantiated once their source HTML element is available in the DOM. The + Button examples illustrate how this can be accomplished. + ++ Modified code so that disabled Button instances no longer fire DOM events. + ++ Pressing the enter key while focused on a form field whose parent form + contains a Button instance of type "submit" will now automatically submit + the form using the first Button instance of type "submit". + ++ Clicking a Button instance of type="submit" will now cause the Button's + parent form's "submit" event to fire. + ++ Modified Button CSS so that the filter used to apply alpha transparency to + a Button's background PNG is only used by IE 6. The previous code was + enabling IE's Alpha image loader for IE 7 in Quirks mode. + ++ Fixed documentation error for "getForm" method. + + +Changes: +-------- + ++ Made the "submitForm" method of YAHOO.widget.Button public (was + previously protected). + ++ Removed "init" event and corresponding "oninit" configuration attribute + from YAHOO.widget.Button and YAHOO.widget.ButtonGroup. + ++ Added the CSS class "ie6" to button.css. This classname is append to root + DOM element of Button instances created with IE 6. By default this class + is used to apply a filter that gives alpha transparency to a Button's + background PNG. + + + +*** Version 2.2.0 *** + +* Button Control introduced diff --git a/lib/yui/button/assets/background.png b/lib/yui/button/assets/background.png new file mode 100755 index 0000000000000000000000000000000000000000..32a72e491aadec4e177ea6dafc18eb0e596b0835 GIT binary patch literal 129 zcmeAS@N?(olHy`uVBq!ia0vp^j6iI}!3HGf{@&OHq&z%b978H@ZS6TI$Y999H22H> z%cg7C#5QQ<|d}62BjvZR2H60wE-$(3-AeXt*@{D|Np;u@pDC#5QQ<|d}62BjvZR2H60wE-$(3-AeX1=9cj|6h7@{#_u8sU*lR z_&>wb?FL>zp1h}vV@SoVq=W_rH;IGN~-|K;%i-0c73 z@c-iO|KRQa-|hd~QeFE1003M`L_t(|+U&?l5`sVg1i`WZK}Epr|6dhmytLs92=mel z9uoULP6;mwyM%qhIpHzkHQ|(SNO(*5TD8?y@wq9xG<+26t_AN^`$=39HtEMPCOjwP e%l`;(0R{kdKn;SADLBOd00006$Gh9E#3p9{H-P6S}q~camLV^=3&tj%#_Xa_x2_Xl57U&w-9pX85Q9;Im dv4Me^VIeE)+1pK9I)PdkJYD@<);T3K0RYcxInw|D literal 0 HcmV?d00001 diff --git a/lib/yui/button/assets/skins/sam/split-button-arrow-focus.png b/lib/yui/button/assets/skins/sam/split-button-arrow-focus.png new file mode 100755 index 0000000000000000000000000000000000000000..167d71eb721ba9b85c6601f9077d5c39faa4ebd2 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_Tx)0S05bpo|DSu#^)isf zToU9L{Qp10^;5h+0~ypkT^vIyZY3ooII;39W@>hC5M-JVa^Poyu7TYlo?{mkWE>b9 b7?>Frva+7N-L$0>sD;7P)z4*}Q$iB}D9ShR literal 0 HcmV?d00001 diff --git a/lib/yui/button/assets/skins/sam/split-button-arrow-hover.png b/lib/yui/button/assets/skins/sam/split-button-arrow-hover.png new file mode 100755 index 0000000000000000000000000000000000000000..167d71eb721ba9b85c6601f9077d5c39faa4ebd2 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_Tx)0S05bpo|DSu#^)isf zToU9L{Qp10^;5h+0~ypkT^vIyZY3ooII;39W@>hC5M-JVa^Poyu7TYlo?{mkWE>b9 b7?>Frva+7N-L$0>sD;7P)z4*}Q$iB}D9ShR literal 0 HcmV?d00001 diff --git a/lib/yui/button/assets/skins/sam/split-button-arrow.png b/lib/yui/button/assets/skins/sam/split-button-arrow.png new file mode 100755 index 0000000000000000000000000000000000000000..b33a93ff2dc2039bd24e4ea3b75ecf4bb3295f84 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoU!3-pmJXhxdDVB6cUq=RpYd5a=M;HP5k|nMY zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5XI0Jk_TpJo1fXx5@|JyBHuocK+ zE(!7r{{Nrh`YB$Zfeh-NE{-7;w~`VPoLG4lGc~(62r^9wIqgTe~DWM4f1sXSq literal 0 HcmV?d00001 diff --git a/lib/yui/button/assets/splitarrow.gif b/lib/yui/button/assets/splitarrow.gif new file mode 100755 index 0000000000000000000000000000000000000000..6d1ce65940cde97983279c08a144b48d9e8e4b89 GIT binary patch literal 145 zcmZ?wbhEHb6ksr7Sj50^^XARS$cXy-`t#?{fB5j>|Ns9CV4(Pug^_`Ql|cu@1F22A-3wdUSxVwHR<{`lNF$F-vEqUn2Y8&$0d-hKG>=h?8FBOG%?}?woIihl=FFK4V4(Pu1x)LJNRV0v<}i=o zJMUhd6kEPVY~7m5?>x^sWoFJ4vs!tbZ4>{Wz3(EXf1kPh_pR*oSZnUBCRWL(;*Za*b6hLhE}Fjgwo%oZ;N6E`f1cgu%fMg_0M=nV82|tP literal 0 HcmV?d00001 diff --git a/lib/yui/button/button-beta-debug.js b/lib/yui/button/button-beta-debug.js new file mode 100755 index 0000000000..c9dfa28cb7 --- /dev/null +++ b/lib/yui/button/button-beta-debug.js @@ -0,0 +1,4554 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/** +* @module button +* @description

The Button Control enables the creation of rich, graphical +* buttons that function like traditional HTML form buttons. Unlike +* tradition HTML form buttons, buttons created with the Button Control can have +* a label that is different from its value. With the inclusion of the optional +* Menu Control, the Button Control can also be +* used to create menu buttons and split buttons, controls that are not +* available natively in HTML. The Button Control can also be thought of as a +* way to create more visually engaging implementations of the browser's +* default radio-button and check-box controls.

+*

The Button Control supports the following types:

+*
+*
push
+*
Basic push button that can execute a user-specified command when +* pressed.
+*
link
+*
Navigates to a specified url when pressed.
+*
submit
+*
Submits the parent form when pressed.
+*
reset
+*
Resets the parent form when pressed.
+*
checkbox
+*
Maintains a "checked" state that can be toggled on and off.
+*
radio
+*
Maintains a "checked" state that can be toggled on and off. Use with +* the ButtonGroup class to create a set of controls that are mutually +* exclusive; checking one button in the set will uncheck all others in +* the group.
+*
menu
+*
When pressed will show/hide a menu.
+*
split
+*
Can execute a user-specified command or display a menu when pressed.
+*
+* @title Button +* @namespace YAHOO.widget +* @requires yahoo, dom, element, event +* @optional container, menu +* @beta +*/ + + +(function () { + + + /** + * The Button class creates a rich, graphical button. + * @param {String} p_oElement String specifying the id attribute of the + * <input>, <button>, + * <a>, or <span> element to + * be used to create the button. + * @param {HTMLInputElement| + * HTMLButtonElement|HTMLElement} p_oElement Object reference for the + * <input>, <button>, + * <a>, or <span> element to be + * used to create the button. + * @param {Object} p_oElement Object literal specifying a set of + * configuration attributes used to create the button. + * @param {Object} p_oAttributes Optional. Object literal specifying a set + * of configuration attributes used to create the button. + * @namespace YAHOO.widget + * @class Button + * @constructor + * @extends YAHOO.util.Element + */ + + + + // Shorthard for utilities + + var Dom = YAHOO.util.Dom, + Event = YAHOO.util.Event, + Lang = YAHOO.lang, + Overlay = YAHOO.widget.Overlay, + Menu = YAHOO.widget.Menu, + + + // Private member variables + + m_oButtons = {}, // Collection of all Button instances + m_oOverlayManager = null, // YAHOO.widget.OverlayManager instance + m_oSubmitTrigger = null, // The button that submitted the form + m_oFocusedButton = null; // The button that has focus + + + + // Private methods + + + + /** + * @method createInputElement + * @description Creates an <input> element of the + * specified type. + * @private + * @param {String} p_sType String specifying the type of + * <input> element to create. + * @param {String} p_sName String specifying the name of + * <input> element to create. + * @param {String} p_sValue String specifying the value of + * <input> element to create. + * @param {String} p_bChecked Boolean specifying if the + * <input> element is to be checked. + * @return {HTMLInputElement} + */ + function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) { + + var oInput, + sInput; + + if (Lang.isString(p_sType) && Lang.isString(p_sName)) { + + if (YAHOO.env.ua.ie) { + + /* + For IE it is necessary to create the element with the + "type," "name," "value," and "checked" properties set all + at once. + */ + + sInput = "<input> or <a>) that + * map to Button configuration attributes and sets them into a collection + * that is passed to the Button constructor. + * @private + * @param {HTMLInputElement|HTMLAnchorElement} p_oElement Object reference to the HTML + * element (either <input> or <span> + * ) used to create the button. + * @param {Object} p_oAttributes Object reference for the collection of + * configuration attributes used to create the button. + */ + function setAttributesFromSrcElement(p_oElement, p_oAttributes) { + + var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(), + me = this, + oAttribute, + oRootNode, + sText; + + + /** + * @method setAttributeFromDOMAttribute + * @description Gets the value of the specified DOM attribute and sets it + * into the collection of configuration attributes used to configure + * the button. + * @private + * @param {String} p_sAttribute String representing the name of the + * attribute to retrieve from the DOM element. + */ + function setAttributeFromDOMAttribute(p_sAttribute) { + + if ( !(p_sAttribute in p_oAttributes) ) { + + /* + Need to use "getAttributeNode" instead of "getAttribute" + because using "getAttribute," IE will return the innerText + of a <button> for the value attribute + rather than the value of the "value" attribute. + */ + + oAttribute = p_oElement.getAttributeNode(p_sAttribute); + + + if (oAttribute && ("value" in oAttribute)) { + + me.logger.log("Setting attribute \"" + p_sAttribute + + "\" using source element's attribute value of \"" + + oAttribute.value + "\""); + + p_oAttributes[p_sAttribute] = oAttribute.value; + + } + + } + + } + + + /** + * @method setFormElementProperties + * @description Gets the value of the attributes from the form element + * and sets them into the collection of configuration attributes used to + * configure the button. + * @private + */ + function setFormElementProperties() { + + setAttributeFromDOMAttribute("type"); + + if (p_oAttributes.type == "button") { + + p_oAttributes.type = "push"; + + } + + if ( !("disabled" in p_oAttributes) ) { + + p_oAttributes.disabled = p_oElement.disabled; + + } + + setAttributeFromDOMAttribute("name"); + setAttributeFromDOMAttribute("value"); + setAttributeFromDOMAttribute("title"); + + } + + + switch (sSrcElementNodeName) { + + case "A": + + p_oAttributes.type = "link"; + + setAttributeFromDOMAttribute("href"); + setAttributeFromDOMAttribute("target"); + + break; + + case "INPUT": + + setFormElementProperties(); + + if ( !("checked" in p_oAttributes) ) { + + p_oAttributes.checked = p_oElement.checked; + + } + + break; + + case "BUTTON": + + setFormElementProperties(); + + oRootNode = p_oElement.parentNode.parentNode; + + if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-checked")) { + + p_oAttributes.checked = true; + + } + + if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-disabled")) { + + p_oAttributes.disabled = true; + + } + + p_oElement.removeAttribute("value"); + + p_oElement.setAttribute("type", "button"); + + break; + + } + + p_oElement.removeAttribute("id"); + p_oElement.removeAttribute("name"); + + if ( !("tabindex" in p_oAttributes) ) { + + p_oAttributes.tabindex = p_oElement.tabIndex; + + } + + if ( !("label" in p_oAttributes) ) { + + // Set the "label" property + + sText = sSrcElementNodeName == "INPUT" ? + p_oElement.value : p_oElement.innerHTML; + + + if (sText && sText.length > 0) { + + p_oAttributes.label = sText; + + } + + } + + } + + + /** + * @method initConfig + * @description Initializes the set of configuration attributes that are + * used to instantiate the button. + * @private + * @param {Object} Object representing the button's set of + * configuration attributes. + */ + function initConfig(p_oConfig) { + + var oAttributes = p_oConfig.attributes, + oSrcElement = oAttributes.srcelement, + sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(), + me = this; + + + if (sSrcElementNodeName == this.NODE_NAME) { + + p_oConfig.element = oSrcElement; + p_oConfig.id = oSrcElement.id; + + Dom.getElementsBy(function (p_oElement) { + + switch (p_oElement.nodeName.toUpperCase()) { + + case "BUTTON": + case "A": + case "INPUT": + + setAttributesFromSrcElement.call(me, p_oElement, + oAttributes); + + break; + + } + + }, "*", oSrcElement); + + } + else { + + switch (sSrcElementNodeName) { + + case "BUTTON": + case "A": + case "INPUT": + + setAttributesFromSrcElement.call(this, oSrcElement, + oAttributes); + + break; + + } + + } + + } + + + + // Constructor + + YAHOO.widget.Button = function (p_oElement, p_oAttributes) { + + var fnSuperClass = YAHOO.widget.Button.superclass.constructor, + oConfig, + oElement; + + if (arguments.length == 1 && !Lang.isString(p_oElement) && + !p_oElement.nodeName) { + + if (!p_oElement.id) { + + p_oElement.id = Dom.generateId(); + + YAHOO.log("No value specified for the button's \"id\" " + + "attribute. Setting button id to \"" + p_oElement.id + + "\".", "warn"); + + } + + this.logger = new YAHOO.widget.LogWriter("Button " + p_oElement.id); + + this.logger.log("No source HTML element. Building the button " + + "using the set of configuration attributes."); + + fnSuperClass.call(this, + (this.createButtonElement(p_oElement.type)), + p_oElement); + + } + else { + + oConfig = { element: null, attributes: (p_oAttributes || {}) }; + + + if (Lang.isString(p_oElement)) { + + oElement = Dom.get(p_oElement); + + if (oElement) { + + if (!oConfig.attributes.id) { + + oConfig.attributes.id = p_oElement; + + } + + this.logger = new YAHOO.widget.LogWriter( + "Button " + oConfig.attributes.id); + + this.logger.log("Building the button using an existing " + + "HTML element as a source element."); + + + oConfig.attributes.srcelement = oElement; + + initConfig.call(this, oConfig); + + + if (!oConfig.element) { + + this.logger.log("Source element could not be used " + + "as is. Creating a new HTML element for " + + "the button."); + + oConfig.element = + this.createButtonElement(oConfig.attributes.type); + + } + + fnSuperClass.call(this, oConfig.element, + oConfig.attributes); + + } + + } + else if (p_oElement.nodeName) { + + if (!oConfig.attributes.id) { + + if (p_oElement.id) { + + oConfig.attributes.id = p_oElement.id; + + } + else { + + oConfig.attributes.id = Dom.generateId(); + + YAHOO.log("No value specified for the button's " + + "\"id\" attribute. Setting button id to \"" + + oConfig.attributes.id + "\".", "warn"); + + } + + } + + + this.logger = new YAHOO.widget.LogWriter( + "Button " + oConfig.attributes.id); + + this.logger.log("Building the button using an existing HTML " + + "element as a source element."); + + + oConfig.attributes.srcelement = p_oElement; + + initConfig.call(this, oConfig); + + + if (!oConfig.element) { + + this.logger.log("Source element could not be used as is." + + " Creating a new HTML element for the button."); + + oConfig.element = + this.createButtonElement(oConfig.attributes.type); + + } + + fnSuperClass.call(this, oConfig.element, oConfig.attributes); + + } + + } + + }; + + + + YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, { + + + // Protected properties + + + /** + * @property _button + * @description Object reference to the button's internal + * <a> or <button> element. + * @default null + * @protected + * @type HTMLAnchorElement|HTMLButtonElement + */ + _button: null, + + + /** + * @property _menu + * @description Object reference to the button's menu. + * @default null + * @protected + * @type {YAHOO.widget.Overlay| + * YAHOO.widget.Menu} + */ + _menu: null, + + + /** + * @property _hiddenFields + * @description Object reference to the <input> + * element, or array of HTML form elements used to represent the button + * when its parent form is submitted. + * @default null + * @protected + * @type HTMLInputElement|Array + */ + _hiddenFields: null, + + + /** + * @property _onclickAttributeValue + * @description Object reference to the button's current value for the + * "onclick" configuration attribute. + * @default null + * @protected + * @type Object + */ + _onclickAttributeValue: null, + + + /** + * @property _activationKeyPressed + * @description Boolean indicating if the key(s) that toggle the button's + * "active" state have been pressed. + * @default false + * @protected + * @type Boolean + */ + _activationKeyPressed: false, + + + /** + * @property _activationButtonPressed + * @description Boolean indicating if the mouse button that toggles + * the button's "active" state has been pressed. + * @default false + * @protected + * @type Boolean + */ + _activationButtonPressed: false, + + + /** + * @property _hasKeyEventHandlers + * @description Boolean indicating if the button's "blur", "keydown" and + * "keyup" event handlers are assigned + * @default false + * @protected + * @type Boolean + */ + _hasKeyEventHandlers: false, + + + /** + * @property _hasMouseEventHandlers + * @description Boolean indicating if the button's "mouseout," + * "mousedown," and "mouseup" event handlers are assigned + * @default false + * @protected + * @type Boolean + */ + _hasMouseEventHandlers: false, + + + + // Constants + + + /** + * @property NODE_NAME + * @description The name of the node to be used for the button's + * root element. + * @default "SPAN" + * @final + * @type String + */ + NODE_NAME: "SPAN", + + + /** + * @property CHECK_ACTIVATION_KEYS + * @description Array of numbers representing keys that (when pressed) + * toggle the button's "checked" attribute. + * @default [32] + * @final + * @type Array + */ + CHECK_ACTIVATION_KEYS: [32], + + + /** + * @property ACTIVATION_KEYS + * @description Array of numbers representing keys that (when presed) + * toggle the button's "active" state. + * @default [13, 32] + * @final + * @type Array + */ + ACTIVATION_KEYS: [13, 32], + + + /** + * @property OPTION_AREA_WIDTH + * @description Width (in pixels) of the area of a split button that + * when pressed will display a menu. + * @default 20 + * @final + * @type Number + */ + OPTION_AREA_WIDTH: 20, + + + /** + * @property CSS_CLASS_NAME + * @description String representing the CSS class(es) to be applied to + * the button's root element. + * @default "yui-button" + * @final + * @type String + */ + CSS_CLASS_NAME: "yui-button", + + + /** + * @property RADIO_DEFAULT_TITLE + * @description String representing the default title applied to buttons + * of type "radio." + * @default "Unchecked. Click to check." + * @final + * @type String + */ + RADIO_DEFAULT_TITLE: "Unchecked. Click to check.", + + + /** + * @property RADIO_CHECKED_TITLE + * @description String representing the title applied to buttons of + * type "radio" when checked. + * @default "Checked. Click to uncheck." + * @final + * @type String + */ + RADIO_CHECKED_TITLE: "Checked. Click to uncheck.", + + + /** + * @property CHECKBOX_DEFAULT_TITLE + * @description String representing the default title applied to + * buttons of type "checkbox." + * @default "Unchecked. Click to check." + * @final + * @type String + */ + CHECKBOX_DEFAULT_TITLE: "Unchecked. Click to check.", + + + /** + * @property CHECKBOX_CHECKED_TITLE + * @description String representing the title applied to buttons of type + * "checkbox" when checked. + * @default "Checked. Click to uncheck." + * @final + * @type String + */ + CHECKBOX_CHECKED_TITLE: "Checked. Click to uncheck.", + + + /** + * @property MENUBUTTON_DEFAULT_TITLE + * @description String representing the default title applied to + * buttons of type "menu." + * @default "Menu collapsed. Click to expand." + * @final + * @type String + */ + MENUBUTTON_DEFAULT_TITLE: "Menu collapsed. Click to expand.", + + + /** + * @property MENUBUTTON_MENU_VISIBLE_TITLE + * @description String representing the title applied to buttons of type + * "menu" when the button's menu is visible. + * @default "Menu expanded. Click or press Esc to collapse." + * @final + * @type String + */ + MENUBUTTON_MENU_VISIBLE_TITLE: + "Menu expanded. Click or press Esc to collapse.", + + + /** + * @property SPLITBUTTON_DEFAULT_TITLE + * @description String representing the default title applied to + * buttons of type "split." + * @default "Menu collapsed. Click inside option region or press + * Ctrl + Shift + M to show the menu." + * @final + * @type String + */ + SPLITBUTTON_DEFAULT_TITLE: ("Menu collapsed. Click inside option " + + "region or press Ctrl + Shift + M to show the menu."), + + + /** + * @property SPLITBUTTON_OPTION_VISIBLE_TITLE + * @description String representing the title applied to buttons of type + * "split" when the button's menu is visible. + * @default "Menu expanded. Press Esc or Ctrl + Shift + M to hide + * the menu." + * @final + * @type String + */ + SPLITBUTTON_OPTION_VISIBLE_TITLE: + "Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.", + + + /** + * @property SUBMIT_TITLE + * @description String representing the title applied to buttons of + * type "submit." + * @default "Click to submit form." + * @final + * @type String + */ + SUBMIT_TITLE: "Click to submit form.", + + + + // Protected attribute setter methods + + + /** + * @method _setType + * @description Sets the value of the button's "type" attribute. + * @protected + * @param {String} p_sType String indicating the value for the button's + * "type" attribute. + */ + _setType: function (p_sType) { + + if (p_sType == "split") { + + this.on("option", this._onOption); + + } + + }, + + + /** + * @method _setLabel + * @description Sets the value of the button's "label" attribute. + * @protected + * @param {String} p_sLabel String indicating the value for the button's + * "label" attribute. + */ + _setLabel: function (p_sLabel) { + + this._button.innerHTML = p_sLabel; + + }, + + + /** + * @method _setTabIndex + * @description Sets the value of the button's "tabindex" attribute. + * @protected + * @param {Number} p_nTabIndex Number indicating the value for the + * button's "tabindex" attribute. + */ + _setTabIndex: function (p_nTabIndex) { + + this._button.tabIndex = p_nTabIndex; + + }, + + + /** + * @method _setTitle + * @description Sets the value of the button's "title" attribute. + * @protected + * @param {String} p_nTabIndex Number indicating the value for + * the button's "title" attribute. + */ + _setTitle: function (p_sTitle) { + + var sTitle = p_sTitle; + + if (this.get("type") != "link") { + + if (!sTitle) { + + switch (this.get("type")) { + + case "radio": + + sTitle = this.RADIO_DEFAULT_TITLE; + + break; + + case "checkbox": + + sTitle = this.CHECKBOX_DEFAULT_TITLE; + + break; + + case "menu": + + sTitle = this.MENUBUTTON_DEFAULT_TITLE; + + break; + + case "split": + + sTitle = this.SPLITBUTTON_DEFAULT_TITLE; + + break; + + case "submit": + + sTitle = this.SUBMIT_TITLE; + + break; + + } + + } + + this._button.title = sTitle; + + } + + }, + + + /** + * @method _setDisabled + * @description Sets the value of the button's "disabled" attribute. + * @protected + * @param {Boolean} p_bDisabled Boolean indicating the value for + * the button's "disabled" attribute. + */ + _setDisabled: function (p_bDisabled) { + + if (this.get("type") != "link") { + + if (p_bDisabled) { + + if (this._menu) { + + this._menu.hide(); + + } + + if (this.hasFocus()) { + + this.blur(); + + } + + this._button.setAttribute("disabled", "disabled"); + + this.addStateCSSClasses("disabled"); + + } + else { + + this._button.removeAttribute("disabled"); + + this.removeStateCSSClasses("disabled"); + + } + + } + + }, + + + /** + * @method _setHref + * @description Sets the value of the button's "href" attribute. + * @protected + * @param {String} p_sHref String indicating the value for the button's + * "href" attribute. + */ + _setHref: function (p_sHref) { + + if (this.get("type") == "link") { + + this._button.href = p_sHref; + + } + + }, + + + /** + * @method _setTarget + * @description Sets the value of the button's "target" attribute. + * @protected + * @param {String} p_sTarget String indicating the value for the button's + * "target" attribute. + */ + _setTarget: function (p_sTarget) { + + if (this.get("type") == "link") { + + this._button.setAttribute("target", p_sTarget); + + } + + }, + + + /** + * @method _setChecked + * @description Sets the value of the button's "target" attribute. + * @protected + * @param {Boolean} p_bChecked Boolean indicating the value for + * the button's "checked" attribute. + */ + _setChecked: function (p_bChecked) { + + var sType = this.get("type"), + sTitle; + + if (sType == "checkbox" || sType == "radio") { + + if (p_bChecked) { + + this.addStateCSSClasses("checked"); + + sTitle = (sType == "radio") ? + this.RADIO_CHECKED_TITLE : + this.CHECKBOX_CHECKED_TITLE; + + } + else { + + this.removeStateCSSClasses("checked"); + + sTitle = (sType == "radio") ? + this.RADIO_DEFAULT_TITLE : + this.CHECKBOX_DEFAULT_TITLE; + + } + + this.set("title", sTitle); + + } + + }, + + + /** + * @method _setMenu + * @description Sets the value of the button's "menu" attribute. + * @protected + * @param {Object} p_oMenu Object indicating the value for the button's + * "menu" attribute. + */ + _setMenu: function (p_oMenu) { + + var bLazyLoad = this.get("lazyloadmenu"), + oButtonElement = this.get("element"), + + /* + Boolean indicating if the value of p_oMenu is an instance + of YAHOO.widget.Menu or YAHOO.widget.Overlay. + */ + + bInstance = false, + + + oMenu, + oMenuElement, + oSrcElement, + aItems, + nItems, + oItem, + i; + + + if (!Overlay) { + + this.logger.log("YAHOO.widget.Overlay dependency not met.", + "error"); + + return false; + + } + + + if (!Menu) { + + this.logger.log("YAHOO.widget.Menu dependency not met.", + "error"); + + return false; + + } + + + function onAppendTo() { + + oMenu.render(oButtonElement.parentNode); + + this.removeListener("appendTo", onAppendTo); + + } + + + function initMenu() { + + if (oMenu) { + + Dom.addClass(oMenu.element, this.get("menuclassname")); + Dom.addClass(oMenu.element, + "yui-" + this.get("type") + "-button-menu"); + + oMenu.showEvent.subscribe(this._onMenuShow, null, this); + oMenu.hideEvent.subscribe(this._onMenuHide, null, this); + oMenu.renderEvent.subscribe(this._onMenuRender, null, this); + + + if (oMenu instanceof Menu) { + + oMenu.keyDownEvent.subscribe(this._onMenuKeyDown, + this, true); + + oMenu.clickEvent.subscribe(this._onMenuClick, + this, true); + + oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded, + this, true); + + oSrcElement = oMenu.srcElement; + + if (oSrcElement && + oSrcElement.nodeName.toUpperCase() == "SELECT") { + + oSrcElement.style.display = "none"; + oSrcElement.parentNode.removeChild(oSrcElement); + + } + + } + else if (oMenu instanceof Overlay) { + + if (!m_oOverlayManager) { + + m_oOverlayManager = + new YAHOO.widget.OverlayManager(); + + } + + m_oOverlayManager.register(oMenu); + + } + + + this._menu = oMenu; + + + if (!bInstance) { + + if (bLazyLoad && !(oMenu instanceof Menu)) { + + /* + Mimic Menu's "lazyload" functionality by adding + a "beforeshow" event listener that renders the + Overlay instance before it is made visible by + the button. + */ + + oMenu.beforeShowEvent.subscribe( + this._onOverlayBeforeShow, null, this); + + } + else if (!bLazyLoad) { + + if (Dom.inDocument(oButtonElement)) { + + oMenu.render(oButtonElement.parentNode); + + } + else { + + this.on("appendTo", onAppendTo); + + } + + } + + } + + } + + } + + + if (p_oMenu && (p_oMenu instanceof Menu)) { + + oMenu = p_oMenu; + aItems = oMenu.getItems(); + nItems = aItems.length; + bInstance = true; + + + if (nItems > 0) { + + i = nItems - 1; + + do { + + oItem = aItems[i]; + + if (oItem) { + + oItem.cfg.subscribeToConfigEvent("selected", + this._onMenuItemSelected, + oItem, + this); + + } + + } + while (i--); + + } + + initMenu.call(this); + + } + else if (p_oMenu && (p_oMenu instanceof Overlay)) { + + oMenu = p_oMenu; + bInstance = true; + + oMenu.cfg.setProperty("visible", false); + oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]); + + initMenu.call(this); + + } + else if (Lang.isArray(p_oMenu)) { + + this.on("appendTo", function () { + + oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad, + itemdata: p_oMenu }); + + initMenu.call(this); + + }); + + } + else if (Lang.isString(p_oMenu)) { + + oMenuElement = Dom.get(p_oMenu); + + if (oMenuElement) { + + if (Dom.hasClass(oMenuElement, + Menu.prototype.CSS_CLASS_NAME) || + oMenuElement.nodeName == "SELECT") { + + oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad }); + + initMenu.call(this); + + } + else { + + oMenu = new Overlay(p_oMenu, { visible: false, + context: [oButtonElement, "tl", "bl"] }); + + initMenu.call(this); + + } + + } + + } + else if (p_oMenu && p_oMenu.nodeName) { + + if (Dom.hasClass(p_oMenu, Menu.prototype.CSS_CLASS_NAME) || + p_oMenu.nodeName == "SELECT") { + + oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad }); + + initMenu.call(this); + + } + else { + + if (!p_oMenu.id) { + + Dom.generateId(p_oMenu); + + } + + oMenu = new Overlay(p_oMenu, { visible: false, + context: [oButtonElement, "tl", "bl"] }); + + initMenu.call(this); + + } + + } + + }, + + + /** + * @method _setOnClick + * @description Sets the value of the button's "onclick" attribute. + * @protected + * @param {Object} p_oObject Object indicating the value for the button's + * "onclick" attribute. + */ + _setOnClick: function (p_oObject) { + + /* + Remove any existing listeners if a "click" event handler + has already been specified. + */ + + if (this._onclickAttributeValue && + (this._onclickAttributeValue != p_oObject)) { + + this.removeListener("click", this._onclickAttributeValue.fn); + + this._onclickAttributeValue = null; + + } + + + if (!this._onclickAttributeValue && + Lang.isObject(p_oObject) && + Lang.isFunction(p_oObject.fn)) { + + this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope); + + this._onclickAttributeValue = p_oObject; + + } + + }, + + + /** + * @method _setSelectedMenuItem + * @description Sets the value of the button's + * "selectedMenuItem" attribute. + * @protected + * @param {Number} p_nIndex Number representing the index of the item + * in the button's menu that is currently selected. + */ + _setSelectedMenuItem: function (p_nIndex) { + + var oMenu = this._menu, + oMenuItem; + + + if (oMenu && oMenu instanceof Menu) { + + oMenuItem = oMenu.getItem(p_nIndex); + + + if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) { + + oMenuItem.cfg.setProperty("selected", true); + + } + + } + + }, + + + // Protected methods + + + + /** + * @method _isActivationKey + * @description Determines if the specified keycode is one that toggles + * the button's "active" state. + * @protected + * @param {Number} p_nKeyCode Number representing the keycode to + * be evaluated. + * @return {Boolean} + */ + _isActivationKey: function (p_nKeyCode) { + + var sType = this.get("type"), + aKeyCodes = (sType == "checkbox" || sType == "radio") ? + this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS, + + nKeyCodes = aKeyCodes.length, + i; + + if (nKeyCodes > 0) { + + i = nKeyCodes - 1; + + do { + + if (p_nKeyCode == aKeyCodes[i]) { + + return true; + + } + + } + while (i--); + + } + + }, + + + /** + * @method _isSplitButtonOptionKey + * @description Determines if the specified keycode is one that toggles + * the display of the split button's menu. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + * @return {Boolean} + */ + _isSplitButtonOptionKey: function (p_oEvent) { + + return (p_oEvent.ctrlKey && p_oEvent.shiftKey && + Event.getCharCode(p_oEvent) == 77); + + }, + + + /** + * @method _addListenersToForm + * @description Adds event handlers to the button's form. + * @protected + */ + _addListenersToForm: function () { + + var oForm = this.getForm(), + oSrcElement, + aListeners, + nListeners, + i, + bHasKeyPressListener; + + + if (oForm) { + + Event.on(oForm, "reset", this._onFormReset, null, this); + Event.on(oForm, "submit", this.createHiddenFields, null, this); + + oSrcElement = this.get("srcelement"); + + + if (this.get("type") == "submit" || + (oSrcElement && oSrcElement.type == "submit")) + { + + aListeners = Event.getListeners(oForm, "keypress"); + bHasKeyPressListener = false; + + if (aListeners) { + + nListeners = aListeners.length; + + if (nListeners > 0) { + + i = nListeners - 1; + + do { + + if (aListeners[i].fn == + YAHOO.widget.Button.onFormKeyPress) + { + + bHasKeyPressListener = true; + break; + + } + + } + while (i--); + + } + + } + + + if (!bHasKeyPressListener) { + + Event.on(oForm, "keypress", + YAHOO.widget.Button.onFormKeyPress); + + } + + } + + } + + }, + + + _originalMaxHeight: -1, + + + /** + * @method _showMenu + * @description Shows the button's menu. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event) that triggered + * the display of the menu. + */ + _showMenu: function (p_oEvent) { + + YAHOO.widget.MenuManager.hideVisible(); + + if (m_oOverlayManager) { + + m_oOverlayManager.hideAll(); + + } + + + var oMenu = this._menu, + nViewportHeight = Dom.getViewportHeight(), + nMenuHeight, + nScrollTop, + nY; + + + if (oMenu && (oMenu instanceof Menu)) { + + oMenu.cfg.applyConfig({ context: [this.get("id"), "tl", "bl"], + constraintoviewport: false, + clicktohide: false, + visible: true }); + + oMenu.cfg.fireQueue(); + + oMenu.align("tl", "bl"); + + /* + Stop the propagation of the event so that the MenuManager + doesn't blur the menu after it gets focus. + */ + + if (p_oEvent.type == "mousedown") { + + Event.stopPropagation(p_oEvent); + + } + + + if (this.get("focusmenu")) { + + this._menu.focus(); + + } + + nMenuHeight = oMenu.element.offsetHeight; + + + if ((oMenu.cfg.getProperty("y") + nMenuHeight) > + nViewportHeight) { + + this.logger.log("Current menu position will place a " + + "portion, or the entire menu outside the boundary of " + + "the viewport. Repositioning the menu to stay " + + "inside the viewport."); + + oMenu.align("bl", "tl"); + + nY = oMenu.cfg.getProperty("y"); + + nScrollTop = Dom.getDocumentScrollTop(); + + + if (nScrollTop >= nY) { + + if (this._originalMaxHeight == -1) { + + this._originalMaxHeight = + oMenu.cfg.getProperty("maxheight"); + + } + + oMenu.cfg.setProperty("maxheight", + (nMenuHeight - ((nScrollTop - nY) + 20))); + + oMenu.align("bl", "tl"); + + } + + } + + } + else if (oMenu && (oMenu instanceof Overlay)) { + + oMenu.show(); + oMenu.align("tl", "bl"); + + nMenuHeight = oMenu.element.offsetHeight; + + + if ((oMenu.cfg.getProperty("y") + nMenuHeight) > + nViewportHeight) { + + this.logger.log("Current menu position will place a " + + "portion, or the entire menu outside the boundary of " + + "the viewport. Repositioning the menu to stay inside" + + " the viewport."); + + oMenu.align("bl", "tl"); + + } + + } + + }, + + + /** + * @method _hideMenu + * @description Hides the button's menu. + * @protected + */ + _hideMenu: function () { + + var oMenu = this._menu; + + if (oMenu) { + + oMenu.hide(); + + } + + }, + + + + + // Protected event handlers + + + /** + * @method _onMouseOver + * @description "mouseover" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onMouseOver: function (p_oEvent) { + + if (!this._hasMouseEventHandlers) { + + this.on("mouseout", this._onMouseOut); + this.on("mousedown", this._onMouseDown); + this.on("mouseup", this._onMouseUp); + + this._hasMouseEventHandlers = true; + + } + + this.addStateCSSClasses("hover"); + + if (this._activationButtonPressed) { + + this.addStateCSSClasses("active"); + + } + + + if (this._bOptionPressed) { + + this.addStateCSSClasses("activeoption"); + + } + + }, + + + /** + * @method _onMouseOut + * @description "mouseout" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onMouseOut: function (p_oEvent) { + + this.removeStateCSSClasses("hover"); + + if (this.get("type") != "menu") { + + this.removeStateCSSClasses("active"); + + } + + if (this._activationButtonPressed || this._bOptionPressed) { + + Event.on(document, "mouseup", this._onDocumentMouseUp, + null, this); + + } + + }, + + + /** + * @method _onDocumentMouseUp + * @description "mouseup" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onDocumentMouseUp: function (p_oEvent) { + + this._activationButtonPressed = false; + this._bOptionPressed = false; + + var sType = this.get("type"); + + if (sType == "menu" || sType == "split") { + + this.removeStateCSSClasses( + (sType == "menu" ? "active" : "activeoption")); + + this._hideMenu(); + + } + + Event.removeListener(document, "mouseup", this._onDocumentMouseUp); + + }, + + + /** + * @method _onMouseDown + * @description "mousedown" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onMouseDown: function (p_oEvent) { + + var sType, + oElement, + nX, + me; + + + function onMouseUp() { + + this._hideMenu(); + this.removeListener("mouseup", onMouseUp); + + } + + + if ((p_oEvent.which || p_oEvent.button) == 1) { + + + if (!this.hasFocus()) { + + this.focus(); + + } + + + sType = this.get("type"); + + + if (sType == "split") { + + oElement = this.get("element"); + nX = Event.getPageX(p_oEvent) - Dom.getX(oElement); + + if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) { + + this.fireEvent("option", p_oEvent); + + } + else { + + this.addStateCSSClasses("active"); + + this._activationButtonPressed = true; + + } + + } + else if (sType == "menu") { + + if (this.isActive()) { + + this._hideMenu(); + + this._activationButtonPressed = false; + + } + else { + + this._showMenu(p_oEvent); + + this._activationButtonPressed = true; + + } + + } + else { + + this.addStateCSSClasses("active"); + + this._activationButtonPressed = true; + + } + + + + if (sType == "split" || sType == "menu") { + + me = this; + + this._hideMenuTimerId = window.setTimeout(function () { + + me.on("mouseup", onMouseUp); + + }, 250); + + } + + } + + }, + + + /** + * @method _onMouseUp + * @description "mouseup" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onMouseUp: function (p_oEvent) { + + var sType = this.get("type"); + + + if (this._hideMenuTimerId) { + + window.clearTimeout(this._hideMenuTimerId); + + } + + + if (sType == "checkbox" || sType == "radio") { + + this.set("checked", !(this.get("checked"))); + + } + + + this._activationButtonPressed = false; + + + if (this.get("type") != "menu") { + + this.removeStateCSSClasses("active"); + + } + + }, + + + /** + * @method _onFocus + * @description "focus" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onFocus: function (p_oEvent) { + + var oElement; + + this.addStateCSSClasses("focus"); + + if (this._activationKeyPressed) { + + this.addStateCSSClasses("active"); + + } + + m_oFocusedButton = this; + + + if (!this._hasKeyEventHandlers) { + + oElement = this._button; + + Event.on(oElement, "blur", this._onBlur, null, this); + Event.on(oElement, "keydown", this._onKeyDown, null, this); + Event.on(oElement, "keyup", this._onKeyUp, null, this); + + this._hasKeyEventHandlers = true; + + } + + + this.fireEvent("focus", p_oEvent); + + }, + + + /** + * @method _onBlur + * @description "blur" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onBlur: function (p_oEvent) { + + this.removeStateCSSClasses("focus"); + + if (this.get("type") != "menu") { + + this.removeStateCSSClasses("active"); + + } + + if (this._activationKeyPressed) { + + Event.on(document, "keyup", this._onDocumentKeyUp, null, this); + + } + + + m_oFocusedButton = null; + + this.fireEvent("blur", p_oEvent); + + }, + + + /** + * @method _onDocumentKeyUp + * @description "keyup" event handler for the document. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onDocumentKeyUp: function (p_oEvent) { + + if (this._isActivationKey(Event.getCharCode(p_oEvent))) { + + this._activationKeyPressed = false; + + Event.removeListener(document, "keyup", this._onDocumentKeyUp); + + } + + }, + + + /** + * @method _onKeyDown + * @description "keydown" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onKeyDown: function (p_oEvent) { + + var oMenu = this._menu; + + + if (this.get("type") == "split" && + this._isSplitButtonOptionKey(p_oEvent)) { + + this.fireEvent("option", p_oEvent); + + } + else if (this._isActivationKey(Event.getCharCode(p_oEvent))) { + + if (this.get("type") == "menu") { + + this._showMenu(p_oEvent); + + } + else { + + this._activationKeyPressed = true; + + this.addStateCSSClasses("active"); + + } + + } + + + if (oMenu && oMenu.cfg.getProperty("visible") && + Event.getCharCode(p_oEvent) == 27) { + + oMenu.hide(); + this.focus(); + + } + + }, + + + /** + * @method _onKeyUp + * @description "keyup" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onKeyUp: function (p_oEvent) { + + var sType; + + if (this._isActivationKey(Event.getCharCode(p_oEvent))) { + + sType = this.get("type"); + + if (sType == "checkbox" || sType == "radio") { + + this.set("checked", !(this.get("checked"))); + + } + + this._activationKeyPressed = false; + + if (this.get("type") != "menu") { + + this.removeStateCSSClasses("active"); + + } + + } + + }, + + + /** + * @method _onClick + * @description "click" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onClick: function (p_oEvent) { + + var sType = this.get("type"), + sTitle, + oForm, + oSrcElement, + oElement, + nX; + + + switch (sType) { + + case "radio": + case "checkbox": + + if (this.get("checked")) { + + sTitle = (sType == "radio") ? + this.RADIO_CHECKED_TITLE : + this.CHECKBOX_CHECKED_TITLE; + + } + else { + + sTitle = (sType == "radio") ? + this.RADIO_DEFAULT_TITLE : + this.CHECKBOX_DEFAULT_TITLE; + + } + + this.set("title", sTitle); + + break; + + case "submit": + + this.submitForm(); + + break; + + case "reset": + + oForm = this.getForm(); + + if (oForm) { + + oForm.reset(); + + } + + break; + + case "menu": + + sTitle = this._menu.cfg.getProperty("visible") ? + this.MENUBUTTON_MENU_VISIBLE_TITLE : + this.MENUBUTTON_DEFAULT_TITLE; + + this.set("title", sTitle); + + break; + + case "split": + + oElement = this.get("element"); + nX = Event.getPageX(p_oEvent) - Dom.getX(oElement); + + if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) { + + return false; + + } + else { + + this._hideMenu(); + + oSrcElement = this.get("srcelement"); + + if (oSrcElement && oSrcElement.type == "submit") { + + this.submitForm(); + + } + + } + + sTitle = this._menu.cfg.getProperty("visible") ? + this.SPLITBUTTON_OPTION_VISIBLE_TITLE : + this.SPLITBUTTON_DEFAULT_TITLE; + + this.set("title", sTitle); + + break; + + } + + }, + + + /** + * @method _onAppendTo + * @description "appendTo" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onAppendTo: function (p_oEvent) { + + /* + It is necessary to call "getForm" using "setTimeout" to make + sure that the button's "form" property returns a node + reference. Sometimes, if you try to get the reference + immediately after appending the field, it is null. + */ + + var me = this; + + window.setTimeout(function () { + + me._addListenersToForm(); + + }, 0); + + }, + + + /** + * @method _onFormReset + * @description "reset" event handler for the button's form. + * @protected + * @param {Event} p_oEvent Object representing the DOM event + * object passed back by the event utility (YAHOO.util.Event). + */ + _onFormReset: function (p_oEvent) { + + var sType = this.get("type"), + oMenu = this._menu; + + if (sType == "checkbox" || sType == "radio") { + + this.resetValue("checked"); + + } + + + if (oMenu && (oMenu instanceof Menu)) { + + this.resetValue("selectedMenuItem"); + + } + + }, + + + /** + * @method _onDocumentMouseDown + * @description "mousedown" event handler for the document. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onDocumentMouseDown: function (p_oEvent) { + + var oTarget = Event.getTarget(p_oEvent), + oButtonElement = this.get("element"), + oMenuElement = this._menu.element; + + if (oTarget != oButtonElement && + !Dom.isAncestor(oButtonElement, oTarget) && + oTarget != oMenuElement && + !Dom.isAncestor(oMenuElement, oTarget)) { + + this._hideMenu(); + + Event.removeListener(document, "mousedown", + this._onDocumentMouseDown); + + } + + }, + + + /** + * @method _onOption + * @description "option" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onOption: function (p_oEvent) { + + if (this.hasClass("yui-split-button-activeoption")) { + + this._hideMenu(); + + this._bOptionPressed = false; + + } + else { + + this._showMenu(p_oEvent); + + this._bOptionPressed = true; + + } + + }, + + + /** + * @method _onOverlayBeforeShow + * @description "beforeshow" event handler for the + * YAHOO.widget.Overlay instance + * serving as the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + */ + _onOverlayBeforeShow: function (p_sType) { + + var oMenu = this._menu; + + oMenu.render(this.get("element").parentNode); + + oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow); + + }, + + + /** + * @method _onMenuShow + * @description "show" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + */ + _onMenuShow: function (p_sType) { + + Event.on(document, "mousedown", this._onDocumentMouseDown, + null, this); + + var sTitle, + sState; + + if (this.get("type") == "split") { + + sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE; + sState = "activeoption"; + + } + else { + + sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE; + sState = "active"; + + } + + this.addStateCSSClasses(sState); + this.set("title", sTitle); + + }, + + + /** + * @method _onMenuHide + * @description "hide" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + */ + _onMenuHide: function (p_sType) { + + var oMenu = this._menu, + sTitle, + sState; + + if (oMenu && (oMenu instanceof Menu) && + this._originalMaxHeight != -1) { + + this._menu.cfg.setProperty("maxheight", + this._originalMaxHeight); + + } + + + if (this.get("type") == "split") { + + sTitle = this.SPLITBUTTON_DEFAULT_TITLE; + sState = "activeoption"; + + } + else { + + sTitle = this.MENUBUTTON_DEFAULT_TITLE; + sState = "active"; + } + + + this.removeStateCSSClasses(sState); + this.set("title", sTitle); + + + if (this.get("type") == "split") { + + this._bOptionPressed = false; + + } + + }, + + + /** + * @method _onMenuKeyDown + * @description "keydown" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + * @param {Array} p_aArgs Array of arguments sent when the event + * was fired. + */ + _onMenuKeyDown: function (p_sType, p_aArgs) { + + var oEvent = p_aArgs[0]; + + if (Event.getCharCode(oEvent) == 27) { + + this.focus(); + + if (this.get("type") == "split") { + + this._bOptionPressed = false; + + } + + } + + }, + + + /** + * @method _onMenuRender + * @description "render" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the + * event thatwas fired. + */ + _onMenuRender: function (p_sType) { + + var oButtonElement = this.get("element"), + oButtonParent = oButtonElement.parentNode, + oMenuElement = this._menu.element; + + + if (oButtonParent != oMenuElement.parentNode) { + + oButtonParent.appendChild(oMenuElement); + + } + + this.set("selectedMenuItem", this.get("selectedMenuItem")); + + }, + + + /** + * @method _onMenuItemSelected + * @description "selectedchange" event handler for each item in the + * button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + * @param {Array} p_aArgs Array of arguments sent when the event + * was fired. + * @param {Number} p_nItem Number representing the index of the menu + * item that subscribed to the event. + */ + _onMenuItemSelected: function (p_sType, p_aArgs, p_nItem) { + + var bSelected = p_aArgs[0]; + + if (bSelected) { + + this.set("selectedMenuItem", p_nItem); + + } + + }, + + + /** + * @method _onMenuItemAdded + * @description "itemadded" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + * @param {Array} p_aArgs Array of arguments sent when the event + * was fired. + * @param { + * YAHOO.widget.MenuItem} p_oItem Object representing the menu + * item that subscribed to the event. + */ + _onMenuItemAdded: function (p_sType, p_aArgs, p_oItem) { + + var oItem = p_aArgs[0]; + + oItem.cfg.subscribeToConfigEvent("selected", + this._onMenuItemSelected, + oItem.index, + this); + + }, + + + /** + * @method _onMenuClick + * @description "click" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + * @param {Array} p_aArgs Array of arguments sent when the event + * was fired. + */ + _onMenuClick: function (p_sType, p_aArgs) { + + var oItem = p_aArgs[1], + oSrcElement; + + if (oItem) { + + oSrcElement = this.get("srcelement"); + + if (oSrcElement && oSrcElement.type == "submit") { + + this.submitForm(); + + } + + this._hideMenu(); + + } + + }, + + + + // Public methods + + + /** + * @method createButtonElement + * @description Creates the button's HTML elements. + * @param {String} p_sType String indicating the type of element + * to create. + * @return {HTMLElement} + */ + createButtonElement: function (p_sType) { + + var sNodeName = this.NODE_NAME, + oElement = document.createElement(sNodeName); + + oElement.innerHTML = "<" + sNodeName + " class=\"first-child\">" + + (p_sType == "link" ? "" : + "") + ""; + + return oElement; + + }, + + + /** + * @method addStateCSSClasses + * @description Appends state-specific CSS classes to the button's root + * DOM element. + */ + addStateCSSClasses: function (p_sState) { + + var sType = this.get("type"); + + if (Lang.isString(p_sState)) { + + if (p_sState != "activeoption") { + + this.addClass(this.CSS_CLASS_NAME + ("-" + p_sState)); + + } + + this.addClass("yui-" + sType + ("-button-" + p_sState)); + + } + + }, + + + /** + * @method removeStateCSSClasses + * @description Removes state-specific CSS classes to the button's root + * DOM element. + */ + removeStateCSSClasses: function (p_sState) { + + var sType = this.get("type"); + + if (Lang.isString(p_sState)) { + + this.removeClass(this.CSS_CLASS_NAME + ("-" + p_sState)); + this.removeClass("yui-" + sType + ("-button-" + p_sState)); + + } + + }, + + + /** + * @method createHiddenFields + * @description Creates the button's hidden form field and appends it + * to its parent form. + * @return {HTMLInputElement|Array} + */ + createHiddenFields: function () { + + this.removeHiddenFields(); + + var oForm = this.getForm(), + oButtonField, + sType, + bCheckable, + oMenu, + oMenuItem, + sName, + oValue, + oMenuField; + + + if (oForm && !this.get("disabled")) { + + sType = this.get("type"); + bCheckable = (sType == "checkbox" || sType == "radio"); + + + if (bCheckable || (m_oSubmitTrigger == this)) { + + this.logger.log("Creating hidden field."); + + oButtonField = createInputElement( + (bCheckable ? sType : "hidden"), + this.get("name"), + this.get("value"), + this.get("checked")); + + + if (oButtonField) { + + if (bCheckable) { + + oButtonField.style.display = "none"; + + } + + oForm.appendChild(oButtonField); + + } + + } + + + oMenu = this._menu; + + + if (oMenu && (oMenu instanceof Menu)) { + + this.logger.log("Creating hidden field for menu."); + + oMenuField = oMenu.srcElement; + oMenuItem = oMenu.getItem(this.get("selectedMenuItem")); + + if (oMenuField && + oMenuField.nodeName.toUpperCase() == "SELECT") { + + oForm.appendChild(oMenuField); + oMenuField.selectedIndex = oMenuItem.index; + + } + else { + + oValue = (oMenuItem.value === null || + oMenuItem.value === "") ? + oMenuItem.cfg.getProperty("text") : + oMenuItem.value; + + sName = this.get("name"); + + if (oValue && sName) { + + oMenuField = createInputElement("hidden", + (sName + "_options"), + oValue); + + oForm.appendChild(oMenuField); + + } + + } + + } + + + if (oButtonField && oMenuField) { + + this._hiddenFields = [oButtonField, oMenuField]; + + } + else if (!oButtonField && oMenuField) { + + this._hiddenFields = oMenuField; + + } + else if (oButtonField && !oMenuField) { + + this._hiddenFields = oButtonField; + + } + + + return this._hiddenFields; + + } + + }, + + + /** + * @method removeHiddenFields + * @description Removes the button's hidden form field(s) from its + * parent form. + */ + removeHiddenFields: function () { + + var oField = this._hiddenFields, + nFields, + i; + + function removeChild(p_oElement) { + + if (Dom.inDocument(p_oElement)) { + + p_oElement.parentNode.removeChild(p_oElement); + + } + + } + + + if (oField) { + + if (Lang.isArray(oField)) { + + nFields = oField.length; + + if (nFields > 0) { + + i = nFields - 1; + + do { + + removeChild(oField[i]); + + } + while (i--); + + } + + } + else { + + removeChild(oField); + + } + + this._hiddenFields = null; + + } + + }, + + + /** + * @method submitForm + * @description Submits the form to which the button belongs. Returns + * true if the form was submitted successfully, false if the submission + * was cancelled. + * @protected + * @return {Boolean} + */ + submitForm: function () { + + var oForm = this.getForm(), + + oSrcElement = this.get("srcelement"), + + /* + Boolean indicating if the event fired successfully + (was not cancelled by any handlers) + */ + + bSubmitForm = false, + + oEvent; + + + if (oForm) { + + if (this.get("type") == "submit" || + (oSrcElement && oSrcElement.type == "submit")) + { + + m_oSubmitTrigger = this; + + } + + + if (YAHOO.env.ua.ie) { + + bSubmitForm = oForm.fireEvent("onsubmit"); + + } + else { // Gecko, Opera, and Safari + + oEvent = document.createEvent("HTMLEvents"); + oEvent.initEvent("submit", true, true); + + bSubmitForm = oForm.dispatchEvent(oEvent); + + } + + + /* + In IE and Safari, dispatching a "submit" event to a form + WILL cause the form's "submit" event to fire, but WILL NOT + submit the form. Therefore, we need to call the "submit" + method as well. + */ + + if ((YAHOO.env.ua.ie || YAHOO.env.ua.webkit) && bSubmitForm) { + + oForm.submit(); + + } + + } + + return bSubmitForm; + + }, + + + /** + * @method init + * @description The Button class's initialization method. + * @param {String} p_oElement String specifying the id attribute of the + * <input>, <button>, + * <a>, or <span> element to + * be used to create the button. + * @param {HTMLInputElement|HTMLButtonElement| + * HTMLElement} p_oElement Object reference for the + * <input>, <button>, + * <a>, or <span> element to be + * used to create the button. + * @param {Object} p_oElement Object literal specifying a set of + * configuration attributes used to create the button. + * @param {Object} p_oAttributes Optional. Object literal specifying a + * set of configuration attributes used to create the button. + */ + init: function (p_oElement, p_oAttributes) { + + var sNodeName = p_oAttributes.type == "link" ? "A" : "BUTTON", + oSrcElement = p_oAttributes.srcelement, + oButton = p_oElement.getElementsByTagName(sNodeName)[0], + oInput; + + + if (!oButton) { + + oInput = p_oElement.getElementsByTagName("INPUT")[0]; + + + if (oInput) { + + oButton = document.createElement("BUTTON"); + oButton.setAttribute("type", "button"); + + oInput.parentNode.replaceChild(oButton, oInput); + + } + + } + + this._button = oButton; + + + YAHOO.widget.Button.superclass.init.call(this, p_oElement, + p_oAttributes); + + + m_oButtons[this.get("id")] = this; + + + this.addClass(this.CSS_CLASS_NAME); + + this.addClass("yui-" + this.get("type") + "-button"); + + Event.on(this._button, "focus", this._onFocus, null, this); + this.on("mouseover", this._onMouseOver); + this.on("click", this._onClick); + this.on("appendTo", this._onAppendTo); + + + var oContainer = this.get("container"), + oElement = this.get("element"), + bElInDoc = Dom.inDocument(oElement), + oParentNode; + + + if (oContainer) { + + if (oSrcElement && oSrcElement != oElement) { + + oParentNode = oSrcElement.parentNode; + + if (oParentNode) { + + oParentNode.removeChild(oSrcElement); + + } + + } + + if (Lang.isString(oContainer)) { + + Event.onContentReady(oContainer, function () { + + this.appendTo(oContainer); + + }, null, this); + + } + else { + + this.appendTo(oContainer); + + } + + } + else if (!bElInDoc && oSrcElement && oSrcElement != oElement) { + + oParentNode = oSrcElement.parentNode; + + if (oParentNode) { + + this.fireEvent("beforeAppendTo", { + type: "beforeAppendTo", + target: oParentNode + }); + + oParentNode.replaceChild(oElement, oSrcElement); + + this.fireEvent("appendTo", { + type: "appendTo", + target: oParentNode + }); + + } + + } + else if (this.get("type") != "link" && bElInDoc && oSrcElement && + oSrcElement == oElement) { + + this._addListenersToForm(); + + } + + this.logger.log("Initialization completed."); + + }, + + + /** + * @method initAttributes + * @description Initializes all of the configuration attributes used to + * create the button. + * @param {Object} p_oAttributes Object literal specifying a set of + * configuration attributes used to create the button. + */ + initAttributes: function (p_oAttributes) { + + var oAttributes = p_oAttributes || {}; + + YAHOO.widget.Button.superclass.initAttributes.call(this, + oAttributes); + + + /** + * @config type + * @description String specifying the button's type. Possible + * values are: "push," "link," "submit," "reset," "checkbox," + * "radio," "menu," and "split." + * @default "push" + * @type String + */ + this.setAttributeConfig("type", { + + value: (oAttributes.type || "push"), + validator: Lang.isString, + writeOnce: true, + method: this._setType + + }); + + + /** + * @config label + * @description String specifying the button's text label + * or innerHTML. + * @default null + * @type String + */ + this.setAttributeConfig("label", { + + value: oAttributes.label, + validator: Lang.isString, + method: this._setLabel + + }); + + + /** + * @config value + * @description Object specifying the value for the button. + * @default null + * @type Object + */ + this.setAttributeConfig("value", { + + value: oAttributes.value + + }); + + + /** + * @config name + * @description String specifying the name for the button. + * @default null + * @type String + */ + this.setAttributeConfig("name", { + + value: oAttributes.name, + validator: Lang.isString + + }); + + + /** + * @config tabindex + * @description Number specifying the tabindex for the button. + * @default null + * @type Number + */ + this.setAttributeConfig("tabindex", { + + value: oAttributes.tabindex, + validator: Lang.isNumber, + method: this._setTabIndex + + }); + + + /** + * @config title + * @description String specifying the title for the button. + * @default null + * @type String + */ + this.configureAttribute("title", { + + value: oAttributes.title, + validator: Lang.isString, + method: this._setTitle + + }); + + + /** + * @config disabled + * @description Boolean indicating if the button should be disabled. + * (Disabled buttons are dimmed and will not respond to user input + * or fire events. Does not apply to button's of type "link.") + * @default false + * @type Boolean + */ + this.setAttributeConfig("disabled", { + + value: (oAttributes.disabled || false), + validator: Lang.isBoolean, + method: this._setDisabled + + }); + + + /** + * @config href + * @description String specifying the href for the button. Applies + * only to buttons of type "link." + * @type String + */ + this.setAttributeConfig("href", { + + value: oAttributes.href, + validator: Lang.isString, + method: this._setHref + + }); + + + /** + * @config target + * @description String specifying the target for the button. + * Applies only to buttons of type "link." + * @type String + */ + this.setAttributeConfig("target", { + + value: oAttributes.target, + validator: Lang.isString, + method: this._setTarget + + }); + + + /** + * @config checked + * @description Boolean indicating if the button is checked. + * Applies only to buttons of type "radio" and "checkbox." + * @default false + * @type Boolean + */ + this.setAttributeConfig("checked", { + + value: (oAttributes.checked || false), + validator: Lang.isBoolean, + method: this._setChecked + + }); + + + /** + * @config container + * @description HTML element reference or string specifying the id + * attribute of the HTML element that the button's markup should be + * rendered into. + * @type HTMLElement|String + * @default null + */ + this.setAttributeConfig("container", { + + value: oAttributes.container, + writeOnce: true + + }); + + + /** + * @config srcelement + * @description Object reference to the HTML element (either + * <input> or <span>) + * used to create the button. + * @type HTMLElement|String + * @default null + */ + this.setAttributeConfig("srcelement", { + + value: oAttributes.srcelement, + writeOnce: true + + }); + + + /** + * @config menu + * @description Object specifying the menu for the button. + * The value can be one of the following: + *
    + *
  • Object specifying a + * YAHOO.widget.Menu instance.
  • + *
  • Object specifying a + * YAHOO.widget.Overlay instance.
  • + *
  • String specifying the id attribute of the <div> + * element used to create the menu. By default the menu + * will be created as an instance of + * YAHOO.widget.Overlay. + * If the + * default CSS class name for YAHOO.widget.Menu is applied to + * the <div> element, it will be created as an + * instance of YAHOO.widget.Menu + * .
  • String specifying the id attribute of the + * <select> element used to create the menu. + *
  • Object specifying the <div> element + * used to create the menu.
  • + *
  • Object specifying the <select> element + * used to create the menu.
  • + *
  • Array of object literals, each representing a set of + * YAHOO.widget.MenuItem + * configuration attributes.
  • + *
  • Array of strings representing the text labels for each menu + * item in the menu.
  • + *
+ * @type YAHOO.widget.Menu|YAHOO.widget.Overlay|HTMLElement|String|Array + * @default null + */ + this.setAttributeConfig("menu", { + + value: null, + method: this._setMenu, + writeOnce: true + + }); + + + /** + * @config lazyloadmenu + * @description Boolean indicating the value to set for the + * "lazyload" + * configuration property of the button's menu. Setting + * "lazyloadmenu" to true will defer rendering of + * the button's menu until the first time it is made visible. + * If "lazyloadmenu" is set to false, the button's + * menu will be rendered immediately if the button is in the + * document, or in response to the button's "appendTo" event if + * the button is not yet in the document. In either case, the + * menu is rendered into the button's parent HTML element. + * This attribute does not apply if a + * YAHOO.widget.Menu or + * YAHOO.widget.Overlay + * instance is passed as the value of the button's "menu" + * configuration attribute. + * YAHOO.widget.Menu or + * YAHOO.widget.Overlay instances should be rendered before + * being set as the value for the "menu" configuration + * attribute. + * @default true + * @type Boolean + */ + this.setAttributeConfig("lazyloadmenu", { + + value: (oAttributes.lazyloadmenu === false ? false : true), + validator: Lang.isBoolean, + writeOnce: true + + }); + + + /** + * @config menuclassname + * @description String representing the CSS class name to be + * applied to the root element of the button's menu. + * @type String + * @default "yui-button-menu" + */ + this.setAttributeConfig("menuclassname", { + + value: (oAttributes.menuclassname || "yui-button-menu"), + validator: Lang.isString, + method: this._setMenuClassName, + writeOnce: true + + }); + + + /** + * @config selectedMenuItem + * @description Number representing the index of the item in the + * button's menu that is currently selected. + * @type Number + * @default null + */ + this.setAttributeConfig("selectedMenuItem", { + + value: 0, + validator: Lang.isNumber, + method: this._setSelectedMenuItem + + }); + + + /** + * @config onclick + * @description Object literal representing the code to be executed + * when the button is clicked. Format:
{
+ * fn: Function, // The handler to call + * when the event fires.
obj: Object, + * // An object to pass back to the handler.
+ * scope: Object // The object to use + * for the scope of the handler.
}
+ * @type Object + * @default null + */ + this.setAttributeConfig("onclick", { + + value: oAttributes.onclick, + method: this._setOnClick + + }); + + + /** + * @config focusmenu + * @description Boolean indicating whether or not the button's menu + * should be focused when it is made visible. + * @type Boolean + * @default true + */ + this.setAttributeConfig("focusmenu", { + + value: (oAttributes.focusmenu === false ? false : true), + validator: Lang.isBoolean + + }); + + }, + + + /** + * @method focus + * @description Causes the button to receive the focus and fires the + * button's "focus" event. + */ + focus: function () { + + if (!this.get("disabled")) { + + this._button.focus(); + + } + + }, + + + /** + * @method blur + * @description Causes the button to lose focus and fires the button's + * "blur" event. + */ + blur: function () { + + if (!this.get("disabled")) { + + this._button.blur(); + + } + + }, + + + /** + * @method hasFocus + * @description Returns a boolean indicating whether or not the button + * has focus. + * @return {Boolean} + */ + hasFocus: function () { + + return (m_oFocusedButton == this); + + }, + + + /** + * @method isActive + * @description Returns a boolean indicating whether or not the button + * is active. + * @return {Boolean} + */ + isActive: function () { + + return this.hasClass(this.CSS_CLASS_NAME + "-active"); + + }, + + + /** + * @method getMenu + * @description Returns a reference to the button's menu. + * @return { + * YAHOO.widget.Overlay|YAHOO.widget.Menu} + */ + getMenu: function () { + + return this._menu; + + }, + + + /** + * @method getForm + * @description Returns a reference to the button's parent form. + * @return {HTMLFormElement} + */ + getForm: function () { + + return this._button.form; + + }, + + + /** + * @method getHiddenFields + * @description Returns an <input> element or + * array of form elements used to represent the button when its parent + * form is submitted. + * @return {HTMLInputElement|Array} + */ + getHiddenFields: function () { + + return this._hiddenFields; + + }, + + + /** + * @method destroy + * @description Removes the button's element from its parent element and + * removes all event handlers. + */ + destroy: function () { + + this.logger.log("Destroying ..."); + + var oElement = this.get("element"), + oParentNode = oElement.parentNode, + oMenu = this._menu; + + if (oMenu) { + + this.logger.log("Destroying menu."); + + oMenu.destroy(); + + } + + this.logger.log("Removing DOM event handlers."); + + Event.purgeElement(oElement); + Event.purgeElement(this._button); + Event.removeListener(document, "mouseup", this._onDocumentMouseUp); + Event.removeListener(document, "keyup", this._onDocumentKeyUp); + Event.removeListener(document, "mousedown", + this._onDocumentMouseDown); + + + var oForm = this.getForm(); + + if (oForm) { + + Event.removeListener(oForm, "reset", this._onFormReset); + Event.removeListener(oForm, "submit", this.createHiddenFields); + + } + + + oParentNode.removeChild(oElement); + + this.logger.log("Removing from document."); + + delete m_oButtons[this.get("id")]; + + this.logger.log("Destroyed."); + + }, + + + fireEvent: function (p_sType , p_aArgs) { + + // Disabled buttons should not respond to DOM events + + if (this.DOM_EVENTS[p_sType] && this.get("disabled")) { + + return; + + } + + YAHOO.widget.Button.superclass.fireEvent.call(this, p_sType, + p_aArgs); + + }, + + + /** + * @method toString + * @description Returns a string representing the button. + * @return {String} + */ + toString: function () { + + return ("Button " + this.get("id")); + + } + + }); + + + /** + * @method YAHOO.widget.Button.onFormKeyPress + * @description "keypress" event handler for the button's form. + * @param {Event} p_oEvent Object representing the DOM event object passed + * back by the event utility (YAHOO.util.Event). + */ + YAHOO.widget.Button.onFormKeyPress = function (p_oEvent) { + + var oTarget = Event.getTarget(p_oEvent), + nCharCode = Event.getCharCode(p_oEvent), + sNodeName = oTarget.nodeName && oTarget.nodeName.toUpperCase(), + sType = oTarget.type, + + /* + Boolean indicating if the form contains any enabled or + disabled YUI submit buttons + */ + + bFormContainsYUIButtons = false, + + oButton, + + oYUISubmitButton, // The form's first, enabled YUI submit button + + /* + The form's first, enabled HTML submit button that precedes any + YUI submit button + */ + + oPrecedingSubmitButton, + + + /* + The form's first, enabled HTML submit button that follows a + YUI button + */ + + oFollowingSubmitButton; + + + function isSubmitButton(p_oElement) { + + var sId, + oSrcElement; + + switch (p_oElement.nodeName.toUpperCase()) { + + case "INPUT": + case "BUTTON": + + if (p_oElement.type == "submit" && !p_oElement.disabled) { + + if (!bFormContainsYUIButtons && + !oPrecedingSubmitButton) { + + oPrecedingSubmitButton = p_oElement; + + } + + if (oYUISubmitButton && !oFollowingSubmitButton) { + + oFollowingSubmitButton = p_oElement; + + } + + } + + break; + + + default: + + sId = p_oElement.id; + + if (sId) { + + oButton = m_oButtons[sId]; + + if (oButton) { + + bFormContainsYUIButtons = true; + + if (!oButton.get("disabled")) { + + oSrcElement = oButton.get("srcelement"); + + if (!oYUISubmitButton && + (oButton.get("type") == "submit" || + (oSrcElement && oSrcElement.type == "submit"))) + { + + oYUISubmitButton = oButton; + + } + + } + + } + + } + + break; + + } + + } + + + if (nCharCode == 13 && ((sNodeName == "INPUT" && (sType == "text" || + sType == "password" || sType == "checkbox" || sType == "radio" || + sType == "file") ) || sNodeName == "SELECT")) + { + + Dom.getElementsBy(isSubmitButton, "*", this); + + + if (oPrecedingSubmitButton) { + + /* + Need to set focus to the first enabled submit button + to make sure that IE includes its name and value + in the form's data set. + */ + + oPrecedingSubmitButton.focus(); + + } + else if (!oPrecedingSubmitButton && oYUISubmitButton) { + + if (oFollowingSubmitButton) { + + /* + Need to call "preventDefault" to ensure that + the name and value of the regular submit button + following the YUI button doesn't get added to the + form's data set when it is submitted. + */ + + Event.preventDefault(p_oEvent); + + } + + oYUISubmitButton.submitForm(); + + } + + } + + }; + + + /** + * @method addHiddenFieldsToForm + * @description Searches the specified form and adds hidden fields for + * instances of YAHOO.widget.Button that are of type "radio," "checkbox," + * "menu," and "split." + * @param {HTMLFormElement} p_oForm Object reference + * for the form to search. + */ + YAHOO.widget.Button.addHiddenFieldsToForm = function (p_oForm) { + + var aButtons = Dom.getElementsByClassName( + YAHOO.widget.Button.prototype.CSS_CLASS_NAME, + "*", + p_oForm), + + nButtons = aButtons.length, + oButton, + sId, + i; + + if (nButtons > 0) { + + YAHOO.log("Form contains " + nButtons + " YUI buttons."); + + for (i = 0; i < nButtons; i++) { + + sId = aButtons[i].id; + + if (sId) { + + oButton = m_oButtons[sId]; + + if (oButton) { + + oButton.createHiddenFields(); + + } + + } + + } + + } + + }; + + + + // Events + + + /** + * @event focus + * @description Fires when the menu item receives focus. Passes back a + * single object representing the original DOM event object passed back by + * the event utility (YAHOO.util.Event) when the event was fired. See + * Element.addListener + * for more information on listening for this event. + * @type YAHOO.util.CustomEvent + */ + + + /** + * @event blur + * @description Fires when the menu item loses the input focus. Passes back + * a single object representing the original DOM event object passed back by + * the event utility (YAHOO.util.Event) when the event was fired. See + * Element.addListener for + * more information on listening for this event. + * @type YAHOO.util.CustomEvent + */ + + + /** + * @event option + * @description Fires when the user invokes the button's option. Passes + * back a single object representing the original DOM event (either + * "mousedown" or "keydown") that caused the "option" event to fire. See + * Element.addListener + * for more information on listening for this event. + * @type YAHOO.util.CustomEvent + */ + +})(); +(function () { + + // Shorthard for utilities + + var Dom = YAHOO.util.Dom, + Event = YAHOO.util.Event, + Lang = YAHOO.lang, + Button = YAHOO.widget.Button, + + // Private collection of radio buttons + + m_oButtons = {}; + + + + /** + * The ButtonGroup class creates a set of buttons that are mutually + * exclusive; checking one button in the set will uncheck all others in the + * button group. + * @param {String} p_oElement String specifying the id attribute of the + * <div> element of the button group. + * @param {HTMLDivElement} p_oElement Object + * specifying the <div> element of the button group. + * @param {Object} p_oElement Object literal specifying a set of + * configuration attributes used to create the button group. + * @param {Object} p_oAttributes Optional. Object literal specifying a set + * of configuration attributes used to create the button group. + * @namespace YAHOO.widget + * @class ButtonGroup + * @constructor + * @extends YAHOO.util.Element + */ + YAHOO.widget.ButtonGroup = function (p_oElement, p_oAttributes) { + + var fnSuperClass = YAHOO.widget.ButtonGroup.superclass.constructor, + sNodeName, + oElement, + sId; + + if (arguments.length == 1 && !Lang.isString(p_oElement) && + !p_oElement.nodeName) { + + if (!p_oElement.id) { + + sId = Dom.generateId(); + + p_oElement.id = sId; + + YAHOO.log("No value specified for the button group's \"id\"" + + " attribute. Setting button group id to \"" + sId + "\".", + "warn"); + + } + + this.logger = new YAHOO.widget.LogWriter("ButtonGroup " + sId); + + this.logger.log("No source HTML element. Building the button " + + "group using the set of configuration attributes."); + + fnSuperClass.call(this, (this._createGroupElement()), p_oElement); + + } + else if (Lang.isString(p_oElement)) { + + oElement = Dom.get(p_oElement); + + if (oElement) { + + if (oElement.nodeName.toUpperCase() == this.NODE_NAME) { + + this.logger = + new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement); + + fnSuperClass.call(this, oElement, p_oAttributes); + + } + + } + + } + else { + + sNodeName = p_oElement.nodeName; + + if (sNodeName && sNodeName == this.NODE_NAME) { + + if (!p_oElement.id) { + + p_oElement.id = Dom.generateId(); + + YAHOO.log("No value specified for the button group's" + + " \"id\" attribute. Setting button group id " + + "to \"" + p_oElement.id + "\".", "warn"); + + } + + this.logger = + new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement.id); + + fnSuperClass.call(this, p_oElement, p_oAttributes); + + } + + } + + }; + + + YAHOO.extend(YAHOO.widget.ButtonGroup, YAHOO.util.Element, { + + + // Protected properties + + + /** + * @property _buttons + * @description Array of buttons in the button group. + * @default null + * @protected + * @type Array + */ + _buttons: null, + + + + // Constants + + + /** + * @property NODE_NAME + * @description The name of the tag to be used for the button + * group's element. + * @default "DIV" + * @final + * @type String + */ + NODE_NAME: "DIV", + + + /** + * @property CSS_CLASS_NAME + * @description String representing the CSS class(es) to be applied + * to the button group's element. + * @default "yui-buttongroup" + * @final + * @type String + */ + CSS_CLASS_NAME: "yui-buttongroup", + + + + // Protected methods + + + /** + * @method _createGroupElement + * @description Creates the button group's element. + * @protected + * @return {HTMLDivElement} + */ + _createGroupElement: function () { + + var oElement = document.createElement(this.NODE_NAME); + + return oElement; + + }, + + + + // Protected attribute setter methods + + + /** + * @method _setDisabled + * @description Sets the value of the button groups's + * "disabled" attribute. + * @protected + * @param {Boolean} p_bDisabled Boolean indicating the value for + * the button group's "disabled" attribute. + */ + _setDisabled: function (p_bDisabled) { + + var nButtons = this.getCount(), + i; + + if (nButtons > 0) { + + i = nButtons - 1; + + do { + + this._buttons[i].set("disabled", p_bDisabled); + + } + while (i--); + + } + + }, + + + + // Protected event handlers + + + /** + * @method _onKeyDown + * @description "keydown" event handler for the button group. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onKeyDown: function (p_oEvent) { + + var oTarget = Event.getTarget(p_oEvent), + nCharCode = Event.getCharCode(p_oEvent), + sId = oTarget.parentNode.parentNode.id, + oButton = m_oButtons[sId], + nIndex = -1; + + + if (nCharCode == 37 || nCharCode == 38) { + + nIndex = (oButton.index === 0) ? + (this._buttons.length - 1) : (oButton.index - 1); + + } + else if (nCharCode == 39 || nCharCode == 40) { + + nIndex = (oButton.index === (this._buttons.length - 1)) ? + 0 : (oButton.index + 1); + + } + + + if (nIndex > -1) { + + this.check(nIndex); + this.getButton(nIndex).focus(); + + } + + }, + + + /** + * @method _onAppendTo + * @description "appendTo" event handler for the button group. + * @protected + * @param {Event} p_oEvent Object representing the event that was fired. + */ + _onAppendTo: function (p_oEvent) { + + var aButtons = this._buttons, + nButtons = aButtons.length, + i; + + for (i = 0; i < nButtons; i++) { + + aButtons[i].appendTo(this.get("element")); + + } + + }, + + + /** + * @method _onButtonCheckedChange + * @description "checkedChange" event handler for each button in the + * button group. + * @protected + * @param {Event} p_oEvent Object representing the event that was fired. + * @param {YAHOO.widget.Button} + * p_oButton Object representing the button that fired the event. + */ + _onButtonCheckedChange: function (p_oEvent, p_oButton) { + + var bChecked = p_oEvent.newValue, + oCheckedButton = this.get("checkedButton"); + + if (bChecked && oCheckedButton != p_oButton) { + + if (oCheckedButton) { + + oCheckedButton.set("checked", false, true); + + } + + this.set("checkedButton", p_oButton); + this.set("value", p_oButton.get("value")); + + } + else if (oCheckedButton && !oCheckedButton.set("checked")) { + + oCheckedButton.set("checked", true, true); + + } + + }, + + + + // Public methods + + + /** + * @method init + * @description The ButtonGroup class's initialization method. + * @param {String} p_oElement String specifying the id attribute of the + * <div> element of the button group. + * @param {HTMLDivElement} p_oElement Object + * specifying the <div> element of the button group. + * @param {Object} p_oElement Object literal specifying a set of + * configuration attributes used to create the button group. + * @param {Object} p_oAttributes Optional. Object literal specifying a + * set of configuration attributes used to create the button group. + */ + init: function (p_oElement, p_oAttributes) { + + this._buttons = []; + + YAHOO.widget.ButtonGroup.superclass.init.call(this, p_oElement, + p_oAttributes); + + this.addClass(this.CSS_CLASS_NAME); + + this.logger.log("Searching for child nodes with the class name " + + "\"yui-radio-button\" to add to the button group."); + + var aButtons = this.getElementsByClassName("yui-radio-button"); + + + if (aButtons.length > 0) { + + this.logger.log("Found " + aButtons.length + + " child nodes with the class name \"yui-radio-button.\"" + + " Attempting to add to button group."); + + this.addButtons(aButtons); + + } + + + this.logger.log("Searching for child nodes with the type of " + + " \"radio\" to add to the button group."); + + function isRadioButton(p_oElement) { + + return (p_oElement.type == "radio"); + + } + + aButtons = + Dom.getElementsBy(isRadioButton, "input", this.get("element")); + + + if (aButtons.length > 0) { + + this.logger.log("Found " + aButtons.length + " child nodes" + + " with the type of \"radio.\" Attempting to add to" + + " button group."); + + this.addButtons(aButtons); + + } + + this.on("keydown", this._onKeyDown); + this.on("appendTo", this._onAppendTo); + + + var oContainer = this.get("container"); + + if (oContainer) { + + if (Lang.isString(oContainer)) { + + Event.onContentReady(oContainer, function () { + + this.appendTo(oContainer); + + }, null, this); + + } + else { + + this.appendTo(oContainer); + + } + + } + + + this.logger.log("Initialization completed."); + + }, + + + /** + * @method initAttributes + * @description Initializes all of the configuration attributes used to + * create the button group. + * @param {Object} p_oAttributes Object literal specifying a set of + * configuration attributes used to create the button group. + */ + initAttributes: function (p_oAttributes) { + + var oAttributes = p_oAttributes || {}; + + YAHOO.widget.ButtonGroup.superclass.initAttributes.call( + this, oAttributes); + + + /** + * @config name + * @description String specifying the name for the button group. + * This name will be applied to each button in the button group. + * @default null + * @type String + */ + this.setAttributeConfig("name", { + + value: oAttributes.name, + validator: Lang.isString + + }); + + + /** + * @config disabled + * @description Boolean indicating if the button group should be + * disabled. Disabling the button group will disable each button + * in the button group. Disabled buttons are dimmed and will not + * respond to user input or fire events. + * @default false + * @type Boolean + */ + this.setAttributeConfig("disabled", { + + value: (oAttributes.disabled || false), + validator: Lang.isBoolean, + method: this._setDisabled + + }); + + + /** + * @config value + * @description Object specifying the value for the button group. + * @default null + * @type Object + */ + this.setAttributeConfig("value", { + + value: oAttributes.value + + }); + + + /** + * @config container + * @description HTML element reference or string specifying the id + * attribute of the HTML element that the button group's markup + * should be rendered into. + * @type HTMLElement|String + * @default null + */ + this.setAttributeConfig("container", { + + value: oAttributes.container, + writeOnce: true + + }); + + + /** + * @config checkedButton + * @description Reference for the button in the button group that + * is checked. + * @type {YAHOO.widget.Button} + * @default null + */ + this.setAttributeConfig("checkedButton", { + + value: null + + }); + + }, + + + /** + * @method addButton + * @description Adds the button to the button group. + * @param {YAHOO.widget.Button} + * p_oButton Object reference for the + * YAHOO.widget.Button instance to be added to the button group. + * @param {String} p_oButton String specifying the id attribute of the + * <input> or <span> element + * to be used to create the button to be added to the button group. + * @param {HTMLInputElement|HTMLElement} p_oButton Object reference for the + * <input> or <span> element + * to be used to create the button to be added to the button group. + * @param {Object} p_oButton Object literal specifying a set of + * YAHOO.widget.Button + * configuration attributes used to configure the button to be added to + * the button group. + * @return {YAHOO.widget.Button} + */ + addButton: function (p_oButton) { + + var oButton, + oButtonElement, + oGroupElement, + nIndex, + sButtonName, + sGroupName; + + + if (p_oButton instanceof Button && + p_oButton.get("type") == "radio") { + + oButton = p_oButton; + + } + else if (!Lang.isString(p_oButton) && !p_oButton.nodeName) { + + p_oButton.type = "radio"; + + oButton = new Button(p_oButton); + + } + else { + + oButton = new Button(p_oButton, { type: "radio" }); + + } + + + if (oButton) { + + nIndex = this._buttons.length; + sButtonName = oButton.get("name"); + sGroupName = this.get("name"); + + oButton.index = nIndex; + + this._buttons[nIndex] = oButton; + m_oButtons[oButton.get("id")] = oButton; + + + if (sButtonName != sGroupName) { + + oButton.set("name", sGroupName); + + } + + + if (this.get("disabled")) { + + oButton.set("disabled", true); + + } + + + if (oButton.get("checked")) { + + this.set("checkedButton", oButton); + + } + + + oButtonElement = oButton.get("element"); + oGroupElement = this.get("element"); + + if (oButtonElement.parentNode != oGroupElement) { + + oGroupElement.appendChild(oButtonElement); + + } + + + oButton.on("checkedChange", + this._onButtonCheckedChange, oButton, this); + + this.logger.log("Button " + oButton.get("id") + " added."); + + return oButton; + + } + + }, + + + /** + * @method addButtons + * @description Adds the array of buttons to the button group. + * @param {Array} p_aButtons Array of + * YAHOO.widget.Button instances to be added + * to the button group. + * @param {Array} p_aButtons Array of strings specifying the id + * attribute of the <input> or <span> + * elements to be used to create the buttons to be added to the + * button group. + * @param {Array} p_aButtons Array of object references for the + * <input> or <span> elements + * to be used to create the buttons to be added to the button group. + * @param {Array} p_aButtons Array of object literals, each containing + * a set of YAHOO.widget.Button + * configuration attributes used to configure each button to be added + * to the button group. + * @return {Array} + */ + addButtons: function (p_aButtons) { + + var nButtons, + oButton, + aButtons, + i; + + if (Lang.isArray(p_aButtons)) { + + nButtons = p_aButtons.length; + aButtons = []; + + if (nButtons > 0) { + + for (i = 0; i < nButtons; i++) { + + oButton = this.addButton(p_aButtons[i]); + + if (oButton) { + + aButtons[aButtons.length] = oButton; + + } + + } + + if (aButtons.length > 0) { + + this.logger.log(aButtons.length + " buttons added."); + + return aButtons; + + } + + } + + } + + }, + + + /** + * @method removeButton + * @description Removes the button at the specified index from the + * button group. + * @param {Number} p_nIndex Number specifying the index of the button + * to be removed from the button group. + */ + removeButton: function (p_nIndex) { + + var oButton = this.getButton(p_nIndex), + nButtons, + i; + + if (oButton) { + + this.logger.log("Removing button " + oButton.get("id") + "."); + + this._buttons.splice(p_nIndex, 1); + delete m_oButtons[oButton.get("id")]; + + oButton.removeListener("checkedChange", + this._onButtonCheckedChange); + + oButton.destroy(); + + + nButtons = this._buttons.length; + + if (nButtons > 0) { + + i = this._buttons.length - 1; + + do { + + this._buttons[i].index = i; + + } + while (i--); + + } + + this.logger.log("Button " + oButton.get("id") + " removed."); + + } + + }, + + + /** + * @method getButton + * @description Returns the button at the specified index. + * @param {Number} p_nIndex The index of the button to retrieve from the + * button group. + * @return {YAHOO.widget.Button} + */ + getButton: function (p_nIndex) { + + if (Lang.isNumber(p_nIndex)) { + + return this._buttons[p_nIndex]; + + } + + }, + + + /** + * @method getButtons + * @description Returns an array of the buttons in the button group. + * @return {Array} + */ + getButtons: function () { + + return this._buttons; + + }, + + + /** + * @method getCount + * @description Returns the number of buttons in the button group. + * @return {Number} + */ + getCount: function () { + + return this._buttons.length; + + }, + + + /** + * @method focus + * @description Sets focus to the button at the specified index. + * @param {Number} p_nIndex Number indicating the index of the button + * to focus. + */ + focus: function (p_nIndex) { + + var oButton, + nButtons, + i; + + if (Lang.isNumber(p_nIndex)) { + + oButton = this._buttons[p_nIndex]; + + if (oButton) { + + oButton.focus(); + + } + + } + else { + + nButtons = this.getCount(); + + for (i = 0; i < nButtons; i++) { + + oButton = this._buttons[i]; + + if (!oButton.get("disabled")) { + + oButton.focus(); + break; + + } + + } + + } + + }, + + + /** + * @method check + * @description Checks the button at the specified index. + * @param {Number} p_nIndex Number indicating the index of the button + * to check. + */ + check: function (p_nIndex) { + + var oButton = this.getButton(p_nIndex); + + if (oButton) { + + oButton.set("checked", true); + + } + + }, + + + /** + * @method destroy + * @description Removes the button group's element from its parent + * element and removes all event handlers. + */ + destroy: function () { + + this.logger.log("Destroying..."); + + var nButtons = this._buttons.length, + oElement = this.get("element"), + oParentNode = oElement.parentNode, + i; + + if (nButtons > 0) { + + i = this._buttons.length - 1; + + do { + + this._buttons[i].destroy(); + + } + while (i--); + + } + + this.logger.log("Removing DOM event handlers."); + + Event.purgeElement(oElement); + + this.logger.log("Removing from document."); + + oParentNode.removeChild(oElement); + + }, + + + /** + * @method toString + * @description Returns a string representing the button group. + * @return {String} + */ + toString: function () { + + return ("ButtonGroup " + this.get("id")); + + } + + }); + +})(); +YAHOO.register("button", YAHOO.widget.Button, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/button/button-beta-min.js b/lib/yui/button/button-beta-min.js new file mode 100755 index 0000000000..be19b02b34 --- /dev/null +++ b/lib/yui/button/button-beta-min.js @@ -0,0 +1,162 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ + +(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Overlay=YAHOO.widget.Overlay,Menu=YAHOO.widget.Menu,m_oButtons={},m_oOverlayManager=null,m_oSubmitTrigger=null,m_oFocusedButton=null;function createInputElement(p_sType,p_sName,p_sValue,p_bChecked){var oInput,sInput;if(Lang.isString(p_sType)&&Lang.isString(p_sName)){if(YAHOO.env.ua.ie){sInput="0){p_oAttributes.label=sText;}}} +function initConfig(p_oConfig){var oAttributes=p_oConfig.attributes,oSrcElement=oAttributes.srcelement,sSrcElementNodeName=oSrcElement.nodeName.toUpperCase(),me=this;if(sSrcElementNodeName==this.NODE_NAME){p_oConfig.element=oSrcElement;p_oConfig.id=oSrcElement.id;Dom.getElementsBy(function(p_oElement){switch(p_oElement.nodeName.toUpperCase()){case"BUTTON":case"A":case"INPUT":setAttributesFromSrcElement.call(me,p_oElement,oAttributes);break;}},"*",oSrcElement);} +else{switch(sSrcElementNodeName){case"BUTTON":case"A":case"INPUT":setAttributesFromSrcElement.call(this,oSrcElement,oAttributes);break;}}} +YAHOO.widget.Button=function(p_oElement,p_oAttributes){var fnSuperClass=YAHOO.widget.Button.superclass.constructor,oConfig,oElement;if(arguments.length==1&&!Lang.isString(p_oElement)&&!p_oElement.nodeName){if(!p_oElement.id){p_oElement.id=Dom.generateId();} +fnSuperClass.call(this,(this.createButtonElement(p_oElement.type)),p_oElement);} +else{oConfig={element:null,attributes:(p_oAttributes||{})};if(Lang.isString(p_oElement)){oElement=Dom.get(p_oElement);if(oElement){if(!oConfig.attributes.id){oConfig.attributes.id=p_oElement;} +oConfig.attributes.srcelement=oElement;initConfig.call(this,oConfig);if(!oConfig.element){oConfig.element=this.createButtonElement(oConfig.attributes.type);} +fnSuperClass.call(this,oConfig.element,oConfig.attributes);}} +else if(p_oElement.nodeName){if(!oConfig.attributes.id){if(p_oElement.id){oConfig.attributes.id=p_oElement.id;} +else{oConfig.attributes.id=Dom.generateId();}} +oConfig.attributes.srcelement=p_oElement;initConfig.call(this,oConfig);if(!oConfig.element){oConfig.element=this.createButtonElement(oConfig.attributes.type);} +fnSuperClass.call(this,oConfig.element,oConfig.attributes);}}};YAHOO.extend(YAHOO.widget.Button,YAHOO.util.Element,{_button:null,_menu:null,_hiddenFields:null,_onclickAttributeValue:null,_activationKeyPressed:false,_activationButtonPressed:false,_hasKeyEventHandlers:false,_hasMouseEventHandlers:false,NODE_NAME:"SPAN",CHECK_ACTIVATION_KEYS:[32],ACTIVATION_KEYS:[13,32],OPTION_AREA_WIDTH:20,CSS_CLASS_NAME:"yui-button",RADIO_DEFAULT_TITLE:"Unchecked. Click to check.",RADIO_CHECKED_TITLE:"Checked. Click to uncheck.",CHECKBOX_DEFAULT_TITLE:"Unchecked. Click to check.",CHECKBOX_CHECKED_TITLE:"Checked. Click to uncheck.",MENUBUTTON_DEFAULT_TITLE:"Menu collapsed. Click to expand.",MENUBUTTON_MENU_VISIBLE_TITLE:"Menu expanded. Click or press Esc to collapse.",SPLITBUTTON_DEFAULT_TITLE:("Menu collapsed. Click inside option "+"region or press Ctrl + Shift + M to show the menu."),SPLITBUTTON_OPTION_VISIBLE_TITLE:"Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.",SUBMIT_TITLE:"Click to submit form.",_setType:function(p_sType){if(p_sType=="split"){this.on("option",this._onOption);}},_setLabel:function(p_sLabel){this._button.innerHTML=p_sLabel;},_setTabIndex:function(p_nTabIndex){this._button.tabIndex=p_nTabIndex;},_setTitle:function(p_sTitle){var sTitle=p_sTitle;if(this.get("type")!="link"){if(!sTitle){switch(this.get("type")){case"radio":sTitle=this.RADIO_DEFAULT_TITLE;break;case"checkbox":sTitle=this.CHECKBOX_DEFAULT_TITLE;break;case"menu":sTitle=this.MENUBUTTON_DEFAULT_TITLE;break;case"split":sTitle=this.SPLITBUTTON_DEFAULT_TITLE;break;case"submit":sTitle=this.SUBMIT_TITLE;break;}} +this._button.title=sTitle;}},_setDisabled:function(p_bDisabled){if(this.get("type")!="link"){if(p_bDisabled){if(this._menu){this._menu.hide();} +if(this.hasFocus()){this.blur();} +this._button.setAttribute("disabled","disabled");this.addStateCSSClasses("disabled");} +else{this._button.removeAttribute("disabled");this.removeStateCSSClasses("disabled");}}},_setHref:function(p_sHref){if(this.get("type")=="link"){this._button.href=p_sHref;}},_setTarget:function(p_sTarget){if(this.get("type")=="link"){this._button.setAttribute("target",p_sTarget);}},_setChecked:function(p_bChecked){var sType=this.get("type"),sTitle;if(sType=="checkbox"||sType=="radio"){if(p_bChecked){this.addStateCSSClasses("checked");sTitle=(sType=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;} +else{this.removeStateCSSClasses("checked");sTitle=(sType=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;} +this.set("title",sTitle);}},_setMenu:function(p_oMenu){var bLazyLoad=this.get("lazyloadmenu"),oButtonElement=this.get("element"),bInstance=false,oMenu,oMenuElement,oSrcElement,aItems,nItems,oItem,i;if(!Overlay){return false;} +if(!Menu){return false;} +function onAppendTo(){oMenu.render(oButtonElement.parentNode);this.removeListener("appendTo",onAppendTo);} +function initMenu(){if(oMenu){Dom.addClass(oMenu.element,this.get("menuclassname"));Dom.addClass(oMenu.element,"yui-"+this.get("type")+"-button-menu");oMenu.showEvent.subscribe(this._onMenuShow,null,this);oMenu.hideEvent.subscribe(this._onMenuHide,null,this);oMenu.renderEvent.subscribe(this._onMenuRender,null,this);if(oMenu instanceof Menu){oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,this,true);oMenu.clickEvent.subscribe(this._onMenuClick,this,true);oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,this,true);oSrcElement=oMenu.srcElement;if(oSrcElement&&oSrcElement.nodeName.toUpperCase()=="SELECT"){oSrcElement.style.display="none";oSrcElement.parentNode.removeChild(oSrcElement);}} +else if(oMenu instanceof Overlay){if(!m_oOverlayManager){m_oOverlayManager=new YAHOO.widget.OverlayManager();} +m_oOverlayManager.register(oMenu);} +this._menu=oMenu;if(!bInstance){if(bLazyLoad&&!(oMenu instanceof Menu)){oMenu.beforeShowEvent.subscribe(this._onOverlayBeforeShow,null,this);} +else if(!bLazyLoad){if(Dom.inDocument(oButtonElement)){oMenu.render(oButtonElement.parentNode);} +else{this.on("appendTo",onAppendTo);}}}}} +if(p_oMenu&&(p_oMenu instanceof Menu)){oMenu=p_oMenu;aItems=oMenu.getItems();nItems=aItems.length;bInstance=true;if(nItems>0){i=nItems-1;do{oItem=aItems[i];if(oItem){oItem.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,oItem,this);}} +while(i--);} +initMenu.call(this);} +else if(p_oMenu&&(p_oMenu instanceof Overlay)){oMenu=p_oMenu;bInstance=true;oMenu.cfg.setProperty("visible",false);oMenu.cfg.setProperty("context",[oButtonElement,"tl","bl"]);initMenu.call(this);} +else if(Lang.isArray(p_oMenu)){this.on("appendTo",function(){oMenu=new Menu(Dom.generateId(),{lazyload:bLazyLoad,itemdata:p_oMenu});initMenu.call(this);});} +else if(Lang.isString(p_oMenu)){oMenuElement=Dom.get(p_oMenu);if(oMenuElement){if(Dom.hasClass(oMenuElement,Menu.prototype.CSS_CLASS_NAME)||oMenuElement.nodeName=="SELECT"){oMenu=new Menu(p_oMenu,{lazyload:bLazyLoad});initMenu.call(this);} +else{oMenu=new Overlay(p_oMenu,{visible:false,context:[oButtonElement,"tl","bl"]});initMenu.call(this);}}} +else if(p_oMenu&&p_oMenu.nodeName){if(Dom.hasClass(p_oMenu,Menu.prototype.CSS_CLASS_NAME)||p_oMenu.nodeName=="SELECT"){oMenu=new Menu(p_oMenu,{lazyload:bLazyLoad});initMenu.call(this);} +else{if(!p_oMenu.id){Dom.generateId(p_oMenu);} +oMenu=new Overlay(p_oMenu,{visible:false,context:[oButtonElement,"tl","bl"]});initMenu.call(this);}}},_setOnClick:function(p_oObject){if(this._onclickAttributeValue&&(this._onclickAttributeValue!=p_oObject)){this.removeListener("click",this._onclickAttributeValue.fn);this._onclickAttributeValue=null;} +if(!this._onclickAttributeValue&&Lang.isObject(p_oObject)&&Lang.isFunction(p_oObject.fn)){this.on("click",p_oObject.fn,p_oObject.obj,p_oObject.scope);this._onclickAttributeValue=p_oObject;}},_setSelectedMenuItem:function(p_nIndex){var oMenu=this._menu,oMenuItem;if(oMenu&&oMenu instanceof Menu){oMenuItem=oMenu.getItem(p_nIndex);if(oMenuItem&&!oMenuItem.cfg.getProperty("selected")){oMenuItem.cfg.setProperty("selected",true);}}},_isActivationKey:function(p_nKeyCode){var sType=this.get("type"),aKeyCodes=(sType=="checkbox"||sType=="radio")?this.CHECK_ACTIVATION_KEYS:this.ACTIVATION_KEYS,nKeyCodes=aKeyCodes.length,i;if(nKeyCodes>0){i=nKeyCodes-1;do{if(p_nKeyCode==aKeyCodes[i]){return true;}} +while(i--);}},_isSplitButtonOptionKey:function(p_oEvent){return(p_oEvent.ctrlKey&&p_oEvent.shiftKey&&Event.getCharCode(p_oEvent)==77);},_addListenersToForm:function(){var oForm=this.getForm(),oSrcElement,aListeners,nListeners,i,bHasKeyPressListener;if(oForm){Event.on(oForm,"reset",this._onFormReset,null,this);Event.on(oForm,"submit",this.createHiddenFields,null,this);oSrcElement=this.get("srcelement");if(this.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit")) +{aListeners=Event.getListeners(oForm,"keypress");bHasKeyPressListener=false;if(aListeners){nListeners=aListeners.length;if(nListeners>0){i=nListeners-1;do{if(aListeners[i].fn==YAHOO.widget.Button.onFormKeyPress) +{bHasKeyPressListener=true;break;}} +while(i--);}} +if(!bHasKeyPressListener){Event.on(oForm,"keypress",YAHOO.widget.Button.onFormKeyPress);}}}},_originalMaxHeight:-1,_showMenu:function(p_oEvent){YAHOO.widget.MenuManager.hideVisible();if(m_oOverlayManager){m_oOverlayManager.hideAll();} +var oMenu=this._menu,nViewportHeight=Dom.getViewportHeight(),nMenuHeight,nScrollTop,nY;if(oMenu&&(oMenu instanceof Menu)){oMenu.cfg.applyConfig({context:[this.get("id"),"tl","bl"],constraintoviewport:false,clicktohide:false,visible:true});oMenu.cfg.fireQueue();oMenu.align("tl","bl");if(p_oEvent.type=="mousedown"){Event.stopPropagation(p_oEvent);} +if(this.get("focusmenu")){this._menu.focus();} +nMenuHeight=oMenu.element.offsetHeight;if((oMenu.cfg.getProperty("y")+nMenuHeight)>nViewportHeight){oMenu.align("bl","tl");nY=oMenu.cfg.getProperty("y");nScrollTop=Dom.getDocumentScrollTop();if(nScrollTop>=nY){if(this._originalMaxHeight==-1){this._originalMaxHeight=oMenu.cfg.getProperty("maxheight");} +oMenu.cfg.setProperty("maxheight",(nMenuHeight-((nScrollTop-nY)+20)));oMenu.align("bl","tl");}}} +else if(oMenu&&(oMenu instanceof Overlay)){oMenu.show();oMenu.align("tl","bl");nMenuHeight=oMenu.element.offsetHeight;if((oMenu.cfg.getProperty("y")+nMenuHeight)>nViewportHeight){oMenu.align("bl","tl");}}},_hideMenu:function(){var oMenu=this._menu;if(oMenu){oMenu.hide();}},_onMouseOver:function(p_oEvent){if(!this._hasMouseEventHandlers){this.on("mouseout",this._onMouseOut);this.on("mousedown",this._onMouseDown);this.on("mouseup",this._onMouseUp);this._hasMouseEventHandlers=true;} +this.addStateCSSClasses("hover");if(this._activationButtonPressed){this.addStateCSSClasses("active");} +if(this._bOptionPressed){this.addStateCSSClasses("activeoption");}},_onMouseOut:function(p_oEvent){this.removeStateCSSClasses("hover");if(this.get("type")!="menu"){this.removeStateCSSClasses("active");} +if(this._activationButtonPressed||this._bOptionPressed){Event.on(document,"mouseup",this._onDocumentMouseUp,null,this);}},_onDocumentMouseUp:function(p_oEvent){this._activationButtonPressed=false;this._bOptionPressed=false;var sType=this.get("type");if(sType=="menu"||sType=="split"){this.removeStateCSSClasses((sType=="menu"?"active":"activeoption"));this._hideMenu();} +Event.removeListener(document,"mouseup",this._onDocumentMouseUp);},_onMouseDown:function(p_oEvent){var sType,oElement,nX,me;function onMouseUp(){this._hideMenu();this.removeListener("mouseup",onMouseUp);} +if((p_oEvent.which||p_oEvent.button)==1){if(!this.hasFocus()){this.focus();} +sType=this.get("type");if(sType=="split"){oElement=this.get("element");nX=Event.getPageX(p_oEvent)-Dom.getX(oElement);if((oElement.offsetWidth-this.OPTION_AREA_WIDTH)"+ +(p_sType=="link"?"":"")+"";return oElement;},addStateCSSClasses:function(p_sState){var sType=this.get("type");if(Lang.isString(p_sState)){if(p_sState!="activeoption"){this.addClass(this.CSS_CLASS_NAME+("-"+p_sState));} +this.addClass("yui-"+sType+("-button-"+p_sState));}},removeStateCSSClasses:function(p_sState){var sType=this.get("type");if(Lang.isString(p_sState)){this.removeClass(this.CSS_CLASS_NAME+("-"+p_sState));this.removeClass("yui-"+sType+("-button-"+p_sState));}},createHiddenFields:function(){this.removeHiddenFields();var oForm=this.getForm(),oButtonField,sType,bCheckable,oMenu,oMenuItem,sName,oValue,oMenuField;if(oForm&&!this.get("disabled")){sType=this.get("type");bCheckable=(sType=="checkbox"||sType=="radio");if(bCheckable||(m_oSubmitTrigger==this)){oButtonField=createInputElement((bCheckable?sType:"hidden"),this.get("name"),this.get("value"),this.get("checked"));if(oButtonField){if(bCheckable){oButtonField.style.display="none";} +oForm.appendChild(oButtonField);}} +oMenu=this._menu;if(oMenu&&(oMenu instanceof Menu)){oMenuField=oMenu.srcElement;oMenuItem=oMenu.getItem(this.get("selectedMenuItem"));if(oMenuField&&oMenuField.nodeName.toUpperCase()=="SELECT"){oForm.appendChild(oMenuField);oMenuField.selectedIndex=oMenuItem.index;} +else{oValue=(oMenuItem.value===null||oMenuItem.value==="")?oMenuItem.cfg.getProperty("text"):oMenuItem.value;sName=this.get("name");if(oValue&&sName){oMenuField=createInputElement("hidden",(sName+"_options"),oValue);oForm.appendChild(oMenuField);}}} +if(oButtonField&&oMenuField){this._hiddenFields=[oButtonField,oMenuField];} +else if(!oButtonField&&oMenuField){this._hiddenFields=oMenuField;} +else if(oButtonField&&!oMenuField){this._hiddenFields=oButtonField;} +return this._hiddenFields;}},removeHiddenFields:function(){var oField=this._hiddenFields,nFields,i;function removeChild(p_oElement){if(Dom.inDocument(p_oElement)){p_oElement.parentNode.removeChild(p_oElement);}} +if(oField){if(Lang.isArray(oField)){nFields=oField.length;if(nFields>0){i=nFields-1;do{removeChild(oField[i]);} +while(i--);}} +else{removeChild(oField);} +this._hiddenFields=null;}},submitForm:function(){var oForm=this.getForm(),oSrcElement=this.get("srcelement"),bSubmitForm=false,oEvent;if(oForm){if(this.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit")) +{m_oSubmitTrigger=this;} +if(YAHOO.env.ua.ie){bSubmitForm=oForm.fireEvent("onsubmit");} +else{oEvent=document.createEvent("HTMLEvents");oEvent.initEvent("submit",true,true);bSubmitForm=oForm.dispatchEvent(oEvent);} +if((YAHOO.env.ua.ie||YAHOO.env.ua.webkit)&&bSubmitForm){oForm.submit();}} +return bSubmitForm;},init:function(p_oElement,p_oAttributes){var sNodeName=p_oAttributes.type=="link"?"A":"BUTTON",oSrcElement=p_oAttributes.srcelement,oButton=p_oElement.getElementsByTagName(sNodeName)[0],oInput;if(!oButton){oInput=p_oElement.getElementsByTagName("INPUT")[0];if(oInput){oButton=document.createElement("BUTTON");oButton.setAttribute("type","button");oInput.parentNode.replaceChild(oButton,oInput);}} +this._button=oButton;YAHOO.widget.Button.superclass.init.call(this,p_oElement,p_oAttributes);m_oButtons[this.get("id")]=this;this.addClass(this.CSS_CLASS_NAME);this.addClass("yui-"+this.get("type")+"-button");Event.on(this._button,"focus",this._onFocus,null,this);this.on("mouseover",this._onMouseOver);this.on("click",this._onClick);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container"),oElement=this.get("element"),bElInDoc=Dom.inDocument(oElement),oParentNode;if(oContainer){if(oSrcElement&&oSrcElement!=oElement){oParentNode=oSrcElement.parentNode;if(oParentNode){oParentNode.removeChild(oSrcElement);}} +if(Lang.isString(oContainer)){Event.onContentReady(oContainer,function(){this.appendTo(oContainer);},null,this);} +else{this.appendTo(oContainer);}} +else if(!bElInDoc&&oSrcElement&&oSrcElement!=oElement){oParentNode=oSrcElement.parentNode;if(oParentNode){this.fireEvent("beforeAppendTo",{type:"beforeAppendTo",target:oParentNode});oParentNode.replaceChild(oElement,oSrcElement);this.fireEvent("appendTo",{type:"appendTo",target:oParentNode});}} +else if(this.get("type")!="link"&&bElInDoc&&oSrcElement&&oSrcElement==oElement){this._addListenersToForm();}},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.Button.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("type",{value:(oAttributes.type||"push"),validator:Lang.isString,writeOnce:true,method:this._setType});this.setAttributeConfig("label",{value:oAttributes.label,validator:Lang.isString,method:this._setLabel});this.setAttributeConfig("value",{value:oAttributes.value});this.setAttributeConfig("name",{value:oAttributes.name,validator:Lang.isString});this.setAttributeConfig("tabindex",{value:oAttributes.tabindex,validator:Lang.isNumber,method:this._setTabIndex});this.configureAttribute("title",{value:oAttributes.title,validator:Lang.isString,method:this._setTitle});this.setAttributeConfig("disabled",{value:(oAttributes.disabled||false),validator:Lang.isBoolean,method:this._setDisabled});this.setAttributeConfig("href",{value:oAttributes.href,validator:Lang.isString,method:this._setHref});this.setAttributeConfig("target",{value:oAttributes.target,validator:Lang.isString,method:this._setTarget});this.setAttributeConfig("checked",{value:(oAttributes.checked||false),validator:Lang.isBoolean,method:this._setChecked});this.setAttributeConfig("container",{value:oAttributes.container,writeOnce:true});this.setAttributeConfig("srcelement",{value:oAttributes.srcelement,writeOnce:true});this.setAttributeConfig("menu",{value:null,method:this._setMenu,writeOnce:true});this.setAttributeConfig("lazyloadmenu",{value:(oAttributes.lazyloadmenu===false?false:true),validator:Lang.isBoolean,writeOnce:true});this.setAttributeConfig("menuclassname",{value:(oAttributes.menuclassname||"yui-button-menu"),validator:Lang.isString,method:this._setMenuClassName,writeOnce:true});this.setAttributeConfig("selectedMenuItem",{value:0,validator:Lang.isNumber,method:this._setSelectedMenuItem});this.setAttributeConfig("onclick",{value:oAttributes.onclick,method:this._setOnClick});this.setAttributeConfig("focusmenu",{value:(oAttributes.focusmenu===false?false:true),validator:Lang.isBoolean});},focus:function(){if(!this.get("disabled")){this._button.focus();}},blur:function(){if(!this.get("disabled")){this._button.blur();}},hasFocus:function(){return(m_oFocusedButton==this);},isActive:function(){return this.hasClass(this.CSS_CLASS_NAME+"-active");},getMenu:function(){return this._menu;},getForm:function(){return this._button.form;},getHiddenFields:function(){return this._hiddenFields;},destroy:function(){var oElement=this.get("element"),oParentNode=oElement.parentNode,oMenu=this._menu;if(oMenu){oMenu.destroy();} +Event.purgeElement(oElement);Event.purgeElement(this._button);Event.removeListener(document,"mouseup",this._onDocumentMouseUp);Event.removeListener(document,"keyup",this._onDocumentKeyUp);Event.removeListener(document,"mousedown",this._onDocumentMouseDown);var oForm=this.getForm();if(oForm){Event.removeListener(oForm,"reset",this._onFormReset);Event.removeListener(oForm,"submit",this.createHiddenFields);} +oParentNode.removeChild(oElement);delete m_oButtons[this.get("id")];},fireEvent:function(p_sType,p_aArgs){if(this.DOM_EVENTS[p_sType]&&this.get("disabled")){return;} +YAHOO.widget.Button.superclass.fireEvent.call(this,p_sType,p_aArgs);},toString:function(){return("Button "+this.get("id"));}});YAHOO.widget.Button.onFormKeyPress=function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),nCharCode=Event.getCharCode(p_oEvent),sNodeName=oTarget.nodeName&&oTarget.nodeName.toUpperCase(),sType=oTarget.type,bFormContainsYUIButtons=false,oButton,oYUISubmitButton,oPrecedingSubmitButton,oFollowingSubmitButton;function isSubmitButton(p_oElement){var sId,oSrcElement;switch(p_oElement.nodeName.toUpperCase()){case"INPUT":case"BUTTON":if(p_oElement.type=="submit"&&!p_oElement.disabled){if(!bFormContainsYUIButtons&&!oPrecedingSubmitButton){oPrecedingSubmitButton=p_oElement;} +if(oYUISubmitButton&&!oFollowingSubmitButton){oFollowingSubmitButton=p_oElement;}} +break;default:sId=p_oElement.id;if(sId){oButton=m_oButtons[sId];if(oButton){bFormContainsYUIButtons=true;if(!oButton.get("disabled")){oSrcElement=oButton.get("srcelement");if(!oYUISubmitButton&&(oButton.get("type")=="submit"||(oSrcElement&&oSrcElement.type=="submit"))) +{oYUISubmitButton=oButton;}}}} +break;}} +if(nCharCode==13&&((sNodeName=="INPUT"&&(sType=="text"||sType=="password"||sType=="checkbox"||sType=="radio"||sType=="file"))||sNodeName=="SELECT")) +{Dom.getElementsBy(isSubmitButton,"*",this);if(oPrecedingSubmitButton){oPrecedingSubmitButton.focus();} +else if(!oPrecedingSubmitButton&&oYUISubmitButton){if(oFollowingSubmitButton){Event.preventDefault(p_oEvent);} +oYUISubmitButton.submitForm();}}};YAHOO.widget.Button.addHiddenFieldsToForm=function(p_oForm){var aButtons=Dom.getElementsByClassName(YAHOO.widget.Button.prototype.CSS_CLASS_NAME,"*",p_oForm),nButtons=aButtons.length,oButton,sId,i;if(nButtons>0){for(i=0;i0){i=nButtons-1;do{this._buttons[i].set("disabled",p_bDisabled);} +while(i--);}},_onKeyDown:function(p_oEvent){var oTarget=Event.getTarget(p_oEvent),nCharCode=Event.getCharCode(p_oEvent),sId=oTarget.parentNode.parentNode.id,oButton=m_oButtons[sId],nIndex=-1;if(nCharCode==37||nCharCode==38){nIndex=(oButton.index===0)?(this._buttons.length-1):(oButton.index-1);} +else if(nCharCode==39||nCharCode==40){nIndex=(oButton.index===(this._buttons.length-1))?0:(oButton.index+1);} +if(nIndex>-1){this.check(nIndex);this.getButton(nIndex).focus();}},_onAppendTo:function(p_oEvent){var aButtons=this._buttons,nButtons=aButtons.length,i;for(i=0;i0){this.addButtons(aButtons);} +function isRadioButton(p_oElement){return(p_oElement.type=="radio");} +aButtons=Dom.getElementsBy(isRadioButton,"input",this.get("element"));if(aButtons.length>0){this.addButtons(aButtons);} +this.on("keydown",this._onKeyDown);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container");if(oContainer){if(Lang.isString(oContainer)){Event.onContentReady(oContainer,function(){this.appendTo(oContainer);},null,this);} +else{this.appendTo(oContainer);}}},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.ButtonGroup.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("name",{value:oAttributes.name,validator:Lang.isString});this.setAttributeConfig("disabled",{value:(oAttributes.disabled||false),validator:Lang.isBoolean,method:this._setDisabled});this.setAttributeConfig("value",{value:oAttributes.value});this.setAttributeConfig("container",{value:oAttributes.container,writeOnce:true});this.setAttributeConfig("checkedButton",{value:null});},addButton:function(p_oButton){var oButton,oButtonElement,oGroupElement,nIndex,sButtonName,sGroupName;if(p_oButton instanceof Button&&p_oButton.get("type")=="radio"){oButton=p_oButton;} +else if(!Lang.isString(p_oButton)&&!p_oButton.nodeName){p_oButton.type="radio";oButton=new Button(p_oButton);} +else{oButton=new Button(p_oButton,{type:"radio"});} +if(oButton){nIndex=this._buttons.length;sButtonName=oButton.get("name");sGroupName=this.get("name");oButton.index=nIndex;this._buttons[nIndex]=oButton;m_oButtons[oButton.get("id")]=oButton;if(sButtonName!=sGroupName){oButton.set("name",sGroupName);} +if(this.get("disabled")){oButton.set("disabled",true);} +if(oButton.get("checked")){this.set("checkedButton",oButton);} +oButtonElement=oButton.get("element");oGroupElement=this.get("element");if(oButtonElement.parentNode!=oGroupElement){oGroupElement.appendChild(oButtonElement);} +oButton.on("checkedChange",this._onButtonCheckedChange,oButton,this);return oButton;}},addButtons:function(p_aButtons){var nButtons,oButton,aButtons,i;if(Lang.isArray(p_aButtons)){nButtons=p_aButtons.length;aButtons=[];if(nButtons>0){for(i=0;i0){return aButtons;}}}},removeButton:function(p_nIndex){var oButton=this.getButton(p_nIndex),nButtons,i;if(oButton){this._buttons.splice(p_nIndex,1);delete m_oButtons[oButton.get("id")];oButton.removeListener("checkedChange",this._onButtonCheckedChange);oButton.destroy();nButtons=this._buttons.length;if(nButtons>0){i=this._buttons.length-1;do{this._buttons[i].index=i;} +while(i--);}}},getButton:function(p_nIndex){if(Lang.isNumber(p_nIndex)){return this._buttons[p_nIndex];}},getButtons:function(){return this._buttons;},getCount:function(){return this._buttons.length;},focus:function(p_nIndex){var oButton,nButtons,i;if(Lang.isNumber(p_nIndex)){oButton=this._buttons[p_nIndex];if(oButton){oButton.focus();}} +else{nButtons=this.getCount();for(i=0;i0){i=this._buttons.length-1;do{this._buttons[i].destroy();} +while(i--);} +Event.purgeElement(oElement);oParentNode.removeChild(oElement);},toString:function(){return("ButtonGroup "+this.get("id"));}});})();YAHOO.register("button",YAHOO.widget.Button,{version:"2.3.0",build:"442"}); \ No newline at end of file diff --git a/lib/yui/button/button-beta.js b/lib/yui/button/button-beta.js new file mode 100755 index 0000000000..83195b829f --- /dev/null +++ b/lib/yui/button/button-beta.js @@ -0,0 +1,4477 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/** +* @module button +* @description

The Button Control enables the creation of rich, graphical +* buttons that function like traditional HTML form buttons. Unlike +* tradition HTML form buttons, buttons created with the Button Control can have +* a label that is different from its value. With the inclusion of the optional +* Menu Control, the Button Control can also be +* used to create menu buttons and split buttons, controls that are not +* available natively in HTML. The Button Control can also be thought of as a +* way to create more visually engaging implementations of the browser's +* default radio-button and check-box controls.

+*

The Button Control supports the following types:

+*
+*
push
+*
Basic push button that can execute a user-specified command when +* pressed.
+*
link
+*
Navigates to a specified url when pressed.
+*
submit
+*
Submits the parent form when pressed.
+*
reset
+*
Resets the parent form when pressed.
+*
checkbox
+*
Maintains a "checked" state that can be toggled on and off.
+*
radio
+*
Maintains a "checked" state that can be toggled on and off. Use with +* the ButtonGroup class to create a set of controls that are mutually +* exclusive; checking one button in the set will uncheck all others in +* the group.
+*
menu
+*
When pressed will show/hide a menu.
+*
split
+*
Can execute a user-specified command or display a menu when pressed.
+*
+* @title Button +* @namespace YAHOO.widget +* @requires yahoo, dom, element, event +* @optional container, menu +* @beta +*/ + + +(function () { + + + /** + * The Button class creates a rich, graphical button. + * @param {String} p_oElement String specifying the id attribute of the + * <input>, <button>, + * <a>, or <span> element to + * be used to create the button. + * @param {HTMLInputElement| + * HTMLButtonElement|HTMLElement} p_oElement Object reference for the + * <input>, <button>, + * <a>, or <span> element to be + * used to create the button. + * @param {Object} p_oElement Object literal specifying a set of + * configuration attributes used to create the button. + * @param {Object} p_oAttributes Optional. Object literal specifying a set + * of configuration attributes used to create the button. + * @namespace YAHOO.widget + * @class Button + * @constructor + * @extends YAHOO.util.Element + */ + + + + // Shorthard for utilities + + var Dom = YAHOO.util.Dom, + Event = YAHOO.util.Event, + Lang = YAHOO.lang, + Overlay = YAHOO.widget.Overlay, + Menu = YAHOO.widget.Menu, + + + // Private member variables + + m_oButtons = {}, // Collection of all Button instances + m_oOverlayManager = null, // YAHOO.widget.OverlayManager instance + m_oSubmitTrigger = null, // The button that submitted the form + m_oFocusedButton = null; // The button that has focus + + + + // Private methods + + + + /** + * @method createInputElement + * @description Creates an <input> element of the + * specified type. + * @private + * @param {String} p_sType String specifying the type of + * <input> element to create. + * @param {String} p_sName String specifying the name of + * <input> element to create. + * @param {String} p_sValue String specifying the value of + * <input> element to create. + * @param {String} p_bChecked Boolean specifying if the + * <input> element is to be checked. + * @return {HTMLInputElement} + */ + function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) { + + var oInput, + sInput; + + if (Lang.isString(p_sType) && Lang.isString(p_sName)) { + + if (YAHOO.env.ua.ie) { + + /* + For IE it is necessary to create the element with the + "type," "name," "value," and "checked" properties set all + at once. + */ + + sInput = "<input> or <a>) that + * map to Button configuration attributes and sets them into a collection + * that is passed to the Button constructor. + * @private + * @param {HTMLInputElement|HTMLAnchorElement} p_oElement Object reference to the HTML + * element (either <input> or <span> + * ) used to create the button. + * @param {Object} p_oAttributes Object reference for the collection of + * configuration attributes used to create the button. + */ + function setAttributesFromSrcElement(p_oElement, p_oAttributes) { + + var sSrcElementNodeName = p_oElement.nodeName.toUpperCase(), + me = this, + oAttribute, + oRootNode, + sText; + + + /** + * @method setAttributeFromDOMAttribute + * @description Gets the value of the specified DOM attribute and sets it + * into the collection of configuration attributes used to configure + * the button. + * @private + * @param {String} p_sAttribute String representing the name of the + * attribute to retrieve from the DOM element. + */ + function setAttributeFromDOMAttribute(p_sAttribute) { + + if ( !(p_sAttribute in p_oAttributes) ) { + + /* + Need to use "getAttributeNode" instead of "getAttribute" + because using "getAttribute," IE will return the innerText + of a <button> for the value attribute + rather than the value of the "value" attribute. + */ + + oAttribute = p_oElement.getAttributeNode(p_sAttribute); + + + if (oAttribute && ("value" in oAttribute)) { + + + p_oAttributes[p_sAttribute] = oAttribute.value; + + } + + } + + } + + + /** + * @method setFormElementProperties + * @description Gets the value of the attributes from the form element + * and sets them into the collection of configuration attributes used to + * configure the button. + * @private + */ + function setFormElementProperties() { + + setAttributeFromDOMAttribute("type"); + + if (p_oAttributes.type == "button") { + + p_oAttributes.type = "push"; + + } + + if ( !("disabled" in p_oAttributes) ) { + + p_oAttributes.disabled = p_oElement.disabled; + + } + + setAttributeFromDOMAttribute("name"); + setAttributeFromDOMAttribute("value"); + setAttributeFromDOMAttribute("title"); + + } + + + switch (sSrcElementNodeName) { + + case "A": + + p_oAttributes.type = "link"; + + setAttributeFromDOMAttribute("href"); + setAttributeFromDOMAttribute("target"); + + break; + + case "INPUT": + + setFormElementProperties(); + + if ( !("checked" in p_oAttributes) ) { + + p_oAttributes.checked = p_oElement.checked; + + } + + break; + + case "BUTTON": + + setFormElementProperties(); + + oRootNode = p_oElement.parentNode.parentNode; + + if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-checked")) { + + p_oAttributes.checked = true; + + } + + if (Dom.hasClass(oRootNode, this.CSS_CLASS_NAME + "-disabled")) { + + p_oAttributes.disabled = true; + + } + + p_oElement.removeAttribute("value"); + + p_oElement.setAttribute("type", "button"); + + break; + + } + + p_oElement.removeAttribute("id"); + p_oElement.removeAttribute("name"); + + if ( !("tabindex" in p_oAttributes) ) { + + p_oAttributes.tabindex = p_oElement.tabIndex; + + } + + if ( !("label" in p_oAttributes) ) { + + // Set the "label" property + + sText = sSrcElementNodeName == "INPUT" ? + p_oElement.value : p_oElement.innerHTML; + + + if (sText && sText.length > 0) { + + p_oAttributes.label = sText; + + } + + } + + } + + + /** + * @method initConfig + * @description Initializes the set of configuration attributes that are + * used to instantiate the button. + * @private + * @param {Object} Object representing the button's set of + * configuration attributes. + */ + function initConfig(p_oConfig) { + + var oAttributes = p_oConfig.attributes, + oSrcElement = oAttributes.srcelement, + sSrcElementNodeName = oSrcElement.nodeName.toUpperCase(), + me = this; + + + if (sSrcElementNodeName == this.NODE_NAME) { + + p_oConfig.element = oSrcElement; + p_oConfig.id = oSrcElement.id; + + Dom.getElementsBy(function (p_oElement) { + + switch (p_oElement.nodeName.toUpperCase()) { + + case "BUTTON": + case "A": + case "INPUT": + + setAttributesFromSrcElement.call(me, p_oElement, + oAttributes); + + break; + + } + + }, "*", oSrcElement); + + } + else { + + switch (sSrcElementNodeName) { + + case "BUTTON": + case "A": + case "INPUT": + + setAttributesFromSrcElement.call(this, oSrcElement, + oAttributes); + + break; + + } + + } + + } + + + + // Constructor + + YAHOO.widget.Button = function (p_oElement, p_oAttributes) { + + var fnSuperClass = YAHOO.widget.Button.superclass.constructor, + oConfig, + oElement; + + if (arguments.length == 1 && !Lang.isString(p_oElement) && + !p_oElement.nodeName) { + + if (!p_oElement.id) { + + p_oElement.id = Dom.generateId(); + + + } + + + + fnSuperClass.call(this, + (this.createButtonElement(p_oElement.type)), + p_oElement); + + } + else { + + oConfig = { element: null, attributes: (p_oAttributes || {}) }; + + + if (Lang.isString(p_oElement)) { + + oElement = Dom.get(p_oElement); + + if (oElement) { + + if (!oConfig.attributes.id) { + + oConfig.attributes.id = p_oElement; + + } + + + + + oConfig.attributes.srcelement = oElement; + + initConfig.call(this, oConfig); + + + if (!oConfig.element) { + + + oConfig.element = + this.createButtonElement(oConfig.attributes.type); + + } + + fnSuperClass.call(this, oConfig.element, + oConfig.attributes); + + } + + } + else if (p_oElement.nodeName) { + + if (!oConfig.attributes.id) { + + if (p_oElement.id) { + + oConfig.attributes.id = p_oElement.id; + + } + else { + + oConfig.attributes.id = Dom.generateId(); + + + } + + } + + + + + + oConfig.attributes.srcelement = p_oElement; + + initConfig.call(this, oConfig); + + + if (!oConfig.element) { + + + oConfig.element = + this.createButtonElement(oConfig.attributes.type); + + } + + fnSuperClass.call(this, oConfig.element, oConfig.attributes); + + } + + } + + }; + + + + YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, { + + + // Protected properties + + + /** + * @property _button + * @description Object reference to the button's internal + * <a> or <button> element. + * @default null + * @protected + * @type HTMLAnchorElement|HTMLButtonElement + */ + _button: null, + + + /** + * @property _menu + * @description Object reference to the button's menu. + * @default null + * @protected + * @type {YAHOO.widget.Overlay| + * YAHOO.widget.Menu} + */ + _menu: null, + + + /** + * @property _hiddenFields + * @description Object reference to the <input> + * element, or array of HTML form elements used to represent the button + * when its parent form is submitted. + * @default null + * @protected + * @type HTMLInputElement|Array + */ + _hiddenFields: null, + + + /** + * @property _onclickAttributeValue + * @description Object reference to the button's current value for the + * "onclick" configuration attribute. + * @default null + * @protected + * @type Object + */ + _onclickAttributeValue: null, + + + /** + * @property _activationKeyPressed + * @description Boolean indicating if the key(s) that toggle the button's + * "active" state have been pressed. + * @default false + * @protected + * @type Boolean + */ + _activationKeyPressed: false, + + + /** + * @property _activationButtonPressed + * @description Boolean indicating if the mouse button that toggles + * the button's "active" state has been pressed. + * @default false + * @protected + * @type Boolean + */ + _activationButtonPressed: false, + + + /** + * @property _hasKeyEventHandlers + * @description Boolean indicating if the button's "blur", "keydown" and + * "keyup" event handlers are assigned + * @default false + * @protected + * @type Boolean + */ + _hasKeyEventHandlers: false, + + + /** + * @property _hasMouseEventHandlers + * @description Boolean indicating if the button's "mouseout," + * "mousedown," and "mouseup" event handlers are assigned + * @default false + * @protected + * @type Boolean + */ + _hasMouseEventHandlers: false, + + + + // Constants + + + /** + * @property NODE_NAME + * @description The name of the node to be used for the button's + * root element. + * @default "SPAN" + * @final + * @type String + */ + NODE_NAME: "SPAN", + + + /** + * @property CHECK_ACTIVATION_KEYS + * @description Array of numbers representing keys that (when pressed) + * toggle the button's "checked" attribute. + * @default [32] + * @final + * @type Array + */ + CHECK_ACTIVATION_KEYS: [32], + + + /** + * @property ACTIVATION_KEYS + * @description Array of numbers representing keys that (when presed) + * toggle the button's "active" state. + * @default [13, 32] + * @final + * @type Array + */ + ACTIVATION_KEYS: [13, 32], + + + /** + * @property OPTION_AREA_WIDTH + * @description Width (in pixels) of the area of a split button that + * when pressed will display a menu. + * @default 20 + * @final + * @type Number + */ + OPTION_AREA_WIDTH: 20, + + + /** + * @property CSS_CLASS_NAME + * @description String representing the CSS class(es) to be applied to + * the button's root element. + * @default "yui-button" + * @final + * @type String + */ + CSS_CLASS_NAME: "yui-button", + + + /** + * @property RADIO_DEFAULT_TITLE + * @description String representing the default title applied to buttons + * of type "radio." + * @default "Unchecked. Click to check." + * @final + * @type String + */ + RADIO_DEFAULT_TITLE: "Unchecked. Click to check.", + + + /** + * @property RADIO_CHECKED_TITLE + * @description String representing the title applied to buttons of + * type "radio" when checked. + * @default "Checked. Click to uncheck." + * @final + * @type String + */ + RADIO_CHECKED_TITLE: "Checked. Click to uncheck.", + + + /** + * @property CHECKBOX_DEFAULT_TITLE + * @description String representing the default title applied to + * buttons of type "checkbox." + * @default "Unchecked. Click to check." + * @final + * @type String + */ + CHECKBOX_DEFAULT_TITLE: "Unchecked. Click to check.", + + + /** + * @property CHECKBOX_CHECKED_TITLE + * @description String representing the title applied to buttons of type + * "checkbox" when checked. + * @default "Checked. Click to uncheck." + * @final + * @type String + */ + CHECKBOX_CHECKED_TITLE: "Checked. Click to uncheck.", + + + /** + * @property MENUBUTTON_DEFAULT_TITLE + * @description String representing the default title applied to + * buttons of type "menu." + * @default "Menu collapsed. Click to expand." + * @final + * @type String + */ + MENUBUTTON_DEFAULT_TITLE: "Menu collapsed. Click to expand.", + + + /** + * @property MENUBUTTON_MENU_VISIBLE_TITLE + * @description String representing the title applied to buttons of type + * "menu" when the button's menu is visible. + * @default "Menu expanded. Click or press Esc to collapse." + * @final + * @type String + */ + MENUBUTTON_MENU_VISIBLE_TITLE: + "Menu expanded. Click or press Esc to collapse.", + + + /** + * @property SPLITBUTTON_DEFAULT_TITLE + * @description String representing the default title applied to + * buttons of type "split." + * @default "Menu collapsed. Click inside option region or press + * Ctrl + Shift + M to show the menu." + * @final + * @type String + */ + SPLITBUTTON_DEFAULT_TITLE: ("Menu collapsed. Click inside option " + + "region or press Ctrl + Shift + M to show the menu."), + + + /** + * @property SPLITBUTTON_OPTION_VISIBLE_TITLE + * @description String representing the title applied to buttons of type + * "split" when the button's menu is visible. + * @default "Menu expanded. Press Esc or Ctrl + Shift + M to hide + * the menu." + * @final + * @type String + */ + SPLITBUTTON_OPTION_VISIBLE_TITLE: + "Menu expanded. Press Esc or Ctrl + Shift + M to hide the menu.", + + + /** + * @property SUBMIT_TITLE + * @description String representing the title applied to buttons of + * type "submit." + * @default "Click to submit form." + * @final + * @type String + */ + SUBMIT_TITLE: "Click to submit form.", + + + + // Protected attribute setter methods + + + /** + * @method _setType + * @description Sets the value of the button's "type" attribute. + * @protected + * @param {String} p_sType String indicating the value for the button's + * "type" attribute. + */ + _setType: function (p_sType) { + + if (p_sType == "split") { + + this.on("option", this._onOption); + + } + + }, + + + /** + * @method _setLabel + * @description Sets the value of the button's "label" attribute. + * @protected + * @param {String} p_sLabel String indicating the value for the button's + * "label" attribute. + */ + _setLabel: function (p_sLabel) { + + this._button.innerHTML = p_sLabel; + + }, + + + /** + * @method _setTabIndex + * @description Sets the value of the button's "tabindex" attribute. + * @protected + * @param {Number} p_nTabIndex Number indicating the value for the + * button's "tabindex" attribute. + */ + _setTabIndex: function (p_nTabIndex) { + + this._button.tabIndex = p_nTabIndex; + + }, + + + /** + * @method _setTitle + * @description Sets the value of the button's "title" attribute. + * @protected + * @param {String} p_nTabIndex Number indicating the value for + * the button's "title" attribute. + */ + _setTitle: function (p_sTitle) { + + var sTitle = p_sTitle; + + if (this.get("type") != "link") { + + if (!sTitle) { + + switch (this.get("type")) { + + case "radio": + + sTitle = this.RADIO_DEFAULT_TITLE; + + break; + + case "checkbox": + + sTitle = this.CHECKBOX_DEFAULT_TITLE; + + break; + + case "menu": + + sTitle = this.MENUBUTTON_DEFAULT_TITLE; + + break; + + case "split": + + sTitle = this.SPLITBUTTON_DEFAULT_TITLE; + + break; + + case "submit": + + sTitle = this.SUBMIT_TITLE; + + break; + + } + + } + + this._button.title = sTitle; + + } + + }, + + + /** + * @method _setDisabled + * @description Sets the value of the button's "disabled" attribute. + * @protected + * @param {Boolean} p_bDisabled Boolean indicating the value for + * the button's "disabled" attribute. + */ + _setDisabled: function (p_bDisabled) { + + if (this.get("type") != "link") { + + if (p_bDisabled) { + + if (this._menu) { + + this._menu.hide(); + + } + + if (this.hasFocus()) { + + this.blur(); + + } + + this._button.setAttribute("disabled", "disabled"); + + this.addStateCSSClasses("disabled"); + + } + else { + + this._button.removeAttribute("disabled"); + + this.removeStateCSSClasses("disabled"); + + } + + } + + }, + + + /** + * @method _setHref + * @description Sets the value of the button's "href" attribute. + * @protected + * @param {String} p_sHref String indicating the value for the button's + * "href" attribute. + */ + _setHref: function (p_sHref) { + + if (this.get("type") == "link") { + + this._button.href = p_sHref; + + } + + }, + + + /** + * @method _setTarget + * @description Sets the value of the button's "target" attribute. + * @protected + * @param {String} p_sTarget String indicating the value for the button's + * "target" attribute. + */ + _setTarget: function (p_sTarget) { + + if (this.get("type") == "link") { + + this._button.setAttribute("target", p_sTarget); + + } + + }, + + + /** + * @method _setChecked + * @description Sets the value of the button's "target" attribute. + * @protected + * @param {Boolean} p_bChecked Boolean indicating the value for + * the button's "checked" attribute. + */ + _setChecked: function (p_bChecked) { + + var sType = this.get("type"), + sTitle; + + if (sType == "checkbox" || sType == "radio") { + + if (p_bChecked) { + + this.addStateCSSClasses("checked"); + + sTitle = (sType == "radio") ? + this.RADIO_CHECKED_TITLE : + this.CHECKBOX_CHECKED_TITLE; + + } + else { + + this.removeStateCSSClasses("checked"); + + sTitle = (sType == "radio") ? + this.RADIO_DEFAULT_TITLE : + this.CHECKBOX_DEFAULT_TITLE; + + } + + this.set("title", sTitle); + + } + + }, + + + /** + * @method _setMenu + * @description Sets the value of the button's "menu" attribute. + * @protected + * @param {Object} p_oMenu Object indicating the value for the button's + * "menu" attribute. + */ + _setMenu: function (p_oMenu) { + + var bLazyLoad = this.get("lazyloadmenu"), + oButtonElement = this.get("element"), + + /* + Boolean indicating if the value of p_oMenu is an instance + of YAHOO.widget.Menu or YAHOO.widget.Overlay. + */ + + bInstance = false, + + + oMenu, + oMenuElement, + oSrcElement, + aItems, + nItems, + oItem, + i; + + + if (!Overlay) { + + + return false; + + } + + + if (!Menu) { + + + return false; + + } + + + function onAppendTo() { + + oMenu.render(oButtonElement.parentNode); + + this.removeListener("appendTo", onAppendTo); + + } + + + function initMenu() { + + if (oMenu) { + + Dom.addClass(oMenu.element, this.get("menuclassname")); + Dom.addClass(oMenu.element, + "yui-" + this.get("type") + "-button-menu"); + + oMenu.showEvent.subscribe(this._onMenuShow, null, this); + oMenu.hideEvent.subscribe(this._onMenuHide, null, this); + oMenu.renderEvent.subscribe(this._onMenuRender, null, this); + + + if (oMenu instanceof Menu) { + + oMenu.keyDownEvent.subscribe(this._onMenuKeyDown, + this, true); + + oMenu.clickEvent.subscribe(this._onMenuClick, + this, true); + + oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded, + this, true); + + oSrcElement = oMenu.srcElement; + + if (oSrcElement && + oSrcElement.nodeName.toUpperCase() == "SELECT") { + + oSrcElement.style.display = "none"; + oSrcElement.parentNode.removeChild(oSrcElement); + + } + + } + else if (oMenu instanceof Overlay) { + + if (!m_oOverlayManager) { + + m_oOverlayManager = + new YAHOO.widget.OverlayManager(); + + } + + m_oOverlayManager.register(oMenu); + + } + + + this._menu = oMenu; + + + if (!bInstance) { + + if (bLazyLoad && !(oMenu instanceof Menu)) { + + /* + Mimic Menu's "lazyload" functionality by adding + a "beforeshow" event listener that renders the + Overlay instance before it is made visible by + the button. + */ + + oMenu.beforeShowEvent.subscribe( + this._onOverlayBeforeShow, null, this); + + } + else if (!bLazyLoad) { + + if (Dom.inDocument(oButtonElement)) { + + oMenu.render(oButtonElement.parentNode); + + } + else { + + this.on("appendTo", onAppendTo); + + } + + } + + } + + } + + } + + + if (p_oMenu && (p_oMenu instanceof Menu)) { + + oMenu = p_oMenu; + aItems = oMenu.getItems(); + nItems = aItems.length; + bInstance = true; + + + if (nItems > 0) { + + i = nItems - 1; + + do { + + oItem = aItems[i]; + + if (oItem) { + + oItem.cfg.subscribeToConfigEvent("selected", + this._onMenuItemSelected, + oItem, + this); + + } + + } + while (i--); + + } + + initMenu.call(this); + + } + else if (p_oMenu && (p_oMenu instanceof Overlay)) { + + oMenu = p_oMenu; + bInstance = true; + + oMenu.cfg.setProperty("visible", false); + oMenu.cfg.setProperty("context", [oButtonElement, "tl", "bl"]); + + initMenu.call(this); + + } + else if (Lang.isArray(p_oMenu)) { + + this.on("appendTo", function () { + + oMenu = new Menu(Dom.generateId(), { lazyload: bLazyLoad, + itemdata: p_oMenu }); + + initMenu.call(this); + + }); + + } + else if (Lang.isString(p_oMenu)) { + + oMenuElement = Dom.get(p_oMenu); + + if (oMenuElement) { + + if (Dom.hasClass(oMenuElement, + Menu.prototype.CSS_CLASS_NAME) || + oMenuElement.nodeName == "SELECT") { + + oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad }); + + initMenu.call(this); + + } + else { + + oMenu = new Overlay(p_oMenu, { visible: false, + context: [oButtonElement, "tl", "bl"] }); + + initMenu.call(this); + + } + + } + + } + else if (p_oMenu && p_oMenu.nodeName) { + + if (Dom.hasClass(p_oMenu, Menu.prototype.CSS_CLASS_NAME) || + p_oMenu.nodeName == "SELECT") { + + oMenu = new Menu(p_oMenu, { lazyload: bLazyLoad }); + + initMenu.call(this); + + } + else { + + if (!p_oMenu.id) { + + Dom.generateId(p_oMenu); + + } + + oMenu = new Overlay(p_oMenu, { visible: false, + context: [oButtonElement, "tl", "bl"] }); + + initMenu.call(this); + + } + + } + + }, + + + /** + * @method _setOnClick + * @description Sets the value of the button's "onclick" attribute. + * @protected + * @param {Object} p_oObject Object indicating the value for the button's + * "onclick" attribute. + */ + _setOnClick: function (p_oObject) { + + /* + Remove any existing listeners if a "click" event handler + has already been specified. + */ + + if (this._onclickAttributeValue && + (this._onclickAttributeValue != p_oObject)) { + + this.removeListener("click", this._onclickAttributeValue.fn); + + this._onclickAttributeValue = null; + + } + + + if (!this._onclickAttributeValue && + Lang.isObject(p_oObject) && + Lang.isFunction(p_oObject.fn)) { + + this.on("click", p_oObject.fn, p_oObject.obj, p_oObject.scope); + + this._onclickAttributeValue = p_oObject; + + } + + }, + + + /** + * @method _setSelectedMenuItem + * @description Sets the value of the button's + * "selectedMenuItem" attribute. + * @protected + * @param {Number} p_nIndex Number representing the index of the item + * in the button's menu that is currently selected. + */ + _setSelectedMenuItem: function (p_nIndex) { + + var oMenu = this._menu, + oMenuItem; + + + if (oMenu && oMenu instanceof Menu) { + + oMenuItem = oMenu.getItem(p_nIndex); + + + if (oMenuItem && !oMenuItem.cfg.getProperty("selected")) { + + oMenuItem.cfg.setProperty("selected", true); + + } + + } + + }, + + + // Protected methods + + + + /** + * @method _isActivationKey + * @description Determines if the specified keycode is one that toggles + * the button's "active" state. + * @protected + * @param {Number} p_nKeyCode Number representing the keycode to + * be evaluated. + * @return {Boolean} + */ + _isActivationKey: function (p_nKeyCode) { + + var sType = this.get("type"), + aKeyCodes = (sType == "checkbox" || sType == "radio") ? + this.CHECK_ACTIVATION_KEYS : this.ACTIVATION_KEYS, + + nKeyCodes = aKeyCodes.length, + i; + + if (nKeyCodes > 0) { + + i = nKeyCodes - 1; + + do { + + if (p_nKeyCode == aKeyCodes[i]) { + + return true; + + } + + } + while (i--); + + } + + }, + + + /** + * @method _isSplitButtonOptionKey + * @description Determines if the specified keycode is one that toggles + * the display of the split button's menu. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + * @return {Boolean} + */ + _isSplitButtonOptionKey: function (p_oEvent) { + + return (p_oEvent.ctrlKey && p_oEvent.shiftKey && + Event.getCharCode(p_oEvent) == 77); + + }, + + + /** + * @method _addListenersToForm + * @description Adds event handlers to the button's form. + * @protected + */ + _addListenersToForm: function () { + + var oForm = this.getForm(), + oSrcElement, + aListeners, + nListeners, + i, + bHasKeyPressListener; + + + if (oForm) { + + Event.on(oForm, "reset", this._onFormReset, null, this); + Event.on(oForm, "submit", this.createHiddenFields, null, this); + + oSrcElement = this.get("srcelement"); + + + if (this.get("type") == "submit" || + (oSrcElement && oSrcElement.type == "submit")) + { + + aListeners = Event.getListeners(oForm, "keypress"); + bHasKeyPressListener = false; + + if (aListeners) { + + nListeners = aListeners.length; + + if (nListeners > 0) { + + i = nListeners - 1; + + do { + + if (aListeners[i].fn == + YAHOO.widget.Button.onFormKeyPress) + { + + bHasKeyPressListener = true; + break; + + } + + } + while (i--); + + } + + } + + + if (!bHasKeyPressListener) { + + Event.on(oForm, "keypress", + YAHOO.widget.Button.onFormKeyPress); + + } + + } + + } + + }, + + + _originalMaxHeight: -1, + + + /** + * @method _showMenu + * @description Shows the button's menu. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event) that triggered + * the display of the menu. + */ + _showMenu: function (p_oEvent) { + + YAHOO.widget.MenuManager.hideVisible(); + + if (m_oOverlayManager) { + + m_oOverlayManager.hideAll(); + + } + + + var oMenu = this._menu, + nViewportHeight = Dom.getViewportHeight(), + nMenuHeight, + nScrollTop, + nY; + + + if (oMenu && (oMenu instanceof Menu)) { + + oMenu.cfg.applyConfig({ context: [this.get("id"), "tl", "bl"], + constraintoviewport: false, + clicktohide: false, + visible: true }); + + oMenu.cfg.fireQueue(); + + oMenu.align("tl", "bl"); + + /* + Stop the propagation of the event so that the MenuManager + doesn't blur the menu after it gets focus. + */ + + if (p_oEvent.type == "mousedown") { + + Event.stopPropagation(p_oEvent); + + } + + + if (this.get("focusmenu")) { + + this._menu.focus(); + + } + + nMenuHeight = oMenu.element.offsetHeight; + + + if ((oMenu.cfg.getProperty("y") + nMenuHeight) > + nViewportHeight) { + + + oMenu.align("bl", "tl"); + + nY = oMenu.cfg.getProperty("y"); + + nScrollTop = Dom.getDocumentScrollTop(); + + + if (nScrollTop >= nY) { + + if (this._originalMaxHeight == -1) { + + this._originalMaxHeight = + oMenu.cfg.getProperty("maxheight"); + + } + + oMenu.cfg.setProperty("maxheight", + (nMenuHeight - ((nScrollTop - nY) + 20))); + + oMenu.align("bl", "tl"); + + } + + } + + } + else if (oMenu && (oMenu instanceof Overlay)) { + + oMenu.show(); + oMenu.align("tl", "bl"); + + nMenuHeight = oMenu.element.offsetHeight; + + + if ((oMenu.cfg.getProperty("y") + nMenuHeight) > + nViewportHeight) { + + + oMenu.align("bl", "tl"); + + } + + } + + }, + + + /** + * @method _hideMenu + * @description Hides the button's menu. + * @protected + */ + _hideMenu: function () { + + var oMenu = this._menu; + + if (oMenu) { + + oMenu.hide(); + + } + + }, + + + + + // Protected event handlers + + + /** + * @method _onMouseOver + * @description "mouseover" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onMouseOver: function (p_oEvent) { + + if (!this._hasMouseEventHandlers) { + + this.on("mouseout", this._onMouseOut); + this.on("mousedown", this._onMouseDown); + this.on("mouseup", this._onMouseUp); + + this._hasMouseEventHandlers = true; + + } + + this.addStateCSSClasses("hover"); + + if (this._activationButtonPressed) { + + this.addStateCSSClasses("active"); + + } + + + if (this._bOptionPressed) { + + this.addStateCSSClasses("activeoption"); + + } + + }, + + + /** + * @method _onMouseOut + * @description "mouseout" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onMouseOut: function (p_oEvent) { + + this.removeStateCSSClasses("hover"); + + if (this.get("type") != "menu") { + + this.removeStateCSSClasses("active"); + + } + + if (this._activationButtonPressed || this._bOptionPressed) { + + Event.on(document, "mouseup", this._onDocumentMouseUp, + null, this); + + } + + }, + + + /** + * @method _onDocumentMouseUp + * @description "mouseup" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onDocumentMouseUp: function (p_oEvent) { + + this._activationButtonPressed = false; + this._bOptionPressed = false; + + var sType = this.get("type"); + + if (sType == "menu" || sType == "split") { + + this.removeStateCSSClasses( + (sType == "menu" ? "active" : "activeoption")); + + this._hideMenu(); + + } + + Event.removeListener(document, "mouseup", this._onDocumentMouseUp); + + }, + + + /** + * @method _onMouseDown + * @description "mousedown" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onMouseDown: function (p_oEvent) { + + var sType, + oElement, + nX, + me; + + + function onMouseUp() { + + this._hideMenu(); + this.removeListener("mouseup", onMouseUp); + + } + + + if ((p_oEvent.which || p_oEvent.button) == 1) { + + + if (!this.hasFocus()) { + + this.focus(); + + } + + + sType = this.get("type"); + + + if (sType == "split") { + + oElement = this.get("element"); + nX = Event.getPageX(p_oEvent) - Dom.getX(oElement); + + if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) { + + this.fireEvent("option", p_oEvent); + + } + else { + + this.addStateCSSClasses("active"); + + this._activationButtonPressed = true; + + } + + } + else if (sType == "menu") { + + if (this.isActive()) { + + this._hideMenu(); + + this._activationButtonPressed = false; + + } + else { + + this._showMenu(p_oEvent); + + this._activationButtonPressed = true; + + } + + } + else { + + this.addStateCSSClasses("active"); + + this._activationButtonPressed = true; + + } + + + + if (sType == "split" || sType == "menu") { + + me = this; + + this._hideMenuTimerId = window.setTimeout(function () { + + me.on("mouseup", onMouseUp); + + }, 250); + + } + + } + + }, + + + /** + * @method _onMouseUp + * @description "mouseup" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onMouseUp: function (p_oEvent) { + + var sType = this.get("type"); + + + if (this._hideMenuTimerId) { + + window.clearTimeout(this._hideMenuTimerId); + + } + + + if (sType == "checkbox" || sType == "radio") { + + this.set("checked", !(this.get("checked"))); + + } + + + this._activationButtonPressed = false; + + + if (this.get("type") != "menu") { + + this.removeStateCSSClasses("active"); + + } + + }, + + + /** + * @method _onFocus + * @description "focus" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onFocus: function (p_oEvent) { + + var oElement; + + this.addStateCSSClasses("focus"); + + if (this._activationKeyPressed) { + + this.addStateCSSClasses("active"); + + } + + m_oFocusedButton = this; + + + if (!this._hasKeyEventHandlers) { + + oElement = this._button; + + Event.on(oElement, "blur", this._onBlur, null, this); + Event.on(oElement, "keydown", this._onKeyDown, null, this); + Event.on(oElement, "keyup", this._onKeyUp, null, this); + + this._hasKeyEventHandlers = true; + + } + + + this.fireEvent("focus", p_oEvent); + + }, + + + /** + * @method _onBlur + * @description "blur" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onBlur: function (p_oEvent) { + + this.removeStateCSSClasses("focus"); + + if (this.get("type") != "menu") { + + this.removeStateCSSClasses("active"); + + } + + if (this._activationKeyPressed) { + + Event.on(document, "keyup", this._onDocumentKeyUp, null, this); + + } + + + m_oFocusedButton = null; + + this.fireEvent("blur", p_oEvent); + + }, + + + /** + * @method _onDocumentKeyUp + * @description "keyup" event handler for the document. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onDocumentKeyUp: function (p_oEvent) { + + if (this._isActivationKey(Event.getCharCode(p_oEvent))) { + + this._activationKeyPressed = false; + + Event.removeListener(document, "keyup", this._onDocumentKeyUp); + + } + + }, + + + /** + * @method _onKeyDown + * @description "keydown" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onKeyDown: function (p_oEvent) { + + var oMenu = this._menu; + + + if (this.get("type") == "split" && + this._isSplitButtonOptionKey(p_oEvent)) { + + this.fireEvent("option", p_oEvent); + + } + else if (this._isActivationKey(Event.getCharCode(p_oEvent))) { + + if (this.get("type") == "menu") { + + this._showMenu(p_oEvent); + + } + else { + + this._activationKeyPressed = true; + + this.addStateCSSClasses("active"); + + } + + } + + + if (oMenu && oMenu.cfg.getProperty("visible") && + Event.getCharCode(p_oEvent) == 27) { + + oMenu.hide(); + this.focus(); + + } + + }, + + + /** + * @method _onKeyUp + * @description "keyup" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onKeyUp: function (p_oEvent) { + + var sType; + + if (this._isActivationKey(Event.getCharCode(p_oEvent))) { + + sType = this.get("type"); + + if (sType == "checkbox" || sType == "radio") { + + this.set("checked", !(this.get("checked"))); + + } + + this._activationKeyPressed = false; + + if (this.get("type") != "menu") { + + this.removeStateCSSClasses("active"); + + } + + } + + }, + + + /** + * @method _onClick + * @description "click" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onClick: function (p_oEvent) { + + var sType = this.get("type"), + sTitle, + oForm, + oSrcElement, + oElement, + nX; + + + switch (sType) { + + case "radio": + case "checkbox": + + if (this.get("checked")) { + + sTitle = (sType == "radio") ? + this.RADIO_CHECKED_TITLE : + this.CHECKBOX_CHECKED_TITLE; + + } + else { + + sTitle = (sType == "radio") ? + this.RADIO_DEFAULT_TITLE : + this.CHECKBOX_DEFAULT_TITLE; + + } + + this.set("title", sTitle); + + break; + + case "submit": + + this.submitForm(); + + break; + + case "reset": + + oForm = this.getForm(); + + if (oForm) { + + oForm.reset(); + + } + + break; + + case "menu": + + sTitle = this._menu.cfg.getProperty("visible") ? + this.MENUBUTTON_MENU_VISIBLE_TITLE : + this.MENUBUTTON_DEFAULT_TITLE; + + this.set("title", sTitle); + + break; + + case "split": + + oElement = this.get("element"); + nX = Event.getPageX(p_oEvent) - Dom.getX(oElement); + + if ((oElement.offsetWidth - this.OPTION_AREA_WIDTH) < nX) { + + return false; + + } + else { + + this._hideMenu(); + + oSrcElement = this.get("srcelement"); + + if (oSrcElement && oSrcElement.type == "submit") { + + this.submitForm(); + + } + + } + + sTitle = this._menu.cfg.getProperty("visible") ? + this.SPLITBUTTON_OPTION_VISIBLE_TITLE : + this.SPLITBUTTON_DEFAULT_TITLE; + + this.set("title", sTitle); + + break; + + } + + }, + + + /** + * @method _onAppendTo + * @description "appendTo" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onAppendTo: function (p_oEvent) { + + /* + It is necessary to call "getForm" using "setTimeout" to make + sure that the button's "form" property returns a node + reference. Sometimes, if you try to get the reference + immediately after appending the field, it is null. + */ + + var me = this; + + window.setTimeout(function () { + + me._addListenersToForm(); + + }, 0); + + }, + + + /** + * @method _onFormReset + * @description "reset" event handler for the button's form. + * @protected + * @param {Event} p_oEvent Object representing the DOM event + * object passed back by the event utility (YAHOO.util.Event). + */ + _onFormReset: function (p_oEvent) { + + var sType = this.get("type"), + oMenu = this._menu; + + if (sType == "checkbox" || sType == "radio") { + + this.resetValue("checked"); + + } + + + if (oMenu && (oMenu instanceof Menu)) { + + this.resetValue("selectedMenuItem"); + + } + + }, + + + /** + * @method _onDocumentMouseDown + * @description "mousedown" event handler for the document. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onDocumentMouseDown: function (p_oEvent) { + + var oTarget = Event.getTarget(p_oEvent), + oButtonElement = this.get("element"), + oMenuElement = this._menu.element; + + if (oTarget != oButtonElement && + !Dom.isAncestor(oButtonElement, oTarget) && + oTarget != oMenuElement && + !Dom.isAncestor(oMenuElement, oTarget)) { + + this._hideMenu(); + + Event.removeListener(document, "mousedown", + this._onDocumentMouseDown); + + } + + }, + + + /** + * @method _onOption + * @description "option" event handler for the button. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onOption: function (p_oEvent) { + + if (this.hasClass("yui-split-button-activeoption")) { + + this._hideMenu(); + + this._bOptionPressed = false; + + } + else { + + this._showMenu(p_oEvent); + + this._bOptionPressed = true; + + } + + }, + + + /** + * @method _onOverlayBeforeShow + * @description "beforeshow" event handler for the + * YAHOO.widget.Overlay instance + * serving as the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + */ + _onOverlayBeforeShow: function (p_sType) { + + var oMenu = this._menu; + + oMenu.render(this.get("element").parentNode); + + oMenu.beforeShowEvent.unsubscribe(this._onOverlayBeforeShow); + + }, + + + /** + * @method _onMenuShow + * @description "show" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + */ + _onMenuShow: function (p_sType) { + + Event.on(document, "mousedown", this._onDocumentMouseDown, + null, this); + + var sTitle, + sState; + + if (this.get("type") == "split") { + + sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE; + sState = "activeoption"; + + } + else { + + sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE; + sState = "active"; + + } + + this.addStateCSSClasses(sState); + this.set("title", sTitle); + + }, + + + /** + * @method _onMenuHide + * @description "hide" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + */ + _onMenuHide: function (p_sType) { + + var oMenu = this._menu, + sTitle, + sState; + + if (oMenu && (oMenu instanceof Menu) && + this._originalMaxHeight != -1) { + + this._menu.cfg.setProperty("maxheight", + this._originalMaxHeight); + + } + + + if (this.get("type") == "split") { + + sTitle = this.SPLITBUTTON_DEFAULT_TITLE; + sState = "activeoption"; + + } + else { + + sTitle = this.MENUBUTTON_DEFAULT_TITLE; + sState = "active"; + } + + + this.removeStateCSSClasses(sState); + this.set("title", sTitle); + + + if (this.get("type") == "split") { + + this._bOptionPressed = false; + + } + + }, + + + /** + * @method _onMenuKeyDown + * @description "keydown" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + * @param {Array} p_aArgs Array of arguments sent when the event + * was fired. + */ + _onMenuKeyDown: function (p_sType, p_aArgs) { + + var oEvent = p_aArgs[0]; + + if (Event.getCharCode(oEvent) == 27) { + + this.focus(); + + if (this.get("type") == "split") { + + this._bOptionPressed = false; + + } + + } + + }, + + + /** + * @method _onMenuRender + * @description "render" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the + * event thatwas fired. + */ + _onMenuRender: function (p_sType) { + + var oButtonElement = this.get("element"), + oButtonParent = oButtonElement.parentNode, + oMenuElement = this._menu.element; + + + if (oButtonParent != oMenuElement.parentNode) { + + oButtonParent.appendChild(oMenuElement); + + } + + this.set("selectedMenuItem", this.get("selectedMenuItem")); + + }, + + + /** + * @method _onMenuItemSelected + * @description "selectedchange" event handler for each item in the + * button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + * @param {Array} p_aArgs Array of arguments sent when the event + * was fired. + * @param {Number} p_nItem Number representing the index of the menu + * item that subscribed to the event. + */ + _onMenuItemSelected: function (p_sType, p_aArgs, p_nItem) { + + var bSelected = p_aArgs[0]; + + if (bSelected) { + + this.set("selectedMenuItem", p_nItem); + + } + + }, + + + /** + * @method _onMenuItemAdded + * @description "itemadded" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + * @param {Array} p_aArgs Array of arguments sent when the event + * was fired. + * @param { + * YAHOO.widget.MenuItem} p_oItem Object representing the menu + * item that subscribed to the event. + */ + _onMenuItemAdded: function (p_sType, p_aArgs, p_oItem) { + + var oItem = p_aArgs[0]; + + oItem.cfg.subscribeToConfigEvent("selected", + this._onMenuItemSelected, + oItem.index, + this); + + }, + + + /** + * @method _onMenuClick + * @description "click" event handler for the button's menu. + * @private + * @param {String} p_sType String representing the name of the event + * that was fired. + * @param {Array} p_aArgs Array of arguments sent when the event + * was fired. + */ + _onMenuClick: function (p_sType, p_aArgs) { + + var oItem = p_aArgs[1], + oSrcElement; + + if (oItem) { + + oSrcElement = this.get("srcelement"); + + if (oSrcElement && oSrcElement.type == "submit") { + + this.submitForm(); + + } + + this._hideMenu(); + + } + + }, + + + + // Public methods + + + /** + * @method createButtonElement + * @description Creates the button's HTML elements. + * @param {String} p_sType String indicating the type of element + * to create. + * @return {HTMLElement} + */ + createButtonElement: function (p_sType) { + + var sNodeName = this.NODE_NAME, + oElement = document.createElement(sNodeName); + + oElement.innerHTML = "<" + sNodeName + " class=\"first-child\">" + + (p_sType == "link" ? "" : + "") + ""; + + return oElement; + + }, + + + /** + * @method addStateCSSClasses + * @description Appends state-specific CSS classes to the button's root + * DOM element. + */ + addStateCSSClasses: function (p_sState) { + + var sType = this.get("type"); + + if (Lang.isString(p_sState)) { + + if (p_sState != "activeoption") { + + this.addClass(this.CSS_CLASS_NAME + ("-" + p_sState)); + + } + + this.addClass("yui-" + sType + ("-button-" + p_sState)); + + } + + }, + + + /** + * @method removeStateCSSClasses + * @description Removes state-specific CSS classes to the button's root + * DOM element. + */ + removeStateCSSClasses: function (p_sState) { + + var sType = this.get("type"); + + if (Lang.isString(p_sState)) { + + this.removeClass(this.CSS_CLASS_NAME + ("-" + p_sState)); + this.removeClass("yui-" + sType + ("-button-" + p_sState)); + + } + + }, + + + /** + * @method createHiddenFields + * @description Creates the button's hidden form field and appends it + * to its parent form. + * @return {HTMLInputElement|Array} + */ + createHiddenFields: function () { + + this.removeHiddenFields(); + + var oForm = this.getForm(), + oButtonField, + sType, + bCheckable, + oMenu, + oMenuItem, + sName, + oValue, + oMenuField; + + + if (oForm && !this.get("disabled")) { + + sType = this.get("type"); + bCheckable = (sType == "checkbox" || sType == "radio"); + + + if (bCheckable || (m_oSubmitTrigger == this)) { + + + oButtonField = createInputElement( + (bCheckable ? sType : "hidden"), + this.get("name"), + this.get("value"), + this.get("checked")); + + + if (oButtonField) { + + if (bCheckable) { + + oButtonField.style.display = "none"; + + } + + oForm.appendChild(oButtonField); + + } + + } + + + oMenu = this._menu; + + + if (oMenu && (oMenu instanceof Menu)) { + + + oMenuField = oMenu.srcElement; + oMenuItem = oMenu.getItem(this.get("selectedMenuItem")); + + if (oMenuField && + oMenuField.nodeName.toUpperCase() == "SELECT") { + + oForm.appendChild(oMenuField); + oMenuField.selectedIndex = oMenuItem.index; + + } + else { + + oValue = (oMenuItem.value === null || + oMenuItem.value === "") ? + oMenuItem.cfg.getProperty("text") : + oMenuItem.value; + + sName = this.get("name"); + + if (oValue && sName) { + + oMenuField = createInputElement("hidden", + (sName + "_options"), + oValue); + + oForm.appendChild(oMenuField); + + } + + } + + } + + + if (oButtonField && oMenuField) { + + this._hiddenFields = [oButtonField, oMenuField]; + + } + else if (!oButtonField && oMenuField) { + + this._hiddenFields = oMenuField; + + } + else if (oButtonField && !oMenuField) { + + this._hiddenFields = oButtonField; + + } + + + return this._hiddenFields; + + } + + }, + + + /** + * @method removeHiddenFields + * @description Removes the button's hidden form field(s) from its + * parent form. + */ + removeHiddenFields: function () { + + var oField = this._hiddenFields, + nFields, + i; + + function removeChild(p_oElement) { + + if (Dom.inDocument(p_oElement)) { + + p_oElement.parentNode.removeChild(p_oElement); + + } + + } + + + if (oField) { + + if (Lang.isArray(oField)) { + + nFields = oField.length; + + if (nFields > 0) { + + i = nFields - 1; + + do { + + removeChild(oField[i]); + + } + while (i--); + + } + + } + else { + + removeChild(oField); + + } + + this._hiddenFields = null; + + } + + }, + + + /** + * @method submitForm + * @description Submits the form to which the button belongs. Returns + * true if the form was submitted successfully, false if the submission + * was cancelled. + * @protected + * @return {Boolean} + */ + submitForm: function () { + + var oForm = this.getForm(), + + oSrcElement = this.get("srcelement"), + + /* + Boolean indicating if the event fired successfully + (was not cancelled by any handlers) + */ + + bSubmitForm = false, + + oEvent; + + + if (oForm) { + + if (this.get("type") == "submit" || + (oSrcElement && oSrcElement.type == "submit")) + { + + m_oSubmitTrigger = this; + + } + + + if (YAHOO.env.ua.ie) { + + bSubmitForm = oForm.fireEvent("onsubmit"); + + } + else { // Gecko, Opera, and Safari + + oEvent = document.createEvent("HTMLEvents"); + oEvent.initEvent("submit", true, true); + + bSubmitForm = oForm.dispatchEvent(oEvent); + + } + + + /* + In IE and Safari, dispatching a "submit" event to a form + WILL cause the form's "submit" event to fire, but WILL NOT + submit the form. Therefore, we need to call the "submit" + method as well. + */ + + if ((YAHOO.env.ua.ie || YAHOO.env.ua.webkit) && bSubmitForm) { + + oForm.submit(); + + } + + } + + return bSubmitForm; + + }, + + + /** + * @method init + * @description The Button class's initialization method. + * @param {String} p_oElement String specifying the id attribute of the + * <input>, <button>, + * <a>, or <span> element to + * be used to create the button. + * @param {HTMLInputElement|HTMLButtonElement| + * HTMLElement} p_oElement Object reference for the + * <input>, <button>, + * <a>, or <span> element to be + * used to create the button. + * @param {Object} p_oElement Object literal specifying a set of + * configuration attributes used to create the button. + * @param {Object} p_oAttributes Optional. Object literal specifying a + * set of configuration attributes used to create the button. + */ + init: function (p_oElement, p_oAttributes) { + + var sNodeName = p_oAttributes.type == "link" ? "A" : "BUTTON", + oSrcElement = p_oAttributes.srcelement, + oButton = p_oElement.getElementsByTagName(sNodeName)[0], + oInput; + + + if (!oButton) { + + oInput = p_oElement.getElementsByTagName("INPUT")[0]; + + + if (oInput) { + + oButton = document.createElement("BUTTON"); + oButton.setAttribute("type", "button"); + + oInput.parentNode.replaceChild(oButton, oInput); + + } + + } + + this._button = oButton; + + + YAHOO.widget.Button.superclass.init.call(this, p_oElement, + p_oAttributes); + + + m_oButtons[this.get("id")] = this; + + + this.addClass(this.CSS_CLASS_NAME); + + this.addClass("yui-" + this.get("type") + "-button"); + + Event.on(this._button, "focus", this._onFocus, null, this); + this.on("mouseover", this._onMouseOver); + this.on("click", this._onClick); + this.on("appendTo", this._onAppendTo); + + + var oContainer = this.get("container"), + oElement = this.get("element"), + bElInDoc = Dom.inDocument(oElement), + oParentNode; + + + if (oContainer) { + + if (oSrcElement && oSrcElement != oElement) { + + oParentNode = oSrcElement.parentNode; + + if (oParentNode) { + + oParentNode.removeChild(oSrcElement); + + } + + } + + if (Lang.isString(oContainer)) { + + Event.onContentReady(oContainer, function () { + + this.appendTo(oContainer); + + }, null, this); + + } + else { + + this.appendTo(oContainer); + + } + + } + else if (!bElInDoc && oSrcElement && oSrcElement != oElement) { + + oParentNode = oSrcElement.parentNode; + + if (oParentNode) { + + this.fireEvent("beforeAppendTo", { + type: "beforeAppendTo", + target: oParentNode + }); + + oParentNode.replaceChild(oElement, oSrcElement); + + this.fireEvent("appendTo", { + type: "appendTo", + target: oParentNode + }); + + } + + } + else if (this.get("type") != "link" && bElInDoc && oSrcElement && + oSrcElement == oElement) { + + this._addListenersToForm(); + + } + + + }, + + + /** + * @method initAttributes + * @description Initializes all of the configuration attributes used to + * create the button. + * @param {Object} p_oAttributes Object literal specifying a set of + * configuration attributes used to create the button. + */ + initAttributes: function (p_oAttributes) { + + var oAttributes = p_oAttributes || {}; + + YAHOO.widget.Button.superclass.initAttributes.call(this, + oAttributes); + + + /** + * @config type + * @description String specifying the button's type. Possible + * values are: "push," "link," "submit," "reset," "checkbox," + * "radio," "menu," and "split." + * @default "push" + * @type String + */ + this.setAttributeConfig("type", { + + value: (oAttributes.type || "push"), + validator: Lang.isString, + writeOnce: true, + method: this._setType + + }); + + + /** + * @config label + * @description String specifying the button's text label + * or innerHTML. + * @default null + * @type String + */ + this.setAttributeConfig("label", { + + value: oAttributes.label, + validator: Lang.isString, + method: this._setLabel + + }); + + + /** + * @config value + * @description Object specifying the value for the button. + * @default null + * @type Object + */ + this.setAttributeConfig("value", { + + value: oAttributes.value + + }); + + + /** + * @config name + * @description String specifying the name for the button. + * @default null + * @type String + */ + this.setAttributeConfig("name", { + + value: oAttributes.name, + validator: Lang.isString + + }); + + + /** + * @config tabindex + * @description Number specifying the tabindex for the button. + * @default null + * @type Number + */ + this.setAttributeConfig("tabindex", { + + value: oAttributes.tabindex, + validator: Lang.isNumber, + method: this._setTabIndex + + }); + + + /** + * @config title + * @description String specifying the title for the button. + * @default null + * @type String + */ + this.configureAttribute("title", { + + value: oAttributes.title, + validator: Lang.isString, + method: this._setTitle + + }); + + + /** + * @config disabled + * @description Boolean indicating if the button should be disabled. + * (Disabled buttons are dimmed and will not respond to user input + * or fire events. Does not apply to button's of type "link.") + * @default false + * @type Boolean + */ + this.setAttributeConfig("disabled", { + + value: (oAttributes.disabled || false), + validator: Lang.isBoolean, + method: this._setDisabled + + }); + + + /** + * @config href + * @description String specifying the href for the button. Applies + * only to buttons of type "link." + * @type String + */ + this.setAttributeConfig("href", { + + value: oAttributes.href, + validator: Lang.isString, + method: this._setHref + + }); + + + /** + * @config target + * @description String specifying the target for the button. + * Applies only to buttons of type "link." + * @type String + */ + this.setAttributeConfig("target", { + + value: oAttributes.target, + validator: Lang.isString, + method: this._setTarget + + }); + + + /** + * @config checked + * @description Boolean indicating if the button is checked. + * Applies only to buttons of type "radio" and "checkbox." + * @default false + * @type Boolean + */ + this.setAttributeConfig("checked", { + + value: (oAttributes.checked || false), + validator: Lang.isBoolean, + method: this._setChecked + + }); + + + /** + * @config container + * @description HTML element reference or string specifying the id + * attribute of the HTML element that the button's markup should be + * rendered into. + * @type HTMLElement|String + * @default null + */ + this.setAttributeConfig("container", { + + value: oAttributes.container, + writeOnce: true + + }); + + + /** + * @config srcelement + * @description Object reference to the HTML element (either + * <input> or <span>) + * used to create the button. + * @type HTMLElement|String + * @default null + */ + this.setAttributeConfig("srcelement", { + + value: oAttributes.srcelement, + writeOnce: true + + }); + + + /** + * @config menu + * @description Object specifying the menu for the button. + * The value can be one of the following: + *
    + *
  • Object specifying a + * YAHOO.widget.Menu instance.
  • + *
  • Object specifying a + * YAHOO.widget.Overlay instance.
  • + *
  • String specifying the id attribute of the <div> + * element used to create the menu. By default the menu + * will be created as an instance of + * YAHOO.widget.Overlay. + * If the + * default CSS class name for YAHOO.widget.Menu is applied to + * the <div> element, it will be created as an + * instance of YAHOO.widget.Menu + * .
  • String specifying the id attribute of the + * <select> element used to create the menu. + *
  • Object specifying the <div> element + * used to create the menu.
  • + *
  • Object specifying the <select> element + * used to create the menu.
  • + *
  • Array of object literals, each representing a set of + * YAHOO.widget.MenuItem + * configuration attributes.
  • + *
  • Array of strings representing the text labels for each menu + * item in the menu.
  • + *
+ * @type YAHOO.widget.Menu|YAHOO.widget.Overlay|HTMLElement|String|Array + * @default null + */ + this.setAttributeConfig("menu", { + + value: null, + method: this._setMenu, + writeOnce: true + + }); + + + /** + * @config lazyloadmenu + * @description Boolean indicating the value to set for the + * "lazyload" + * configuration property of the button's menu. Setting + * "lazyloadmenu" to true will defer rendering of + * the button's menu until the first time it is made visible. + * If "lazyloadmenu" is set to false, the button's + * menu will be rendered immediately if the button is in the + * document, or in response to the button's "appendTo" event if + * the button is not yet in the document. In either case, the + * menu is rendered into the button's parent HTML element. + * This attribute does not apply if a + * YAHOO.widget.Menu or + * YAHOO.widget.Overlay + * instance is passed as the value of the button's "menu" + * configuration attribute. + * YAHOO.widget.Menu or + * YAHOO.widget.Overlay instances should be rendered before + * being set as the value for the "menu" configuration + * attribute. + * @default true + * @type Boolean + */ + this.setAttributeConfig("lazyloadmenu", { + + value: (oAttributes.lazyloadmenu === false ? false : true), + validator: Lang.isBoolean, + writeOnce: true + + }); + + + /** + * @config menuclassname + * @description String representing the CSS class name to be + * applied to the root element of the button's menu. + * @type String + * @default "yui-button-menu" + */ + this.setAttributeConfig("menuclassname", { + + value: (oAttributes.menuclassname || "yui-button-menu"), + validator: Lang.isString, + method: this._setMenuClassName, + writeOnce: true + + }); + + + /** + * @config selectedMenuItem + * @description Number representing the index of the item in the + * button's menu that is currently selected. + * @type Number + * @default null + */ + this.setAttributeConfig("selectedMenuItem", { + + value: 0, + validator: Lang.isNumber, + method: this._setSelectedMenuItem + + }); + + + /** + * @config onclick + * @description Object literal representing the code to be executed + * when the button is clicked. Format:
{
+ * fn: Function, // The handler to call + * when the event fires.
obj: Object, + * // An object to pass back to the handler.
+ * scope: Object // The object to use + * for the scope of the handler.
}
+ * @type Object + * @default null + */ + this.setAttributeConfig("onclick", { + + value: oAttributes.onclick, + method: this._setOnClick + + }); + + + /** + * @config focusmenu + * @description Boolean indicating whether or not the button's menu + * should be focused when it is made visible. + * @type Boolean + * @default true + */ + this.setAttributeConfig("focusmenu", { + + value: (oAttributes.focusmenu === false ? false : true), + validator: Lang.isBoolean + + }); + + }, + + + /** + * @method focus + * @description Causes the button to receive the focus and fires the + * button's "focus" event. + */ + focus: function () { + + if (!this.get("disabled")) { + + this._button.focus(); + + } + + }, + + + /** + * @method blur + * @description Causes the button to lose focus and fires the button's + * "blur" event. + */ + blur: function () { + + if (!this.get("disabled")) { + + this._button.blur(); + + } + + }, + + + /** + * @method hasFocus + * @description Returns a boolean indicating whether or not the button + * has focus. + * @return {Boolean} + */ + hasFocus: function () { + + return (m_oFocusedButton == this); + + }, + + + /** + * @method isActive + * @description Returns a boolean indicating whether or not the button + * is active. + * @return {Boolean} + */ + isActive: function () { + + return this.hasClass(this.CSS_CLASS_NAME + "-active"); + + }, + + + /** + * @method getMenu + * @description Returns a reference to the button's menu. + * @return { + * YAHOO.widget.Overlay|YAHOO.widget.Menu} + */ + getMenu: function () { + + return this._menu; + + }, + + + /** + * @method getForm + * @description Returns a reference to the button's parent form. + * @return {HTMLFormElement} + */ + getForm: function () { + + return this._button.form; + + }, + + + /** + * @method getHiddenFields + * @description Returns an <input> element or + * array of form elements used to represent the button when its parent + * form is submitted. + * @return {HTMLInputElement|Array} + */ + getHiddenFields: function () { + + return this._hiddenFields; + + }, + + + /** + * @method destroy + * @description Removes the button's element from its parent element and + * removes all event handlers. + */ + destroy: function () { + + + var oElement = this.get("element"), + oParentNode = oElement.parentNode, + oMenu = this._menu; + + if (oMenu) { + + + oMenu.destroy(); + + } + + + Event.purgeElement(oElement); + Event.purgeElement(this._button); + Event.removeListener(document, "mouseup", this._onDocumentMouseUp); + Event.removeListener(document, "keyup", this._onDocumentKeyUp); + Event.removeListener(document, "mousedown", + this._onDocumentMouseDown); + + + var oForm = this.getForm(); + + if (oForm) { + + Event.removeListener(oForm, "reset", this._onFormReset); + Event.removeListener(oForm, "submit", this.createHiddenFields); + + } + + + oParentNode.removeChild(oElement); + + + delete m_oButtons[this.get("id")]; + + + }, + + + fireEvent: function (p_sType , p_aArgs) { + + // Disabled buttons should not respond to DOM events + + if (this.DOM_EVENTS[p_sType] && this.get("disabled")) { + + return; + + } + + YAHOO.widget.Button.superclass.fireEvent.call(this, p_sType, + p_aArgs); + + }, + + + /** + * @method toString + * @description Returns a string representing the button. + * @return {String} + */ + toString: function () { + + return ("Button " + this.get("id")); + + } + + }); + + + /** + * @method YAHOO.widget.Button.onFormKeyPress + * @description "keypress" event handler for the button's form. + * @param {Event} p_oEvent Object representing the DOM event object passed + * back by the event utility (YAHOO.util.Event). + */ + YAHOO.widget.Button.onFormKeyPress = function (p_oEvent) { + + var oTarget = Event.getTarget(p_oEvent), + nCharCode = Event.getCharCode(p_oEvent), + sNodeName = oTarget.nodeName && oTarget.nodeName.toUpperCase(), + sType = oTarget.type, + + /* + Boolean indicating if the form contains any enabled or + disabled YUI submit buttons + */ + + bFormContainsYUIButtons = false, + + oButton, + + oYUISubmitButton, // The form's first, enabled YUI submit button + + /* + The form's first, enabled HTML submit button that precedes any + YUI submit button + */ + + oPrecedingSubmitButton, + + + /* + The form's first, enabled HTML submit button that follows a + YUI button + */ + + oFollowingSubmitButton; + + + function isSubmitButton(p_oElement) { + + var sId, + oSrcElement; + + switch (p_oElement.nodeName.toUpperCase()) { + + case "INPUT": + case "BUTTON": + + if (p_oElement.type == "submit" && !p_oElement.disabled) { + + if (!bFormContainsYUIButtons && + !oPrecedingSubmitButton) { + + oPrecedingSubmitButton = p_oElement; + + } + + if (oYUISubmitButton && !oFollowingSubmitButton) { + + oFollowingSubmitButton = p_oElement; + + } + + } + + break; + + + default: + + sId = p_oElement.id; + + if (sId) { + + oButton = m_oButtons[sId]; + + if (oButton) { + + bFormContainsYUIButtons = true; + + if (!oButton.get("disabled")) { + + oSrcElement = oButton.get("srcelement"); + + if (!oYUISubmitButton && + (oButton.get("type") == "submit" || + (oSrcElement && oSrcElement.type == "submit"))) + { + + oYUISubmitButton = oButton; + + } + + } + + } + + } + + break; + + } + + } + + + if (nCharCode == 13 && ((sNodeName == "INPUT" && (sType == "text" || + sType == "password" || sType == "checkbox" || sType == "radio" || + sType == "file") ) || sNodeName == "SELECT")) + { + + Dom.getElementsBy(isSubmitButton, "*", this); + + + if (oPrecedingSubmitButton) { + + /* + Need to set focus to the first enabled submit button + to make sure that IE includes its name and value + in the form's data set. + */ + + oPrecedingSubmitButton.focus(); + + } + else if (!oPrecedingSubmitButton && oYUISubmitButton) { + + if (oFollowingSubmitButton) { + + /* + Need to call "preventDefault" to ensure that + the name and value of the regular submit button + following the YUI button doesn't get added to the + form's data set when it is submitted. + */ + + Event.preventDefault(p_oEvent); + + } + + oYUISubmitButton.submitForm(); + + } + + } + + }; + + + /** + * @method addHiddenFieldsToForm + * @description Searches the specified form and adds hidden fields for + * instances of YAHOO.widget.Button that are of type "radio," "checkbox," + * "menu," and "split." + * @param {HTMLFormElement} p_oForm Object reference + * for the form to search. + */ + YAHOO.widget.Button.addHiddenFieldsToForm = function (p_oForm) { + + var aButtons = Dom.getElementsByClassName( + YAHOO.widget.Button.prototype.CSS_CLASS_NAME, + "*", + p_oForm), + + nButtons = aButtons.length, + oButton, + sId, + i; + + if (nButtons > 0) { + + + for (i = 0; i < nButtons; i++) { + + sId = aButtons[i].id; + + if (sId) { + + oButton = m_oButtons[sId]; + + if (oButton) { + + oButton.createHiddenFields(); + + } + + } + + } + + } + + }; + + + + // Events + + + /** + * @event focus + * @description Fires when the menu item receives focus. Passes back a + * single object representing the original DOM event object passed back by + * the event utility (YAHOO.util.Event) when the event was fired. See + * Element.addListener + * for more information on listening for this event. + * @type YAHOO.util.CustomEvent + */ + + + /** + * @event blur + * @description Fires when the menu item loses the input focus. Passes back + * a single object representing the original DOM event object passed back by + * the event utility (YAHOO.util.Event) when the event was fired. See + * Element.addListener for + * more information on listening for this event. + * @type YAHOO.util.CustomEvent + */ + + + /** + * @event option + * @description Fires when the user invokes the button's option. Passes + * back a single object representing the original DOM event (either + * "mousedown" or "keydown") that caused the "option" event to fire. See + * Element.addListener + * for more information on listening for this event. + * @type YAHOO.util.CustomEvent + */ + +})(); +(function () { + + // Shorthard for utilities + + var Dom = YAHOO.util.Dom, + Event = YAHOO.util.Event, + Lang = YAHOO.lang, + Button = YAHOO.widget.Button, + + // Private collection of radio buttons + + m_oButtons = {}; + + + + /** + * The ButtonGroup class creates a set of buttons that are mutually + * exclusive; checking one button in the set will uncheck all others in the + * button group. + * @param {String} p_oElement String specifying the id attribute of the + * <div> element of the button group. + * @param {HTMLDivElement} p_oElement Object + * specifying the <div> element of the button group. + * @param {Object} p_oElement Object literal specifying a set of + * configuration attributes used to create the button group. + * @param {Object} p_oAttributes Optional. Object literal specifying a set + * of configuration attributes used to create the button group. + * @namespace YAHOO.widget + * @class ButtonGroup + * @constructor + * @extends YAHOO.util.Element + */ + YAHOO.widget.ButtonGroup = function (p_oElement, p_oAttributes) { + + var fnSuperClass = YAHOO.widget.ButtonGroup.superclass.constructor, + sNodeName, + oElement, + sId; + + if (arguments.length == 1 && !Lang.isString(p_oElement) && + !p_oElement.nodeName) { + + if (!p_oElement.id) { + + sId = Dom.generateId(); + + p_oElement.id = sId; + + + } + + + + fnSuperClass.call(this, (this._createGroupElement()), p_oElement); + + } + else if (Lang.isString(p_oElement)) { + + oElement = Dom.get(p_oElement); + + if (oElement) { + + if (oElement.nodeName.toUpperCase() == this.NODE_NAME) { + + + fnSuperClass.call(this, oElement, p_oAttributes); + + } + + } + + } + else { + + sNodeName = p_oElement.nodeName; + + if (sNodeName && sNodeName == this.NODE_NAME) { + + if (!p_oElement.id) { + + p_oElement.id = Dom.generateId(); + + + } + + + fnSuperClass.call(this, p_oElement, p_oAttributes); + + } + + } + + }; + + + YAHOO.extend(YAHOO.widget.ButtonGroup, YAHOO.util.Element, { + + + // Protected properties + + + /** + * @property _buttons + * @description Array of buttons in the button group. + * @default null + * @protected + * @type Array + */ + _buttons: null, + + + + // Constants + + + /** + * @property NODE_NAME + * @description The name of the tag to be used for the button + * group's element. + * @default "DIV" + * @final + * @type String + */ + NODE_NAME: "DIV", + + + /** + * @property CSS_CLASS_NAME + * @description String representing the CSS class(es) to be applied + * to the button group's element. + * @default "yui-buttongroup" + * @final + * @type String + */ + CSS_CLASS_NAME: "yui-buttongroup", + + + + // Protected methods + + + /** + * @method _createGroupElement + * @description Creates the button group's element. + * @protected + * @return {HTMLDivElement} + */ + _createGroupElement: function () { + + var oElement = document.createElement(this.NODE_NAME); + + return oElement; + + }, + + + + // Protected attribute setter methods + + + /** + * @method _setDisabled + * @description Sets the value of the button groups's + * "disabled" attribute. + * @protected + * @param {Boolean} p_bDisabled Boolean indicating the value for + * the button group's "disabled" attribute. + */ + _setDisabled: function (p_bDisabled) { + + var nButtons = this.getCount(), + i; + + if (nButtons > 0) { + + i = nButtons - 1; + + do { + + this._buttons[i].set("disabled", p_bDisabled); + + } + while (i--); + + } + + }, + + + + // Protected event handlers + + + /** + * @method _onKeyDown + * @description "keydown" event handler for the button group. + * @protected + * @param {Event} p_oEvent Object representing the DOM event object + * passed back by the event utility (YAHOO.util.Event). + */ + _onKeyDown: function (p_oEvent) { + + var oTarget = Event.getTarget(p_oEvent), + nCharCode = Event.getCharCode(p_oEvent), + sId = oTarget.parentNode.parentNode.id, + oButton = m_oButtons[sId], + nIndex = -1; + + + if (nCharCode == 37 || nCharCode == 38) { + + nIndex = (oButton.index === 0) ? + (this._buttons.length - 1) : (oButton.index - 1); + + } + else if (nCharCode == 39 || nCharCode == 40) { + + nIndex = (oButton.index === (this._buttons.length - 1)) ? + 0 : (oButton.index + 1); + + } + + + if (nIndex > -1) { + + this.check(nIndex); + this.getButton(nIndex).focus(); + + } + + }, + + + /** + * @method _onAppendTo + * @description "appendTo" event handler for the button group. + * @protected + * @param {Event} p_oEvent Object representing the event that was fired. + */ + _onAppendTo: function (p_oEvent) { + + var aButtons = this._buttons, + nButtons = aButtons.length, + i; + + for (i = 0; i < nButtons; i++) { + + aButtons[i].appendTo(this.get("element")); + + } + + }, + + + /** + * @method _onButtonCheckedChange + * @description "checkedChange" event handler for each button in the + * button group. + * @protected + * @param {Event} p_oEvent Object representing the event that was fired. + * @param {YAHOO.widget.Button} + * p_oButton Object representing the button that fired the event. + */ + _onButtonCheckedChange: function (p_oEvent, p_oButton) { + + var bChecked = p_oEvent.newValue, + oCheckedButton = this.get("checkedButton"); + + if (bChecked && oCheckedButton != p_oButton) { + + if (oCheckedButton) { + + oCheckedButton.set("checked", false, true); + + } + + this.set("checkedButton", p_oButton); + this.set("value", p_oButton.get("value")); + + } + else if (oCheckedButton && !oCheckedButton.set("checked")) { + + oCheckedButton.set("checked", true, true); + + } + + }, + + + + // Public methods + + + /** + * @method init + * @description The ButtonGroup class's initialization method. + * @param {String} p_oElement String specifying the id attribute of the + * <div> element of the button group. + * @param {HTMLDivElement} p_oElement Object + * specifying the <div> element of the button group. + * @param {Object} p_oElement Object literal specifying a set of + * configuration attributes used to create the button group. + * @param {Object} p_oAttributes Optional. Object literal specifying a + * set of configuration attributes used to create the button group. + */ + init: function (p_oElement, p_oAttributes) { + + this._buttons = []; + + YAHOO.widget.ButtonGroup.superclass.init.call(this, p_oElement, + p_oAttributes); + + this.addClass(this.CSS_CLASS_NAME); + + + var aButtons = this.getElementsByClassName("yui-radio-button"); + + + if (aButtons.length > 0) { + + + this.addButtons(aButtons); + + } + + + + function isRadioButton(p_oElement) { + + return (p_oElement.type == "radio"); + + } + + aButtons = + Dom.getElementsBy(isRadioButton, "input", this.get("element")); + + + if (aButtons.length > 0) { + + + this.addButtons(aButtons); + + } + + this.on("keydown", this._onKeyDown); + this.on("appendTo", this._onAppendTo); + + + var oContainer = this.get("container"); + + if (oContainer) { + + if (Lang.isString(oContainer)) { + + Event.onContentReady(oContainer, function () { + + this.appendTo(oContainer); + + }, null, this); + + } + else { + + this.appendTo(oContainer); + + } + + } + + + + }, + + + /** + * @method initAttributes + * @description Initializes all of the configuration attributes used to + * create the button group. + * @param {Object} p_oAttributes Object literal specifying a set of + * configuration attributes used to create the button group. + */ + initAttributes: function (p_oAttributes) { + + var oAttributes = p_oAttributes || {}; + + YAHOO.widget.ButtonGroup.superclass.initAttributes.call( + this, oAttributes); + + + /** + * @config name + * @description String specifying the name for the button group. + * This name will be applied to each button in the button group. + * @default null + * @type String + */ + this.setAttributeConfig("name", { + + value: oAttributes.name, + validator: Lang.isString + + }); + + + /** + * @config disabled + * @description Boolean indicating if the button group should be + * disabled. Disabling the button group will disable each button + * in the button group. Disabled buttons are dimmed and will not + * respond to user input or fire events. + * @default false + * @type Boolean + */ + this.setAttributeConfig("disabled", { + + value: (oAttributes.disabled || false), + validator: Lang.isBoolean, + method: this._setDisabled + + }); + + + /** + * @config value + * @description Object specifying the value for the button group. + * @default null + * @type Object + */ + this.setAttributeConfig("value", { + + value: oAttributes.value + + }); + + + /** + * @config container + * @description HTML element reference or string specifying the id + * attribute of the HTML element that the button group's markup + * should be rendered into. + * @type HTMLElement|String + * @default null + */ + this.setAttributeConfig("container", { + + value: oAttributes.container, + writeOnce: true + + }); + + + /** + * @config checkedButton + * @description Reference for the button in the button group that + * is checked. + * @type {YAHOO.widget.Button} + * @default null + */ + this.setAttributeConfig("checkedButton", { + + value: null + + }); + + }, + + + /** + * @method addButton + * @description Adds the button to the button group. + * @param {YAHOO.widget.Button} + * p_oButton Object reference for the + * YAHOO.widget.Button instance to be added to the button group. + * @param {String} p_oButton String specifying the id attribute of the + * <input> or <span> element + * to be used to create the button to be added to the button group. + * @param {HTMLInputElement|HTMLElement} p_oButton Object reference for the + * <input> or <span> element + * to be used to create the button to be added to the button group. + * @param {Object} p_oButton Object literal specifying a set of + * YAHOO.widget.Button + * configuration attributes used to configure the button to be added to + * the button group. + * @return {YAHOO.widget.Button} + */ + addButton: function (p_oButton) { + + var oButton, + oButtonElement, + oGroupElement, + nIndex, + sButtonName, + sGroupName; + + + if (p_oButton instanceof Button && + p_oButton.get("type") == "radio") { + + oButton = p_oButton; + + } + else if (!Lang.isString(p_oButton) && !p_oButton.nodeName) { + + p_oButton.type = "radio"; + + oButton = new Button(p_oButton); + + } + else { + + oButton = new Button(p_oButton, { type: "radio" }); + + } + + + if (oButton) { + + nIndex = this._buttons.length; + sButtonName = oButton.get("name"); + sGroupName = this.get("name"); + + oButton.index = nIndex; + + this._buttons[nIndex] = oButton; + m_oButtons[oButton.get("id")] = oButton; + + + if (sButtonName != sGroupName) { + + oButton.set("name", sGroupName); + + } + + + if (this.get("disabled")) { + + oButton.set("disabled", true); + + } + + + if (oButton.get("checked")) { + + this.set("checkedButton", oButton); + + } + + + oButtonElement = oButton.get("element"); + oGroupElement = this.get("element"); + + if (oButtonElement.parentNode != oGroupElement) { + + oGroupElement.appendChild(oButtonElement); + + } + + + oButton.on("checkedChange", + this._onButtonCheckedChange, oButton, this); + + + return oButton; + + } + + }, + + + /** + * @method addButtons + * @description Adds the array of buttons to the button group. + * @param {Array} p_aButtons Array of + * YAHOO.widget.Button instances to be added + * to the button group. + * @param {Array} p_aButtons Array of strings specifying the id + * attribute of the <input> or <span> + * elements to be used to create the buttons to be added to the + * button group. + * @param {Array} p_aButtons Array of object references for the + * <input> or <span> elements + * to be used to create the buttons to be added to the button group. + * @param {Array} p_aButtons Array of object literals, each containing + * a set of YAHOO.widget.Button + * configuration attributes used to configure each button to be added + * to the button group. + * @return {Array} + */ + addButtons: function (p_aButtons) { + + var nButtons, + oButton, + aButtons, + i; + + if (Lang.isArray(p_aButtons)) { + + nButtons = p_aButtons.length; + aButtons = []; + + if (nButtons > 0) { + + for (i = 0; i < nButtons; i++) { + + oButton = this.addButton(p_aButtons[i]); + + if (oButton) { + + aButtons[aButtons.length] = oButton; + + } + + } + + if (aButtons.length > 0) { + + + return aButtons; + + } + + } + + } + + }, + + + /** + * @method removeButton + * @description Removes the button at the specified index from the + * button group. + * @param {Number} p_nIndex Number specifying the index of the button + * to be removed from the button group. + */ + removeButton: function (p_nIndex) { + + var oButton = this.getButton(p_nIndex), + nButtons, + i; + + if (oButton) { + + + this._buttons.splice(p_nIndex, 1); + delete m_oButtons[oButton.get("id")]; + + oButton.removeListener("checkedChange", + this._onButtonCheckedChange); + + oButton.destroy(); + + + nButtons = this._buttons.length; + + if (nButtons > 0) { + + i = this._buttons.length - 1; + + do { + + this._buttons[i].index = i; + + } + while (i--); + + } + + + } + + }, + + + /** + * @method getButton + * @description Returns the button at the specified index. + * @param {Number} p_nIndex The index of the button to retrieve from the + * button group. + * @return {YAHOO.widget.Button} + */ + getButton: function (p_nIndex) { + + if (Lang.isNumber(p_nIndex)) { + + return this._buttons[p_nIndex]; + + } + + }, + + + /** + * @method getButtons + * @description Returns an array of the buttons in the button group. + * @return {Array} + */ + getButtons: function () { + + return this._buttons; + + }, + + + /** + * @method getCount + * @description Returns the number of buttons in the button group. + * @return {Number} + */ + getCount: function () { + + return this._buttons.length; + + }, + + + /** + * @method focus + * @description Sets focus to the button at the specified index. + * @param {Number} p_nIndex Number indicating the index of the button + * to focus. + */ + focus: function (p_nIndex) { + + var oButton, + nButtons, + i; + + if (Lang.isNumber(p_nIndex)) { + + oButton = this._buttons[p_nIndex]; + + if (oButton) { + + oButton.focus(); + + } + + } + else { + + nButtons = this.getCount(); + + for (i = 0; i < nButtons; i++) { + + oButton = this._buttons[i]; + + if (!oButton.get("disabled")) { + + oButton.focus(); + break; + + } + + } + + } + + }, + + + /** + * @method check + * @description Checks the button at the specified index. + * @param {Number} p_nIndex Number indicating the index of the button + * to check. + */ + check: function (p_nIndex) { + + var oButton = this.getButton(p_nIndex); + + if (oButton) { + + oButton.set("checked", true); + + } + + }, + + + /** + * @method destroy + * @description Removes the button group's element from its parent + * element and removes all event handlers. + */ + destroy: function () { + + + var nButtons = this._buttons.length, + oElement = this.get("element"), + oParentNode = oElement.parentNode, + i; + + if (nButtons > 0) { + + i = this._buttons.length - 1; + + do { + + this._buttons[i].destroy(); + + } + while (i--); + + } + + + Event.purgeElement(oElement); + + + oParentNode.removeChild(oElement); + + }, + + + /** + * @method toString + * @description Returns a string representing the button group. + * @return {String} + */ + toString: function () { + + return ("ButtonGroup " + this.get("id")); + + } + + }); + +})(); +YAHOO.register("button", YAHOO.widget.Button, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/calendar/README b/lib/yui/calendar/README index d4fc65d143..3c04748c14 100755 --- a/lib/yui/calendar/README +++ b/lib/yui/calendar/README @@ -1,5 +1,38 @@ Calendar Release Notes +*** version 2.3.0 *** + + - Added checks to select, selectCell, deselect and deselectCell methods to ensure the Calendar/Calendar group was not set to an invalid state by programmatically selecting unselectable dates or cells. + - Added new locale configuration properties for the Month/Year label used in the Calendar header (MY_LABEL_MONTH_POSITION, MY_LABEL_YEAR_POSITION, MY_LABEL_YEAR_SUFFIX, MY_LABEL_MONTH_SUFFIX). Japan is an example locale, where customization of the Month/Year label is required. + - Changed "first", "last" class names to "first-of-type", "last-of-type", to avoid collision with YUI Grids' use of the "first" class name. + - Added public isDateOOB method, to check if a given date is outside of the minimum/maximum configuration dates of the Calendar. + - Deprecated YAHOO.widget.Calendar.browser, refactored to use YAHOO.env.ua instead. + - Removed overflow:hidden from default Calendar/CalendarGroup container for non-IE6 browsers to fix clipping issue with IE7 when CalendarGroup was inside a box with a specific width. overflow:hidden is still required for IE6 with an iframe shim. + - Added Opera container width calculation fix to CalendarGroup.show method, to fix incorrect wrapping when using a CalendarGroup which is initially rendered hidden (display:none). Previously this fix was only applied on render. + +*** version 2.2.2 *** + + - Fixed problem with selected dates being shared across instances, when more than one Calendar/CalendarGroup was on the page + +*** version 2.2.1 *** + + - Fixed problem with selectCell adding duplicate selected date entries for dates which were already selected + - Fixed problem with CalendarGroup iframe shim not covering the CalendarGroup title area + - Removed javascript:void(null) from close button and cell links which was interrupting form submission and firing onbeforeunload in IE + - Fixed problem with CalendarGroup getSelectedDates returning invalid results, when used in conjunction with the "selected" Config property (either passed in the constructor config argument or set seperately after construction) + - Refactored Calendar and CalendarGroup to improve performance, especially when working with a large number of instances in IE6 + +*** version 2.2.0 *** + + - Image customization can now be done through CSS. Images for Close, Left and Right Arrows are now pulled in using CSS defined in calendar.css and by default use relative paths to the images in the same directory as calendar.css. + - Deprecated Calendar.IMG_ROOT and NAV_ARROW_LEFT, NAV_ARROW_RIGHT configuration properties. Customizations based on older releases which set these properties will still function as expected. + - Deprecated CalendarGroup.CSS_2UPCLOSE. Calendar's Style.CSS_CLOSE property now represents the new default CSS class (calclose) for the close button. CSS_2UPCLOSE is still applied along with CSS_CLOSE to the new markup for the close button to support existing customizations of the CSS_2UPCLOSE CSS class (close-icon) + - Fixed problem with Safari setting Calendar pages to incorrect dates if the pages spanned a year boundary in CalendarGroups with 3 or more pages, due to a bug in Safari's implementation of Date setMonth + - Fixed problem with CalendarGroup setMonth rendering Calendar pages with incorrect dates in all browsers if current pages spanned year boundary + - Fixed incorrect CalendarGroup logging statement in calendar-debug.js + - Fixed domEventMap support for Safari versions prior to 2.0.2, caused by hasOwnProperty not being supported + - Removed unused private property : _pageDate from Calendar class + *** version 0.12.2 *** - Corrected documentation for clearTime function to reflect the change from midnight to noon diff --git a/lib/yui/calendar/assets/calendar-core.css b/lib/yui/calendar/assets/calendar-core.css new file mode 100755 index 0000000000..d25fd0427f --- /dev/null +++ b/lib/yui/calendar/assets/calendar-core.css @@ -0,0 +1,88 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/** + * CORE + * + * This is the set of CSS rules required by Calendar to drive core functionality and structure. + * Changes to these rules may result in the Calendar not functioning or rendering correctly. + * + * They should not be modified for skinning. + **/ + +/* CALENDAR BOUNDING BOX */ +.yui-calcontainer { + position:relative; + float:left; + _overflow:hidden; /* IE6 only, to clip iframe shim */ +} + +/* IFRAME SHIM */ +.yui-calcontainer iframe { + position:absolute; + border:none; + margin:0;padding:0; + z-index:0; + width:100%; + height:100%; + left:0px; + top:0px; +} + +/* IFRAME SHIM IE6 only */ +.yui-calcontainer iframe.fixedsize { + width:50em; + height:50em; + top:-1px; + left:-1px; +} + +/* BOUNDING BOX FOR EACH CALENDAR GROUP PAGE */ +.yui-calcontainer.multi .groupcal { + z-index:1; + float:left; + position:relative; +} + +/* TITLE BAR */ +.yui-calcontainer .title { + position:relative; + z-index:1; +} + +/* CLOSE ICON CONTAINER */ +.yui-calcontainer .close-icon { + position:absolute; + z-index:1; +} + +/* CALENDAR TABLE */ +.yui-calendar { + position:relative; +} + +/* NAVBAR LEFT ARROW CONTAINER */ +.yui-calendar .calnavleft { + position:absolute; + z-index:1; +} + +/* NAVBAR RIGHT ARROW CONTAINER */ +.yui-calendar .calnavright { + position:absolute; + z-index:1; +} + +/* NAVBAR TEXT CONTAINER */ +.yui-calendar .calheader { + position:relative; + width:100%; + text-align:center; +} + +/* Specific changes for calendar running under fonts/reset */ +.yui-calendar .calbody a:hover {background:inherit;} +p#clear {clear:left; padding-top:10px;} \ No newline at end of file diff --git a/lib/yui/calendar/assets/calendar.css b/lib/yui/calendar/assets/calendar.css index b97a705362..377b93191d 100755 --- a/lib/yui/calendar/assets/calendar.css +++ b/lib/yui/calendar/assets/calendar.css @@ -1,28 +1,35 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -Version 0.12 +version: 2.3.0 */ - .yui-calcontainer { position:relative; padding:5px; background-color:#F7F9FB; border:1px solid #7B9EBD; float:left; - overflow:hidden; + _overflow:hidden; /* IE6 only, to clip iframe shim */ } .yui-calcontainer iframe { position:absolute; border:none; margin:0;padding:0; - left:-1px; - top:-1px; z-index:0; + width:100%; + height:100%; + left:0px; + top:0px; +} + +/* IE6 only */ +.yui-calcontainer iframe.fixedsize { width:50em; height:50em; + top:-1px; + left:-1px; } .yui-calcontainer.multi { @@ -57,6 +64,13 @@ Version 0.12 z-index:1; } +.yui-calcontainer .calclose { + background: url("calx.gif") no-repeat; + width:17px; + height:13px; + cursor:pointer; +} + /* Calendar element styles */ .yui-calendar { @@ -73,7 +87,6 @@ Version 0.12 .yui-calendar .calnavleft { position:absolute; - background-repeat:no-repeat; cursor:pointer; top:2px; bottom:0; @@ -81,18 +94,19 @@ Version 0.12 height:12px; left:2px; z-index:1; + background: url("callt.gif") no-repeat; } .yui-calendar .calnavright { position:absolute; - background-repeat:no-repeat; cursor:pointer; top:2px; bottom:0; width:9px; - height:12px; + height:12px; right:2px; z-index:1; + background: url("calrt.gif") no-repeat; } .yui-calendar td.calcell { @@ -186,6 +200,6 @@ Version 0.12 border-right-width:2px; } -/*Specific changes for calendar running under fonts/reset */ -.yui-calendar a:hover {background:inherit;} +/* Specific changes for calendar running under fonts/reset */ +.yui-calendar .calbody a:hover {background:inherit;} p#clear {clear:left; padding-top:10px;} diff --git a/lib/yui/calendar/assets/skins/sam/calendar-skin.css b/lib/yui/calendar/assets/skins/sam/calendar-skin.css new file mode 100755 index 0000000000..66a6df4b11 --- /dev/null +++ b/lib/yui/calendar/assets/skins/sam/calendar-skin.css @@ -0,0 +1,231 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/** + * SAM + * + * Skin colors used: + * + * - Control Border : 808080 + * - Control Chrome : f2f2f2 + * - Cell Borders : cccccc + * - Normal Cell BG : ffffff + * - Date Links : 0066cc + * - Selected Cells BG : b3d4ff + * - Cell Hover BG : 426fd9 + * - Disabled BG : cccccc + * - Disabled Text Color : a6a6a6 + **/ + +/* CALENDAR BOUNDING BOX */ +.yui-skin-sam .yui-calcontainer { + background-color:#f2f2f2; + border:1px solid #808080; + padding:10px; +} + +/* CALENDARGROUP BOUNDING BOX */ +.yui-skin-sam .yui-calcontainer.multi { + padding:0 5px 0 5px; +} + +/* BOUNDING BOX FOR EACH CALENDAR GROUP PAGE */ +.yui-skin-sam .yui-calcontainer.multi .groupcal { + background-color:transparent; + border:none; + padding:10px 5px 10px 5px; + margin:0; +} + +/* TITLE BAR */ +.yui-skin-sam .yui-calcontainer .title { + background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0; + border-bottom:1px solid #cccccc; + font:100% sans-serif; + color:#000; + font-weight:bold; + height:auto; + padding:.4em; + margin:0 -10px 10px -10px; + top:0; + left:0; + text-align:left; +} + +.yui-skin-sam .yui-calcontainer.multi .title { + margin:0 -5px 0 -5px; +} + +.yui-skin-sam .yui-calcontainer.withtitle { + padding-top:0; +} + +/* CLOSE BUTTON */ +.yui-skin-sam .yui-calcontainer .calclose { + background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -300px; + width:25px; + height:15px; + top:.4em; + right:.4em; + cursor:pointer; +} + +/* CALENDAR TABLE */ +.yui-skin-sam .yui-calendar { + border-spacing:0; + border-collapse:collapse; + font:100% sans-serif; + text-align:center; +} + +/* NAVBAR BOUNDING BOX */ +.yui-skin-sam .yui-calendar .calhead { + background:transparent; + border:none; + vertical-align:middle; +} + +/* NAVBAR TEXT CONTAINER */ +.yui-skin-sam .yui-calendar .calheader { + background:transparent; + font-weight:bold; + padding:0 0 .6em 0; + text-align:center; +} + +.yui-skin-sam .yui-calendar .calheader img { + border:none; +} + +/* NAVBAR LEFT ARROW */ +.yui-skin-sam .yui-calendar .calnavleft { + background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -450px; + width:25px; + height:15px; + top:0; + bottom:0; + left:-10px; + margin-left:.4em; + cursor:pointer; +} + +/* NAVBAR RIGHT ARROW */ +.yui-skin-sam .yui-calendar .calnavright { + background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -500px; + width:25px; + height:15px; + top:0; + bottom:0; + right:-10px; + margin-right:.4em; + cursor:pointer; +} + +/* WEEKDAY HEADER ROW */ +.yui-skin-sam .yui-calendar .calweekdayrow { + height:2em; +} + +/* WEEKDAY (Su, Mo, Tu...) HEADER CELLS */ +.yui-skin-sam .yui-calendar .calweekdaycell { + color:#000; + font-weight:bold; + text-align:center; + width:2em; +} + +/* CALENDAR FOOTER. NOT IMPLEMENTED BY DEFAULT */ +.yui-skin-sam .yui-calendar .calfoot { + background-color:#f2f2f2; +} + +/* WEEK NUMBERS (ROW HEADERS/FOOTERS) */ +.yui-skin-sam .yui-calendar .calrowhead, .yui-skin-sam .yui-calendar .calrowfoot { + color:#a6a6a6; + font-size:85%; + font-style:normal; + font-weight:normal; +} + +.yui-skin-sam .yui-calendar .calrowhead { + text-align:right; + padding-right:2px; +} + +.yui-skin-sam .yui-calendar .calrowfoot { + text-align:left; + padding-left:2px; +} + +/* NORMAL CELLS */ +.yui-skin-sam .yui-calendar td.calcell { + border:1px solid #cccccc; + background:#fff; + padding:1px; + height:1.6em; + line-height:1.6em; /* set line height equal to cell height to center vertically */ + text-align:center; + white-space:nowrap; +} + +/* LINK INSIDE NORMAL CELLS */ +.yui-skin-sam .yui-calendar td.calcell a { + color:#0066cc; + display:block; + height:100%; + text-decoration:none; +} + +/* TODAY'S DATE */ +.yui-skin-sam .yui-calendar td.calcell.today { + background-color:#000; +} + +.yui-skin-sam .yui-calendar td.calcell.today a { + background-color:#fff; +} + +/* OOM DATES */ +.yui-skin-sam .yui-calendar td.calcell.oom { + background-color:#cccccc; + color:#a6a6a6; + cursor:default; +} + +/* SELECTED DATE */ +.yui-skin-sam .yui-calendar td.calcell.selected { + background-color:#fff; + color:#000; +} + +.yui-skin-sam .yui-calendar td.calcell.selected a { + background-color:#b3d4ff; + color:#000; +} + +/* HOVER DATE */ +.yui-skin-sam .yui-calendar td.calcell.calcellhover { + background-color:#426fd9; + color:#fff; + cursor:pointer; +} + +.yui-skin-sam .yui-calendar td.calcell.calcellhover a { + background-color:#426fd9; + color:#fff; +} + +/* DEFAULT OOB DATES */ +.yui-skin-sam .yui-calendar td.calcell.previous { + color:#e0e0e0; +} + +/* CUSTOM RENDERERS */ +.yui-skin-sam .yui-calendar td.calcell.restricted { text-decoration:line-through; } +.yui-skin-sam .yui-calendar td.calcell.highlight1 { background-color:#ccff99; } +.yui-skin-sam .yui-calendar td.calcell.highlight2 { background-color:#99ccff; } +.yui-skin-sam .yui-calendar td.calcell.highlight3 { background-color:#ffcccc; } +.yui-skin-sam .yui-calendar td.calcell.highlight4 { background-color:#ccff99; } \ No newline at end of file diff --git a/lib/yui/calendar/assets/skins/sam/calendar.css b/lib/yui/calendar/assets/skins/sam/calendar.css new file mode 100755 index 0000000000..2b6d11a196 --- /dev/null +++ b/lib/yui/calendar/assets/skins/sam/calendar.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0px;top:0px;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;}.yui-calendar .calnavright{position:absolute;z-index:1;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;border-bottom:1px solid #cccccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding-right:2px;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding-left:2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #cccccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#0066cc;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#cccccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#ccff99;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#99ccff;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#ffcccc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#ccff99;} diff --git a/lib/yui/calendar/calendar-debug.js b/lib/yui/calendar/calendar-debug.js index 622feef52e..47a54b3d7d 100755 --- a/lib/yui/calendar/calendar-debug.js +++ b/lib/yui/calendar/calendar-debug.js @@ -1,487 +1,701 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 -*/ -/** -* 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. -* @namespace YAHOO.util -* @class Config -* @constructor -* @param {Object} owner The owner Object to which this Config Object belongs -*/ -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 - * @property owner - * @type Object - */ - owner : null, - - /** - * Boolean flag that specifies whether a queue is currently being executed - * @property queueInProgress - * @type Boolean - */ - queueInProgress : false, - - - /** - * Validates that the value passed in is a Boolean. - * @method checkBoolean - * @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. - * @method checkNumber - * @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. -* @method init -* @param {Object} owner The owner Object to which this Config Object belongs -*/ -YAHOO.util.Config.prototype.init = function(owner) { - - this.owner = owner; - - /** - * Object reference to the owner of this Config Object - * @event configChangedEvent - */ - this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged"); - this.queueInProgress = false; - - /* Private Members */ - - /** - * Maintains the local collection of configuration property objects and their specified values - * @property config - * @private - * @type Object - */ - var config = {}; - - /** - * Maintains the local collection of configuration property objects as they were initially applied. - * This object is used when resetting a property. - * @property initialConfig - * @private - * @type Object - */ - var initialConfig = {}; - - /** - * Maintains the local, normalized CustomEvent queue - * @property eventQueue - * @private - * @type Object - */ - var eventQueue = []; - - /** - * Fires a configuration property event using the specified value. - * @method fireEvent - * @private - * @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 */ - - /** - * Adds a property to the Config Object's private config hash. - * @method addProperty - * @param {String} key The configuration property's name - * @param {Object} propertyObject The Object containing all of this property's arguments - */ - 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); - } - }; - - /** - * Returns a key-value configuration map of the values currently set in the Config Object. - * @method getConfig - * @return {Object} The current config, represented in a key-value map - */ - 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; - }; - - /** - * Returns the value of specified property. - * @method getProperty - * @param {String} key The name of the property - * @return {Object} The value of the specified property - */ - this.getProperty = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.value; - } else { - return undefined; - } - }; - - /** - * Resets the specified property's value to its initial value. - * @method resetProperty - * @param {String} key The name of the property - * @return {Boolean} True is the property was reset, false if not - */ - this.resetProperty = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (initialConfig[key] && initialConfig[key] != 'undefined') { - this.setProperty(key, initialConfig[key]); - } - return true; - } else { - return false; - } - }; - - /** - * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired. - * @method setProperty - * @param {String} key The name of the property - * @param {String} value The value to set the property to - * @param {Boolean} silent Whether the value should be set silently, without firing the property event. - * @return {Boolean} True, if the set was successful, false if it failed. - */ - 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; - } - } - }; - - /** - * 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. - * @method queueProperty - * @param {String} key The name of the property - * @param {String} value The value to set the property to - * @return {Boolean} true, if the set was successful, false if it failed. - */ - 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 0) { + + i = nSubscribers - 1; + + do { + + subsc = evt.subscribers[i]; + + if (subsc && subsc.obj == obj && subsc.fn == fn) { + + return true; + + } + + } + while (i--); + + } + + return false; + + }; + + YAHOO.lang.augmentProto(Config, YAHOO.util.EventProvider); + +}()); /** * YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility @@ -676,7 +890,6 @@ YAHOO.widget.DateMath = { * @param {Date} date The JavaScript date for which to find the week number * @param {Number} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is * the calendar year of parameter "date". - * @param {Number} weekStartsOn OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday). * @return {Number} The week number of the given date. */ getWeekNumber : function(date, calendarYear) { @@ -757,7 +970,7 @@ YAHOO.widget.DateMath = { }; /** -* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month ("one-up") or two-month ("two-up") interface. Calendars are generated entirely via script and can be navigated without any page refreshes. +* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month or multi-month interface. Calendars are generated entirely via script and can be navigated without any page refreshes. * @module calendar * @title Calendar * @namespace YAHOO.widget @@ -774,7 +987,6 @@ YAHOO.widget.DateMath = { * * <div id="cal1Container"></div> * -* Note that the table can be replaced with any kind of element. *

* @namespace YAHOO.widget * @class Calendar @@ -791,9 +1003,10 @@ YAHOO.widget.Calendar = function(id, containerId, config) { * The path to be used for images loaded for the Calendar * @property YAHOO.widget.Calendar.IMG_ROOT * @static +* @deprecated You can now customize images by overriding the calclose, calnavleft and calnavright default CSS classes for the close icon, left arrow and right arrow respectively * @type String */ -YAHOO.widget.Calendar.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.IMG_ROOT = null; /** * Type constant used for renderers to represent an individual date (M/D/Y) @@ -858,6 +1071,153 @@ YAHOO.widget.Calendar.DISPLAY_DAYS = 42; */ YAHOO.widget.Calendar.STOP_RENDER = "S"; +/** +* Constant used to represent short date field string formats (e.g. Tu or Feb) +* @property YAHOO.widget.Calendar.SHORT +* @static +* @final +* @type String +*/ +YAHOO.widget.Calendar.SHORT = "short"; + +/** +* Constant used to represent long date field string formats (e.g. Monday or February) +* @property YAHOO.widget.Calendar.LONG +* @static +* @final +* @type String +*/ +YAHOO.widget.Calendar.LONG = "long"; + +/** +* Constant used to represent medium date field string formats (e.g. Mon) +* @property YAHOO.widget.Calendar.MEDIUM +* @static +* @final +* @type String +*/ +YAHOO.widget.Calendar.MEDIUM = "medium"; + +/** +* Constant used to represent single character date field string formats (e.g. M, T, W) +* @property YAHOO.widget.Calendar.ONE_CHAR +* @static +* @final +* @type String +*/ +YAHOO.widget.Calendar.ONE_CHAR = "1char"; + +/** +* The set of default Config property keys and values for the Calendar +* @property YAHOO.widget.Calendar._DEFAULT_CONFIG +* @final +* @static +* @private +* @type Object +*/ +YAHOO.widget.Calendar._DEFAULT_CONFIG = { + // Default values for pagedate and selected are not class level constants - they are set during instance creation + PAGEDATE : {key:"pagedate", value:null}, + SELECTED : {key:"selected", value:null}, + TITLE : {key:"title", value:""}, + CLOSE : {key:"close", value:false}, + IFRAME : {key:"iframe", value:(YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) ? true : false}, + MINDATE : {key:"mindate", value:null}, + MAXDATE : {key:"maxdate", value:null}, + MULTI_SELECT : {key:"multi_select", value:false}, + START_WEEKDAY : {key:"start_weekday", value:0}, + SHOW_WEEKDAYS : {key:"show_weekdays", value:true}, + SHOW_WEEK_HEADER : {key:"show_week_header", value:false}, + SHOW_WEEK_FOOTER : {key:"show_week_footer", value:false}, + HIDE_BLANK_WEEKS : {key:"hide_blank_weeks", value:false}, + NAV_ARROW_LEFT: {key:"nav_arrow_left", value:null} , + NAV_ARROW_RIGHT : {key:"nav_arrow_right", value:null} , + MONTHS_SHORT : {key:"months_short", value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]}, + MONTHS_LONG: {key:"months_long", value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]}, + WEEKDAYS_1CHAR: {key:"weekdays_1char", value:["S", "M", "T", "W", "T", "F", "S"]}, + WEEKDAYS_SHORT: {key:"weekdays_short", value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]}, + WEEKDAYS_MEDIUM: {key:"weekdays_medium", value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}, + WEEKDAYS_LONG: {key:"weekdays_long", value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]}, + LOCALE_MONTHS:{key:"locale_months", value:"long"}, + LOCALE_WEEKDAYS:{key:"locale_weekdays", value:"short"}, + DATE_DELIMITER:{key:"date_delimiter", value:","}, + DATE_FIELD_DELIMITER:{key:"date_field_delimiter", value:"/"}, + DATE_RANGE_DELIMITER:{key:"date_range_delimiter", value:"-"}, + MY_MONTH_POSITION:{key:"my_month_position", value:1}, + MY_YEAR_POSITION:{key:"my_year_position", value:2}, + MD_MONTH_POSITION:{key:"md_month_position", value:1}, + MD_DAY_POSITION:{key:"md_day_position", value:2}, + MDY_MONTH_POSITION:{key:"mdy_month_position", value:1}, + MDY_DAY_POSITION:{key:"mdy_day_position", value:2}, + MDY_YEAR_POSITION:{key:"mdy_year_position", value:3}, + MY_LABEL_MONTH_POSITION:{key:"my_label_month_position", value:1}, + MY_LABEL_YEAR_POSITION:{key:"my_label_year_position", value:2}, + MY_LABEL_MONTH_SUFFIX:{key:"my_label_month_suffix", value:" "}, + MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix", value:""} +}; + +/** +* The set of Custom Event types supported by the Calendar +* @property YAHOO.widget.Calendar._EVENT_TYPES +* @final +* @static +* @private +* @type Object +*/ +YAHOO.widget.Calendar._EVENT_TYPES = { + BEFORE_SELECT : "beforeSelect", + SELECT : "select", + BEFORE_DESELECT : "beforeDeselect", + DESELECT : "deselect", + CHANGE_PAGE : "changePage", + BEFORE_RENDER : "beforeRender", + RENDER : "render", + RESET : "reset", + CLEAR : "clear" +}; + +/** +* The set of default style constants for the Calendar +* @property YAHOO.widget.Calendar._STYLES +* @final +* @static +* @private +* @type Object +*/ +YAHOO.widget.Calendar._STYLES = { + CSS_ROW_HEADER: "calrowhead", + CSS_ROW_FOOTER: "calrowfoot", + CSS_CELL : "calcell", + CSS_CELL_SELECTOR : "selector", + CSS_CELL_SELECTED : "selected", + CSS_CELL_SELECTABLE : "selectable", + CSS_CELL_RESTRICTED : "restricted", + CSS_CELL_TODAY : "today", + CSS_CELL_OOM : "oom", + CSS_CELL_OOB : "previous", + CSS_HEADER : "calheader", + CSS_HEADER_TEXT : "calhead", + CSS_BODY : "calbody", + CSS_WEEKDAY_CELL : "calweekdaycell", + CSS_WEEKDAY_ROW : "calweekdayrow", + CSS_FOOTER : "calfoot", + CSS_CALENDAR : "yui-calendar", + CSS_SINGLE : "single", + CSS_CONTAINER : "yui-calcontainer", + CSS_NAV_LEFT : "calnavleft", + CSS_NAV_RIGHT : "calnavright", + CSS_CLOSE : "calclose", + 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" +}; + YAHOO.widget.Calendar.prototype = { /** @@ -933,14 +1293,6 @@ YAHOO.widget.Calendar.prototype = { */ _renderStack : null, - /** - * A Date object representing the month/year that the calendar is initially set to - * @property _pageDate - * @private - * @type Date - */ - _pageDate : null, - /** * The private list of initially selected dates. * @property _selectedDates @@ -967,17 +1319,14 @@ YAHOO.widget.Calendar.prototype = { * @param {Object} config The configuration object containing the Calendar's arguments */ YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) { - this.logger = new YAHOO.widget.LogWriter("Calendar_Core " + id); - + this.logger = new YAHOO.widget.LogWriter("Calendar " + id); this.initEvents(); this.today = new Date(); YAHOO.widget.DateMath.clearTime(this.today); this.id = id; this.oDomContainer = document.getElementById(containerId); - if (! this.oDomContainer) { - this.logger.log("No valid container present.", "error"); - } + if (! this.oDomContainer) { this.logger.log("No valid container present.", "error"); } /** * The Config object used to hold the configuration variables for the Calendar @@ -1004,7 +1353,7 @@ YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) { YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE); - + this.cellDates = []; this.cells = []; this.renderStack = []; @@ -1020,30 +1369,41 @@ YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) { }; /** -* Renders the built-in IFRAME shim for the IE6 and below +* Default Config listener for the iframe property. If the iframe config property is set to true, +* renders the built-in IFRAME shim if the container is relatively or absolutely positioned. +* * @method configIframe */ YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) { var useIframe = args[0]; - if (YAHOO.util.Dom.inDocument(this.oDomContainer)) { - if (useIframe) { - var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); + if (!this.parent) { + if (YAHOO.util.Dom.inDocument(this.oDomContainer)) { + if (useIframe) { + var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); + + if (pos == "absolute" || pos == "relative") { + + if (!YAHOO.util.Dom.inDocument(this.iframe)) { + this.iframe = document.createElement("iframe"); + this.iframe.src = "javascript:false;"; + + YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); + + if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { + YAHOO.util.Dom.addClass(this.iframe, "fixedsize"); + } - if (this.browser == "ie" && (pos == "absolute" || pos == "relative")) { - if (! YAHOO.util.Dom.inDocument(this.iframe)) { - this.iframe = document.createElement("iframe"); - this.iframe.src = "javascript:false;"; - YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); - this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); + this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); + } } - } - } else { - if (this.iframe) { - if (this.iframe.parentNode) { - this.iframe.parentNode.removeChild(this.iframe); + } else { + if (this.iframe) { + if (this.iframe.parentNode) { + this.iframe.parentNode.removeChild(this.iframe); + } + this.iframe = null; } - this.iframe = null; } } } @@ -1055,7 +1415,7 @@ YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) { var title = args[0]; - var close = this.cfg.getProperty("close"); + var close = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key); var titleDiv; @@ -1084,24 +1444,31 @@ YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) { var close = args[0]; - var title = this.cfg.getProperty("title"); + var title = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key); + + var DEPR_CLOSE_PATH = "us/my/bn/x_d.gif"; var linkClose; if (close === true) { linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a"); - linkClose.href = "javascript:void(null);"; + linkClose.href = "#"; linkClose.className = "link-close"; - YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true); - var imgClose = document.createElement("img"); - imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + "us/my/bn/x_d.gif"; - imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE; - linkClose.appendChild(imgClose); + YAHOO.util.Event.addListener(linkClose, "click", function(e, cal) {cal.hide(); YAHOO.util.Event.preventDefault(e); }, this); + + if (YAHOO.widget.Calendar.IMG_ROOT !== null) { + var imgClose = document.createElement("img"); + imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + DEPR_CLOSE_PATH; + imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE; + linkClose.appendChild(imgClose); + } else { + linkClose.innerHTML = ''; + } + this.oDomContainer.appendChild(linkClose); YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle"); } else { linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null; - if (linkClose) { YAHOO.util.Event.purgeElement(linkClose); this.oDomContainer.removeChild(linkClose); @@ -1118,61 +1485,63 @@ YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.initEvents = function() { + var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; + /** * Fired before a selection is made * @event beforeSelectEvent */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect"); + this.beforeSelectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT); /** * Fired when a selection is made * @event selectEvent * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. */ - this.selectEvent = new YAHOO.util.CustomEvent("select"); + this.selectEvent = new YAHOO.util.CustomEvent(defEvents.SELECT); /** * Fired before a selection is made * @event beforeDeselectEvent */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect"); + this.beforeDeselectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT); /** * Fired when a selection is made * @event deselectEvent * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. */ - this.deselectEvent = new YAHOO.util.CustomEvent("deselect"); + this.deselectEvent = new YAHOO.util.CustomEvent(defEvents.DESELECT); /** * Fired when the Calendar page is changed * @event changePageEvent */ - this.changePageEvent = new YAHOO.util.CustomEvent("changePage"); + this.changePageEvent = new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE); /** * Fired before the Calendar is rendered * @event beforeRenderEvent */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); + this.beforeRenderEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER); /** * Fired when the Calendar is rendered * @event renderEvent */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); + this.renderEvent = new YAHOO.util.CustomEvent(defEvents.RENDER); /** * Fired when the Calendar is reset * @event resetEvent */ - this.resetEvent = new YAHOO.util.CustomEvent("reset"); + this.resetEvent = new YAHOO.util.CustomEvent(defEvents.RESET); /** * Fired when the Calendar is cleared * @event clearEvent */ - this.clearEvent = new YAHOO.util.CustomEvent("clear"); + this.clearEvent = new YAHOO.util.CustomEvent(defEvents.CLEAR); this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true); this.selectEvent.subscribe(this.onSelect, this, true); @@ -1184,7 +1553,6 @@ YAHOO.widget.Calendar.prototype.initEvents = function() { this.clearEvent.subscribe(this.onClear, this, true); }; - /** * The default event function that is attached to a date link within a calendar cell * when the calendar is rendered. @@ -1193,17 +1561,30 @@ YAHOO.widget.Calendar.prototype.initEvents = function() { * @param {Calendar} cal A reference to the calendar passed by the Event utility */ YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) { + var cell,index,d,date; + var target = YAHOO.util.Event.getTarget(e); + var tagName = target.tagName.toLowerCase(); + var defSelector = false; - var cell,index,d,date; + while (tagName != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { + + if (!defSelector && tagName == "a" && YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) { + defSelector = true; + } - while (target.tagName.toLowerCase() != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { target = target.parentNode; - if (target.tagName.toLowerCase() == "html") { + tagName = target.tagName.toLowerCase(); + if (tagName == "html") { return; } } - + + if (defSelector) { + // Stop link href navigation for default renderer + YAHOO.util.Event.preventDefault(e); + } + cell = target; if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) { @@ -1214,22 +1595,21 @@ YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) { var link; cal.logger.log("Selecting cell " + index + " via click", "info"); - if (cal.Options.MULTI_SELECT) { link = cell.getElementsByTagName("a")[0]; if (link) { link.blur(); } - + var cellDate = cal.cellDates[index]; var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate); - + if (cellDateIndex > -1) { cal.deselectCell(index); } else { cal.selectCell(index); } - + } else { link = cell.getElementsByTagName("a")[0]; if (link) { @@ -1294,13 +1674,15 @@ YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) { YAHOO.widget.Calendar.prototype.setupConfig = function() { + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + /** * The month/year representing the current visible Calendar date (mm/yyyy) * @config pagedate * @type String * @default today's date */ - this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } ); + this.cfg.addProperty(defCfg.PAGEDATE.key, { value:new Date(), handler:this.configPageDate } ); /** * The date or range of dates representing the current Calendar selection @@ -1308,7 +1690,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default [] */ - this.cfg.addProperty("selected", { value:[], handler:this.configSelected } ); + this.cfg.addProperty(defCfg.SELECTED.key, { value:[], handler:this.configSelected } ); /** * The title to display above the Calendar's month header @@ -1316,7 +1698,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "" */ - this.cfg.addProperty("title", { value:"", handler:this.configTitle } ); + this.cfg.addProperty(defCfg.TITLE.key, { value:defCfg.TITLE.value, handler:this.configTitle } ); /** * Whether or not a close button should be displayed for this Calendar @@ -1324,15 +1706,18 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("close", { value:false, handler:this.configClose } ); + this.cfg.addProperty(defCfg.CLOSE.key, { value:defCfg.CLOSE.value, handler:this.configClose } ); /** * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below. + * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be + * enabled if required. + * * @config iframe * @type Boolean - * @default true + * @default true for IE6 and below, false for all other browsers */ - this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.IFRAME.key, { value:defCfg.IFRAME.value, handler:this.configIframe, validator:this.cfg.checkBoolean } ); /** * The minimum selectable date in the current Calendar (mm/dd/yyyy) @@ -1340,7 +1725,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default null */ - this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } ); + this.cfg.addProperty(defCfg.MINDATE.key, { value:defCfg.MINDATE.value, handler:this.configMinDate } ); /** * The maximum selectable date in the current Calendar (mm/dd/yyyy) @@ -1348,7 +1733,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default null */ - this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } ); + this.cfg.addProperty(defCfg.MAXDATE.key, { value:defCfg.MAXDATE.value, handler:this.configMaxDate } ); // Options properties @@ -1359,7 +1744,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.MULTI_SELECT.key, { value:defCfg.MULTI_SELECT.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * The weekday the week begins on. Default is 0 (Sunday). @@ -1367,7 +1752,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type number * @default 0 */ - this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.START_WEEKDAY.key, { value:defCfg.START_WEEKDAY.value, handler:this.configOptions, validator:this.cfg.checkNumber } ); /** * True if the Calendar should show weekday labels. True by default. @@ -1375,7 +1760,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default true */ - this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEKDAYS.key, { value:defCfg.SHOW_WEEKDAYS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should show week row headers. False by default. @@ -1383,7 +1768,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEK_HEADER.key, { value:defCfg.SHOW_WEEK_HEADER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should show week row footers. False by default. @@ -1391,7 +1776,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEK_FOOTER.key,{ value:defCfg.SHOW_WEEK_FOOTER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should suppress weeks that are not a part of the current month. False by default. @@ -1399,23 +1784,25 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - + this.cfg.addProperty(defCfg.HIDE_BLANK_WEEKS.key, { value:defCfg.HIDE_BLANK_WEEKS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + /** * The image that should be used for the left navigation arrow. * @config NAV_ARROW_LEFT * @type String - * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif" + * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" + * @default null */ - this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.configOptions } ); + this.cfg.addProperty(defCfg.NAV_ARROW_LEFT.key, { value:defCfg.NAV_ARROW_LEFT.value, handler:this.configOptions } ); /** - * The image that should be used for the left navigation arrow. + * The image that should be used for the right navigation arrow. * @config NAV_ARROW_RIGHT * @type String - * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif" + * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" + * @default null */ - this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.configOptions } ); + this.cfg.addProperty(defCfg.NAV_ARROW_RIGHT.key, { value:defCfg.NAV_ARROW_RIGHT.value, handler:this.configOptions } ); // Locale properties @@ -1425,7 +1812,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] */ - this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.MONTHS_SHORT.key, { value:defCfg.MONTHS_SHORT.value, handler:this.configLocale } ); /** * The long month labels for the current locale. @@ -1433,7 +1820,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" */ - this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.MONTHS_LONG.key, { value:defCfg.MONTHS_LONG.value, handler:this.configLocale } ); /** * The 1-character weekday labels for the current locale. @@ -1441,7 +1828,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["S", "M", "T", "W", "T", "F", "S"] */ - this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.WEEKDAYS_1CHAR.key, { value:defCfg.WEEKDAYS_1CHAR.value, handler:this.configLocale } ); /** * The short weekday labels for the current locale. @@ -1449,7 +1836,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] */ - this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.WEEKDAYS_SHORT.key, { value:defCfg.WEEKDAYS_SHORT.value, handler:this.configLocale } ); /** * The medium weekday labels for the current locale. @@ -1457,7 +1844,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] */ - this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.WEEKDAYS_MEDIUM.key, { value:defCfg.WEEKDAYS_MEDIUM.value, handler:this.configLocale } ); /** * The long weekday labels for the current locale. @@ -1465,7 +1852,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] */ - this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.WEEKDAYS_LONG.key, { value:defCfg.WEEKDAYS_LONG.value, handler:this.configLocale } ); /** * Refreshes the locale values used to build the Calendar. @@ -1473,17 +1860,17 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @private */ var refreshLocale = function() { - this.cfg.refireEvent("LOCALE_MONTHS"); - this.cfg.refireEvent("LOCALE_WEEKDAYS"); + this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); + this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); }; - this.cfg.subscribeToConfigEvent("START_WEEKDAY", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("MONTHS_SHORT", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("MONTHS_LONG", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG", refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.START_WEEKDAY.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.MONTHS_SHORT.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.MONTHS_LONG.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_1CHAR.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_SHORT.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_MEDIUM.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_LONG.key, refreshLocale, this, true); /** * The setting that determines which length of month labels should be used. Possible values are "short" and "long". @@ -1491,7 +1878,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "long" */ - this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } ); + this.cfg.addProperty(defCfg.LOCALE_MONTHS.key, { value:defCfg.LOCALE_MONTHS.value, handler:this.configLocaleValues } ); /** * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". @@ -1499,7 +1886,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "short" */ - this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } ); + this.cfg.addProperty(defCfg.LOCALE_WEEKDAYS.key, { value:defCfg.LOCALE_WEEKDAYS.value, handler:this.configLocaleValues } ); /** * The value used to delimit individual dates in a date string passed to various Calendar functions. @@ -1507,7 +1894,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "," */ - this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } ); + this.cfg.addProperty(defCfg.DATE_DELIMITER.key, { value:defCfg.DATE_DELIMITER.value, handler:this.configLocale } ); /** * The value used to delimit date fields in a date string passed to various Calendar functions. @@ -1515,7 +1902,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "/" */ - this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } ); + this.cfg.addProperty(defCfg.DATE_FIELD_DELIMITER.key, { value:defCfg.DATE_FIELD_DELIMITER.value, handler:this.configLocale } ); /** * The value used to delimit date ranges in a date string passed to various Calendar functions. @@ -1523,7 +1910,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "-" */ - this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } ); + this.cfg.addProperty(defCfg.DATE_RANGE_DELIMITER.key, { value:defCfg.DATE_RANGE_DELIMITER.value, handler:this.configLocale } ); /** * The position of the month in a month/year date string @@ -1531,7 +1918,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MY_MONTH_POSITION.key, { value:defCfg.MY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/year date string @@ -1539,7 +1926,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MY_YEAR_POSITION.key, { value:defCfg.MY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day date string @@ -1547,7 +1934,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MD_MONTH_POSITION.key, { value:defCfg.MD_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/year date string @@ -1555,7 +1942,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MD_DAY_POSITION.key, { value:defCfg.MD_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day/year date string @@ -1563,7 +1950,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_MONTH_POSITION.key, { value:defCfg.MDY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/day/year date string @@ -1571,7 +1958,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_DAY_POSITION.key, { value:defCfg.MDY_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/day/year date string @@ -1579,7 +1966,39 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 3 */ - this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_YEAR_POSITION.key, { value:defCfg.MDY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); + + /** + * The position of the month in the month year label string used as the Calendar header + * @config MY_LABEL_MONTH_POSITION + * @type Number + * @default 1 + */ + this.cfg.addProperty(defCfg.MY_LABEL_MONTH_POSITION.key, { value:defCfg.MY_LABEL_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); + + /** + * The position of the year in the month year label string used as the Calendar header + * @config MY_LABEL_YEAR_POSITION + * @type Number + * @default 2 + */ + this.cfg.addProperty(defCfg.MY_LABEL_YEAR_POSITION.key, { value:defCfg.MY_LABEL_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); + + /** + * The suffix used after the month when rendering the Calendar header + * @config MY_LABEL_MONTH_SUFFIX + * @type String + * @default " " + */ + this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.configLocale } ); + + /** + * The suffix used after the year when rendering the Calendar header + * @config MY_LABEL_YEAR_SUFFIX + * @type String + * @default "" + */ + this.cfg.addProperty(defCfg.MY_LABEL_YEAR_SUFFIX.key, { value:defCfg.MY_LABEL_YEAR_SUFFIX.value, handler:this.configLocale } ); }; /** @@ -1587,34 +2006,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @method configPageDate */ YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { - var val = args[0]; - var month, year, aMonthYear; - - if (val) { - if (val instanceof Date) { - val = YAHOO.widget.DateMath.findMonthStart(val); - this.cfg.setProperty("pagedate", val, true); - if (! this._pageDate) { - this._pageDate = this.cfg.getProperty("pagedate"); - } - return; - } else { - aMonthYear = val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER")); - month = parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1], 10)-1; - year = parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1], 10); - } - } else { - month = this.today.getMonth(); - year = this.today.getFullYear(); - } - - this.cfg.setProperty("pagedate", new Date(year, month, 1), true); - - this.logger.log("Set month/year to " + month + "/" + year, "info"); - - if (! this._pageDate) { - this._pageDate = this.cfg.getProperty("pagedate"); - } + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true); }; /** @@ -1623,9 +2015,9 @@ YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) { var val = args[0]; - if (typeof val == 'string') { + if (YAHOO.lang.isString(val)) { val = this._parseDate(val); - this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2])); + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, new Date(val[0],(val[1]-1),val[2])); } }; @@ -1635,9 +2027,9 @@ YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) { var val = args[0]; - if (typeof val == 'string') { + if (YAHOO.lang.isString(val)) { val = this._parseDate(val); - this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2])); + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, new Date(val[0],(val[1]-1),val[2])); } }; @@ -1647,14 +2039,15 @@ YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) { var selected = args[0]; + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; if (selected) { - if (typeof selected == 'string') { - this.cfg.setProperty("selected", this._parseDates(selected), true); + if (YAHOO.lang.isString(selected)) { + this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); } } if (! this._selectedDates) { - this._selectedDates = this.cfg.getProperty("selected"); + this._selectedDates = this.cfg.getProperty(cfgSelected); } }; @@ -1663,9 +2056,7 @@ YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) { * @method configOptions */ YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { - type = type.toUpperCase(); - var val = args[0]; - this.Options[type] = val; + this.Options[type.toUpperCase()] = args[0]; }; /** @@ -1673,13 +2064,11 @@ YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { * @method configLocale */ YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) { - type = type.toUpperCase(); - var val = args[0]; - this.Locale[type] = val; - - this.cfg.refireEvent("LOCALE_MONTHS"); - this.cfg.refireEvent("LOCALE_WEEKDAYS"); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + this.Locale[type.toUpperCase()] = args[0]; + this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); + this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); }; /** @@ -1687,37 +2076,39 @@ YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) { * @method configLocaleValues */ YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) { - type = type.toUpperCase(); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + + type = type.toLowerCase(); var val = args[0]; switch (type) { - case "LOCALE_MONTHS": + case defCfg.LOCALE_MONTHS.key: switch (val) { - case "short": - this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat(); + case YAHOO.widget.Calendar.SHORT: + this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat(); break; - case "long": - this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat(); + case YAHOO.widget.Calendar.LONG: + this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat(); break; } break; - case "LOCALE_WEEKDAYS": + case defCfg.LOCALE_WEEKDAYS.key: switch (val) { - case "1char": - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat(); + case YAHOO.widget.Calendar.ONE_CHAR: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_1CHAR.key).concat(); break; - case "short": - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat(); + case YAHOO.widget.Calendar.SHORT: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_SHORT.key).concat(); break; - case "medium": - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat(); + case YAHOO.widget.Calendar.MEDIUM: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_MEDIUM.key).concat(); break; - case "long": - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat(); + case YAHOO.widget.Calendar.LONG: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_LONG.key).concat(); break; } - var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY"); + var START_WEEKDAY = this.cfg.getProperty(defCfg.START_WEEKDAY.key); if (START_WEEKDAY > 0) { for (var w=0;w'; html[html.length] = '
'; - var renderLeft, renderRight = false; + var renderLeft, renderRight = false; - if (this.parent) { - if (this.index === 0) { - renderLeft = true; - } - if (this.index == (this.parent.cfg.getProperty("pages") -1)) { - renderRight = true; - } - } else { + if (this.parent) { + if (this.index === 0) { renderLeft = true; + } + if (this.index == (this.parent.cfg.getProperty("pages") -1)) { renderRight = true; } + } else { + renderLeft = true; + renderRight = true; + } - var cal = this.parent || this; - - if (renderLeft) { - html[html.length] = ' '; + var cal = this.parent || this; + + if (renderLeft) { + var leftArrow = this.cfg.getProperty(defCfg.NAV_ARROW_LEFT.key); + // Check for deprecated customization - If someone set IMG_ROOT, but didn't set NAV_ARROW_LEFT, then set NAV_ARROW_LEFT to the old deprecated value + if (leftArrow === null && YAHOO.widget.Calendar.IMG_ROOT !== null) { + leftArrow = YAHOO.widget.Calendar.IMG_ROOT + DEPR_NAV_LEFT; } - - html[html.length] = this.buildMonthLabel(); - - if (renderRight) { - html[html.length] = ' '; + var leftStyle = (leftArrow === null) ? "" : ' style="background-image:url(' + leftArrow + ')"'; + html[html.length] = ' '; + } + + html[html.length] = this.buildMonthLabel(); + + if (renderRight) { + var rightArrow = this.cfg.getProperty(defCfg.NAV_ARROW_RIGHT.key); + if (rightArrow === null && YAHOO.widget.Calendar.IMG_ROOT !== null) { + rightArrow = YAHOO.widget.Calendar.IMG_ROOT + DEPR_NAV_RIGHT; } + var rightStyle = (rightArrow === null) ? "" : ' style="background-image:url(' + rightArrow + ')"'; + html[html.length] = ' '; + } + html[html.length] = '
\n\n'; - html[html.length] = ''; - html[html.length] = ''; - html[html.length] = ''; - - if (this.cfg.getProperty("SHOW_WEEKDAYS")) { + if (this.cfg.getProperty(defCfg.SHOW_WEEKDAYS.key)) { html = this.buildWeekdays(html); } @@ -1948,9 +2367,11 @@ YAHOO.widget.Calendar.prototype.renderHeader = function(html) { */ YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) { + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + html[html.length] = ''; - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { + if (this.cfg.getProperty(defCfg.SHOW_WEEK_HEADER.key)) { html[html.length] = ' '; } @@ -1958,7 +2379,7 @@ YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) { html[html.length] = '' + this.Locale.LOCALE_WEEKDAYS[i] + ''; } - if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { + if (this.cfg.getProperty(defCfg.SHOW_WEEK_FOOTER.key)) { html[html.length] = ' '; } @@ -1976,8 +2397,9 @@ YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) { */ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { this.logger.log("Rendering body", "info"); - - var startDay = this.cfg.getProperty("START_WEEKDAY"); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + + var startDay = this.cfg.getProperty(defCfg.START_WEEKDAY.key); this.preMonthDays = workingDate.getDay(); if (startDay > 0) { @@ -1989,7 +2411,6 @@ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate(); this.postMonthDays = YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays; - this.logger.log(this.preMonthDays + " preciding out-of-month days", "info"); this.logger.log(this.monthDays + " month days", "info"); this.logger.log(this.postMonthDays + " post-month days", "info"); @@ -1997,10 +2418,34 @@ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays); this.logger.log("Calendar page starts on " + workingDate, "info"); - var useDate,weekNum,weekClass; - useDate = this.cfg.getProperty("pagedate"); - - html[html.length] = ''; + var weekNum,weekClass; + var weekPrefix = "w"; + var cellPrefix = "_cell"; + var workingDayPrefix = "wd"; + var dayPrefix = "d"; + + var cellRenderers; + var renderer; + + var todayYear = this.today.getFullYear(); + var todayMonth = this.today.getMonth(); + var todayDate = this.today.getDate(); + + var useDate = this.cfg.getProperty(defCfg.PAGEDATE.key); + var hideBlankWeeks = this.cfg.getProperty(defCfg.HIDE_BLANK_WEEKS.key); + var showWeekFooter = this.cfg.getProperty(defCfg.SHOW_WEEK_FOOTER.key); + var showWeekHeader = this.cfg.getProperty(defCfg.SHOW_WEEK_HEADER.key); + var mindate = this.cfg.getProperty(defCfg.MINDATE.key); + var maxdate = this.cfg.getProperty(defCfg.MAXDATE.key); + + if (mindate) { + mindate = YAHOO.widget.DateMath.clearTime(mindate); + } + if (maxdate) { + maxdate = YAHOO.widget.DateMath.clearTime(maxdate); + } + + html[html.length] = ''; var i = 0; @@ -2015,46 +2460,42 @@ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { for (var r=0;r<6;r++) { weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay); + weekClass = weekPrefix + weekNum; - weekClass = "w" + weekNum; - - if (r !== 0 && this.isDateOOM(workingDate) && this.cfg.getProperty("HIDE_BLANK_WEEKS") === true) { + // Local OOM check for performance, since we already have pagedate + if (r !== 0 && hideBlankWeeks === true && workingDate.getMonth() != useDate.getMonth()) { break; } else { - + html[html.length] = ''; - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); } + if (showWeekHeader) { html = this.renderRowHeader(weekNum, html); } for (var d=0;d<7;d++){ // Render actual days - var cellRenderers = []; + cellRenderers = []; + renderer = null; this.clearElement(cell); - - YAHOO.util.Dom.addClass(cell, "calcell"); - - cell.id = this.id + "_cell" + i; + cell.className = this.Style.CSS_CELL; + cell.id = this.id + cellPrefix + i; this.logger.log("Rendering cell " + cell.id + " (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender"); - cell.innerHTML = i; - - var renderer = null; - - if (workingDate.getFullYear() == this.today.getFullYear() && - workingDate.getMonth() == this.today.getMonth() && - workingDate.getDate() == this.today.getDate()) { + if (workingDate.getDate() == todayDate && + workingDate.getMonth() == todayMonth && + workingDate.getFullYear() == todayYear) { cellRenderers[cellRenderers.length]=cal.renderCellStyleToday; } - this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates - - if (this.isDateOOM(workingDate)) { + var workingArray = [workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; + this.cellDates[this.cellDates.length] = workingArray; // Add this date to cellDates + + // Local OOM check for performance, since we already have pagedate + if (workingDate.getMonth() != useDate.getMonth()) { cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth; } else { - - YAHOO.util.Dom.addClass(cell, "wd" + workingDate.getDay()); - YAHOO.util.Dom.addClass(cell, "d" + workingDate.getDate()); + YAHOO.util.Dom.addClass(cell, workingDayPrefix + workingDate.getDay()); + YAHOO.util.Dom.addClass(cell, dayPrefix + workingDate.getDate()); for (var s=0;s -1) { + if (this._indexOfSelectedFieldArray(workingArray) > -1) { cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected; } - var mindate = this.cfg.getProperty("mindate"); - var maxdate = this.cfg.getProperty("maxdate"); - - if (mindate) { - mindate = YAHOO.widget.DateMath.clearTime(mindate); - } - if (maxdate) { - maxdate = YAHOO.widget.DateMath.clearTime(maxdate); - } - - if ( - (mindate && (workingDate.getTime() < mindate.getTime())) || + if ((mindate && (workingDate.getTime() < mindate.getTime())) || (maxdate && (workingDate.getTime() > maxdate.getTime())) ) { cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate; @@ -2155,14 +2585,10 @@ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { cellRenderers[cellRenderers.length]=cal.styleCellDefault; cellRenderers[cellRenderers.length]=cal.renderCellDefault; } - - - for (var x=0;x= 7 && this.cfg.getProperty("HIDE_BLANK_WEEKS")) { + if (hideBlankWeeks && postDays >= 7) { var blankWeeks = Math.floor(postDays/7); for (var p=0;p'; @@ -2243,13 +2670,13 @@ YAHOO.widget.Calendar.prototype.render = function() { html[html.length] = ''; this.oDomContainer.innerHTML = html.join("\n"); - + this.applyListeners(); this.cells = this.oDomContainer.getElementsByTagName("td"); - this.cfg.refireEvent("title"); - this.cfg.refireEvent("close"); - this.cfg.refireEvent("iframe"); + this.cfg.refireEvent(defCfg.TITLE.key); + this.cfg.refireEvent(defCfg.CLOSE.key); + this.cfg.refireEvent(defCfg.IFRAME.key); this.renderEvent.fire(); }; @@ -2262,28 +2689,29 @@ YAHOO.widget.Calendar.prototype.applyListeners = function() { var root = this.oDomContainer; var cal = this.parent || this; - - var linkLeft, linkRight; - linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, "a", root); - linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, "a", root); + var anchor = "a"; + var mousedown = "mousedown"; + + var linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, anchor, root); + var linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, anchor, root); - if (linkLeft) { + if (linkLeft && linkLeft.length > 0) { this.linkLeft = linkLeft[0]; - YAHOO.util.Event.addListener(this.linkLeft, "mousedown", cal.previousMonth, cal, true); + YAHOO.util.Event.addListener(this.linkLeft, mousedown, cal.previousMonth, cal, true); } - if (linkRight) { + if (linkRight && linkRight.length > 0) { this.linkRight = linkRight[0]; - YAHOO.util.Event.addListener(this.linkRight, "mousedown", cal.nextMonth, cal, true); + YAHOO.util.Event.addListener(this.linkRight, mousedown, cal.nextMonth, cal, true); } if (this.domEventMap) { var el,elements; for (var cls in this.domEventMap) { - if (this.domEventMap.hasOwnProperty(cls)) { + if (YAHOO.lang.hasOwnProperty(this.domEventMap, cls)) { var items = this.domEventMap[cls]; - + if (! (items instanceof Array)) { items = [items]; } @@ -2328,7 +2756,7 @@ YAHOO.widget.Calendar.prototype.getDateFieldsByCellId = function(id) { id = parseInt(id, 10); return this.cellDates[id]; }; - + // BEGIN BUILT-IN TABLE CELL RENDERERS /** @@ -2378,7 +2806,7 @@ YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) { * @param {HTMLTableCellElement} cell The current working cell in the calendar */ YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) { - cell.innerHTML = '' + this.buildDayLabel(workingDate) + ""; + cell.innerHTML = '' + this.buildDayLabel(workingDate) + ""; }; /** @@ -2496,7 +2924,8 @@ YAHOO.widget.Calendar.prototype.renderBodyCellRestricted = function(workingDate, * @param {Number} count The number of months to add to the current calendar */ YAHOO.widget.Calendar.prototype.addMonths = function(count) { - this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count)); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.MONTH, count)); this.resetRenderers(); this.changePageEvent.fire(); }; @@ -2508,7 +2937,8 @@ YAHOO.widget.Calendar.prototype.addMonths = function(count) { * @param {Number} count The number of months to subtract from the current calendar */ YAHOO.widget.Calendar.prototype.subtractMonths = function(count) { - this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count)); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.MONTH, count)); this.resetRenderers(); this.changePageEvent.fire(); }; @@ -2520,7 +2950,8 @@ YAHOO.widget.Calendar.prototype.subtractMonths = function(count) { * @param {Number} count The number of years to add to the current calendar */ YAHOO.widget.Calendar.prototype.addYears = function(count) { - this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count)); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.YEAR, count)); this.resetRenderers(); this.changePageEvent.fire(); }; @@ -2532,7 +2963,8 @@ YAHOO.widget.Calendar.prototype.addYears = function(count) { * @param {Number} count The number of years to subtract from the current calendar */ YAHOO.widget.Calendar.prototype.subtractYears = function(count) { - this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count)); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.YEAR, count)); this.resetRenderers(); this.changePageEvent.fire(); }; @@ -2579,8 +3011,9 @@ YAHOO.widget.Calendar.prototype.previousYear = function() { * @method reset */ YAHOO.widget.Calendar.prototype.reset = function() { - this.cfg.resetProperty("selected"); - this.cfg.resetProperty("pagedate"); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + this.cfg.resetProperty(defCfg.SELECTED.key); + this.cfg.resetProperty(defCfg.PAGEDATE.key); this.resetEvent.fire(); }; @@ -2590,8 +3023,9 @@ YAHOO.widget.Calendar.prototype.reset = function() { * @method clear */ YAHOO.widget.Calendar.prototype.clear = function() { - this.cfg.setProperty("selected", []); - this.cfg.setProperty("pagedate", new Date(this.today.getTime())); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + this.cfg.setProperty(defCfg.SELECTED.key, []); + this.cfg.setProperty(defCfg.PAGEDATE.key, new Date(this.today.getTime())); this.clearEvent.fire(); }; @@ -2599,6 +3033,12 @@ YAHOO.widget.Calendar.prototype.clear = function() { * 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. +* +* Any dates which are OOB (out of bounds, not selectable) will not be selected and the array of +* selected dates passed to the selectEvent will not contain OOB dates. +* +* If all dates are OOB, the no state change will occur; beforeSelect and select events will not be fired. +* * @method select * @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). @@ -2609,27 +3049,43 @@ YAHOO.widget.Calendar.prototype.clear = function() { YAHOO.widget.Calendar.prototype.select = function(date) { this.logger.log("Select: " + date, "info"); - this.beforeSelectEvent.fire(); - - var selected = this.cfg.getProperty("selected"); var aToBeSelected = this._toFieldArray(date); this.logger.log("Selection field array: " + aToBeSelected, "info"); - for (var a=0;a 0) { + if (this.parent) { + this.parent.cfg.setProperty(cfgSelected, selected); + } else { + this.cfg.setProperty(cfgSelected, selected); + } + this.selectEvent.fire(validDates); } - this.selectEvent.fire(aToBeSelected); - return this.getSelectedDates(); }; @@ -2637,36 +3093,46 @@ YAHOO.widget.Calendar.prototype.select = function(date) { * 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. +* +* If the cell is not marked with the CSS_CELL_SELECTABLE class (as is the case by default for out of month +* or out of bounds cells), it will not be selected and in such a case beforeSelect and select events will not be fired. +* * @method selectCell * @param {Number} cellIndex The index of the cell to select in the current calendar. * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.Calendar.prototype.selectCell = function(cellIndex) { - this.beforeSelectEvent.fire(); - - var selected = this.cfg.getProperty("selected"); var cell = this.cells[cellIndex]; var cellDate = this.cellDates[cellIndex]; - var dCellDate = this._toDate(cellDate); this.logger.log("Select: " + dCellDate, "info"); + + var selectable = YAHOO.util.Dom.hasClass(cell, this.Style.CSS_CELL_SELECTABLE); + if (!selectable) {this.logger.log("The cell at cellIndex:" + cellIndex + " is not a selectable cell. beforeSelect, select events not fired", "info"); } - var selectDate = cellDate.concat(); + if (selectable) { - selected[selected.length] = selectDate; + this.beforeSelectEvent.fire(); - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); - } + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; + var selected = this.cfg.getProperty(cfgSelected); - this.renderCellStyleSelected(dCellDate,cell); + var selectDate = cellDate.concat(); - this.selectEvent.fire([selectDate]); + if (this._indexOfSelectedFieldArray(selectDate) == -1) { + selected[selected.length] = selectDate; + } + if (this.parent) { + this.parent.cfg.setProperty(cfgSelected, selected); + } else { + this.cfg.setProperty(cfgSelected, selected); + } + this.renderCellStyleSelected(dCellDate,cell); + this.selectEvent.fire([selectDate]); - this.doCellMouseOut.call(cell, null, this); + this.doCellMouseOut.call(cell, null, this); + } return this.getSelectedDates(); }; @@ -2675,6 +3141,12 @@ YAHOO.widget.Calendar.prototype.selectCell = function(cellIndex) { * 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. +* +* The method will not attempt to deselect any dates which are OOB (out of bounds, and hence not selectable) +* and the array of deselected dates passed to the deselectEvent will not contain any OOB dates. +* +* If all dates are OOB, beforeDeselect and deselect events will not be fired. +* * @method deselect * @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). @@ -2683,29 +3155,45 @@ YAHOO.widget.Calendar.prototype.selectCell = function(cellIndex) { * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.Calendar.prototype.deselect = function(date) { - this.beforeDeselectEvent.fire(); + this.logger.log("Deselect: " + date, "info"); - var selected = this.cfg.getProperty("selected"); + var aToBeDeselected = this._toFieldArray(date); + this.logger.log("Deselection field array: " + aToBeDeselected, "info"); - var aToBeSelected = this._toFieldArray(date); + var validDates = []; + var selected = []; + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; - for (var a=0;a 0) { + if (this.parent) { + this.parent.cfg.setProperty(cfgSelected, selected); + } else { + this.cfg.setProperty(cfgSelected, selected); + } + this.deselectEvent.fire(validDates); } - this.deselectEvent.fire(aToBeSelected); - return this.getSelectedDates(); }; @@ -2713,40 +3201,50 @@ YAHOO.widget.Calendar.prototype.deselect = function(date) { * 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. +* +* If the cell is not marked with the CSS_CELL_SELECTABLE class (as is the case by default for out of month +* or out of bounds cells), the method will not attempt to deselect it and in such a case, beforeDeselect and +* deselect events will not be fired. +* * @method deselectCell * @param {Number} cellIndex The index of the cell to deselect in the current calendar. * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ -YAHOO.widget.Calendar.prototype.deselectCell = function(i) { - this.beforeDeselectEvent.fire(); +YAHOO.widget.Calendar.prototype.deselectCell = function(cellIndex) { + var cell = this.cells[cellIndex]; + var cellDate = this.cellDates[cellIndex]; + var cellDateIndex = this._indexOfSelectedFieldArray(cellDate); - var selected = this.cfg.getProperty("selected"); + var selectable = YAHOO.util.Dom.hasClass(cell, this.Style.CSS_CELL_SELECTABLE); + if (!selectable) { this.logger.log("The cell at cellIndex:" + cellIndex + " is not a selectable/deselectable cell", "info"); } - var cell = this.cells[i]; - var cellDate = this.cellDates[i]; - var cellDateIndex = this._indexOfSelectedFieldArray(cellDate); + if (selectable) { - var dCellDate = this._toDate(cellDate); + this.beforeDeselectEvent.fire(); - var selectDate = cellDate.concat(); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + var selected = this.cfg.getProperty(defCfg.SELECTED.key); - if (cellDateIndex > -1) { - if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() && - this.cfg.getProperty("pagedate").getFullYear() == dCellDate.getFullYear()) { - YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED); - } + var dCellDate = this._toDate(cellDate); + var selectDate = cellDate.concat(); - selected.splice(cellDateIndex, 1); - } + if (cellDateIndex > -1) { + if (this.cfg.getProperty(defCfg.PAGEDATE.key).getMonth() == dCellDate.getMonth() && + this.cfg.getProperty(defCfg.PAGEDATE.key).getFullYear() == dCellDate.getFullYear()) { + YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED); + } + selected.splice(cellDateIndex, 1); + } + if (this.parent) { + this.parent.cfg.setProperty(defCfg.SELECTED.key, selected); + } else { + this.cfg.setProperty(defCfg.SELECTED.key, selected); + } - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); + this.deselectEvent.fire(selectDate); } - - this.deselectEvent.fire(selectDate); + return this.getSelectedDates(); }; @@ -2760,15 +3258,17 @@ YAHOO.widget.Calendar.prototype.deselectCell = function(i) { */ YAHOO.widget.Calendar.prototype.deselectAll = function() { this.beforeDeselectEvent.fire(); + + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; - var selected = this.cfg.getProperty("selected"); + var selected = this.cfg.getProperty(cfgSelected); var count = selected.length; var sel = selected.concat(); if (this.parent) { - this.parent.cfg.setProperty("selected", []); + this.parent.cfg.setProperty(cfgSelected, []); } else { - this.cfg.setProperty("selected", []); + this.cfg.setProperty(cfgSelected, []); } if (count > 0) { @@ -2798,9 +3298,9 @@ YAHOO.widget.Calendar.prototype._toFieldArray = function(date) { if (date instanceof Date) { returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]]; - } else if (typeof date == 'string') { + } else if (YAHOO.lang.isString(date)) { returnDate = this._parseDates(date); - } else if (date instanceof Array) { + } else if (YAHOO.lang.isArray(date)) { for (var i=0;i maxDate.getTime())); +}; + +/** + * Parses a pagedate configuration property value. The value can either be specified as a string of form "mm/yyyy" or a Date object + * and is parsed into a Date object normalized to the first day of the month. If no value is passed in, the month and year from today's date are used to create the Date object + * @method _parsePageDate + * @private + * @param {Date|String} date Pagedate value which needs to be parsed + * @return {Date} The Date object representing the pagedate + */ +YAHOO.widget.Calendar.prototype._parsePageDate = function(date) { + var parsedDate; + + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + + if (date) { + if (date instanceof Date) { + parsedDate = YAHOO.widget.DateMath.findMonthStart(date); + } else { + var month, year, aMonthYear; + aMonthYear = date.split(this.cfg.getProperty(defCfg.DATE_FIELD_DELIMITER.key)); + month = parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_MONTH_POSITION.key)-1], 10)-1; + year = parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_YEAR_POSITION.key)-1], 10); + + parsedDate = new Date(year, month, 1); + } + } else { + parsedDate = new Date(this.today.getFullYear(), this.today.getMonth(), 1); } - return isOOM; + return parsedDate; }; // END UTILITY METHODS @@ -2893,7 +3446,7 @@ YAHOO.widget.Calendar.prototype.isDateOOM = function(date) { * @deprecated Event handlers for this event should be susbcribed to beforeSelectEvent. */ YAHOO.widget.Calendar.prototype.onBeforeSelect = function() { - if (this.cfg.getProperty("MULTI_SELECT") === false) { + if (this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MULTI_SELECT.key) === false) { if (this.parent) { this.parent.callChildFunction("clearAllBodyCellStyles", this.Style.CSS_CELL_SELECTED); this.parent.deselectAll(); @@ -3154,9 +3707,10 @@ YAHOO.widget.Calendar.prototype.clearAllBodyCellStyles = function(style) { * @param {Number} month The numeric month, from 0 (January) to 11 (December) */ YAHOO.widget.Calendar.prototype.setMonth = function(month) { - var current = this.cfg.getProperty("pagedate"); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + var current = this.cfg.getProperty(cfgPageDate); current.setMonth(parseInt(month, 10)); - this.cfg.setProperty("pagedate", current); + this.cfg.setProperty(cfgPageDate, current); }; /** @@ -3165,9 +3719,10 @@ YAHOO.widget.Calendar.prototype.setMonth = function(month) { * @param {Number} year The numeric 4-digit year */ YAHOO.widget.Calendar.prototype.setYear = function(year) { - var current = this.cfg.getProperty("pagedate"); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + var current = this.cfg.getProperty(cfgPageDate); current.setFullYear(parseInt(year, 10)); - this.cfg.setProperty("pagedate", current); + this.cfg.setProperty(cfgPageDate, current); }; /** @@ -3177,7 +3732,7 @@ YAHOO.widget.Calendar.prototype.setYear = function(year) { */ YAHOO.widget.Calendar.prototype.getSelectedDates = function() { var returnDates = []; - var selected = this.cfg.getProperty("selected"); + var selected = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key); for (var d=0;d 0) { - this.oDomContainer.style.width = w + "px"; - } - }; - this.renderEvent.subscribe(fixWidth,this,true); + if (YAHOO.env.ua.opera){ + this.renderEvent.subscribe(this._fixWidth, this, true); } - - this.logger.log("Initialized " + pageCount + "-page CalendarGroup", "info"); + this.logger.log("Initialized " + this.pages.length + "-page CalendarGroup", "info"); }; YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { + + var defCfg = YAHOO.widget.CalendarGroup._DEFAULT_CONFIG; + /** * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments. * @config pages * @type Number * @default 2 */ - this.cfg.addProperty("pages", { value:2, validator:this.cfg.checkNumber, handler:this.configPages } ); + this.cfg.addProperty(defCfg.PAGES.key, { value:defCfg.PAGES.value, validator:this.cfg.checkNumber, handler:this.configPages } ); /** * The month/year representing the current visible Calendar date (mm/yyyy) @@ -3383,7 +3930,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default today's date */ - this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } ); + this.cfg.addProperty(defCfg.PAGEDATE.key, { value:new Date(), handler:this.configPageDate } ); /** * The date or range of dates representing the current Calendar selection @@ -3391,7 +3938,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default [] */ - this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.SELECTED.key, { value:[], handler:this.configSelected } ); /** * The title to display above the CalendarGroup's month header @@ -3399,7 +3946,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "" */ - this.cfg.addProperty("title", { value:"", handler:this.configTitle } ); + this.cfg.addProperty(defCfg.TITLE.key, { value:defCfg.TITLE.value, handler:this.configTitle } ); /** * Whether or not a close button should be displayed for this CalendarGroup @@ -3407,15 +3954,18 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("close", { value:false, handler:this.configClose } ); + this.cfg.addProperty(defCfg.CLOSE.key, { value:defCfg.CLOSE.value, handler:this.configClose } ); /** * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below. + * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be + * enabled if required. + * * @config iframe * @type Boolean - * @default true + * @default true for IE6 and below, false for all other browsers */ - this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.IFRAME.key, { value:defCfg.IFRAME.value, handler:this.configIframe, validator:this.cfg.checkBoolean } ); /** * The minimum selectable date in the current Calendar (mm/dd/yyyy) @@ -3423,7 +3973,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default null */ - this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.MINDATE.key, { value:defCfg.MINDATE.value, handler:this.delegateConfig } ); /** * The maximum selectable date in the current Calendar (mm/dd/yyyy) @@ -3431,7 +3981,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default null */ - this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.MAXDATE.key, { value:defCfg.MAXDATE.value, handler:this.delegateConfig } ); // Options properties @@ -3441,7 +3991,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.MULTI_SELECT.key, { value:defCfg.MULTI_SELECT.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * The weekday the week begins on. Default is 0 (Sunday). @@ -3449,7 +3999,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type number * @default 0 */ - this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.START_WEEKDAY.key, { value:defCfg.START_WEEKDAY.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * True if the Calendar should show weekday labels. True by default. @@ -3457,7 +4007,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default true */ - this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEKDAYS.key, { value:defCfg.SHOW_WEEKDAYS.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should show week row headers. False by default. @@ -3465,7 +4015,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEK_HEADER.key,{ value:defCfg.SHOW_WEEK_HEADER.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should show week row footers. False by default. @@ -3473,7 +4023,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEK_FOOTER.key,{ value:defCfg.SHOW_WEEK_FOOTER.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should suppress weeks that are not a part of the current month. False by default. @@ -3481,23 +4031,25 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.HIDE_BLANK_WEEKS.key,{ value:defCfg.HIDE_BLANK_WEEKS.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * The image that should be used for the left navigation arrow. * @config NAV_ARROW_LEFT * @type String - * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif" + * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" + * @default null */ - this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.NAV_ARROW_LEFT.key, { value:defCfg.NAV_ARROW_LEFT.value, handler:this.delegateConfig } ); /** - * The image that should be used for the left navigation arrow. + * The image that should be used for the right navigation arrow. * @config NAV_ARROW_RIGHT * @type String - * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif" + * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" + * @default null */ - this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.NAV_ARROW_RIGHT.key, { value:defCfg.NAV_ARROW_RIGHT.value, handler:this.delegateConfig } ); // Locale properties @@ -3507,7 +4059,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] */ - this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.MONTHS_SHORT.key, { value:defCfg.MONTHS_SHORT.value, handler:this.delegateConfig } ); /** * The long month labels for the current locale. @@ -3515,7 +4067,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" */ - this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.MONTHS_LONG.key, { value:defCfg.MONTHS_LONG.value, handler:this.delegateConfig } ); /** * The 1-character weekday labels for the current locale. @@ -3523,7 +4075,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["S", "M", "T", "W", "T", "F", "S"] */ - this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.WEEKDAYS_1CHAR.key, { value:defCfg.WEEKDAYS_1CHAR.value, handler:this.delegateConfig } ); /** * The short weekday labels for the current locale. @@ -3531,7 +4083,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] */ - this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.WEEKDAYS_SHORT.key, { value:defCfg.WEEKDAYS_SHORT.value, handler:this.delegateConfig } ); /** * The medium weekday labels for the current locale. @@ -3539,7 +4091,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] */ - this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.WEEKDAYS_MEDIUM.key, { value:defCfg.WEEKDAYS_MEDIUM.value, handler:this.delegateConfig } ); /** * The long weekday labels for the current locale. @@ -3547,7 +4099,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] */ - this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.WEEKDAYS_LONG.key, { value:defCfg.WEEKDAYS_LONG.value, handler:this.delegateConfig } ); /** * The setting that determines which length of month labels should be used. Possible values are "short" and "long". @@ -3555,7 +4107,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "long" */ - this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.LOCALE_MONTHS.key, { value:defCfg.LOCALE_MONTHS.value, handler:this.delegateConfig } ); /** * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". @@ -3563,7 +4115,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "short" */ - this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.LOCALE_WEEKDAYS.key, { value:defCfg.LOCALE_WEEKDAYS.value, handler:this.delegateConfig } ); /** * The value used to delimit individual dates in a date string passed to various Calendar functions. @@ -3571,7 +4123,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "," */ - this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.DATE_DELIMITER.key, { value:defCfg.DATE_DELIMITER.value, handler:this.delegateConfig } ); /** * The value used to delimit date fields in a date string passed to various Calendar functions. @@ -3579,7 +4131,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "/" */ - this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.DATE_FIELD_DELIMITER.key,{ value:defCfg.DATE_FIELD_DELIMITER.value, handler:this.delegateConfig } ); /** * The value used to delimit date ranges in a date string passed to various Calendar functions. @@ -3587,7 +4139,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "-" */ - this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.DATE_RANGE_DELIMITER.key,{ value:defCfg.DATE_RANGE_DELIMITER.value, handler:this.delegateConfig } ); /** * The position of the month in a month/year date string @@ -3595,7 +4147,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MY_MONTH_POSITION.key, { value:defCfg.MY_MONTH_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/year date string @@ -3603,7 +4155,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MY_YEAR_POSITION.key, { value:defCfg.MY_YEAR_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day date string @@ -3611,7 +4163,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MD_MONTH_POSITION.key, { value:defCfg.MD_MONTH_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/year date string @@ -3619,7 +4171,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MD_DAY_POSITION.key, { value:defCfg.MD_DAY_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day/year date string @@ -3627,7 +4179,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_MONTH_POSITION.key, { value:defCfg.MDY_MONTH_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/day/year date string @@ -3635,7 +4187,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_DAY_POSITION.key, { value:defCfg.MDY_DAY_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/day/year date string @@ -3643,8 +4195,39 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 3 */ - this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_YEAR_POSITION.key, { value:defCfg.MDY_YEAR_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + /** + * The position of the month in the month year label string used as the Calendar header + * @config MY_LABEL_MONTH_POSITION + * @type Number + * @default 1 + */ + this.cfg.addProperty(defCfg.MY_LABEL_MONTH_POSITION.key, { value:defCfg.MY_LABEL_MONTH_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + + /** + * The position of the year in the month year label string used as the Calendar header + * @config MY_LABEL_YEAR_POSITION + * @type Number + * @default 2 + */ + this.cfg.addProperty(defCfg.MY_LABEL_YEAR_POSITION.key, { value:defCfg.MY_LABEL_YEAR_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + + /** + * The suffix used after the month when rendering the Calendar header + * @config MY_LABEL_MONTH_SUFFIX + * @type String + * @default " " + */ + this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.delegateConfig } ); + + /** + * The suffix used after the year when rendering the Calendar header + * @config MY_LABEL_YEAR_SUFFIX + * @type String + * @default "" + */ + this.cfg.addProperty(defCfg.MY_LABEL_YEAR_SUFFIX.key, { value:defCfg.MY_LABEL_YEAR_SUFFIX.value, handler:this.delegateConfig } ); }; /** @@ -3653,6 +4236,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { */ YAHOO.widget.CalendarGroup.prototype.initEvents = function() { var me = this; + var strEvent = "Event"; /** * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents @@ -3665,7 +4249,7 @@ YAHOO.widget.CalendarGroup.prototype.initEvents = function() { var sub = function(fn, obj, bOverride) { for (var p=0;p 0) ? this.pages[0].cfg.getProperty(cfgSelected) : []; + this.cfg.setProperty(cfgSelected, selected, true); +}; + + /** * Delegates a configuration property to the CustomEvents associated with the CalendarGroup's children * @method delegateConfig @@ -3834,7 +4452,7 @@ YAHOO.widget.CalendarGroup.prototype.delegateConfig = function(type, args, obj) * @param {Function} fn The function to apply to each Calendar page object */ YAHOO.widget.CalendarGroup.prototype.setChildFunction = function(fnName, fn) { - var pageCount = this.cfg.getProperty("pages"); + var pageCount = this.cfg.getProperty(YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGES.key); for (var p=0;p0) { year+=1; @@ -3945,11 +4576,14 @@ YAHOO.widget.CalendarGroup.prototype.select = function(date) { }; /** -* 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. +* Selects dates in the CalendarGroup based on the cell index provided. This method is used to select cells without having to do a full render. The selected style is applied to the cells directly. +* The value of the MULTI_SELECT Configuration attribute will determine the set of dates which get selected. +*
    +*
  • If MULTI_SELECT is false, selectCell will select the cell at the specified index for only the last displayed Calendar page.
  • +*
  • If MULTI_SELECT is true, selectCell will select the cell at the specified index, on each displayed Calendar page.
  • +*
* @method selectCell -* @param {Number} cellIndex The index of the cell to select in the current calendar. +* @param {Number} cellIndex The index of the cell to be selected. * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.CalendarGroup.prototype.selectCell = function(cellIndex) { @@ -3996,11 +4630,11 @@ YAHOO.widget.CalendarGroup.prototype.deselectAll = function() { }; /** -* 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. +* Deselects dates in the CalendarGroup based on the cell index provided. This method is used to select cells without having to do a full render. The selected style is applied to the cells directly. +* deselectCell will deselect the cell at the specified index on each displayed Calendar page. +* * @method deselectCell -* @param {Number} cellIndex The index of the cell to deselect in the current calendar. +* @param {Number} cellIndex The index of the cell to deselect. * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.CalendarGroup.prototype.deselectCell = function(cellIndex) { @@ -4087,8 +4721,7 @@ YAHOO.widget.CalendarGroup.prototype.previousYear = function() { */ YAHOO.widget.CalendarGroup.prototype.getSelectedDates = function() { var returnDates = []; - var selected = this.cfg.getProperty("selected"); - + var selected = this.cfg.getProperty(YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.SELECTED.key); for (var d=0;d 11)) { + var DM = YAHOO.widget.DateMath; + var newDate = DM.add(date, DM.MONTH, iMonth-date.getMonth()); + date.setTime(newDate.getTime()); + } else { + date.setMonth(iMonth); + } +}; + +/** + * Fixes the width of the CalendarGroup container element, to account for miswrapped floats + * @method _fixWidth + * @private + */ +YAHOO.widget.CalendarGroup.prototype._fixWidth = function() { + var startW = this.oDomContainer.offsetWidth; + var w = 0; + for (var p=0;p 0) { + this.oDomContainer.style.width = w + "px"; + } +}; + + /** * CSS class representing the container for the calendar * @property YAHOO.widget.CalendarGroup.CSS_CONTAINER @@ -4229,11 +4910,13 @@ YAHOO.widget.CalendarGroup.CSS_2UPTITLE = "title"; * @property YAHOO.widget.CalendarGroup.CSS_2UPCLOSE * @static * @final +* @deprecated Along with Calendar.IMG_ROOT and NAV_ARROW_LEFT, NAV_ARROW_RIGHT configuration properties. +* Calendar's Style.CSS_CLOSE property now represents the CSS class used to render the close icon * @type String */ YAHOO.widget.CalendarGroup.CSS_2UPCLOSE = "close-icon"; -YAHOO.augment(YAHOO.widget.CalendarGroup, YAHOO.widget.Calendar, "buildDayLabel", +YAHOO.lang.augmentProto(YAHOO.widget.CalendarGroup, YAHOO.widget.Calendar, "buildDayLabel", "buildMonthLabel", "renderOutOfBoundsDate", "renderRowHeader", @@ -4251,10 +4934,21 @@ YAHOO.augment(YAHOO.widget.CalendarGroup, YAHOO.widget.Calendar, "buildDayLabel" "initStyles", "configTitle", "configClose", + "configIframe", "hide", - "show", "browser"); +/** +* The set of default Config property keys and values for the CalendarGroup +* @property YAHOO.widget.CalendarGroup._DEFAULT_CONFIG +* @final +* @static +* @private +* @type Object +*/ +YAHOO.widget.CalendarGroup._DEFAULT_CONFIG = YAHOO.widget.Calendar._DEFAULT_CONFIG; +YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGES = {key:"pages", value:2}; + /** * Returns a string representation of the object. * @method toString @@ -4280,4 +4974,6 @@ YAHOO.extend(YAHOO.widget.Calendar2up, YAHOO.widget.CalendarGroup); /** * @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default. */ -YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up; \ No newline at end of file +YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up; + +YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/calendar/calendar-min.js b/lib/yui/calendar/calendar-min.js index 53b1d938e2..98877bae0a 100755 --- a/lib/yui/calendar/calendar-min.js +++ b/lib/yui/calendar/calendar-min.js @@ -1,113 +1,130 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 +version: 2.3.0 */ -YAHOO.util.Config=function(owner){if(owner){this.init(owner);}};YAHOO.util.Config.prototype={owner:null,queueInProgress:false,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){if(initialConfig[key]&&initialConfig[key]!='undefined'){this.setProperty(key,initialConfig[key]);} -return true;}else{return false;}};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;i11){while(newMonth>11){newMonth-=12;years+=1;}} +(function(){YAHOO.util.Config=function(owner){if(owner){this.init(owner);} +if(!owner){}};var Lang=YAHOO.lang,CustomEvent=YAHOO.util.CustomEvent,Config=YAHOO.util.Config;Config.CONFIG_CHANGED_EVENT="configChanged";Config.BOOLEAN_TYPE="boolean";Config.prototype={owner:null,queueInProgress:false,config:null,initialConfig:null,eventQueue:null,configChangedEvent:null,init:function(owner){this.owner=owner;this.configChangedEvent=this.createEvent(Config.CONFIG_CHANGED_EVENT);this.configChangedEvent.signature=CustomEvent.LIST;this.queueInProgress=false;this.config={};this.initialConfig={};this.eventQueue=[];},checkBoolean:function(val){return(typeof val==Config.BOOLEAN_TYPE);},checkNumber:function(val){return(!isNaN(val));},fireEvent:function(key,value){var property=this.config[key];if(property&&property.event){property.event.fire(value);}},addProperty:function(key,propertyObject){key=key.toLowerCase();this.config[key]=propertyObject;propertyObject.event=this.createEvent(key,{scope:this.owner});propertyObject.event.signature=CustomEvent.LIST;propertyObject.key=key;if(propertyObject.handler){propertyObject.event.subscribe(propertyObject.handler,this.owner);} +this.setProperty(key,propertyObject.value,true);if(!propertyObject.suppressEvent){this.queueProperty(key,propertyObject.value);}},getConfig:function(){var cfg={},prop,property;for(prop in this.config){property=this.config[prop];if(property&&property.event){cfg[prop]=property.value;}} +return cfg;},getProperty:function(key){var property=this.config[key.toLowerCase()];if(property&&property.event){return property.value;}else{return undefined;}},resetProperty:function(key){key=key.toLowerCase();var property=this.config[key];if(property&&property.event){if(this.initialConfig[key]&&!Lang.isUndefined(this.initialConfig[key])){this.setProperty(key,this.initialConfig[key]);} +return true;}else{return false;}},setProperty:function(key,value,silent){var property;key=key.toLowerCase();if(this.queueInProgress&&!silent){this.queueProperty(key,value);return true;}else{property=this.config[key];if(property&&property.event){if(property.validator&&!property.validator(value)){return false;}else{property.value=value;if(!silent){this.fireEvent(key,value);this.configChangedEvent.fire([key,value]);} +return true;}}else{return false;}}},queueProperty:function(key,value){key=key.toLowerCase();var property=this.config[key],foundDuplicate=false,iLen,queueItem,queueItemKey,queueItemValue,sLen,supercedesCheck,qLen,queueItemCheck,queueItemCheckKey,queueItemCheckValue,i,s,q;if(property&&property.event){if(!Lang.isUndefined(value)&&property.validator&&!property.validator(value)){return false;}else{if(!Lang.isUndefined(value)){property.value=value;}else{value=property.value;} +foundDuplicate=false;iLen=this.eventQueue.length;for(i=0;i0){i=nSubscribers-1;do{subsc=evt.subscribers[i];if(subsc&&subsc.obj==obj&&subsc.fn==fn){return true;}} +while(i--);} +return false;};YAHOO.lang.augmentProto(Config,YAHOO.util.EventProvider);}());YAHOO.widget.DateMath={DAY:"D",WEEK:"W",YEAR:"Y",MONTH:"M",ONE_DAY_MS:1000*60*60*24,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;},subtract:function(date,field,amount){return this.add(date,field,(amount*-1));},before:function(date,compareTo){var ms=compareTo.getTime();if(date.getTime()ms){return true;}else{return false;}},between:function(date,dateBegin,dateEnd){if(this.after(date,dateBegin)&&this.before(date,dateEnd)){return true;}else{return false;}},getJan1:function(calendarYear){return new Date(calendarYear,0,1);},getDayOffset:function(date,calendarYear){var beginYear=this.getJan1(calendarYear);var dayOffset=Math.ceil((date.getTime()-beginYear.getTime())/this.ONE_DAY_MS);return dayOffset;},getWeekNumber:function(date,calendarYear){date=this.clearTime(date);var nearestThurs=new Date(date.getTime()+(4*this.ONE_DAY_MS)-((date.getDay())*this.ONE_DAY_MS));var jan1=new Date(nearestThurs.getFullYear(),0,1);var dayOfYear=((nearestThurs.getTime()-jan1.getTime())/this.ONE_DAY_MS)-1;var weekNum=Math.ceil((dayOfYear)/7);return weekNum;},isYearOverlapWeek:function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getFullYear()!=weekBeginDate.getFullYear()){overlaps=true;} return overlaps;},isMonthOverlapWeek:function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getMonth()!=weekBeginDate.getMonth()){overlaps=true;} -return overlaps;},findMonthStart:function(date){var start=new Date(date.getFullYear(),date.getMonth(),1);return start;},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;},clearTime:function(date){date.setHours(12,0,0,0);return date;}};YAHOO.widget.Calendar=function(id,containerId,config){this.init(id,containerId,config);};YAHOO.widget.Calendar.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.DATE="D";YAHOO.widget.Calendar.MONTH_DAY="MD";YAHOO.widget.Calendar.WEEKDAY="WD";YAHOO.widget.Calendar.RANGE="R";YAHOO.widget.Calendar.MONTH="M";YAHOO.widget.Calendar.DISPLAY_DAYS=42;YAHOO.widget.Calendar.STOP_RENDER="S";YAHOO.widget.Calendar.prototype={Config:null,parent:null,index:-1,cells:null,cellDates:null,id:null,oDomContainer:null,today:null,renderStack:null,_renderStack:null,_pageDate:null,_selectedDates:null,domEventMap:null};YAHOO.widget.Calendar.prototype.init=function(id,containerId,config){this.initEvents();this.today=new Date();YAHOO.widget.DateMath.clearTime(this.today);this.id=id;this.oDomContainer=document.getElementById(containerId);this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.initStyles();YAHOO.util.Dom.addClass(this.oDomContainer,this.Style.CSS_CONTAINER);YAHOO.util.Dom.addClass(this.oDomContainer,this.Style.CSS_SINGLE);this.cellDates=[];this.cells=[];this.renderStack=[];this._renderStack=[];this.setupConfig();if(config){this.cfg.applyConfig(config,true);} -this.cfg.fireQueue();};YAHOO.widget.Calendar.prototype.configIframe=function(type,args,obj){var useIframe=args[0];if(YAHOO.util.Dom.inDocument(this.oDomContainer)){if(useIframe){var pos=YAHOO.util.Dom.getStyle(this.oDomContainer,"position");if(this.browser=="ie"&&(pos=="absolute"||pos=="relative")){if(!YAHOO.util.Dom.inDocument(this.iframe)){this.iframe=document.createElement("iframe");this.iframe.src="javascript:false;";YAHOO.util.Dom.setStyle(this.iframe,"opacity","0");this.oDomContainer.insertBefore(this.iframe,this.oDomContainer.firstChild);}}}else{if(this.iframe){if(this.iframe.parentNode){this.iframe.parentNode.removeChild(this.iframe);} -this.iframe=null;}}}};YAHOO.widget.Calendar.prototype.configTitle=function(type,args,obj){var title=args[0];var close=this.cfg.getProperty("close");var titleDiv;if(title&&title!==""){titleDiv=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE,"div",this.oDomContainer)[0]||document.createElement("div");titleDiv.className=YAHOO.widget.CalendarGroup.CSS_2UPTITLE;titleDiv.innerHTML=title;this.oDomContainer.insertBefore(titleDiv,this.oDomContainer.firstChild);YAHOO.util.Dom.addClass(this.oDomContainer,"withtitle");}else{titleDiv=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE,"div",this.oDomContainer)[0]||null;if(titleDiv){YAHOO.util.Event.purgeElement(titleDiv);this.oDomContainer.removeChild(titleDiv);} -if(!close){YAHOO.util.Dom.removeClass(this.oDomContainer,"withtitle");}}};YAHOO.widget.Calendar.prototype.configClose=function(type,args,obj){var close=args[0];var title=this.cfg.getProperty("title");var linkClose;if(close===true){linkClose=YAHOO.util.Dom.getElementsByClassName("link-close","a",this.oDomContainer)[0]||document.createElement("a");linkClose.href="javascript:void(null);";linkClose.className="link-close";YAHOO.util.Event.addListener(linkClose,"click",this.hide,this,true);var imgClose=document.createElement("img");imgClose.src=YAHOO.widget.Calendar.IMG_ROOT+"us/my/bn/x_d.gif";imgClose.className=YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;linkClose.appendChild(imgClose);this.oDomContainer.appendChild(linkClose);YAHOO.util.Dom.addClass(this.oDomContainer,"withtitle");}else{linkClose=YAHOO.util.Dom.getElementsByClassName("link-close","a",this.oDomContainer)[0]||null;if(linkClose){YAHOO.util.Event.purgeElement(linkClose);this.oDomContainer.removeChild(linkClose);} -if(!title||title===""){YAHOO.util.Dom.removeClass(this.oDomContainer,"withtitle");}}};YAHOO.widget.Calendar.prototype.initEvents=function(){this.beforeSelectEvent=new YAHOO.util.CustomEvent("beforeSelect");this.selectEvent=new YAHOO.util.CustomEvent("select");this.beforeDeselectEvent=new YAHOO.util.CustomEvent("beforeDeselect");this.deselectEvent=new YAHOO.util.CustomEvent("deselect");this.changePageEvent=new YAHOO.util.CustomEvent("changePage");this.beforeRenderEvent=new YAHOO.util.CustomEvent("beforeRender");this.renderEvent=new YAHOO.util.CustomEvent("render");this.resetEvent=new YAHOO.util.CustomEvent("reset");this.clearEvent=new YAHOO.util.CustomEvent("clear");this.beforeSelectEvent.subscribe(this.onBeforeSelect,this,true);this.selectEvent.subscribe(this.onSelect,this,true);this.beforeDeselectEvent.subscribe(this.onBeforeDeselect,this,true);this.deselectEvent.subscribe(this.onDeselect,this,true);this.changePageEvent.subscribe(this.onChangePage,this,true);this.renderEvent.subscribe(this.onRender,this,true);this.resetEvent.subscribe(this.onReset,this,true);this.clearEvent.subscribe(this.onClear,this,true);};YAHOO.widget.Calendar.prototype.doSelectCell=function(e,cal){var target=YAHOO.util.Event.getTarget(e);var cell,index,d,date;while(target.tagName.toLowerCase()!="td"&&!YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}} +return overlaps;},findMonthStart:function(date){var start=new Date(date.getFullYear(),date.getMonth(),1);return start;},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;},clearTime:function(date){date.setHours(12,0,0,0);return date;}};YAHOO.widget.Calendar=function(id,containerId,config){this.init(id,containerId,config);};YAHOO.widget.Calendar.IMG_ROOT=null;YAHOO.widget.Calendar.DATE="D";YAHOO.widget.Calendar.MONTH_DAY="MD";YAHOO.widget.Calendar.WEEKDAY="WD";YAHOO.widget.Calendar.RANGE="R";YAHOO.widget.Calendar.MONTH="M";YAHOO.widget.Calendar.DISPLAY_DAYS=42;YAHOO.widget.Calendar.STOP_RENDER="S";YAHOO.widget.Calendar.SHORT="short";YAHOO.widget.Calendar.LONG="long";YAHOO.widget.Calendar.MEDIUM="medium";YAHOO.widget.Calendar.ONE_CHAR="1char";YAHOO.widget.Calendar._DEFAULT_CONFIG={PAGEDATE:{key:"pagedate",value:null},SELECTED:{key:"selected",value:null},TITLE:{key:"title",value:""},CLOSE:{key:"close",value:false},IFRAME:{key:"iframe",value:(YAHOO.env.ua.ie&&YAHOO.env.ua.ie<=6)?true:false},MINDATE:{key:"mindate",value:null},MAXDATE:{key:"maxdate",value:null},MULTI_SELECT:{key:"multi_select",value:false},START_WEEKDAY:{key:"start_weekday",value:0},SHOW_WEEKDAYS:{key:"show_weekdays",value:true},SHOW_WEEK_HEADER:{key:"show_week_header",value:false},SHOW_WEEK_FOOTER:{key:"show_week_footer",value:false},HIDE_BLANK_WEEKS:{key:"hide_blank_weeks",value:false},NAV_ARROW_LEFT:{key:"nav_arrow_left",value:null},NAV_ARROW_RIGHT:{key:"nav_arrow_right",value:null},MONTHS_SHORT:{key:"months_short",value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},MONTHS_LONG:{key:"months_long",value:["January","February","March","April","May","June","July","August","September","October","November","December"]},WEEKDAYS_1CHAR:{key:"weekdays_1char",value:["S","M","T","W","T","F","S"]},WEEKDAYS_SHORT:{key:"weekdays_short",value:["Su","Mo","Tu","We","Th","Fr","Sa"]},WEEKDAYS_MEDIUM:{key:"weekdays_medium",value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},WEEKDAYS_LONG:{key:"weekdays_long",value:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},LOCALE_MONTHS:{key:"locale_months",value:"long"},LOCALE_WEEKDAYS:{key:"locale_weekdays",value:"short"},DATE_DELIMITER:{key:"date_delimiter",value:","},DATE_FIELD_DELIMITER:{key:"date_field_delimiter",value:"/"},DATE_RANGE_DELIMITER:{key:"date_range_delimiter",value:"-"},MY_MONTH_POSITION:{key:"my_month_position",value:1},MY_YEAR_POSITION:{key:"my_year_position",value:2},MD_MONTH_POSITION:{key:"md_month_position",value:1},MD_DAY_POSITION:{key:"md_day_position",value:2},MDY_MONTH_POSITION:{key:"mdy_month_position",value:1},MDY_DAY_POSITION:{key:"mdy_day_position",value:2},MDY_YEAR_POSITION:{key:"mdy_year_position",value:3},MY_LABEL_MONTH_POSITION:{key:"my_label_month_position",value:1},MY_LABEL_YEAR_POSITION:{key:"my_label_year_position",value:2},MY_LABEL_MONTH_SUFFIX:{key:"my_label_month_suffix",value:" "},MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix",value:""}};YAHOO.widget.Calendar._EVENT_TYPES={BEFORE_SELECT:"beforeSelect",SELECT:"select",BEFORE_DESELECT:"beforeDeselect",DESELECT:"deselect",CHANGE_PAGE:"changePage",BEFORE_RENDER:"beforeRender",RENDER:"render",RESET:"reset",CLEAR:"clear"};YAHOO.widget.Calendar._STYLES={CSS_ROW_HEADER:"calrowhead",CSS_ROW_FOOTER:"calrowfoot",CSS_CELL:"calcell",CSS_CELL_SELECTOR:"selector",CSS_CELL_SELECTED:"selected",CSS_CELL_SELECTABLE:"selectable",CSS_CELL_RESTRICTED:"restricted",CSS_CELL_TODAY:"today",CSS_CELL_OOM:"oom",CSS_CELL_OOB:"previous",CSS_HEADER:"calheader",CSS_HEADER_TEXT:"calhead",CSS_BODY:"calbody",CSS_WEEKDAY_CELL:"calweekdaycell",CSS_WEEKDAY_ROW:"calweekdayrow",CSS_FOOTER:"calfoot",CSS_CALENDAR:"yui-calendar",CSS_SINGLE:"single",CSS_CONTAINER:"yui-calcontainer",CSS_NAV_LEFT:"calnavleft",CSS_NAV_RIGHT:"calnavright",CSS_CLOSE:"calclose",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"};YAHOO.widget.Calendar.prototype={Config:null,parent:null,index:-1,cells:null,cellDates:null,id:null,oDomContainer:null,today:null,renderStack:null,_renderStack:null,_selectedDates:null,domEventMap:null};YAHOO.widget.Calendar.prototype.init=function(id,containerId,config){this.initEvents();this.today=new Date();YAHOO.widget.DateMath.clearTime(this.today);this.id=id;this.oDomContainer=document.getElementById(containerId);this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.initStyles();YAHOO.util.Dom.addClass(this.oDomContainer,this.Style.CSS_CONTAINER);YAHOO.util.Dom.addClass(this.oDomContainer,this.Style.CSS_SINGLE);this.cellDates=[];this.cells=[];this.renderStack=[];this._renderStack=[];this.setupConfig();if(config){this.cfg.applyConfig(config,true);} +this.cfg.fireQueue();};YAHOO.widget.Calendar.prototype.configIframe=function(type,args,obj){var useIframe=args[0];if(!this.parent){if(YAHOO.util.Dom.inDocument(this.oDomContainer)){if(useIframe){var pos=YAHOO.util.Dom.getStyle(this.oDomContainer,"position");if(pos=="absolute"||pos=="relative"){if(!YAHOO.util.Dom.inDocument(this.iframe)){this.iframe=document.createElement("iframe");this.iframe.src="javascript:false;";YAHOO.util.Dom.setStyle(this.iframe,"opacity","0");if(YAHOO.env.ua.ie&&YAHOO.env.ua.ie<=6){YAHOO.util.Dom.addClass(this.iframe,"fixedsize");} +this.oDomContainer.insertBefore(this.iframe,this.oDomContainer.firstChild);}}}else{if(this.iframe){if(this.iframe.parentNode){this.iframe.parentNode.removeChild(this.iframe);} +this.iframe=null;}}}}};YAHOO.widget.Calendar.prototype.configTitle=function(type,args,obj){var title=args[0];var close=this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key);var titleDiv;if(title&&title!==""){titleDiv=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE,"div",this.oDomContainer)[0]||document.createElement("div");titleDiv.className=YAHOO.widget.CalendarGroup.CSS_2UPTITLE;titleDiv.innerHTML=title;this.oDomContainer.insertBefore(titleDiv,this.oDomContainer.firstChild);YAHOO.util.Dom.addClass(this.oDomContainer,"withtitle");}else{titleDiv=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE,"div",this.oDomContainer)[0]||null;if(titleDiv){YAHOO.util.Event.purgeElement(titleDiv);this.oDomContainer.removeChild(titleDiv);} +if(!close){YAHOO.util.Dom.removeClass(this.oDomContainer,"withtitle");}}};YAHOO.widget.Calendar.prototype.configClose=function(type,args,obj){var close=args[0];var title=this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key);var DEPR_CLOSE_PATH="us/my/bn/x_d.gif";var linkClose;if(close===true){linkClose=YAHOO.util.Dom.getElementsByClassName("link-close","a",this.oDomContainer)[0]||document.createElement("a");linkClose.href="#";linkClose.className="link-close";YAHOO.util.Event.addListener(linkClose,"click",function(e,cal){cal.hide();YAHOO.util.Event.preventDefault(e);},this);if(YAHOO.widget.Calendar.IMG_ROOT!==null){var imgClose=document.createElement("img");imgClose.src=YAHOO.widget.Calendar.IMG_ROOT+DEPR_CLOSE_PATH;imgClose.className=YAHOO.widget.CalendarGroup.CSS_2UPCLOSE;linkClose.appendChild(imgClose);}else{linkClose.innerHTML='';} +this.oDomContainer.appendChild(linkClose);YAHOO.util.Dom.addClass(this.oDomContainer,"withtitle");}else{linkClose=YAHOO.util.Dom.getElementsByClassName("link-close","a",this.oDomContainer)[0]||null;if(linkClose){YAHOO.util.Event.purgeElement(linkClose);this.oDomContainer.removeChild(linkClose);} +if(!title||title===""){YAHOO.util.Dom.removeClass(this.oDomContainer,"withtitle");}}};YAHOO.widget.Calendar.prototype.initEvents=function(){var defEvents=YAHOO.widget.Calendar._EVENT_TYPES;this.beforeSelectEvent=new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT);this.selectEvent=new YAHOO.util.CustomEvent(defEvents.SELECT);this.beforeDeselectEvent=new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT);this.deselectEvent=new YAHOO.util.CustomEvent(defEvents.DESELECT);this.changePageEvent=new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE);this.beforeRenderEvent=new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER);this.renderEvent=new YAHOO.util.CustomEvent(defEvents.RENDER);this.resetEvent=new YAHOO.util.CustomEvent(defEvents.RESET);this.clearEvent=new YAHOO.util.CustomEvent(defEvents.CLEAR);this.beforeSelectEvent.subscribe(this.onBeforeSelect,this,true);this.selectEvent.subscribe(this.onSelect,this,true);this.beforeDeselectEvent.subscribe(this.onBeforeDeselect,this,true);this.deselectEvent.subscribe(this.onDeselect,this,true);this.changePageEvent.subscribe(this.onChangePage,this,true);this.renderEvent.subscribe(this.onRender,this,true);this.resetEvent.subscribe(this.onReset,this,true);this.clearEvent.subscribe(this.onClear,this,true);};YAHOO.widget.Calendar.prototype.doSelectCell=function(e,cal){var cell,index,d,date;var target=YAHOO.util.Event.getTarget(e);var tagName=target.tagName.toLowerCase();var defSelector=false;while(tagName!="td"&&!YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){if(!defSelector&&tagName=="a"&&YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTOR)){defSelector=true;} +target=target.parentNode;tagName=target.tagName.toLowerCase();if(tagName=="html"){return;}} +if(defSelector){YAHOO.util.Event.preventDefault(e);} cell=target;if(YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_SELECTABLE)){index=cell.id.split("cell")[1];d=cal.cellDates[index];date=new Date(d[0],d[1]-1,d[2]);var link;if(cal.Options.MULTI_SELECT){link=cell.getElementsByTagName("a")[0];if(link){link.blur();} var cellDate=cal.cellDates[index];var cellDateIndex=cal._indexOfSelectedFieldArray(cellDate);if(cellDateIndex>-1){cal.deselectCell(index);}else{cal.selectCell(index);}}else{link=cell.getElementsByTagName("a")[0];if(link){link.blur();} cal.selectCell(index);}}};YAHOO.widget.Calendar.prototype.doCellMouseOver=function(e,cal){var target;if(e){target=YAHOO.util.Event.getTarget(e);}else{target=this;} while(target.tagName.toLowerCase()!="td"){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}} if(YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){YAHOO.util.Dom.addClass(target,cal.Style.CSS_CELL_HOVER);}};YAHOO.widget.Calendar.prototype.doCellMouseOut=function(e,cal){var target;if(e){target=YAHOO.util.Event.getTarget(e);}else{target=this;} while(target.tagName.toLowerCase()!="td"){target=target.parentNode;if(target.tagName.toLowerCase()=="html"){return;}} -if(YAHOO.util.Dom.hasClass(target,cal.Style.CSS_CELL_SELECTABLE)){YAHOO.util.Dom.removeClass(target,cal.Style.CSS_CELL_HOVER);}};YAHOO.widget.Calendar.prototype.setupConfig=function(){this.cfg.addProperty("pagedate",{value:new Date(),handler:this.configPageDate});this.cfg.addProperty("selected",{value:[],handler:this.configSelected});this.cfg.addProperty("title",{value:"",handler:this.configTitle});this.cfg.addProperty("close",{value:false,handler:this.configClose});this.cfg.addProperty("iframe",{value:true,handler:this.configIframe,validator:this.cfg.checkBoolean});this.cfg.addProperty("mindate",{value:null,handler:this.configMinDate});this.cfg.addProperty("maxdate",{value:null,handler:this.configMaxDate});this.cfg.addProperty("MULTI_SELECT",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("START_WEEKDAY",{value:0,handler:this.configOptions,validator:this.cfg.checkNumber});this.cfg.addProperty("SHOW_WEEKDAYS",{value:true,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_HEADER",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_FOOTER",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("HIDE_BLANK_WEEKS",{value:false,handler:this.configOptions,validator:this.cfg.checkBoolean});this.cfg.addProperty("NAV_ARROW_LEFT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/callt.gif",handler:this.configOptions});this.cfg.addProperty("NAV_ARROW_RIGHT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/calrt.gif",handler:this.configOptions});this.cfg.addProperty("MONTHS_SHORT",{value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],handler:this.configLocale});this.cfg.addProperty("MONTHS_LONG",{value:["January","February","March","April","May","June","July","August","September","October","November","December"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_1CHAR",{value:["S","M","T","W","T","F","S"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_SHORT",{value:["Su","Mo","Tu","We","Th","Fr","Sa"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_MEDIUM",{value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],handler:this.configLocale});this.cfg.addProperty("WEEKDAYS_LONG",{value:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],handler:this.configLocale});var refreshLocale=function(){this.cfg.refireEvent("LOCALE_MONTHS");this.cfg.refireEvent("LOCALE_WEEKDAYS");};this.cfg.subscribeToConfigEvent("START_WEEKDAY",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("MONTHS_SHORT",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("MONTHS_LONG",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM",refreshLocale,this,true);this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG",refreshLocale,this,true);this.cfg.addProperty("LOCALE_MONTHS",{value:"long",handler:this.configLocaleValues});this.cfg.addProperty("LOCALE_WEEKDAYS",{value:"short",handler:this.configLocaleValues});this.cfg.addProperty("DATE_DELIMITER",{value:",",handler:this.configLocale});this.cfg.addProperty("DATE_FIELD_DELIMITER",{value:"/",handler:this.configLocale});this.cfg.addProperty("DATE_RANGE_DELIMITER",{value:"-",handler:this.configLocale});this.cfg.addProperty("MY_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MY_YEAR_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_DAY_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_MONTH_POSITION",{value:1,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_DAY_POSITION",{value:2,handler:this.configLocale,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_YEAR_POSITION",{value:3,handler:this.configLocale,validator:this.cfg.checkNumber});};YAHOO.widget.Calendar.prototype.configPageDate=function(type,args,obj){var val=args[0];var month,year,aMonthYear;if(val){if(val instanceof Date){val=YAHOO.widget.DateMath.findMonthStart(val);this.cfg.setProperty("pagedate",val,true);if(!this._pageDate){this._pageDate=this.cfg.getProperty("pagedate");} -return;}else{aMonthYear=val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER"));month=parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1],10)-1;year=parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1],10);}}else{month=this.today.getMonth();year=this.today.getFullYear();} -this.cfg.setProperty("pagedate",new Date(year,month,1),true);if(!this._pageDate){this._pageDate=this.cfg.getProperty("pagedate");}};YAHOO.widget.Calendar.prototype.configMinDate=function(type,args,obj){var val=args[0];if(typeof val=='string'){val=this._parseDate(val);this.cfg.setProperty("mindate",new Date(val[0],(val[1]-1),val[2]));}};YAHOO.widget.Calendar.prototype.configMaxDate=function(type,args,obj){var val=args[0];if(typeof val=='string'){val=this._parseDate(val);this.cfg.setProperty("maxdate",new Date(val[0],(val[1]-1),val[2]));}};YAHOO.widget.Calendar.prototype.configSelected=function(type,args,obj){var selected=args[0];if(selected){if(typeof selected=='string'){this.cfg.setProperty("selected",this._parseDates(selected),true);}} -if(!this._selectedDates){this._selectedDates=this.cfg.getProperty("selected");}};YAHOO.widget.Calendar.prototype.configOptions=function(type,args,obj){type=type.toUpperCase();var val=args[0];this.Options[type]=val;};YAHOO.widget.Calendar.prototype.configLocale=function(type,args,obj){type=type.toUpperCase();var val=args[0];this.Locale[type]=val;this.cfg.refireEvent("LOCALE_MONTHS");this.cfg.refireEvent("LOCALE_WEEKDAYS");};YAHOO.widget.Calendar.prototype.configLocaleValues=function(type,args,obj){type=type.toUpperCase();var val=args[0];switch(type){case"LOCALE_MONTHS":switch(val){case"short":this.Locale.LOCALE_MONTHS=this.cfg.getProperty("MONTHS_SHORT").concat();break;case"long":this.Locale.LOCALE_MONTHS=this.cfg.getProperty("MONTHS_LONG").concat();break;} -break;case"LOCALE_WEEKDAYS":switch(val){case"1char":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_1CHAR").concat();break;case"short":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_SHORT").concat();break;case"medium":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_MEDIUM").concat();break;case"long":this.Locale.LOCALE_WEEKDAYS=this.cfg.getProperty("WEEKDAYS_LONG").concat();break;} -var START_WEEKDAY=this.cfg.getProperty("START_WEEKDAY");if(START_WEEKDAY>0){for(var w=0;w0){for(var w=0;w';html[html.length]='
';var renderLeft,renderRight=false;if(this.parent){if(this.index===0){renderLeft=true;} if(this.index==(this.parent.cfg.getProperty("pages")-1)){renderRight=true;}}else{renderLeft=true;renderRight=true;} -var cal=this.parent||this;if(renderLeft){html[html.length]=' ';} -html[html.length]=this.buildMonthLabel();if(renderRight){html[html.length]=' ';} -html[html.length]='
';html[html.length]='';html[html.length]='';if(this.cfg.getProperty("SHOW_WEEKDAYS")){html=this.buildWeekdays(html);} -html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.buildWeekdays=function(html){html[html.length]='';if(this.cfg.getProperty("SHOW_WEEK_HEADER")){html[html.length]=' ';} +var cal=this.parent||this;if(renderLeft){var leftArrow=this.cfg.getProperty(defCfg.NAV_ARROW_LEFT.key);if(leftArrow===null&&YAHOO.widget.Calendar.IMG_ROOT!==null){leftArrow=YAHOO.widget.Calendar.IMG_ROOT+DEPR_NAV_LEFT;} +var leftStyle=(leftArrow===null)?"":' style="background-image:url('+leftArrow+')"';html[html.length]=' ';} +html[html.length]=this.buildMonthLabel();if(renderRight){var rightArrow=this.cfg.getProperty(defCfg.NAV_ARROW_RIGHT.key);if(rightArrow===null&&YAHOO.widget.Calendar.IMG_ROOT!==null){rightArrow=YAHOO.widget.Calendar.IMG_ROOT+DEPR_NAV_RIGHT;} +var rightStyle=(rightArrow===null)?"":' style="background-image:url('+rightArrow+')"';html[html.length]=' ';} +html[html.length]='\n\n';if(this.cfg.getProperty(defCfg.SHOW_WEEKDAYS.key)){html=this.buildWeekdays(html);} +html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.buildWeekdays=function(html){var defCfg=YAHOO.widget.Calendar._DEFAULT_CONFIG;html[html.length]='';if(this.cfg.getProperty(defCfg.SHOW_WEEK_HEADER.key)){html[html.length]=' ';} for(var i=0;i'+this.Locale.LOCALE_WEEKDAYS[i]+'';} -if(this.cfg.getProperty("SHOW_WEEK_FOOTER")){html[html.length]=' ';} -html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.renderBody=function(workingDate,html){var startDay=this.cfg.getProperty("START_WEEKDAY");this.preMonthDays=workingDate.getDay();if(startDay>0){this.preMonthDays-=startDay;} +if(this.cfg.getProperty(defCfg.SHOW_WEEK_FOOTER.key)){html[html.length]=' ';} +html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.renderBody=function(workingDate,html){var defCfg=YAHOO.widget.Calendar._DEFAULT_CONFIG;var startDay=this.cfg.getProperty(defCfg.START_WEEKDAY.key);this.preMonthDays=workingDate.getDay();if(startDay>0){this.preMonthDays-=startDay;} if(this.preMonthDays<0){this.preMonthDays+=7;} -this.monthDays=YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();this.postMonthDays=YAHOO.widget.Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays;workingDate=YAHOO.widget.DateMath.subtract(workingDate,YAHOO.widget.DateMath.DAY,this.preMonthDays);var useDate,weekNum,weekClass;useDate=this.cfg.getProperty("pagedate");html[html.length]='';var i=0;var tempDiv=document.createElement("div");var cell=document.createElement("td");tempDiv.appendChild(cell);var jan1=new Date(useDate.getFullYear(),0,1);var cal=this.parent||this;for(var r=0;r<6;r++){weekNum=YAHOO.widget.DateMath.getWeekNumber(workingDate,useDate.getFullYear(),startDay);weekClass="w"+weekNum;if(r!==0&&this.isDateOOM(workingDate)&&this.cfg.getProperty("HIDE_BLANK_WEEKS")===true){break;}else{html[html.length]='';if(this.cfg.getProperty("SHOW_WEEK_HEADER")){html=this.renderRowHeader(weekNum,html);} -for(var d=0;d<7;d++){var cellRenderers=[];this.clearElement(cell);YAHOO.util.Dom.addClass(cell,"calcell");cell.id=this.id+"_cell"+i;cell.innerHTML=i;var renderer=null;if(workingDate.getFullYear()==this.today.getFullYear()&&workingDate.getMonth()==this.today.getMonth()&&workingDate.getDate()==this.today.getDate()){cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;} -this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];if(this.isDateOOM(workingDate)){cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;}else{YAHOO.util.Dom.addClass(cell,"wd"+workingDate.getDay());YAHOO.util.Dom.addClass(cell,"d"+workingDate.getDate());for(var s=0;s';var i=0;var tempDiv=document.createElement("div");var cell=document.createElement("td");tempDiv.appendChild(cell);var jan1=new Date(useDate.getFullYear(),0,1);var cal=this.parent||this;for(var r=0;r<6;r++){weekNum=YAHOO.widget.DateMath.getWeekNumber(workingDate,useDate.getFullYear(),startDay);weekClass=weekPrefix+weekNum;if(r!==0&&hideBlankWeeks===true&&workingDate.getMonth()!=useDate.getMonth()){break;}else{html[html.length]='';if(showWeekHeader){html=this.renderRowHeader(weekNum,html);} +for(var d=0;d<7;d++){cellRenderers=[];renderer=null;this.clearElement(cell);cell.className=this.Style.CSS_CELL;cell.id=this.id+cellPrefix+i;if(workingDate.getDate()==todayDate&&workingDate.getMonth()==todayMonth&&workingDate.getFullYear()==todayYear){cellRenderers[cellRenderers.length]=cal.renderCellStyleToday;} +var workingArray=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];this.cellDates[this.cellDates.length]=workingArray;if(workingDate.getMonth()!=useDate.getMonth()){cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth;}else{YAHOO.util.Dom.addClass(cell,workingDayPrefix+workingDate.getDay());YAHOO.util.Dom.addClass(cell,dayPrefix+workingDate.getDate());for(var s=0;s=d1.getTime()&&workingDate.getTime()<=d2.getTime()){renderer=rArray[2];if(workingDate.getTime()==d2.getTime()){this.renderStack.splice(s,1);}} break;case YAHOO.widget.Calendar.WEEKDAY:var weekday=rArray[1][0];if(workingDate.getDay()+1==weekday){renderer=rArray[2];} break;case YAHOO.widget.Calendar.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]=cal.renderCellStyleSelected;} -var mindate=this.cfg.getProperty("mindate");var maxdate=this.cfg.getProperty("maxdate");if(mindate){mindate=YAHOO.widget.DateMath.clearTime(mindate);} -if(maxdate){maxdate=YAHOO.widget.DateMath.clearTime(maxdate);} +if(this._indexOfSelectedFieldArray(workingArray)>-1){cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected;} if((mindate&&(workingDate.getTime()maxdate.getTime()))){cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate;}else{cellRenderers[cellRenderers.length]=cal.styleCellDefault;cellRenderers[cellRenderers.length]=cal.renderCellDefault;} -for(var x=0;x=0&&i<=6){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TOP);} if((i%7)===0){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_LEFT);} if(((i+1)%7)===0){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_RIGHT);} -var postDays=this.postMonthDays;if(postDays>=7&&this.cfg.getProperty("HIDE_BLANK_WEEKS")){var blankWeeks=Math.floor(postDays/7);for(var p=0;p=7){var blankWeeks=Math.floor(postDays/7);for(var p=0;p=((this.preMonthDays+postDays+this.monthDays)-7)){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_BOTTOM);} html[html.length]=tempDiv.innerHTML;i++;} -if(this.cfg.getProperty("SHOW_WEEK_FOOTER")){html=this.renderRowFooter(weekNum,html);} +if(showWeekFooter){html=this.renderRowFooter(weekNum,html);} html[html.length]='';}} -html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.renderFooter=function(html){return html;};YAHOO.widget.Calendar.prototype.render=function(){this.beforeRenderEvent.fire();var workingDate=YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty("pagedate"));this.resetRenderers();this.cellDates.length=0;YAHOO.util.Event.purgeElement(this.oDomContainer,true);var html=[];html[html.length]='';html=this.renderHeader(html);html=this.renderBody(workingDate,html);html=this.renderFooter(html);html[html.length]='
';this.oDomContainer.innerHTML=html.join("\n");this.applyListeners();this.cells=this.oDomContainer.getElementsByTagName("td");this.cfg.refireEvent("title");this.cfg.refireEvent("close");this.cfg.refireEvent("iframe");this.renderEvent.fire();};YAHOO.widget.Calendar.prototype.applyListeners=function(){var root=this.oDomContainer;var cal=this.parent||this;var linkLeft,linkRight;linkLeft=YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT,"a",root);linkRight=YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT,"a",root);if(linkLeft){this.linkLeft=linkLeft[0];YAHOO.util.Event.addListener(this.linkLeft,"mousedown",cal.previousMonth,cal,true);} -if(linkRight){this.linkRight=linkRight[0];YAHOO.util.Event.addListener(this.linkRight,"mousedown",cal.nextMonth,cal,true);} -if(this.domEventMap){var el,elements;for(var cls in this.domEventMap){if(this.domEventMap.hasOwnProperty(cls)){var items=this.domEventMap[cls];if(!(items instanceof Array)){items=[items];} +html[html.length]='';return html;};YAHOO.widget.Calendar.prototype.renderFooter=function(html){return html;};YAHOO.widget.Calendar.prototype.render=function(){this.beforeRenderEvent.fire();var defCfg=YAHOO.widget.Calendar._DEFAULT_CONFIG;var workingDate=YAHOO.widget.DateMath.findMonthStart(this.cfg.getProperty(defCfg.PAGEDATE.key));this.resetRenderers();this.cellDates.length=0;YAHOO.util.Event.purgeElement(this.oDomContainer,true);var html=[];html[html.length]='';html=this.renderHeader(html);html=this.renderBody(workingDate,html);html=this.renderFooter(html);html[html.length]='
';this.oDomContainer.innerHTML=html.join("\n");this.applyListeners();this.cells=this.oDomContainer.getElementsByTagName("td");this.cfg.refireEvent(defCfg.TITLE.key);this.cfg.refireEvent(defCfg.CLOSE.key);this.cfg.refireEvent(defCfg.IFRAME.key);this.renderEvent.fire();};YAHOO.widget.Calendar.prototype.applyListeners=function(){var root=this.oDomContainer;var cal=this.parent||this;var anchor="a";var mousedown="mousedown";var linkLeft=YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT,anchor,root);var linkRight=YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT,anchor,root);if(linkLeft&&linkLeft.length>0){this.linkLeft=linkLeft[0];YAHOO.util.Event.addListener(this.linkLeft,mousedown,cal.previousMonth,cal,true);} +if(linkRight&&linkRight.length>0){this.linkRight=linkRight[0];YAHOO.util.Event.addListener(this.linkRight,mousedown,cal.nextMonth,cal,true);} +if(this.domEventMap){var el,elements;for(var cls in this.domEventMap){if(YAHOO.lang.hasOwnProperty(this.domEventMap,cls)){var items=this.domEventMap[cls];if(!(items instanceof Array)){items=[items];} for(var i=0;i'+weekNum+'';return html;};YAHOO.widget.Calendar.prototype.renderRowFooter=function(weekNum,html){html[html.length]=''+weekNum+'';return html;};YAHOO.widget.Calendar.prototype.renderCellDefault=function(workingDate,cell){cell.innerHTML=''+this.buildDayLabel(workingDate)+"";};YAHOO.widget.Calendar.prototype.styleCellDefault=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTABLE);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT1);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT2);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT3);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT4);};YAHOO.widget.Calendar.prototype.renderCellStyleToday=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TODAY);};YAHOO.widget.Calendar.prototype.renderCellStyleSelected=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTED);};YAHOO.widget.Calendar.prototype.renderCellNotThisMonth=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOM);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.renderBodyCellRestricted=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL);YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_RESTRICTED);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.addMonths=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.MONTH,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.subtractMonths=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.MONTH,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.addYears=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.YEAR,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.subtractYears=function(count){this.cfg.setProperty("pagedate",YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"),YAHOO.widget.DateMath.YEAR,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.nextMonth=function(){this.addMonths(1);};YAHOO.widget.Calendar.prototype.previousMonth=function(){this.subtractMonths(1);};YAHOO.widget.Calendar.prototype.nextYear=function(){this.addYears(1);};YAHOO.widget.Calendar.prototype.previousYear=function(){this.subtractYears(1);};YAHOO.widget.Calendar.prototype.reset=function(){this.cfg.resetProperty("selected");this.cfg.resetProperty("pagedate");this.resetEvent.fire();};YAHOO.widget.Calendar.prototype.clear=function(){this.cfg.setProperty("selected",[]);this.cfg.setProperty("pagedate",new Date(this.today.getTime()));this.clearEvent.fire();};YAHOO.widget.Calendar.prototype.select=function(date){this.beforeSelectEvent.fire();var selected=this.cfg.getProperty("selected");var aToBeSelected=this._toFieldArray(date);for(var a=0;a-1){if(this.cfg.getProperty("pagedate").getMonth()==dCellDate.getMonth()&&this.cfg.getProperty("pagedate").getFullYear()==dCellDate.getFullYear()){YAHOO.util.Dom.removeClass(cell,this.Style.CSS_CELL_SELECTED);} +YAHOO.util.Event.addListener(this.oDomContainer,"click",this.doSelectCell,this);YAHOO.util.Event.addListener(this.oDomContainer,"mouseover",this.doCellMouseOver,this);YAHOO.util.Event.addListener(this.oDomContainer,"mouseout",this.doCellMouseOut,this);};YAHOO.widget.Calendar.prototype.getDateByCellId=function(id){var date=this.getDateFieldsByCellId(id);return new Date(date[0],date[1]-1,date[2]);};YAHOO.widget.Calendar.prototype.getDateFieldsByCellId=function(id){id=id.toLowerCase().split("_cell")[1];id=parseInt(id,10);return this.cellDates[id];};YAHOO.widget.Calendar.prototype.renderOutOfBoundsDate=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOB);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.renderRowHeader=function(weekNum,html){html[html.length]=''+weekNum+'';return html;};YAHOO.widget.Calendar.prototype.renderRowFooter=function(weekNum,html){html[html.length]=''+weekNum+'';return html;};YAHOO.widget.Calendar.prototype.renderCellDefault=function(workingDate,cell){cell.innerHTML=''+this.buildDayLabel(workingDate)+"";};YAHOO.widget.Calendar.prototype.styleCellDefault=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTABLE);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT1);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT2);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT3);};YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT4);};YAHOO.widget.Calendar.prototype.renderCellStyleToday=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TODAY);};YAHOO.widget.Calendar.prototype.renderCellStyleSelected=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTED);};YAHOO.widget.Calendar.prototype.renderCellNotThisMonth=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOM);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.renderBodyCellRestricted=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL);YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_RESTRICTED);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar.STOP_RENDER;};YAHOO.widget.Calendar.prototype.addMonths=function(count){var cfgPageDate=YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;this.cfg.setProperty(cfgPageDate,YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate),YAHOO.widget.DateMath.MONTH,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.subtractMonths=function(count){var cfgPageDate=YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;this.cfg.setProperty(cfgPageDate,YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate),YAHOO.widget.DateMath.MONTH,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.addYears=function(count){var cfgPageDate=YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;this.cfg.setProperty(cfgPageDate,YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate),YAHOO.widget.DateMath.YEAR,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.subtractYears=function(count){var cfgPageDate=YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key;this.cfg.setProperty(cfgPageDate,YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate),YAHOO.widget.DateMath.YEAR,count));this.resetRenderers();this.changePageEvent.fire();};YAHOO.widget.Calendar.prototype.nextMonth=function(){this.addMonths(1);};YAHOO.widget.Calendar.prototype.previousMonth=function(){this.subtractMonths(1);};YAHOO.widget.Calendar.prototype.nextYear=function(){this.addYears(1);};YAHOO.widget.Calendar.prototype.previousYear=function(){this.subtractYears(1);};YAHOO.widget.Calendar.prototype.reset=function(){var defCfg=YAHOO.widget.Calendar._DEFAULT_CONFIG;this.cfg.resetProperty(defCfg.SELECTED.key);this.cfg.resetProperty(defCfg.PAGEDATE.key);this.resetEvent.fire();};YAHOO.widget.Calendar.prototype.clear=function(){var defCfg=YAHOO.widget.Calendar._DEFAULT_CONFIG;this.cfg.setProperty(defCfg.SELECTED.key,[]);this.cfg.setProperty(defCfg.PAGEDATE.key,new Date(this.today.getTime()));this.clearEvent.fire();};YAHOO.widget.Calendar.prototype.select=function(date){var aToBeSelected=this._toFieldArray(date);var validDates=[];var selected=[];var cfgSelected=YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;for(var a=0;a0){if(this.parent){this.parent.cfg.setProperty(cfgSelected,selected);}else{this.cfg.setProperty(cfgSelected,selected);} +this.selectEvent.fire(validDates);} +return this.getSelectedDates();};YAHOO.widget.Calendar.prototype.selectCell=function(cellIndex){var cell=this.cells[cellIndex];var cellDate=this.cellDates[cellIndex];var dCellDate=this._toDate(cellDate);var selectable=YAHOO.util.Dom.hasClass(cell,this.Style.CSS_CELL_SELECTABLE);if(selectable){this.beforeSelectEvent.fire();var cfgSelected=YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;var selected=this.cfg.getProperty(cfgSelected);var selectDate=cellDate.concat();if(this._indexOfSelectedFieldArray(selectDate)==-1){selected[selected.length]=selectDate;} +if(this.parent){this.parent.cfg.setProperty(cfgSelected,selected);}else{this.cfg.setProperty(cfgSelected,selected);} +this.renderCellStyleSelected(dCellDate,cell);this.selectEvent.fire([selectDate]);this.doCellMouseOut.call(cell,null,this);} +return this.getSelectedDates();};YAHOO.widget.Calendar.prototype.deselect=function(date){var aToBeDeselected=this._toFieldArray(date);var validDates=[];var selected=[];var cfgSelected=YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;for(var a=0;a0){if(this.parent){this.parent.cfg.setProperty(cfgSelected,selected);}else{this.cfg.setProperty(cfgSelected,selected);} +this.deselectEvent.fire(validDates);} +return this.getSelectedDates();};YAHOO.widget.Calendar.prototype.deselectCell=function(cellIndex){var cell=this.cells[cellIndex];var cellDate=this.cellDates[cellIndex];var cellDateIndex=this._indexOfSelectedFieldArray(cellDate);var selectable=YAHOO.util.Dom.hasClass(cell,this.Style.CSS_CELL_SELECTABLE);if(selectable){this.beforeDeselectEvent.fire();var defCfg=YAHOO.widget.Calendar._DEFAULT_CONFIG;var selected=this.cfg.getProperty(defCfg.SELECTED.key);var dCellDate=this._toDate(cellDate);var selectDate=cellDate.concat();if(cellDateIndex>-1){if(this.cfg.getProperty(defCfg.PAGEDATE.key).getMonth()==dCellDate.getMonth()&&this.cfg.getProperty(defCfg.PAGEDATE.key).getFullYear()==dCellDate.getFullYear()){YAHOO.util.Dom.removeClass(cell,this.Style.CSS_CELL_SELECTED);} selected.splice(cellDateIndex,1);} -if(this.parent){this.parent.cfg.setProperty("selected",selected);}else{this.cfg.setProperty("selected",selected);} -this.deselectEvent.fire(selectDate);return this.getSelectedDates();};YAHOO.widget.Calendar.prototype.deselectAll=function(){this.beforeDeselectEvent.fire();var selected=this.cfg.getProperty("selected");var count=selected.length;var sel=selected.concat();if(this.parent){this.parent.cfg.setProperty("selected",[]);}else{this.cfg.setProperty("selected",[]);} +if(this.parent){this.parent.cfg.setProperty(defCfg.SELECTED.key,selected);}else{this.cfg.setProperty(defCfg.SELECTED.key,selected);} +this.deselectEvent.fire(selectDate);} +return this.getSelectedDates();};YAHOO.widget.Calendar.prototype.deselectAll=function(){this.beforeDeselectEvent.fire();var cfgSelected=YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key;var selected=this.cfg.getProperty(cfgSelected);var count=selected.length;var sel=selected.concat();if(this.parent){this.parent.cfg.setProperty(cfgSelected,[]);}else{this.cfg.setProperty(cfgSelected,[]);} if(count>0){this.deselectEvent.fire(sel);} -return this.getSelectedDates();};YAHOO.widget.Calendar.prototype._toFieldArray=function(date){var returnDate=[];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;imaxDate.getTime()));};YAHOO.widget.Calendar.prototype._parsePageDate=function(date){var parsedDate;var defCfg=YAHOO.widget.Calendar._DEFAULT_CONFIG;if(date){if(date instanceof Date){parsedDate=YAHOO.widget.DateMath.findMonthStart(date);}else{var month,year,aMonthYear;aMonthYear=date.split(this.cfg.getProperty(defCfg.DATE_FIELD_DELIMITER.key));month=parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_MONTH_POSITION.key)-1],10)-1;year=parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_YEAR_POSITION.key)-1],10);parsedDate=new Date(year,month,1);}}else{parsedDate=new Date(this.today.getFullYear(),this.today.getMonth(),1);} +return parsedDate;};YAHOO.widget.Calendar.prototype.onBeforeSelect=function(){if(this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MULTI_SELECT.key)===false){if(this.parent){this.parent.callChildFunction("clearAllBodyCellStyles",this.Style.CSS_CELL_SELECTED);this.parent.deselectAll();}else{this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);this.deselectAll();}}};YAHOO.widget.Calendar.prototype.onSelect=function(selected){};YAHOO.widget.Calendar.prototype.onBeforeDeselect=function(){};YAHOO.widget.Calendar.prototype.onDeselect=function(deselected){};YAHOO.widget.Calendar.prototype.onChangePage=function(){this.render();};YAHOO.widget.Calendar.prototype.onRender=function(){};YAHOO.widget.Calendar.prototype.onReset=function(){this.render();};YAHOO.widget.Calendar.prototype.onClear=function(){this.render();};YAHOO.widget.Calendar.prototype.validate=function(){return true;};YAHOO.widget.Calendar.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.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.DATE;} for(var i=0;i0){this.init(id,containerId,config);}};YAHOO.widget.CalendarGroup.prototype.init=function(id,containerId,config){this.initEvents();this.initStyles();this.pages=[];this.id=id;this.containerId=containerId;this.oDomContainer=document.getElementById(containerId);YAHOO.util.Dom.addClass(this.oDomContainer,YAHOO.widget.CalendarGroup.CSS_CONTAINER);YAHOO.util.Dom.addClass(this.oDomContainer,YAHOO.widget.CalendarGroup.CSS_MULTI_UP);this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.setupConfig();if(config){this.cfg.applyConfig(config,true);} -this.cfg.fireQueue();if(this.browser=="opera"){var fixWidth=function(){var startW=this.oDomContainer.offsetWidth;var w=0;for(var p=0;p0){this.oDomContainer.style.width=w+"px";}};this.renderEvent.subscribe(fixWidth,this,true);}};YAHOO.widget.CalendarGroup.prototype.setupConfig=function(){this.cfg.addProperty("pages",{value:2,validator:this.cfg.checkNumber,handler:this.configPages});this.cfg.addProperty("pagedate",{value:new Date(),handler:this.configPageDate});this.cfg.addProperty("selected",{value:[],handler:this.delegateConfig});this.cfg.addProperty("title",{value:"",handler:this.configTitle});this.cfg.addProperty("close",{value:false,handler:this.configClose});this.cfg.addProperty("iframe",{value:true,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("mindate",{value:null,handler:this.delegateConfig});this.cfg.addProperty("maxdate",{value:null,handler:this.delegateConfig});this.cfg.addProperty("MULTI_SELECT",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("START_WEEKDAY",{value:0,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("SHOW_WEEKDAYS",{value:true,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_HEADER",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("SHOW_WEEK_FOOTER",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("HIDE_BLANK_WEEKS",{value:false,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty("NAV_ARROW_LEFT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/callt.gif",handler:this.delegateConfig});this.cfg.addProperty("NAV_ARROW_RIGHT",{value:YAHOO.widget.Calendar.IMG_ROOT+"us/tr/calrt.gif",handler:this.delegateConfig});this.cfg.addProperty("MONTHS_SHORT",{value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],handler:this.delegateConfig});this.cfg.addProperty("MONTHS_LONG",{value:["January","February","March","April","May","June","July","August","September","October","November","December"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_1CHAR",{value:["S","M","T","W","T","F","S"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_SHORT",{value:["Su","Mo","Tu","We","Th","Fr","Sa"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_MEDIUM",{value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],handler:this.delegateConfig});this.cfg.addProperty("WEEKDAYS_LONG",{value:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],handler:this.delegateConfig});this.cfg.addProperty("LOCALE_MONTHS",{value:"long",handler:this.delegateConfig});this.cfg.addProperty("LOCALE_WEEKDAYS",{value:"short",handler:this.delegateConfig});this.cfg.addProperty("DATE_DELIMITER",{value:",",handler:this.delegateConfig});this.cfg.addProperty("DATE_FIELD_DELIMITER",{value:"/",handler:this.delegateConfig});this.cfg.addProperty("DATE_RANGE_DELIMITER",{value:"-",handler:this.delegateConfig});this.cfg.addProperty("MY_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MY_YEAR_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MD_DAY_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_MONTH_POSITION",{value:1,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_DAY_POSITION",{value:2,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty("MDY_YEAR_POSITION",{value:3,handler:this.delegateConfig,validator:this.cfg.checkNumber});};YAHOO.widget.CalendarGroup.prototype.initEvents=function(){var me=this;var sub=function(fn,obj,bOverride){for(var p=0;p0){year+=1;} +this.cfg.fireQueue();if(YAHOO.env.ua.opera){this.renderEvent.subscribe(this._fixWidth,this,true);}};YAHOO.widget.CalendarGroup.prototype.setupConfig=function(){var defCfg=YAHOO.widget.CalendarGroup._DEFAULT_CONFIG;this.cfg.addProperty(defCfg.PAGES.key,{value:defCfg.PAGES.value,validator:this.cfg.checkNumber,handler:this.configPages});this.cfg.addProperty(defCfg.PAGEDATE.key,{value:new Date(),handler:this.configPageDate});this.cfg.addProperty(defCfg.SELECTED.key,{value:[],handler:this.configSelected});this.cfg.addProperty(defCfg.TITLE.key,{value:defCfg.TITLE.value,handler:this.configTitle});this.cfg.addProperty(defCfg.CLOSE.key,{value:defCfg.CLOSE.value,handler:this.configClose});this.cfg.addProperty(defCfg.IFRAME.key,{value:defCfg.IFRAME.value,handler:this.configIframe,validator:this.cfg.checkBoolean});this.cfg.addProperty(defCfg.MINDATE.key,{value:defCfg.MINDATE.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.MAXDATE.key,{value:defCfg.MAXDATE.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.MULTI_SELECT.key,{value:defCfg.MULTI_SELECT.value,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty(defCfg.START_WEEKDAY.key,{value:defCfg.START_WEEKDAY.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.SHOW_WEEKDAYS.key,{value:defCfg.SHOW_WEEKDAYS.value,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty(defCfg.SHOW_WEEK_HEADER.key,{value:defCfg.SHOW_WEEK_HEADER.value,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty(defCfg.SHOW_WEEK_FOOTER.key,{value:defCfg.SHOW_WEEK_FOOTER.value,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty(defCfg.HIDE_BLANK_WEEKS.key,{value:defCfg.HIDE_BLANK_WEEKS.value,handler:this.delegateConfig,validator:this.cfg.checkBoolean});this.cfg.addProperty(defCfg.NAV_ARROW_LEFT.key,{value:defCfg.NAV_ARROW_LEFT.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.NAV_ARROW_RIGHT.key,{value:defCfg.NAV_ARROW_RIGHT.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.MONTHS_SHORT.key,{value:defCfg.MONTHS_SHORT.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.MONTHS_LONG.key,{value:defCfg.MONTHS_LONG.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.WEEKDAYS_1CHAR.key,{value:defCfg.WEEKDAYS_1CHAR.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.WEEKDAYS_SHORT.key,{value:defCfg.WEEKDAYS_SHORT.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.WEEKDAYS_MEDIUM.key,{value:defCfg.WEEKDAYS_MEDIUM.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.WEEKDAYS_LONG.key,{value:defCfg.WEEKDAYS_LONG.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.LOCALE_MONTHS.key,{value:defCfg.LOCALE_MONTHS.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.LOCALE_WEEKDAYS.key,{value:defCfg.LOCALE_WEEKDAYS.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.DATE_DELIMITER.key,{value:defCfg.DATE_DELIMITER.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.DATE_FIELD_DELIMITER.key,{value:defCfg.DATE_FIELD_DELIMITER.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.DATE_RANGE_DELIMITER.key,{value:defCfg.DATE_RANGE_DELIMITER.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.MY_MONTH_POSITION.key,{value:defCfg.MY_MONTH_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MY_YEAR_POSITION.key,{value:defCfg.MY_YEAR_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MD_MONTH_POSITION.key,{value:defCfg.MD_MONTH_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MD_DAY_POSITION.key,{value:defCfg.MD_DAY_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MDY_MONTH_POSITION.key,{value:defCfg.MDY_MONTH_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MDY_DAY_POSITION.key,{value:defCfg.MDY_DAY_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MDY_YEAR_POSITION.key,{value:defCfg.MDY_YEAR_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MY_LABEL_MONTH_POSITION.key,{value:defCfg.MY_LABEL_MONTH_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MY_LABEL_YEAR_POSITION.key,{value:defCfg.MY_LABEL_YEAR_POSITION.value,handler:this.delegateConfig,validator:this.cfg.checkNumber});this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key,{value:defCfg.MY_LABEL_MONTH_SUFFIX.value,handler:this.delegateConfig});this.cfg.addProperty(defCfg.MY_LABEL_YEAR_SUFFIX.key,{value:defCfg.MY_LABEL_YEAR_SUFFIX.value,handler:this.delegateConfig});};YAHOO.widget.CalendarGroup.prototype.initEvents=function(){var me=this;var strEvent="Event";var sub=function(fn,obj,bOverride){for(var p=0;p0)?this.pages[0].cfg.getProperty(cfgSelected):[];this.cfg.setProperty(cfgSelected,selected,true);};YAHOO.widget.CalendarGroup.prototype.delegateConfig=function(type,args,obj){var val=args[0];var cal;for(var p=0;p0){year+=1;} cal.setYear(year);}};YAHOO.widget.CalendarGroup.prototype.render=function(){this.renderHeader();for(var p=0;p=0;--p){var cal=this.pages[p];cal.previousMonth();}};YAHOO.widget.CalendarGroup.prototype.nextYear=function(){for(var p=0;p=0;--p){var cal=this.pages[p];cal.previousMonth();}};YAHOO.widget.CalendarGroup.prototype.nextYear=function(){for(var p=0;p11)){var DM=YAHOO.widget.DateMath;var newDate=DM.add(date,DM.MONTH,iMonth-date.getMonth());date.setTime(newDate.getTime());}else{date.setMonth(iMonth);}};YAHOO.widget.CalendarGroup.prototype._fixWidth=function(){var startW=this.oDomContainer.offsetWidth;var w=0;for(var p=0;p0){this.oDomContainer.style.width=w+"px";}};YAHOO.widget.CalendarGroup.CSS_CONTAINER="yui-calcontainer";YAHOO.widget.CalendarGroup.CSS_MULTI_UP="multi";YAHOO.widget.CalendarGroup.CSS_2UPTITLE="title";YAHOO.widget.CalendarGroup.CSS_2UPCLOSE="close-icon";YAHOO.lang.augmentProto(YAHOO.widget.CalendarGroup,YAHOO.widget.Calendar,"buildDayLabel","buildMonthLabel","renderOutOfBoundsDate","renderRowHeader","renderRowFooter","renderCellDefault","styleCellDefault","renderCellStyleHighlight1","renderCellStyleHighlight2","renderCellStyleHighlight3","renderCellStyleHighlight4","renderCellStyleToday","renderCellStyleSelected","renderCellNotThisMonth","renderBodyCellRestricted","initStyles","configTitle","configClose","configIframe","hide","browser");YAHOO.widget.CalendarGroup._DEFAULT_CONFIG=YAHOO.widget.Calendar._DEFAULT_CONFIG;YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGES={key:"pages",value:2};YAHOO.widget.CalendarGroup.prototype.toString=function(){return"CalendarGroup "+this.id;};YAHOO.widget.CalGrp=YAHOO.widget.CalendarGroup;YAHOO.widget.Calendar2up=function(id,containerId,config){this.init(id,containerId,config);};YAHOO.extend(YAHOO.widget.Calendar2up,YAHOO.widget.CalendarGroup);YAHOO.widget.Cal2up=YAHOO.widget.Calendar2up;YAHOO.register("calendar",YAHOO.widget.Calendar,{version:"2.3.0",build:"442"}); \ No newline at end of file diff --git a/lib/yui/calendar/calendar.js b/lib/yui/calendar/calendar.js index 060b3ca8cd..0f554186af 100755 --- a/lib/yui/calendar/calendar.js +++ b/lib/yui/calendar/calendar.js @@ -1,476 +1,695 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 -*/ -/** -* 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. -* @namespace YAHOO.util -* @class Config -* @constructor -* @param {Object} owner The owner Object to which this Config Object belongs -*/ -YAHOO.util.Config = function(owner) { - if (owner) { - this.init(owner); - } -}; - -YAHOO.util.Config.prototype = { - - /** - * Object reference to the owner of this Config Object - * @property owner - * @type Object - */ - owner : null, - - /** - * Boolean flag that specifies whether a queue is currently being executed - * @property queueInProgress - * @type Boolean - */ - queueInProgress : false, - - - /** - * Validates that the value passed in is a Boolean. - * @method checkBoolean - * @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. - * @method checkNumber - * @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. -* @method init -* @param {Object} owner The owner Object to which this Config Object belongs -*/ -YAHOO.util.Config.prototype.init = function(owner) { - - this.owner = owner; - - /** - * Object reference to the owner of this Config Object - * @event configChangedEvent - */ - this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged"); - - this.queueInProgress = false; - - /* Private Members */ - - /** - * Maintains the local collection of configuration property objects and their specified values - * @property config - * @private - * @type Object - */ - var config = {}; - - /** - * Maintains the local collection of configuration property objects as they were initially applied. - * This object is used when resetting a property. - * @property initialConfig - * @private - * @type Object - */ - var initialConfig = {}; - - /** - * Maintains the local, normalized CustomEvent queue - * @property eventQueue - * @private - * @type Object - */ - var eventQueue = []; - - /** - * Fires a configuration property event using the specified value. - * @method fireEvent - * @private - * @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 */ - - /** - * Adds a property to the Config Object's private config hash. - * @method addProperty - * @param {String} key The configuration property's name - * @param {Object} propertyObject The Object containing all of this property's arguments - */ - 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); - } - }; - - /** - * Returns a key-value configuration map of the values currently set in the Config Object. - * @method getConfig - * @return {Object} The current config, represented in a key-value map - */ - 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; - }; - - /** - * Returns the value of specified property. - * @method getProperty - * @param {String} key The name of the property - * @return {Object} The value of the specified property - */ - this.getProperty = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.value; - } else { - return undefined; - } - }; - - /** - * Resets the specified property's value to its initial value. - * @method resetProperty - * @param {String} key The name of the property - * @return {Boolean} True is the property was reset, false if not - */ - this.resetProperty = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (initialConfig[key] && initialConfig[key] != 'undefined') { - this.setProperty(key, initialConfig[key]); - } - return true; - } else { - return false; - } - }; - - /** - * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired. - * @method setProperty - * @param {String} key The name of the property - * @param {String} value The value to set the property to - * @param {Boolean} silent Whether the value should be set silently, without firing the property event. - * @return {Boolean} True, if the set was successful, false if it failed. - */ - 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; - } - } - }; - - /** - * 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. - * @method queueProperty - * @param {String} key The name of the property - * @param {String} value The value to set the property to - * @return {Boolean} true, if the set was successful, false if it failed. - */ - 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 0) { + + i = nSubscribers - 1; + + do { + + subsc = evt.subscribers[i]; + + if (subsc && subsc.obj == obj && subsc.fn == fn) { + + return true; + + } + + } + while (i--); + + } + + return false; + + }; + + YAHOO.lang.augmentProto(Config, YAHOO.util.EventProvider); + +}()); /** * YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility @@ -665,7 +884,6 @@ YAHOO.widget.DateMath = { * @param {Date} date The JavaScript date for which to find the week number * @param {Number} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is * the calendar year of parameter "date". - * @param {Number} weekStartsOn OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday). * @return {Number} The week number of the given date. */ getWeekNumber : function(date, calendarYear) { @@ -746,7 +964,7 @@ YAHOO.widget.DateMath = { }; /** -* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month ("one-up") or two-month ("two-up") interface. Calendars are generated entirely via script and can be navigated without any page refreshes. +* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month or multi-month interface. Calendars are generated entirely via script and can be navigated without any page refreshes. * @module calendar * @title Calendar * @namespace YAHOO.widget @@ -763,7 +981,6 @@ YAHOO.widget.DateMath = { * * <div id="cal1Container"></div> * -* Note that the table can be replaced with any kind of element. *

* @namespace YAHOO.widget * @class Calendar @@ -780,9 +997,10 @@ YAHOO.widget.Calendar = function(id, containerId, config) { * The path to be used for images loaded for the Calendar * @property YAHOO.widget.Calendar.IMG_ROOT * @static +* @deprecated You can now customize images by overriding the calclose, calnavleft and calnavright default CSS classes for the close icon, left arrow and right arrow respectively * @type String */ -YAHOO.widget.Calendar.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.IMG_ROOT = null; /** * Type constant used for renderers to represent an individual date (M/D/Y) @@ -847,6 +1065,153 @@ YAHOO.widget.Calendar.DISPLAY_DAYS = 42; */ YAHOO.widget.Calendar.STOP_RENDER = "S"; +/** +* Constant used to represent short date field string formats (e.g. Tu or Feb) +* @property YAHOO.widget.Calendar.SHORT +* @static +* @final +* @type String +*/ +YAHOO.widget.Calendar.SHORT = "short"; + +/** +* Constant used to represent long date field string formats (e.g. Monday or February) +* @property YAHOO.widget.Calendar.LONG +* @static +* @final +* @type String +*/ +YAHOO.widget.Calendar.LONG = "long"; + +/** +* Constant used to represent medium date field string formats (e.g. Mon) +* @property YAHOO.widget.Calendar.MEDIUM +* @static +* @final +* @type String +*/ +YAHOO.widget.Calendar.MEDIUM = "medium"; + +/** +* Constant used to represent single character date field string formats (e.g. M, T, W) +* @property YAHOO.widget.Calendar.ONE_CHAR +* @static +* @final +* @type String +*/ +YAHOO.widget.Calendar.ONE_CHAR = "1char"; + +/** +* The set of default Config property keys and values for the Calendar +* @property YAHOO.widget.Calendar._DEFAULT_CONFIG +* @final +* @static +* @private +* @type Object +*/ +YAHOO.widget.Calendar._DEFAULT_CONFIG = { + // Default values for pagedate and selected are not class level constants - they are set during instance creation + PAGEDATE : {key:"pagedate", value:null}, + SELECTED : {key:"selected", value:null}, + TITLE : {key:"title", value:""}, + CLOSE : {key:"close", value:false}, + IFRAME : {key:"iframe", value:(YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) ? true : false}, + MINDATE : {key:"mindate", value:null}, + MAXDATE : {key:"maxdate", value:null}, + MULTI_SELECT : {key:"multi_select", value:false}, + START_WEEKDAY : {key:"start_weekday", value:0}, + SHOW_WEEKDAYS : {key:"show_weekdays", value:true}, + SHOW_WEEK_HEADER : {key:"show_week_header", value:false}, + SHOW_WEEK_FOOTER : {key:"show_week_footer", value:false}, + HIDE_BLANK_WEEKS : {key:"hide_blank_weeks", value:false}, + NAV_ARROW_LEFT: {key:"nav_arrow_left", value:null} , + NAV_ARROW_RIGHT : {key:"nav_arrow_right", value:null} , + MONTHS_SHORT : {key:"months_short", value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]}, + MONTHS_LONG: {key:"months_long", value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]}, + WEEKDAYS_1CHAR: {key:"weekdays_1char", value:["S", "M", "T", "W", "T", "F", "S"]}, + WEEKDAYS_SHORT: {key:"weekdays_short", value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]}, + WEEKDAYS_MEDIUM: {key:"weekdays_medium", value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}, + WEEKDAYS_LONG: {key:"weekdays_long", value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]}, + LOCALE_MONTHS:{key:"locale_months", value:"long"}, + LOCALE_WEEKDAYS:{key:"locale_weekdays", value:"short"}, + DATE_DELIMITER:{key:"date_delimiter", value:","}, + DATE_FIELD_DELIMITER:{key:"date_field_delimiter", value:"/"}, + DATE_RANGE_DELIMITER:{key:"date_range_delimiter", value:"-"}, + MY_MONTH_POSITION:{key:"my_month_position", value:1}, + MY_YEAR_POSITION:{key:"my_year_position", value:2}, + MD_MONTH_POSITION:{key:"md_month_position", value:1}, + MD_DAY_POSITION:{key:"md_day_position", value:2}, + MDY_MONTH_POSITION:{key:"mdy_month_position", value:1}, + MDY_DAY_POSITION:{key:"mdy_day_position", value:2}, + MDY_YEAR_POSITION:{key:"mdy_year_position", value:3}, + MY_LABEL_MONTH_POSITION:{key:"my_label_month_position", value:1}, + MY_LABEL_YEAR_POSITION:{key:"my_label_year_position", value:2}, + MY_LABEL_MONTH_SUFFIX:{key:"my_label_month_suffix", value:" "}, + MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix", value:""} +}; + +/** +* The set of Custom Event types supported by the Calendar +* @property YAHOO.widget.Calendar._EVENT_TYPES +* @final +* @static +* @private +* @type Object +*/ +YAHOO.widget.Calendar._EVENT_TYPES = { + BEFORE_SELECT : "beforeSelect", + SELECT : "select", + BEFORE_DESELECT : "beforeDeselect", + DESELECT : "deselect", + CHANGE_PAGE : "changePage", + BEFORE_RENDER : "beforeRender", + RENDER : "render", + RESET : "reset", + CLEAR : "clear" +}; + +/** +* The set of default style constants for the Calendar +* @property YAHOO.widget.Calendar._STYLES +* @final +* @static +* @private +* @type Object +*/ +YAHOO.widget.Calendar._STYLES = { + CSS_ROW_HEADER: "calrowhead", + CSS_ROW_FOOTER: "calrowfoot", + CSS_CELL : "calcell", + CSS_CELL_SELECTOR : "selector", + CSS_CELL_SELECTED : "selected", + CSS_CELL_SELECTABLE : "selectable", + CSS_CELL_RESTRICTED : "restricted", + CSS_CELL_TODAY : "today", + CSS_CELL_OOM : "oom", + CSS_CELL_OOB : "previous", + CSS_HEADER : "calheader", + CSS_HEADER_TEXT : "calhead", + CSS_BODY : "calbody", + CSS_WEEKDAY_CELL : "calweekdaycell", + CSS_WEEKDAY_ROW : "calweekdayrow", + CSS_FOOTER : "calfoot", + CSS_CALENDAR : "yui-calendar", + CSS_SINGLE : "single", + CSS_CONTAINER : "yui-calcontainer", + CSS_NAV_LEFT : "calnavleft", + CSS_NAV_RIGHT : "calnavright", + CSS_CLOSE : "calclose", + 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" +}; + YAHOO.widget.Calendar.prototype = { /** @@ -922,14 +1287,6 @@ YAHOO.widget.Calendar.prototype = { */ _renderStack : null, - /** - * A Date object representing the month/year that the calendar is initially set to - * @property _pageDate - * @private - * @type Date - */ - _pageDate : null, - /** * The private list of initially selected dates. * @property _selectedDates @@ -988,7 +1345,7 @@ YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) { YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); YAHOO.util.Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE); - + this.cellDates = []; this.cells = []; this.renderStack = []; @@ -1004,30 +1361,41 @@ YAHOO.widget.Calendar.prototype.init = function(id, containerId, config) { }; /** -* Renders the built-in IFRAME shim for the IE6 and below +* Default Config listener for the iframe property. If the iframe config property is set to true, +* renders the built-in IFRAME shim if the container is relatively or absolutely positioned. +* * @method configIframe */ YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) { var useIframe = args[0]; - if (YAHOO.util.Dom.inDocument(this.oDomContainer)) { - if (useIframe) { - var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); + if (!this.parent) { + if (YAHOO.util.Dom.inDocument(this.oDomContainer)) { + if (useIframe) { + var pos = YAHOO.util.Dom.getStyle(this.oDomContainer, "position"); + + if (pos == "absolute" || pos == "relative") { + + if (!YAHOO.util.Dom.inDocument(this.iframe)) { + this.iframe = document.createElement("iframe"); + this.iframe.src = "javascript:false;"; + + YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); + + if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { + YAHOO.util.Dom.addClass(this.iframe, "fixedsize"); + } - if (this.browser == "ie" && (pos == "absolute" || pos == "relative")) { - if (! YAHOO.util.Dom.inDocument(this.iframe)) { - this.iframe = document.createElement("iframe"); - this.iframe.src = "javascript:false;"; - YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); - this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); + this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); + } } - } - } else { - if (this.iframe) { - if (this.iframe.parentNode) { - this.iframe.parentNode.removeChild(this.iframe); + } else { + if (this.iframe) { + if (this.iframe.parentNode) { + this.iframe.parentNode.removeChild(this.iframe); + } + this.iframe = null; } - this.iframe = null; } } } @@ -1039,7 +1407,7 @@ YAHOO.widget.Calendar.prototype.configIframe = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) { var title = args[0]; - var close = this.cfg.getProperty("close"); + var close = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.CLOSE.key); var titleDiv; @@ -1068,24 +1436,31 @@ YAHOO.widget.Calendar.prototype.configTitle = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) { var close = args[0]; - var title = this.cfg.getProperty("title"); + var title = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.TITLE.key); + + var DEPR_CLOSE_PATH = "us/my/bn/x_d.gif"; var linkClose; if (close === true) { linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || document.createElement("a"); - linkClose.href = "javascript:void(null);"; + linkClose.href = "#"; linkClose.className = "link-close"; - YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true); - var imgClose = document.createElement("img"); - imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + "us/my/bn/x_d.gif"; - imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE; - linkClose.appendChild(imgClose); + YAHOO.util.Event.addListener(linkClose, "click", function(e, cal) {cal.hide(); YAHOO.util.Event.preventDefault(e); }, this); + + if (YAHOO.widget.Calendar.IMG_ROOT !== null) { + var imgClose = document.createElement("img"); + imgClose.src = YAHOO.widget.Calendar.IMG_ROOT + DEPR_CLOSE_PATH; + imgClose.className = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE; + linkClose.appendChild(imgClose); + } else { + linkClose.innerHTML = ''; + } + this.oDomContainer.appendChild(linkClose); YAHOO.util.Dom.addClass(this.oDomContainer, "withtitle"); } else { linkClose = YAHOO.util.Dom.getElementsByClassName("link-close", "a", this.oDomContainer)[0] || null; - if (linkClose) { YAHOO.util.Event.purgeElement(linkClose); this.oDomContainer.removeChild(linkClose); @@ -1102,61 +1477,63 @@ YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.initEvents = function() { + var defEvents = YAHOO.widget.Calendar._EVENT_TYPES; + /** * Fired before a selection is made * @event beforeSelectEvent */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect"); + this.beforeSelectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_SELECT); /** * Fired when a selection is made * @event selectEvent * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. */ - this.selectEvent = new YAHOO.util.CustomEvent("select"); + this.selectEvent = new YAHOO.util.CustomEvent(defEvents.SELECT); /** * Fired before a selection is made * @event beforeDeselectEvent */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect"); + this.beforeDeselectEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_DESELECT); /** * Fired when a selection is made * @event deselectEvent * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. */ - this.deselectEvent = new YAHOO.util.CustomEvent("deselect"); + this.deselectEvent = new YAHOO.util.CustomEvent(defEvents.DESELECT); /** * Fired when the Calendar page is changed * @event changePageEvent */ - this.changePageEvent = new YAHOO.util.CustomEvent("changePage"); + this.changePageEvent = new YAHOO.util.CustomEvent(defEvents.CHANGE_PAGE); /** * Fired before the Calendar is rendered * @event beforeRenderEvent */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); + this.beforeRenderEvent = new YAHOO.util.CustomEvent(defEvents.BEFORE_RENDER); /** * Fired when the Calendar is rendered * @event renderEvent */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); + this.renderEvent = new YAHOO.util.CustomEvent(defEvents.RENDER); /** * Fired when the Calendar is reset * @event resetEvent */ - this.resetEvent = new YAHOO.util.CustomEvent("reset"); + this.resetEvent = new YAHOO.util.CustomEvent(defEvents.RESET); /** * Fired when the Calendar is cleared * @event clearEvent */ - this.clearEvent = new YAHOO.util.CustomEvent("clear"); + this.clearEvent = new YAHOO.util.CustomEvent(defEvents.CLEAR); this.beforeSelectEvent.subscribe(this.onBeforeSelect, this, true); this.selectEvent.subscribe(this.onSelect, this, true); @@ -1168,7 +1545,6 @@ YAHOO.widget.Calendar.prototype.initEvents = function() { this.clearEvent.subscribe(this.onClear, this, true); }; - /** * The default event function that is attached to a date link within a calendar cell * when the calendar is rendered. @@ -1177,17 +1553,30 @@ YAHOO.widget.Calendar.prototype.initEvents = function() { * @param {Calendar} cal A reference to the calendar passed by the Event utility */ YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) { + var cell,index,d,date; + var target = YAHOO.util.Event.getTarget(e); + var tagName = target.tagName.toLowerCase(); + var defSelector = false; - var cell,index,d,date; + while (tagName != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { + + if (!defSelector && tagName == "a" && YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) { + defSelector = true; + } - while (target.tagName.toLowerCase() != "td" && ! YAHOO.util.Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { target = target.parentNode; - if (target.tagName.toLowerCase() == "html") { + tagName = target.tagName.toLowerCase(); + if (tagName == "html") { return; } } - + + if (defSelector) { + // Stop link href navigation for default renderer + YAHOO.util.Event.preventDefault(e); + } + cell = target; if (YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) { @@ -1202,16 +1591,16 @@ YAHOO.widget.Calendar.prototype.doSelectCell = function(e, cal) { if (link) { link.blur(); } - + var cellDate = cal.cellDates[index]; var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate); - + if (cellDateIndex > -1) { cal.deselectCell(index); } else { cal.selectCell(index); } - + } else { link = cell.getElementsByTagName("a")[0]; if (link) { @@ -1276,13 +1665,15 @@ YAHOO.widget.Calendar.prototype.doCellMouseOut = function(e, cal) { YAHOO.widget.Calendar.prototype.setupConfig = function() { + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + /** * The month/year representing the current visible Calendar date (mm/yyyy) * @config pagedate * @type String * @default today's date */ - this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } ); + this.cfg.addProperty(defCfg.PAGEDATE.key, { value:new Date(), handler:this.configPageDate } ); /** * The date or range of dates representing the current Calendar selection @@ -1290,7 +1681,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default [] */ - this.cfg.addProperty("selected", { value:[], handler:this.configSelected } ); + this.cfg.addProperty(defCfg.SELECTED.key, { value:[], handler:this.configSelected } ); /** * The title to display above the Calendar's month header @@ -1298,7 +1689,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "" */ - this.cfg.addProperty("title", { value:"", handler:this.configTitle } ); + this.cfg.addProperty(defCfg.TITLE.key, { value:defCfg.TITLE.value, handler:this.configTitle } ); /** * Whether or not a close button should be displayed for this Calendar @@ -1306,15 +1697,18 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("close", { value:false, handler:this.configClose } ); + this.cfg.addProperty(defCfg.CLOSE.key, { value:defCfg.CLOSE.value, handler:this.configClose } ); /** * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below. + * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be + * enabled if required. + * * @config iframe * @type Boolean - * @default true + * @default true for IE6 and below, false for all other browsers */ - this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.IFRAME.key, { value:defCfg.IFRAME.value, handler:this.configIframe, validator:this.cfg.checkBoolean } ); /** * The minimum selectable date in the current Calendar (mm/dd/yyyy) @@ -1322,7 +1716,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default null */ - this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } ); + this.cfg.addProperty(defCfg.MINDATE.key, { value:defCfg.MINDATE.value, handler:this.configMinDate } ); /** * The maximum selectable date in the current Calendar (mm/dd/yyyy) @@ -1330,7 +1724,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default null */ - this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } ); + this.cfg.addProperty(defCfg.MAXDATE.key, { value:defCfg.MAXDATE.value, handler:this.configMaxDate } ); // Options properties @@ -1341,7 +1735,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.MULTI_SELECT.key, { value:defCfg.MULTI_SELECT.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * The weekday the week begins on. Default is 0 (Sunday). @@ -1349,7 +1743,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type number * @default 0 */ - this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.START_WEEKDAY.key, { value:defCfg.START_WEEKDAY.value, handler:this.configOptions, validator:this.cfg.checkNumber } ); /** * True if the Calendar should show weekday labels. True by default. @@ -1357,7 +1751,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default true */ - this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEKDAYS.key, { value:defCfg.SHOW_WEEKDAYS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should show week row headers. False by default. @@ -1365,7 +1759,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEK_HEADER.key, { value:defCfg.SHOW_WEEK_HEADER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should show week row footers. False by default. @@ -1373,7 +1767,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEK_FOOTER.key,{ value:defCfg.SHOW_WEEK_FOOTER.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should suppress weeks that are not a part of the current month. False by default. @@ -1381,23 +1775,25 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - + this.cfg.addProperty(defCfg.HIDE_BLANK_WEEKS.key, { value:defCfg.HIDE_BLANK_WEEKS.value, handler:this.configOptions, validator:this.cfg.checkBoolean } ); + /** * The image that should be used for the left navigation arrow. * @config NAV_ARROW_LEFT * @type String - * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif" + * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" + * @default null */ - this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.configOptions } ); + this.cfg.addProperty(defCfg.NAV_ARROW_LEFT.key, { value:defCfg.NAV_ARROW_LEFT.value, handler:this.configOptions } ); /** - * The image that should be used for the left navigation arrow. + * The image that should be used for the right navigation arrow. * @config NAV_ARROW_RIGHT * @type String - * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif" + * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" + * @default null */ - this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.configOptions } ); + this.cfg.addProperty(defCfg.NAV_ARROW_RIGHT.key, { value:defCfg.NAV_ARROW_RIGHT.value, handler:this.configOptions } ); // Locale properties @@ -1407,7 +1803,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] */ - this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.MONTHS_SHORT.key, { value:defCfg.MONTHS_SHORT.value, handler:this.configLocale } ); /** * The long month labels for the current locale. @@ -1415,7 +1811,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" */ - this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.MONTHS_LONG.key, { value:defCfg.MONTHS_LONG.value, handler:this.configLocale } ); /** * The 1-character weekday labels for the current locale. @@ -1423,7 +1819,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["S", "M", "T", "W", "T", "F", "S"] */ - this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.WEEKDAYS_1CHAR.key, { value:defCfg.WEEKDAYS_1CHAR.value, handler:this.configLocale } ); /** * The short weekday labels for the current locale. @@ -1431,7 +1827,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] */ - this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.WEEKDAYS_SHORT.key, { value:defCfg.WEEKDAYS_SHORT.value, handler:this.configLocale } ); /** * The medium weekday labels for the current locale. @@ -1439,7 +1835,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] */ - this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.WEEKDAYS_MEDIUM.key, { value:defCfg.WEEKDAYS_MEDIUM.value, handler:this.configLocale } ); /** * The long weekday labels for the current locale. @@ -1447,7 +1843,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String[] * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] */ - this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.configLocale } ); + this.cfg.addProperty(defCfg.WEEKDAYS_LONG.key, { value:defCfg.WEEKDAYS_LONG.value, handler:this.configLocale } ); /** * Refreshes the locale values used to build the Calendar. @@ -1455,17 +1851,17 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @private */ var refreshLocale = function() { - this.cfg.refireEvent("LOCALE_MONTHS"); - this.cfg.refireEvent("LOCALE_WEEKDAYS"); + this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); + this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); }; - this.cfg.subscribeToConfigEvent("START_WEEKDAY", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("MONTHS_SHORT", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("MONTHS_LONG", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("WEEKDAYS_1CHAR", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("WEEKDAYS_SHORT", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("WEEKDAYS_MEDIUM", refreshLocale, this, true); - this.cfg.subscribeToConfigEvent("WEEKDAYS_LONG", refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.START_WEEKDAY.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.MONTHS_SHORT.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.MONTHS_LONG.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_1CHAR.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_SHORT.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_MEDIUM.key, refreshLocale, this, true); + this.cfg.subscribeToConfigEvent(defCfg.WEEKDAYS_LONG.key, refreshLocale, this, true); /** * The setting that determines which length of month labels should be used. Possible values are "short" and "long". @@ -1473,7 +1869,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "long" */ - this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } ); + this.cfg.addProperty(defCfg.LOCALE_MONTHS.key, { value:defCfg.LOCALE_MONTHS.value, handler:this.configLocaleValues } ); /** * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". @@ -1481,7 +1877,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "short" */ - this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } ); + this.cfg.addProperty(defCfg.LOCALE_WEEKDAYS.key, { value:defCfg.LOCALE_WEEKDAYS.value, handler:this.configLocaleValues } ); /** * The value used to delimit individual dates in a date string passed to various Calendar functions. @@ -1489,7 +1885,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "," */ - this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } ); + this.cfg.addProperty(defCfg.DATE_DELIMITER.key, { value:defCfg.DATE_DELIMITER.value, handler:this.configLocale } ); /** * The value used to delimit date fields in a date string passed to various Calendar functions. @@ -1497,7 +1893,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "/" */ - this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } ); + this.cfg.addProperty(defCfg.DATE_FIELD_DELIMITER.key, { value:defCfg.DATE_FIELD_DELIMITER.value, handler:this.configLocale } ); /** * The value used to delimit date ranges in a date string passed to various Calendar functions. @@ -1505,7 +1901,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type String * @default "-" */ - this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } ); + this.cfg.addProperty(defCfg.DATE_RANGE_DELIMITER.key, { value:defCfg.DATE_RANGE_DELIMITER.value, handler:this.configLocale } ); /** * The position of the month in a month/year date string @@ -1513,7 +1909,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MY_MONTH_POSITION.key, { value:defCfg.MY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/year date string @@ -1521,7 +1917,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MY_YEAR_POSITION.key, { value:defCfg.MY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day date string @@ -1529,7 +1925,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MD_MONTH_POSITION.key, { value:defCfg.MD_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/year date string @@ -1537,7 +1933,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MD_DAY_POSITION.key, { value:defCfg.MD_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day/year date string @@ -1545,7 +1941,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_MONTH_POSITION.key, { value:defCfg.MDY_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/day/year date string @@ -1553,7 +1949,7 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_DAY_POSITION.key, { value:defCfg.MDY_DAY_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/day/year date string @@ -1561,39 +1957,47 @@ YAHOO.widget.Calendar.prototype.setupConfig = function() { * @type Number * @default 3 */ - this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_YEAR_POSITION.key, { value:defCfg.MDY_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); + + /** + * The position of the month in the month year label string used as the Calendar header + * @config MY_LABEL_MONTH_POSITION + * @type Number + * @default 1 + */ + this.cfg.addProperty(defCfg.MY_LABEL_MONTH_POSITION.key, { value:defCfg.MY_LABEL_MONTH_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); + + /** + * The position of the year in the month year label string used as the Calendar header + * @config MY_LABEL_YEAR_POSITION + * @type Number + * @default 2 + */ + this.cfg.addProperty(defCfg.MY_LABEL_YEAR_POSITION.key, { value:defCfg.MY_LABEL_YEAR_POSITION.value, handler:this.configLocale, validator:this.cfg.checkNumber } ); + + /** + * The suffix used after the month when rendering the Calendar header + * @config MY_LABEL_MONTH_SUFFIX + * @type String + * @default " " + */ + this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.configLocale } ); + + /** + * The suffix used after the year when rendering the Calendar header + * @config MY_LABEL_YEAR_SUFFIX + * @type String + * @default "" + */ + this.cfg.addProperty(defCfg.MY_LABEL_YEAR_SUFFIX.key, { value:defCfg.MY_LABEL_YEAR_SUFFIX.value, handler:this.configLocale } ); }; /** * The default handler for the "pagedate" property * @method configPageDate */ -YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { - var val = args[0]; - var month, year, aMonthYear; - - if (val) { - if (val instanceof Date) { - val = YAHOO.widget.DateMath.findMonthStart(val); - this.cfg.setProperty("pagedate", val, true); - if (! this._pageDate) { - this._pageDate = this.cfg.getProperty("pagedate"); - } - return; - } else { - aMonthYear = val.split(this.cfg.getProperty("DATE_FIELD_DELIMITER")); - month = parseInt(aMonthYear[this.cfg.getProperty("MY_MONTH_POSITION")-1], 10)-1; - year = parseInt(aMonthYear[this.cfg.getProperty("MY_YEAR_POSITION")-1], 10); - } - } else { - month = this.today.getMonth(); - year = this.today.getFullYear(); - } - - this.cfg.setProperty("pagedate", new Date(year, month, 1), true); - if (! this._pageDate) { - this._pageDate = this.cfg.getProperty("pagedate"); - } +YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key, this._parsePageDate(args[0]), true); }; /** @@ -1602,9 +2006,9 @@ YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) { var val = args[0]; - if (typeof val == 'string') { + if (YAHOO.lang.isString(val)) { val = this._parseDate(val); - this.cfg.setProperty("mindate", new Date(val[0],(val[1]-1),val[2])); + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MINDATE.key, new Date(val[0],(val[1]-1),val[2])); } }; @@ -1614,9 +2018,9 @@ YAHOO.widget.Calendar.prototype.configMinDate = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) { var val = args[0]; - if (typeof val == 'string') { + if (YAHOO.lang.isString(val)) { val = this._parseDate(val); - this.cfg.setProperty("maxdate", new Date(val[0],(val[1]-1),val[2])); + this.cfg.setProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MAXDATE.key, new Date(val[0],(val[1]-1),val[2])); } }; @@ -1626,14 +2030,15 @@ YAHOO.widget.Calendar.prototype.configMaxDate = function(type, args, obj) { */ YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) { var selected = args[0]; + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; if (selected) { - if (typeof selected == 'string') { - this.cfg.setProperty("selected", this._parseDates(selected), true); + if (YAHOO.lang.isString(selected)) { + this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); } } if (! this._selectedDates) { - this._selectedDates = this.cfg.getProperty("selected"); + this._selectedDates = this.cfg.getProperty(cfgSelected); } }; @@ -1642,9 +2047,7 @@ YAHOO.widget.Calendar.prototype.configSelected = function(type, args, obj) { * @method configOptions */ YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { - type = type.toUpperCase(); - var val = args[0]; - this.Options[type] = val; + this.Options[type.toUpperCase()] = args[0]; }; /** @@ -1652,13 +2055,11 @@ YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { * @method configLocale */ YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) { - type = type.toUpperCase(); - var val = args[0]; - this.Locale[type] = val; - - this.cfg.refireEvent("LOCALE_MONTHS"); - this.cfg.refireEvent("LOCALE_WEEKDAYS"); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + this.Locale[type.toUpperCase()] = args[0]; + this.cfg.refireEvent(defCfg.LOCALE_MONTHS.key); + this.cfg.refireEvent(defCfg.LOCALE_WEEKDAYS.key); }; /** @@ -1666,37 +2067,39 @@ YAHOO.widget.Calendar.prototype.configLocale = function(type, args, obj) { * @method configLocaleValues */ YAHOO.widget.Calendar.prototype.configLocaleValues = function(type, args, obj) { - type = type.toUpperCase(); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + + type = type.toLowerCase(); var val = args[0]; switch (type) { - case "LOCALE_MONTHS": + case defCfg.LOCALE_MONTHS.key: switch (val) { - case "short": - this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_SHORT").concat(); + case YAHOO.widget.Calendar.SHORT: + this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_SHORT.key).concat(); break; - case "long": - this.Locale.LOCALE_MONTHS = this.cfg.getProperty("MONTHS_LONG").concat(); + case YAHOO.widget.Calendar.LONG: + this.Locale.LOCALE_MONTHS = this.cfg.getProperty(defCfg.MONTHS_LONG.key).concat(); break; } break; - case "LOCALE_WEEKDAYS": + case defCfg.LOCALE_WEEKDAYS.key: switch (val) { - case "1char": - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_1CHAR").concat(); + case YAHOO.widget.Calendar.ONE_CHAR: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_1CHAR.key).concat(); break; - case "short": - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_SHORT").concat(); + case YAHOO.widget.Calendar.SHORT: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_SHORT.key).concat(); break; - case "medium": - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_MEDIUM").concat(); + case YAHOO.widget.Calendar.MEDIUM: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_MEDIUM.key).concat(); break; - case "long": - this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty("WEEKDAYS_LONG").concat(); + case YAHOO.widget.Calendar.LONG: + this.Locale.LOCALE_WEEKDAYS = this.cfg.getProperty(defCfg.WEEKDAYS_LONG.key).concat(); break; } - var START_WEEKDAY = this.cfg.getProperty("START_WEEKDAY"); + var START_WEEKDAY = this.cfg.getProperty(defCfg.START_WEEKDAY.key); if (START_WEEKDAY > 0) { for (var w=0;w'; html[html.length] = '
'; - var renderLeft, renderRight = false; + var renderLeft, renderRight = false; - if (this.parent) { - if (this.index === 0) { - renderLeft = true; - } - if (this.index == (this.parent.cfg.getProperty("pages") -1)) { - renderRight = true; - } - } else { + if (this.parent) { + if (this.index === 0) { renderLeft = true; + } + if (this.index == (this.parent.cfg.getProperty("pages") -1)) { renderRight = true; } + } else { + renderLeft = true; + renderRight = true; + } - var cal = this.parent || this; - - if (renderLeft) { - html[html.length] = ' '; + var cal = this.parent || this; + + if (renderLeft) { + var leftArrow = this.cfg.getProperty(defCfg.NAV_ARROW_LEFT.key); + // Check for deprecated customization - If someone set IMG_ROOT, but didn't set NAV_ARROW_LEFT, then set NAV_ARROW_LEFT to the old deprecated value + if (leftArrow === null && YAHOO.widget.Calendar.IMG_ROOT !== null) { + leftArrow = YAHOO.widget.Calendar.IMG_ROOT + DEPR_NAV_LEFT; } - - html[html.length] = this.buildMonthLabel(); - - if (renderRight) { - html[html.length] = ' '; + var leftStyle = (leftArrow === null) ? "" : ' style="background-image:url(' + leftArrow + ')"'; + html[html.length] = ' '; + } + + html[html.length] = this.buildMonthLabel(); + + if (renderRight) { + var rightArrow = this.cfg.getProperty(defCfg.NAV_ARROW_RIGHT.key); + if (rightArrow === null && YAHOO.widget.Calendar.IMG_ROOT !== null) { + rightArrow = YAHOO.widget.Calendar.IMG_ROOT + DEPR_NAV_RIGHT; } + var rightStyle = (rightArrow === null) ? "" : ' style="background-image:url(' + rightArrow + ')"'; + html[html.length] = ' '; + } + html[html.length] = '
\n\n'; - html[html.length] = ''; - html[html.length] = ''; - html[html.length] = ''; - - if (this.cfg.getProperty("SHOW_WEEKDAYS")) { + if (this.cfg.getProperty(defCfg.SHOW_WEEKDAYS.key)) { html = this.buildWeekdays(html); } @@ -1925,9 +2357,11 @@ YAHOO.widget.Calendar.prototype.renderHeader = function(html) { */ YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) { + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + html[html.length] = ''; - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { + if (this.cfg.getProperty(defCfg.SHOW_WEEK_HEADER.key)) { html[html.length] = ' '; } @@ -1935,7 +2369,7 @@ YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) { html[html.length] = '' + this.Locale.LOCALE_WEEKDAYS[i] + ''; } - if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { + if (this.cfg.getProperty(defCfg.SHOW_WEEK_FOOTER.key)) { html[html.length] = ' '; } @@ -1952,8 +2386,9 @@ YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) { * @return {Array} The current working HTML array */ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { - - var startDay = this.cfg.getProperty("START_WEEKDAY"); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + + var startDay = this.cfg.getProperty(defCfg.START_WEEKDAY.key); this.preMonthDays = workingDate.getDay(); if (startDay > 0) { @@ -1968,10 +2403,34 @@ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays); - var useDate,weekNum,weekClass; - useDate = this.cfg.getProperty("pagedate"); - - html[html.length] = ''; + var weekNum,weekClass; + var weekPrefix = "w"; + var cellPrefix = "_cell"; + var workingDayPrefix = "wd"; + var dayPrefix = "d"; + + var cellRenderers; + var renderer; + + var todayYear = this.today.getFullYear(); + var todayMonth = this.today.getMonth(); + var todayDate = this.today.getDate(); + + var useDate = this.cfg.getProperty(defCfg.PAGEDATE.key); + var hideBlankWeeks = this.cfg.getProperty(defCfg.HIDE_BLANK_WEEKS.key); + var showWeekFooter = this.cfg.getProperty(defCfg.SHOW_WEEK_FOOTER.key); + var showWeekHeader = this.cfg.getProperty(defCfg.SHOW_WEEK_HEADER.key); + var mindate = this.cfg.getProperty(defCfg.MINDATE.key); + var maxdate = this.cfg.getProperty(defCfg.MAXDATE.key); + + if (mindate) { + mindate = YAHOO.widget.DateMath.clearTime(mindate); + } + if (maxdate) { + maxdate = YAHOO.widget.DateMath.clearTime(maxdate); + } + + html[html.length] = ''; var i = 0; @@ -1986,45 +2445,41 @@ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { for (var r=0;r<6;r++) { weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useDate.getFullYear(), startDay); + weekClass = weekPrefix + weekNum; - weekClass = "w" + weekNum; - - if (r !== 0 && this.isDateOOM(workingDate) && this.cfg.getProperty("HIDE_BLANK_WEEKS") === true) { + // Local OOM check for performance, since we already have pagedate + if (r !== 0 && hideBlankWeeks === true && workingDate.getMonth() != useDate.getMonth()) { break; } else { - + html[html.length] = ''; - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); } + if (showWeekHeader) { html = this.renderRowHeader(weekNum, html); } for (var d=0;d<7;d++){ // Render actual days - var cellRenderers = []; + cellRenderers = []; + renderer = null; this.clearElement(cell); - - YAHOO.util.Dom.addClass(cell, "calcell"); - - cell.id = this.id + "_cell" + i; + cell.className = this.Style.CSS_CELL; + cell.id = this.id + cellPrefix + i; - cell.innerHTML = i; - - var renderer = null; - - if (workingDate.getFullYear() == this.today.getFullYear() && - workingDate.getMonth() == this.today.getMonth() && - workingDate.getDate() == this.today.getDate()) { + if (workingDate.getDate() == todayDate && + workingDate.getMonth() == todayMonth && + workingDate.getFullYear() == todayYear) { cellRenderers[cellRenderers.length]=cal.renderCellStyleToday; } - this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates - - if (this.isDateOOM(workingDate)) { + var workingArray = [workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; + this.cellDates[this.cellDates.length] = workingArray; // Add this date to cellDates + + // Local OOM check for performance, since we already have pagedate + if (workingDate.getMonth() != useDate.getMonth()) { cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth; } else { - - YAHOO.util.Dom.addClass(cell, "wd" + workingDate.getDay()); - YAHOO.util.Dom.addClass(cell, "d" + workingDate.getDate()); + YAHOO.util.Dom.addClass(cell, workingDayPrefix + workingDate.getDay()); + YAHOO.util.Dom.addClass(cell, dayPrefix + workingDate.getDate()); for (var s=0;s -1) { + if (this._indexOfSelectedFieldArray(workingArray) > -1) { cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected; } - var mindate = this.cfg.getProperty("mindate"); - var maxdate = this.cfg.getProperty("maxdate"); - - if (mindate) { - mindate = YAHOO.widget.DateMath.clearTime(mindate); - } - if (maxdate) { - maxdate = YAHOO.widget.DateMath.clearTime(maxdate); - } - - if ( - (mindate && (workingDate.getTime() < mindate.getTime())) || + if ((mindate && (workingDate.getTime() < mindate.getTime())) || (maxdate && (workingDate.getTime() > maxdate.getTime())) ) { cellRenderers[cellRenderers.length]=cal.renderOutOfBoundsDate; @@ -2125,12 +2569,9 @@ YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { cellRenderers[cellRenderers.length]=cal.styleCellDefault; cellRenderers[cellRenderers.length]=cal.renderCellDefault; } - - - for (var x=0;x= 7 && this.cfg.getProperty("HIDE_BLANK_WEEKS")) { + if (hideBlankWeeks && postDays >= 7) { var blankWeeks = Math.floor(postDays/7); for (var p=0;p'; @@ -2211,13 +2653,13 @@ YAHOO.widget.Calendar.prototype.render = function() { html[html.length] = ''; this.oDomContainer.innerHTML = html.join("\n"); - + this.applyListeners(); this.cells = this.oDomContainer.getElementsByTagName("td"); - this.cfg.refireEvent("title"); - this.cfg.refireEvent("close"); - this.cfg.refireEvent("iframe"); + this.cfg.refireEvent(defCfg.TITLE.key); + this.cfg.refireEvent(defCfg.CLOSE.key); + this.cfg.refireEvent(defCfg.IFRAME.key); this.renderEvent.fire(); }; @@ -2230,28 +2672,29 @@ YAHOO.widget.Calendar.prototype.applyListeners = function() { var root = this.oDomContainer; var cal = this.parent || this; - - var linkLeft, linkRight; - linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, "a", root); - linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, "a", root); + var anchor = "a"; + var mousedown = "mousedown"; + + var linkLeft = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, anchor, root); + var linkRight = YAHOO.util.Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, anchor, root); - if (linkLeft) { + if (linkLeft && linkLeft.length > 0) { this.linkLeft = linkLeft[0]; - YAHOO.util.Event.addListener(this.linkLeft, "mousedown", cal.previousMonth, cal, true); + YAHOO.util.Event.addListener(this.linkLeft, mousedown, cal.previousMonth, cal, true); } - if (linkRight) { + if (linkRight && linkRight.length > 0) { this.linkRight = linkRight[0]; - YAHOO.util.Event.addListener(this.linkRight, "mousedown", cal.nextMonth, cal, true); + YAHOO.util.Event.addListener(this.linkRight, mousedown, cal.nextMonth, cal, true); } if (this.domEventMap) { var el,elements; for (var cls in this.domEventMap) { - if (this.domEventMap.hasOwnProperty(cls)) { + if (YAHOO.lang.hasOwnProperty(this.domEventMap, cls)) { var items = this.domEventMap[cls]; - + if (! (items instanceof Array)) { items = [items]; } @@ -2296,7 +2739,7 @@ YAHOO.widget.Calendar.prototype.getDateFieldsByCellId = function(id) { id = parseInt(id, 10); return this.cellDates[id]; }; - + // BEGIN BUILT-IN TABLE CELL RENDERERS /** @@ -2346,7 +2789,7 @@ YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) { * @param {HTMLTableCellElement} cell The current working cell in the calendar */ YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) { - cell.innerHTML = '' + this.buildDayLabel(workingDate) + ""; + cell.innerHTML = '' + this.buildDayLabel(workingDate) + ""; }; /** @@ -2464,7 +2907,8 @@ YAHOO.widget.Calendar.prototype.renderBodyCellRestricted = function(workingDate, * @param {Number} count The number of months to add to the current calendar */ YAHOO.widget.Calendar.prototype.addMonths = function(count) { - this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count)); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.MONTH, count)); this.resetRenderers(); this.changePageEvent.fire(); }; @@ -2476,7 +2920,8 @@ YAHOO.widget.Calendar.prototype.addMonths = function(count) { * @param {Number} count The number of months to subtract from the current calendar */ YAHOO.widget.Calendar.prototype.subtractMonths = function(count) { - this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.MONTH, count)); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.MONTH, count)); this.resetRenderers(); this.changePageEvent.fire(); }; @@ -2488,7 +2933,8 @@ YAHOO.widget.Calendar.prototype.subtractMonths = function(count) { * @param {Number} count The number of years to add to the current calendar */ YAHOO.widget.Calendar.prototype.addYears = function(count) { - this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.add(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count)); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.add(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.YEAR, count)); this.resetRenderers(); this.changePageEvent.fire(); }; @@ -2500,7 +2946,8 @@ YAHOO.widget.Calendar.prototype.addYears = function(count) { * @param {Number} count The number of years to subtract from the current calendar */ YAHOO.widget.Calendar.prototype.subtractYears = function(count) { - this.cfg.setProperty("pagedate", YAHOO.widget.DateMath.subtract(this.cfg.getProperty("pagedate"), YAHOO.widget.DateMath.YEAR, count)); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + this.cfg.setProperty(cfgPageDate, YAHOO.widget.DateMath.subtract(this.cfg.getProperty(cfgPageDate), YAHOO.widget.DateMath.YEAR, count)); this.resetRenderers(); this.changePageEvent.fire(); }; @@ -2547,8 +2994,9 @@ YAHOO.widget.Calendar.prototype.previousYear = function() { * @method reset */ YAHOO.widget.Calendar.prototype.reset = function() { - this.cfg.resetProperty("selected"); - this.cfg.resetProperty("pagedate"); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + this.cfg.resetProperty(defCfg.SELECTED.key); + this.cfg.resetProperty(defCfg.PAGEDATE.key); this.resetEvent.fire(); }; @@ -2558,8 +3006,9 @@ YAHOO.widget.Calendar.prototype.reset = function() { * @method clear */ YAHOO.widget.Calendar.prototype.clear = function() { - this.cfg.setProperty("selected", []); - this.cfg.setProperty("pagedate", new Date(this.today.getTime())); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + this.cfg.setProperty(defCfg.SELECTED.key, []); + this.cfg.setProperty(defCfg.PAGEDATE.key, new Date(this.today.getTime())); this.clearEvent.fire(); }; @@ -2567,6 +3016,12 @@ YAHOO.widget.Calendar.prototype.clear = function() { * 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. +* +* Any dates which are OOB (out of bounds, not selectable) will not be selected and the array of +* selected dates passed to the selectEvent will not contain OOB dates. +* +* If all dates are OOB, the no state change will occur; beforeSelect and select events will not be fired. +* * @method select * @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). @@ -2575,26 +3030,42 @@ YAHOO.widget.Calendar.prototype.clear = function() { * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.Calendar.prototype.select = function(date) { - this.beforeSelectEvent.fire(); - var selected = this.cfg.getProperty("selected"); var aToBeSelected = this._toFieldArray(date); - for (var a=0;a 0) { + if (this.parent) { + this.parent.cfg.setProperty(cfgSelected, selected); + } else { + this.cfg.setProperty(cfgSelected, selected); + } + this.selectEvent.fire(validDates); } - this.selectEvent.fire(aToBeSelected); - return this.getSelectedDates(); }; @@ -2602,35 +3073,44 @@ YAHOO.widget.Calendar.prototype.select = function(date) { * 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. +* +* If the cell is not marked with the CSS_CELL_SELECTABLE class (as is the case by default for out of month +* or out of bounds cells), it will not be selected and in such a case beforeSelect and select events will not be fired. +* * @method selectCell * @param {Number} cellIndex The index of the cell to select in the current calendar. * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.Calendar.prototype.selectCell = function(cellIndex) { - this.beforeSelectEvent.fire(); - - var selected = this.cfg.getProperty("selected"); var cell = this.cells[cellIndex]; var cellDate = this.cellDates[cellIndex]; - var dCellDate = this._toDate(cellDate); + + var selectable = YAHOO.util.Dom.hasClass(cell, this.Style.CSS_CELL_SELECTABLE); - var selectDate = cellDate.concat(); + if (selectable) { - selected[selected.length] = selectDate; + this.beforeSelectEvent.fire(); - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); - } + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; + var selected = this.cfg.getProperty(cfgSelected); - this.renderCellStyleSelected(dCellDate,cell); + var selectDate = cellDate.concat(); - this.selectEvent.fire([selectDate]); + if (this._indexOfSelectedFieldArray(selectDate) == -1) { + selected[selected.length] = selectDate; + } + if (this.parent) { + this.parent.cfg.setProperty(cfgSelected, selected); + } else { + this.cfg.setProperty(cfgSelected, selected); + } + this.renderCellStyleSelected(dCellDate,cell); + this.selectEvent.fire([selectDate]); - this.doCellMouseOut.call(cell, null, this); + this.doCellMouseOut.call(cell, null, this); + } return this.getSelectedDates(); }; @@ -2639,6 +3119,12 @@ YAHOO.widget.Calendar.prototype.selectCell = function(cellIndex) { * 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. +* +* The method will not attempt to deselect any dates which are OOB (out of bounds, and hence not selectable) +* and the array of deselected dates passed to the deselectEvent will not contain any OOB dates. +* +* If all dates are OOB, beforeDeselect and deselect events will not be fired. +* * @method deselect * @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). @@ -2647,29 +3133,42 @@ YAHOO.widget.Calendar.prototype.selectCell = function(cellIndex) { * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.Calendar.prototype.deselect = function(date) { - this.beforeDeselectEvent.fire(); - var selected = this.cfg.getProperty("selected"); + var aToBeDeselected = this._toFieldArray(date); - var aToBeSelected = this._toFieldArray(date); + var validDates = []; + var selected = []; + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; - for (var a=0;a 0) { + if (this.parent) { + this.parent.cfg.setProperty(cfgSelected, selected); + } else { + this.cfg.setProperty(cfgSelected, selected); + } + this.deselectEvent.fire(validDates); } - this.deselectEvent.fire(aToBeSelected); - return this.getSelectedDates(); }; @@ -2677,40 +3176,49 @@ YAHOO.widget.Calendar.prototype.deselect = function(date) { * 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. +* +* If the cell is not marked with the CSS_CELL_SELECTABLE class (as is the case by default for out of month +* or out of bounds cells), the method will not attempt to deselect it and in such a case, beforeDeselect and +* deselect events will not be fired. +* * @method deselectCell * @param {Number} cellIndex The index of the cell to deselect in the current calendar. * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ -YAHOO.widget.Calendar.prototype.deselectCell = function(i) { - this.beforeDeselectEvent.fire(); +YAHOO.widget.Calendar.prototype.deselectCell = function(cellIndex) { + var cell = this.cells[cellIndex]; + var cellDate = this.cellDates[cellIndex]; + var cellDateIndex = this._indexOfSelectedFieldArray(cellDate); - var selected = this.cfg.getProperty("selected"); + var selectable = YAHOO.util.Dom.hasClass(cell, this.Style.CSS_CELL_SELECTABLE); - var cell = this.cells[i]; - var cellDate = this.cellDates[i]; - var cellDateIndex = this._indexOfSelectedFieldArray(cellDate); + if (selectable) { - var dCellDate = this._toDate(cellDate); + this.beforeDeselectEvent.fire(); - var selectDate = cellDate.concat(); + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + var selected = this.cfg.getProperty(defCfg.SELECTED.key); - if (cellDateIndex > -1) { - if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() && - this.cfg.getProperty("pagedate").getFullYear() == dCellDate.getFullYear()) { - YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED); - } + var dCellDate = this._toDate(cellDate); + var selectDate = cellDate.concat(); - selected.splice(cellDateIndex, 1); - } + if (cellDateIndex > -1) { + if (this.cfg.getProperty(defCfg.PAGEDATE.key).getMonth() == dCellDate.getMonth() && + this.cfg.getProperty(defCfg.PAGEDATE.key).getFullYear() == dCellDate.getFullYear()) { + YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED); + } + selected.splice(cellDateIndex, 1); + } + if (this.parent) { + this.parent.cfg.setProperty(defCfg.SELECTED.key, selected); + } else { + this.cfg.setProperty(defCfg.SELECTED.key, selected); + } - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); + this.deselectEvent.fire(selectDate); } - - this.deselectEvent.fire(selectDate); + return this.getSelectedDates(); }; @@ -2724,15 +3232,17 @@ YAHOO.widget.Calendar.prototype.deselectCell = function(i) { */ YAHOO.widget.Calendar.prototype.deselectAll = function() { this.beforeDeselectEvent.fire(); + + var cfgSelected = YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key; - var selected = this.cfg.getProperty("selected"); + var selected = this.cfg.getProperty(cfgSelected); var count = selected.length; var sel = selected.concat(); if (this.parent) { - this.parent.cfg.setProperty("selected", []); + this.parent.cfg.setProperty(cfgSelected, []); } else { - this.cfg.setProperty("selected", []); + this.cfg.setProperty(cfgSelected, []); } if (count > 0) { @@ -2762,9 +3272,9 @@ YAHOO.widget.Calendar.prototype._toFieldArray = function(date) { if (date instanceof Date) { returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]]; - } else if (typeof date == 'string') { + } else if (YAHOO.lang.isString(date)) { returnDate = this._parseDates(date); - } else if (date instanceof Array) { + } else if (YAHOO.lang.isArray(date)) { for (var i=0;i maxDate.getTime())); +}; + +/** + * Parses a pagedate configuration property value. The value can either be specified as a string of form "mm/yyyy" or a Date object + * and is parsed into a Date object normalized to the first day of the month. If no value is passed in, the month and year from today's date are used to create the Date object + * @method _parsePageDate + * @private + * @param {Date|String} date Pagedate value which needs to be parsed + * @return {Date} The Date object representing the pagedate + */ +YAHOO.widget.Calendar.prototype._parsePageDate = function(date) { + var parsedDate; + + var defCfg = YAHOO.widget.Calendar._DEFAULT_CONFIG; + + if (date) { + if (date instanceof Date) { + parsedDate = YAHOO.widget.DateMath.findMonthStart(date); + } else { + var month, year, aMonthYear; + aMonthYear = date.split(this.cfg.getProperty(defCfg.DATE_FIELD_DELIMITER.key)); + month = parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_MONTH_POSITION.key)-1], 10)-1; + year = parseInt(aMonthYear[this.cfg.getProperty(defCfg.MY_YEAR_POSITION.key)-1], 10); + + parsedDate = new Date(year, month, 1); + } + } else { + parsedDate = new Date(this.today.getFullYear(), this.today.getMonth(), 1); } - return isOOM; + return parsedDate; }; // END UTILITY METHODS @@ -2857,7 +3420,7 @@ YAHOO.widget.Calendar.prototype.isDateOOM = function(date) { * @deprecated Event handlers for this event should be susbcribed to beforeSelectEvent. */ YAHOO.widget.Calendar.prototype.onBeforeSelect = function() { - if (this.cfg.getProperty("MULTI_SELECT") === false) { + if (this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.MULTI_SELECT.key) === false) { if (this.parent) { this.parent.callChildFunction("clearAllBodyCellStyles", this.Style.CSS_CELL_SELECTED); this.parent.deselectAll(); @@ -3118,9 +3681,10 @@ YAHOO.widget.Calendar.prototype.clearAllBodyCellStyles = function(style) { * @param {Number} month The numeric month, from 0 (January) to 11 (December) */ YAHOO.widget.Calendar.prototype.setMonth = function(month) { - var current = this.cfg.getProperty("pagedate"); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + var current = this.cfg.getProperty(cfgPageDate); current.setMonth(parseInt(month, 10)); - this.cfg.setProperty("pagedate", current); + this.cfg.setProperty(cfgPageDate, current); }; /** @@ -3129,9 +3693,10 @@ YAHOO.widget.Calendar.prototype.setMonth = function(month) { * @param {Number} year The numeric 4-digit year */ YAHOO.widget.Calendar.prototype.setYear = function(year) { - var current = this.cfg.getProperty("pagedate"); + var cfgPageDate = YAHOO.widget.Calendar._DEFAULT_CONFIG.PAGEDATE.key; + var current = this.cfg.getProperty(cfgPageDate); current.setFullYear(parseInt(year, 10)); - this.cfg.setProperty("pagedate", current); + this.cfg.setProperty(cfgPageDate, current); }; /** @@ -3141,7 +3706,7 @@ YAHOO.widget.Calendar.prototype.setYear = function(year) { */ YAHOO.widget.Calendar.prototype.getSelectedDates = function() { var returnDates = []; - var selected = this.cfg.getProperty("selected"); + var selected = this.cfg.getProperty(YAHOO.widget.Calendar._DEFAULT_CONFIG.SELECTED.key); for (var d=0;d 0) { - this.oDomContainer.style.width = w + "px"; - } - }; - this.renderEvent.subscribe(fixWidth,this,true); + if (YAHOO.env.ua.opera){ + this.renderEvent.subscribe(this._fixWidth, this, true); } }; YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { + + var defCfg = YAHOO.widget.CalendarGroup._DEFAULT_CONFIG; + /** * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments. * @config pages * @type Number * @default 2 */ - this.cfg.addProperty("pages", { value:2, validator:this.cfg.checkNumber, handler:this.configPages } ); + this.cfg.addProperty(defCfg.PAGES.key, { value:defCfg.PAGES.value, validator:this.cfg.checkNumber, handler:this.configPages } ); /** * The month/year representing the current visible Calendar date (mm/yyyy) @@ -3343,7 +3902,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default today's date */ - this.cfg.addProperty("pagedate", { value:new Date(), handler:this.configPageDate } ); + this.cfg.addProperty(defCfg.PAGEDATE.key, { value:new Date(), handler:this.configPageDate } ); /** * The date or range of dates representing the current Calendar selection @@ -3351,7 +3910,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default [] */ - this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.SELECTED.key, { value:[], handler:this.configSelected } ); /** * The title to display above the CalendarGroup's month header @@ -3359,7 +3918,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "" */ - this.cfg.addProperty("title", { value:"", handler:this.configTitle } ); + this.cfg.addProperty(defCfg.TITLE.key, { value:defCfg.TITLE.value, handler:this.configTitle } ); /** * Whether or not a close button should be displayed for this CalendarGroup @@ -3367,15 +3926,18 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("close", { value:false, handler:this.configClose } ); + this.cfg.addProperty(defCfg.CLOSE.key, { value:defCfg.CLOSE.value, handler:this.configClose } ); /** * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below. + * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be + * enabled if required. + * * @config iframe * @type Boolean - * @default true + * @default true for IE6 and below, false for all other browsers */ - this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.IFRAME.key, { value:defCfg.IFRAME.value, handler:this.configIframe, validator:this.cfg.checkBoolean } ); /** * The minimum selectable date in the current Calendar (mm/dd/yyyy) @@ -3383,7 +3945,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default null */ - this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.MINDATE.key, { value:defCfg.MINDATE.value, handler:this.delegateConfig } ); /** * The maximum selectable date in the current Calendar (mm/dd/yyyy) @@ -3391,7 +3953,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default null */ - this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.MAXDATE.key, { value:defCfg.MAXDATE.value, handler:this.delegateConfig } ); // Options properties @@ -3401,7 +3963,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.MULTI_SELECT.key, { value:defCfg.MULTI_SELECT.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * The weekday the week begins on. Default is 0 (Sunday). @@ -3409,7 +3971,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type number * @default 0 */ - this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.START_WEEKDAY.key, { value:defCfg.START_WEEKDAY.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * True if the Calendar should show weekday labels. True by default. @@ -3417,7 +3979,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default true */ - this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEKDAYS.key, { value:defCfg.SHOW_WEEKDAYS.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should show week row headers. False by default. @@ -3425,7 +3987,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEK_HEADER.key,{ value:defCfg.SHOW_WEEK_HEADER.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should show week row footers. False by default. @@ -3433,7 +3995,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.SHOW_WEEK_FOOTER.key,{ value:defCfg.SHOW_WEEK_FOOTER.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * True if the Calendar should suppress weeks that are not a part of the current month. False by default. @@ -3441,23 +4003,25 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Boolean * @default false */ - this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty(defCfg.HIDE_BLANK_WEEKS.key,{ value:defCfg.HIDE_BLANK_WEEKS.value, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); /** * The image that should be used for the left navigation arrow. * @config NAV_ARROW_LEFT * @type String - * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif" + * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" + * @default null */ - this.cfg.addProperty("NAV_ARROW_LEFT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/callt.gif", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.NAV_ARROW_LEFT.key, { value:defCfg.NAV_ARROW_LEFT.value, handler:this.delegateConfig } ); /** - * The image that should be used for the left navigation arrow. + * The image that should be used for the right navigation arrow. * @config NAV_ARROW_RIGHT * @type String - * @default YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif" + * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" + * @default null */ - this.cfg.addProperty("NAV_ARROW_RIGHT", { value:YAHOO.widget.Calendar.IMG_ROOT + "us/tr/calrt.gif", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.NAV_ARROW_RIGHT.key, { value:defCfg.NAV_ARROW_RIGHT.value, handler:this.delegateConfig } ); // Locale properties @@ -3467,7 +4031,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] */ - this.cfg.addProperty("MONTHS_SHORT", { value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.MONTHS_SHORT.key, { value:defCfg.MONTHS_SHORT.value, handler:this.delegateConfig } ); /** * The long month labels for the current locale. @@ -3475,7 +4039,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" */ - this.cfg.addProperty("MONTHS_LONG", { value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.MONTHS_LONG.key, { value:defCfg.MONTHS_LONG.value, handler:this.delegateConfig } ); /** * The 1-character weekday labels for the current locale. @@ -3483,7 +4047,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["S", "M", "T", "W", "T", "F", "S"] */ - this.cfg.addProperty("WEEKDAYS_1CHAR", { value:["S", "M", "T", "W", "T", "F", "S"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.WEEKDAYS_1CHAR.key, { value:defCfg.WEEKDAYS_1CHAR.value, handler:this.delegateConfig } ); /** * The short weekday labels for the current locale. @@ -3491,7 +4055,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] */ - this.cfg.addProperty("WEEKDAYS_SHORT", { value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.WEEKDAYS_SHORT.key, { value:defCfg.WEEKDAYS_SHORT.value, handler:this.delegateConfig } ); /** * The medium weekday labels for the current locale. @@ -3499,7 +4063,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] */ - this.cfg.addProperty("WEEKDAYS_MEDIUM", { value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.WEEKDAYS_MEDIUM.key, { value:defCfg.WEEKDAYS_MEDIUM.value, handler:this.delegateConfig } ); /** * The long weekday labels for the current locale. @@ -3507,7 +4071,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String[] * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] */ - this.cfg.addProperty("WEEKDAYS_LONG", { value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.WEEKDAYS_LONG.key, { value:defCfg.WEEKDAYS_LONG.value, handler:this.delegateConfig } ); /** * The setting that determines which length of month labels should be used. Possible values are "short" and "long". @@ -3515,7 +4079,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "long" */ - this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.LOCALE_MONTHS.key, { value:defCfg.LOCALE_MONTHS.value, handler:this.delegateConfig } ); /** * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". @@ -3523,7 +4087,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "short" */ - this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.LOCALE_WEEKDAYS.key, { value:defCfg.LOCALE_WEEKDAYS.value, handler:this.delegateConfig } ); /** * The value used to delimit individual dates in a date string passed to various Calendar functions. @@ -3531,7 +4095,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "," */ - this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.DATE_DELIMITER.key, { value:defCfg.DATE_DELIMITER.value, handler:this.delegateConfig } ); /** * The value used to delimit date fields in a date string passed to various Calendar functions. @@ -3539,7 +4103,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "/" */ - this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.DATE_FIELD_DELIMITER.key,{ value:defCfg.DATE_FIELD_DELIMITER.value, handler:this.delegateConfig } ); /** * The value used to delimit date ranges in a date string passed to various Calendar functions. @@ -3547,7 +4111,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type String * @default "-" */ - this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } ); + this.cfg.addProperty(defCfg.DATE_RANGE_DELIMITER.key,{ value:defCfg.DATE_RANGE_DELIMITER.value, handler:this.delegateConfig } ); /** * The position of the month in a month/year date string @@ -3555,7 +4119,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MY_MONTH_POSITION.key, { value:defCfg.MY_MONTH_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/year date string @@ -3563,7 +4127,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MY_YEAR_POSITION.key, { value:defCfg.MY_YEAR_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day date string @@ -3571,7 +4135,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MD_MONTH_POSITION.key, { value:defCfg.MD_MONTH_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/year date string @@ -3579,7 +4143,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MD_DAY_POSITION.key, { value:defCfg.MD_DAY_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the month in a month/day/year date string @@ -3587,7 +4151,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 1 */ - this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_MONTH_POSITION.key, { value:defCfg.MDY_MONTH_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the day in a month/day/year date string @@ -3595,7 +4159,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 2 */ - this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_DAY_POSITION.key, { value:defCfg.MDY_DAY_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); /** * The position of the year in a month/day/year date string @@ -3603,8 +4167,39 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { * @type Number * @default 3 */ - this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + this.cfg.addProperty(defCfg.MDY_YEAR_POSITION.key, { value:defCfg.MDY_YEAR_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + + /** + * The position of the month in the month year label string used as the Calendar header + * @config MY_LABEL_MONTH_POSITION + * @type Number + * @default 1 + */ + this.cfg.addProperty(defCfg.MY_LABEL_MONTH_POSITION.key, { value:defCfg.MY_LABEL_MONTH_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + /** + * The position of the year in the month year label string used as the Calendar header + * @config MY_LABEL_YEAR_POSITION + * @type Number + * @default 2 + */ + this.cfg.addProperty(defCfg.MY_LABEL_YEAR_POSITION.key, { value:defCfg.MY_LABEL_YEAR_POSITION.value, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); + + /** + * The suffix used after the month when rendering the Calendar header + * @config MY_LABEL_MONTH_SUFFIX + * @type String + * @default " " + */ + this.cfg.addProperty(defCfg.MY_LABEL_MONTH_SUFFIX.key, { value:defCfg.MY_LABEL_MONTH_SUFFIX.value, handler:this.delegateConfig } ); + + /** + * The suffix used after the year when rendering the Calendar header + * @config MY_LABEL_YEAR_SUFFIX + * @type String + * @default "" + */ + this.cfg.addProperty(defCfg.MY_LABEL_YEAR_SUFFIX.key, { value:defCfg.MY_LABEL_YEAR_SUFFIX.value, handler:this.delegateConfig } ); }; /** @@ -3613,6 +4208,7 @@ YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { */ YAHOO.widget.CalendarGroup.prototype.initEvents = function() { var me = this; + var strEvent = "Event"; /** * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents @@ -3625,7 +4221,7 @@ YAHOO.widget.CalendarGroup.prototype.initEvents = function() { var sub = function(fn, obj, bOverride) { for (var p=0;p 0) ? this.pages[0].cfg.getProperty(cfgSelected) : []; + this.cfg.setProperty(cfgSelected, selected, true); +}; + + /** * Delegates a configuration property to the CustomEvents associated with the CalendarGroup's children * @method delegateConfig @@ -3794,7 +4424,7 @@ YAHOO.widget.CalendarGroup.prototype.delegateConfig = function(type, args, obj) * @param {Function} fn The function to apply to each Calendar page object */ YAHOO.widget.CalendarGroup.prototype.setChildFunction = function(fnName, fn) { - var pageCount = this.cfg.getProperty("pages"); + var pageCount = this.cfg.getProperty(YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGES.key); for (var p=0;p0) { year+=1; @@ -3906,11 +4548,14 @@ YAHOO.widget.CalendarGroup.prototype.select = function(date) { }; /** -* 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. +* Selects dates in the CalendarGroup based on the cell index provided. This method is used to select cells without having to do a full render. The selected style is applied to the cells directly. +* The value of the MULTI_SELECT Configuration attribute will determine the set of dates which get selected. +*
    +*
  • If MULTI_SELECT is false, selectCell will select the cell at the specified index for only the last displayed Calendar page.
  • +*
  • If MULTI_SELECT is true, selectCell will select the cell at the specified index, on each displayed Calendar page.
  • +*
* @method selectCell -* @param {Number} cellIndex The index of the cell to select in the current calendar. +* @param {Number} cellIndex The index of the cell to be selected. * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.CalendarGroup.prototype.selectCell = function(cellIndex) { @@ -3957,11 +4602,11 @@ YAHOO.widget.CalendarGroup.prototype.deselectAll = function() { }; /** -* 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. +* Deselects dates in the CalendarGroup based on the cell index provided. This method is used to select cells without having to do a full render. The selected style is applied to the cells directly. +* deselectCell will deselect the cell at the specified index on each displayed Calendar page. +* * @method deselectCell -* @param {Number} cellIndex The index of the cell to deselect in the current calendar. +* @param {Number} cellIndex The index of the cell to deselect. * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. */ YAHOO.widget.CalendarGroup.prototype.deselectCell = function(cellIndex) { @@ -4048,8 +4693,7 @@ YAHOO.widget.CalendarGroup.prototype.previousYear = function() { */ YAHOO.widget.CalendarGroup.prototype.getSelectedDates = function() { var returnDates = []; - var selected = this.cfg.getProperty("selected"); - + var selected = this.cfg.getProperty(YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.SELECTED.key); for (var d=0;d 11)) { + var DM = YAHOO.widget.DateMath; + var newDate = DM.add(date, DM.MONTH, iMonth-date.getMonth()); + date.setTime(newDate.getTime()); + } else { + date.setMonth(iMonth); + } +}; + +/** + * Fixes the width of the CalendarGroup container element, to account for miswrapped floats + * @method _fixWidth + * @private + */ +YAHOO.widget.CalendarGroup.prototype._fixWidth = function() { + var startW = this.oDomContainer.offsetWidth; + var w = 0; + for (var p=0;p 0) { + this.oDomContainer.style.width = w + "px"; + } +}; + + /** * CSS class representing the container for the calendar * @property YAHOO.widget.CalendarGroup.CSS_CONTAINER @@ -4190,11 +4882,13 @@ YAHOO.widget.CalendarGroup.CSS_2UPTITLE = "title"; * @property YAHOO.widget.CalendarGroup.CSS_2UPCLOSE * @static * @final +* @deprecated Along with Calendar.IMG_ROOT and NAV_ARROW_LEFT, NAV_ARROW_RIGHT configuration properties. +* Calendar's Style.CSS_CLOSE property now represents the CSS class used to render the close icon * @type String */ YAHOO.widget.CalendarGroup.CSS_2UPCLOSE = "close-icon"; -YAHOO.augment(YAHOO.widget.CalendarGroup, YAHOO.widget.Calendar, "buildDayLabel", +YAHOO.lang.augmentProto(YAHOO.widget.CalendarGroup, YAHOO.widget.Calendar, "buildDayLabel", "buildMonthLabel", "renderOutOfBoundsDate", "renderRowHeader", @@ -4212,10 +4906,21 @@ YAHOO.augment(YAHOO.widget.CalendarGroup, YAHOO.widget.Calendar, "buildDayLabel" "initStyles", "configTitle", "configClose", + "configIframe", "hide", - "show", "browser"); +/** +* The set of default Config property keys and values for the CalendarGroup +* @property YAHOO.widget.CalendarGroup._DEFAULT_CONFIG +* @final +* @static +* @private +* @type Object +*/ +YAHOO.widget.CalendarGroup._DEFAULT_CONFIG = YAHOO.widget.Calendar._DEFAULT_CONFIG; +YAHOO.widget.CalendarGroup._DEFAULT_CONFIG.PAGES = {key:"pages", value:2}; + /** * Returns a string representation of the object. * @method toString @@ -4241,4 +4946,6 @@ YAHOO.extend(YAHOO.widget.Calendar2up, YAHOO.widget.CalendarGroup); /** * @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default. */ -YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up; \ No newline at end of file +YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up; + +YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/colorpicker/README b/lib/yui/colorpicker/README new file mode 100755 index 0000000000..330b53182b --- /dev/null +++ b/lib/yui/colorpicker/README @@ -0,0 +1,4 @@ +ColorPicker - Release Notes + +2.3.0 + * Initial release diff --git a/lib/yui/colorpicker/assets/colorpicker_core.css b/lib/yui/colorpicker/assets/colorpicker_core.css new file mode 100755 index 0000000000..5aa3015efe --- /dev/null +++ b/lib/yui/colorpicker/assets/colorpicker_core.css @@ -0,0 +1,6 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ diff --git a/lib/yui/colorpicker/assets/hue_thumb.png b/lib/yui/colorpicker/assets/hue_thumb.png new file mode 100755 index 0000000000000000000000000000000000000000..14d5db4862403a43231ac4766301552afa79e8ae GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+3?vf;>QaFeOS+@4BLl;=8&~`zjDUQ}64!{5 z;QX|b^2DN42FH~Aq*MjZ+{E`+k2Qi@7Ao zFBm9x{S+_IKn6ok7srr_TS*Cr74CR#a^B hhMOMV_Dn1i4C!Z>gq7E&G66L+c)I$ztaD0e0ssu{I5q$P literal 0 HcmV?d00001 diff --git a/lib/yui/colorpicker/assets/picker_mask.png b/lib/yui/colorpicker/assets/picker_mask.png new file mode 100755 index 0000000000000000000000000000000000000000..f8d91932b376af76ccfac030c12eb9fec7ee4c63 GIT binary patch literal 12174 zcmV;9FLBU`P)_6|b&%Dfjpyv}j54LBIXFZqhE-_t{2r7|?ya1%Cs>h{sswI&ir4|Fh z$jAgxe*E!Arq9Rc<1hC3+xpMn|Ni&&sREphKX2dqw+!rCg4fvHA{v>|sAOH9VUq1Wx=i{&V_yqRn;}h7QkI%<-7fW_4(VkZ}j!+ z*W3A4Q2+7AAN1S*{zm`&=RfJ^|M;1H`st@nDf0RFlp-IAiA&;HZ{w3b`^>wEDMb|H zcWo7$YKZ}V2ee&$PJPY#JEPa?S+a1^5~E@1g&W3xW#A&D$3t?w{=G7DSsA*r_4-%Y z`s|z_E&o@}NSYWQ_Q@Xg&3d|Ou zW&0J1V(Gn21@Ok$tl7ApUjkd|>Gf{~b_Mkc=*rd-*uVe&`%Pc}`s=SZK(DV?u$Q+4 zw*GP77{rl7z$bi8N=|4%dgnzQK{K@X9=v7^ctch^o|!a57b!8M)R5bd+^DZB*f)2h zXi(pP{pA7dU4m@DUcq}~?BDNws-MON*}ARvB9}^yYkUl^^T(x&iy;x&pXVP)oMH zG4>x1DYCNm`n+yi_f;$KX~32?&=bL&3KR!`?Ad)hXq&kbL*FF~DPi6Lgmfs6L(D+0 zND0vbo2}RNnI*FeDS>21aabAxyE61@^}W7lp{p^l|7WGkjF52;svSZcA8su7jAYiZ3LweO3*sn5! zSD>!n=?3mEUmKmhK6d%BxhCszn^Za-*h3D(8SY6kiNgaaXQX90(eY3K$c_zH0Bie! zBHJ2UyB-p(7Bef5YbLIag?2iM6)3&}lecGR>8-$C0bN;o1$K2uG_Y5@@20Q6ep|mt z*;#x0tH7=ryq?1awzczFEUg2jL1spUI~;shFFVJMWT3#Y2!p-uSjIu7V%f`fjs-Ap z^O>)I7X@&(g2WB97X@e*&x;21dj4(4t<5d)+aC4x2CzHGU+%zOzu(5F>;Cn4UV*tj zZ$V@8yjpp$fL&R8ZO0o+m)B>04HkLJJo2A^{CRu7ZvXb}emug@Fk>GfXvJPL@_-^q z01_^oksZ=)$m(QUUX;~R(;!CYEsBZDLoIZEb1~!wBOR^fg#bCy%lortW+6TF_FY@w z&6w46@B~bZ!ZnoFU!@$z>E}`k{^oUMnFB{O&3px81f^O z51QS()3a{J?CEH!+pUC&YHNa5>Eykw2XY`qJYY8f?~*Z#9Wbu!EB)#UYzgYy^IbES z3h4T`vT|kq^`Z574Oq_r_AIDJ0c{44L7>OU1PLbsz#Hu@vK`wj512a*;t0UHoeBa? zk6L-sMY|p{s1$`s7O*7~*BX(c{b~v9`g)Thw{{({Us@kq|5b2nV9S~lBm$l;MJBR- zSsN}46ctdtgi9+$xa(0`+j0;b5@@3(htB#Thl4>@u&CE;xE$KTV_CN$*;#_wksf7p zH>9;!8MRBwYyjM)2y#PKP>c6P+kZ7HSsw`0kDr;x8GBY&%c%cEP&e$K0;+W$c6Ga3 z-f4l|(a#9Tgjm>eL6n{@$mNioz>^;m>!~orEy~tWx3~ zOIPqpfCGkR(H?r%tE(Zjv@CMcj9p#<%|dfa05{ue+I>B?x*{YBs9Lr@sIdpzjet7C z(j3YXHqYbA7G>{gy$rQE(#f8iq4wzn3QC-$G_@y1j3806bjQvT*z2!Z!CPeq$}$Qt zKiFGHksaJG`+EfLE_ox5tq+;W^uV3*u}1^OjK^IhVL9wdjz0DhDyAkTJeq`!B#Pcg zhP)_7_7G+P^?uQ&deV!Q8k_%Iz3u(DO+Od8Pl9$mZo9rWlUfCjjYrK(<6~b$ZT0S1 zS3O;Ux%tu+)a&a-3?R6yAif2U*Sn8h->)oR%UIXfo6X1d@8#Re{rTQ*_p!In<@$MS zi0rd9cH9YgPHQJ6i50k+-%kgas7Aw(CeRhp9mnRTLOFML>EN7Z(g?zUW!g!Hg9HcE;V1EAh^ef|OhyG~Aswq6=s?q4)8Rd863y;SWj zSY7I8OIMc~2-fXFMwH5^wNOOZdAr8m>OGbX*q5qptG2GXdan<;-u3UQn|Fkfk?i04PcV*!JYNDjCSSa=A`)xBsyFVf!o zcEj3Z$<&e+vLHr0ak9iY3#aPde)nR zA-C1eupV=%_1K$crutm{Xra05zTK<7Zd!fooV!f@ zjN&Brbhe|X^)|DOW?&^TSXpb-J8|rPncYZ6g>MN)cr9$&910<@S`i zkQl{aQy;-2thth!_d8NT%MNOLaRo zCuFG|O0cz;&U9i--BvN-HZ`yK2WHwUjV^zvpBugv*x@U8x z({-K67HqPx8;i~;!e{od_khhIU{6k}7aYNF7KD;K_3|HlOG;X68|WyQts~R_Ey{93p$q#vLD)BBQJf!DrZ2nhQiG*TS=m|!i=sNPks~sAWNwo((+QeE z#&&JLOxr|mJq#Wvwe^U!h^q1|mxGNOYb!WJG9t^^ z7DMZKI!Lj#PN|b)?X9WqMFoppm0nG~SG!I#I0zVZ`DqtCYId&sD^t_0?Sst)+mcAN zUvx@c>}O&7-Gj-m-xe7Z%Keh9Wq_!IMZnTSjO}I%4>EJ4jWgw@5p#Q)LYiP`6fiQd z^$Ve27n-UX6~u~jBf+k#TtGMMS9dA;lIYZHi)4l30jO7QF&T(%QhouWT^ zynfVSX2S`ZnZPko&ykt#z}4MKa~F_k(OQ~~0%y}dDP!_F!}v#hlq(gM^>trIkoxdHpiniE-2)#zvMuOXYZ z@JTauPGdhoUrzx&2nsFzYz-P9uOq1X=#HU5Icmr1+m7`=TI)3+i)$@z)KfDUFrb|e zMgs?s-Dk1u&Z5gh$7`mpZ50a_t)I09Z_Y2;>j48bSd6fih|8uJJL^RwJv?I9MOj1S zdLU4vQqm5rNLt8_pn<5I7Sa+!IUbUAt>rFsNh$%|eUVd;2@Sq8wo0jAKq5vm`3kt3 z=3N~Rsk>_m9Wl3@TSRJXnS>Dm>Ye59TAeks*WX>pFw%@&JCaPu7;eaM#?H163Yxqm ziO1X{Y;1uY1)XquF~r!S{e#6HD+K5cU}@)0U+V%VRlwA-9$@K^y(J@8pB$}LpzaKz z#@63&zauQRhE`R26msV$Z^{OZT{Yqz~|MKp5@rfxL0c0%O-=ufe>>^uw{kcP3JqOoTg z+bjHcEIkgV+Xd`yFtrAF15DLXpaVjTJA-wc7@{Rz2CcE1z_Vdg<2a#%A@fTHRary$ zx^qPy{_{TkOX+1&?B6kR^}s#nLpfB<^+cJ+!)2=@cHV%N&a^i{jchr@!b(pU4J^^d zO17|ADFAxZ`eGm^1_e)qtT@Ery0EFfmaLv(=|+cN8%Rh$tyRdxLGaieqrB*@ zL#S!P*wWof-%8)Qb4e_g_L$k4z#SDq0S(+`G&PH>PTX|r+7{K~Ti3eID{{XsPtw=} z0bxo@dr1_)!UUvA#=f(B>9TP$k}MsN5fF`Yl1{Sda#ZD%T;wD_* zrR(uRL+ilL+JnOY9wm9-+$udbbEn?0(LOj>$r_hai=7gPtL*qQi|ZPXQR$29gp zkeHn=VZ^I8vx(Xr3C^*P2@HVj>StOa=0bwJ{*liQX>WaLOu?0&v$0Jsj zZGj8Z3^mjKv_3!Zt()Tzw)7pqx@$jMW2a1WYelRebzTA;ZOaH?FNSYztt>#^x{9&}1iB)CrBSv~c-4}XJO4VNu`kuHu8xMR`H+r@WMy3&f@(oD zV-IQUBfyT>ItFjOyTqV&0>y3{a4&QaiC7u|8A%bSB@^2+!6JcGyO0!VK!4kJZHk>1 znNk-3?ybKKaCMsmp|tx{qUMoqf7#pY9YA&lk%ZZwrPU|5J9327sG0NZzDc%Dr%025 zqCIwz@d$Rqv$k9j0=G{sMPM7F99180rOMfIOX{5lSZj~hBGDq+p)@>{DBd>D(nB2@ zz1GjEM9YEo=n!M0*-1Ij*Dw%_*w@JncJ0>&i~KC^eP`rF2U)|W{@J)VA!A!|1Qar* z*jjIw0i|Z_ef0$;GbCeMEUibRZ?mK78J{kaZ6ym=Hg~jl6AQ>=HEZjAwYpG94|(1j zW6N|q-Bz=DfN-cDdxU)xSwru&TsGqlj#fXTK+$96&LKfghSJ8J%i;Ld466Ic7^EwK zuHB7AWfjo^qGj`m7f~6w&sVL%jGPcDOR5_pYDq3q8i?$oc2L&4#06v<775i>3x}i}tq++VK{F93+C@%G zValBBMTkrmmI0*)W{`~}Bamck?hjo=AIT2H;zr=Ov-i5ctc-b|dO^D>y);olB4TMB zC|XiP28;VR$Cqm(8I)rp>kC5c^snH_B6o0E;XOGDq4mJAaYlw*nfA;o{!0X+V9n+`Q=20nuSDlk0 zdgAwJ=+@w{od%FmxoH4qYj6Ry<_6@487vZ>V-HCY_L4Ek;gHVAHhozyMcV2<0vW}W z{7{x50y!yd{Q&F2azst1q4hSTulr-+Tp`h%A*?MwAJ_+zEJ?ObOB4spn(@)R)X>2& zf=kQ!usm=ppk%N<3>mc_`qq7y4os*fgh3{fE%yV-ALNecQ9724spY3iR-n%;mLmd6 zE873Ja6=*qeEPg1Cyb7X=BtLlGg9Z#Gl5!Z*j^VXfzjv;q(@hx2?D~5Jdw7U_P2|X zXdzX>N67uq%&cTd!^|?#(m5pyv#$2jQbRr?MwiJL*{)@0>KMC94OKA3K#t72B8eGQ zho%5VV9w47VpMu*-A$wNL!A%GiU-iw7fW|M05Jh}mf1p5fbI&HM3Gac!nzy#;7ldzS7-AeZ2l+khNtzzZzBJg{dp zb~=mbyw7Y0_M9bK!fawT={_?Rk|qSC2C5A~wb;**BF6L!W`$oc0wS#Y$YvKE zd17j5OQIOlnsscaN0*DLL$AtD>*~b_1WCz@B5FbwppQe4OMr?AbDH21$qb#P1Oo$h z`Jrt*5Px-YLqh0lp~&%y-E2wy05*1A5Qnk%VHvfhCyH zC=hpY#SvhGb9KOVK)%&Y^RnGaB(p=7)*V4_v-Gn7YcXoCFRC_(RZ!S6b8Cfqwbxbv zIj6A?%91d9Xt1|+Of}XTw3;!B44<0% znWwtB|2&P4+P1NSp^2?K9QLkzeJ!ClT9SHNtqA8<27~p{mMh}O4{Na_#LV9CBRDWv z0#Jih47q~#9>@&J3tPNlQHDPawRfPgO~%%`y0s}74Z!7ym6a4BPiw1+ygEt-x+0)F zb#IHD5sR_Ifd)sVNL0&_vGT}Xc+?%csAYn*+Q^s#o56yZ9IR5MSuC&vo8!1&Bi#ab zqlFVvgjB+%|65pFi}1B2Pjo6A6*5T>N(ltKX>(B|m0NHnM|lj~Jr~#sRwic^FJ1-T`NnK`Sm1G_Iw#v}#|WQK-WlSrb8+AYnEC!}nrHzOofG;mq1M+5E# zF0gem)7`OLLSQ3s1BPWaokAx|WSl1)5O_Z6ba(|#QZlH~GNb{nI{^wDZ8k5vpDICX zWG18F@zH)Vr5-va5qopI{6+-mtjzF^x9ma0=x8jY25H&De=xXL-ukp$GA4EJ?nEl- zQ?{Ut(U?OkHjw~DK_d!wv%y_+E+_VTv|H%tHi!TN=lLhqd)(n^$wIw5XbX}6n z`wVcC!1m9<6ftn4w>5(+5MMNCf!6LiiE4Whw^Y6wQ<}v(+fAE42iREv2fEtS=E3Z# z5uh!P+mj_oiZsVqH6tECPhe|8cAs!~*a#jwEAVkGN;B?DgH?WY8pQ;Rv=0J-zk#a?d`U!O06|i&_pC0~% zs`H#tCai{-F-YNecP#Zgvjn-m4!WXHOEei+>hHL2yn0o89qjDD)2se_dhnP@n|qag zq7K&uG4;zpyE+``=ZwZifMAQ|GqM9DW;}m7&*Dql$%OnMBsqMELWGhrj(%q3(o|;F zm3fVvSr`q@)mGl(=b*|dsgt6oOp6bR~u`cPXan(Y?Gyewo|O!dC`^>(LOeEI&2wo%g8#w=7X*X=dws6C9Z=RM)P&R>XeWcW*}*S9|dBO z#E4vw6hn)0PQ$k*rB~U=N_Ki%gBgJqonHde7}bdbG3X-bM%8BGh!5%`glVkCChN}~g3BW$M}kFK2>ONsVtFvIPh8-j|! zP`X_o->~@7R1I1~_EP)g01;!(lkT_dq{zVuDO3BhOrBuw4xoebW0}oV0S%e1I!G@ zS(<=GAhvWhk}V>&+|*Y)b=L0-?9AW-BY4bAxj;rqE3At~Ky}WW0=SHa2iUo(K{h79 zoT?DC0FAa;NfwZ-@hm`!>^_u$QRi@h3rq?mNydOZGE=G{H&Tn{xCKvROl{R@LvI^( zB**_YItF)xh#kMXDH{M%hCO)$0MF=nR&EvuhTU2bMl1Q!wJQMKqreW=pfU8fHKC=;%8?Wy zW7a2QbPj5(!NIjz>u$oivp7#D1d0NoTZEjF9$;1MK(IMCCG zx#4mA491Rzkwx{-qhlU*CEw$JHpIZDM;^H+`-KBjpLq;>6vPe?U29I&lkB=&7dC0T zkL-zu_B9&G9&wIzIR`R>lTzb(!J|=U9R-`&X&KV;#bWceXp7Ay_biXxa!>Y)!Gw|^ zRzPXZRpL4+;23w5y4e9ilxJLLJ(vJZZMK~=hmp~M@T|Zw#n?zU2c03D=h^@)oM4jt zsnM*VVdlh?mfl95dUI}PN`okEK2kL0v3MjOvN9u+K?D|Fd;ZM@K@!6VE-4WpdRjVS z`e9&)&ImiJgbn!Hp)7H-n8gVs%>dH{es0F7IG{|}g8|!fpqD#of!gVkQq&1hX3_GZ z_3_C-5c<`Ii&6%I$Pr){sa-I;}6YGm*O`nF^QD6H`R=aiQ0s=u4 zTza2}Kqg;X`>lWu)lt7?a43FWI*YMWGq5^yjaX|lW+X^@MFS{LxLd9dEvFY2K>Mgp?OA;_w>u?86cFL0 zl^u|i`zRqxP>`3><7&bkb1pweD>LXk79h=KJ3K9)2o~)&cO%)=1g}F zezt&oXXmE4tL+eryM}%D`&caP0o?<5GC3n&x1^uY*oC}O)4&Ny&lDB0x4RvToOh&) zr$x!r&{le0YierKcvjGr`MhwQN2@c|(vL0gU66c2WH&Pd(};GS(b>6m9(kOx2U$5v z@|0jSjm6$YCkMz`nb*JIW&u`KPe-hr@wz*AM^1+0bSRGYKYlwV;Do^T4dXIFHa6J1 z)5oZS&(qlha)lDCehAo6iE0Y?R>0YuTY#ACrKQ=>*;xRyl>~C^y1g2X{k0@ro$W{? zwvM-s$pDz_i65J#OcG%Bz!;8vLC%YD?so%r2z*0VV~N1-I_u_z2H-X|cn0LCMglSM zk_53Mlgw>~!{KUf$8{>kWIt>;QEu|Y(%7QI@3#!A20N#nd+-LJ&->U1fju>|lm~u` zMVtiAa2v1VIPJr2mhANV{@gxO%YTY*rpumms_z`G6*Nz z@vOfDix06fV0>$B$utX(vNk(w-AuBv%gzxK2aX60xFRL6_ufZ}bZ!6>Cu>P8z_~%E zH<=FdoV||Vfm~{K063R%M}Vz=BS&@=XYTJbm>oS$PO`<-#+Jr*?hJ)Bt`PObM)kSZ8H|g?k<=*@;I^`DUND+wP){p6|2G-|G5*}WiV*^B=KId- z;G@Tf8k-jmEBQtPM31$T_1&(cVlBrp3fd&t$w|wntNq&V-IN5&It_E4@Imd|Kl?!< zfuUTc3zAHObCRvo`Z^&~rld%Ai4Mrxfz*f=J2kV1&iOMk#tIN2lVtAiQla>BXSp(9++bG|?7bP^y}FKW_JBeC3hEjw3ZfkQ=ooGj?Ibj8S#saVB*- z(a3wWYzYE&Mi#gdr2U=EcHfQNhXCmfHXuAzgA3lI-REUKqmoum9Ai$?F!CHEmD0~z zqF9XWl^>uxWn#1olpsOM+>$6(x}0oQrzmhdPl^o4kuac)((nmM5;-1}WlGssZT7om z&`$%t(;*_@Mk^abP-k3?V4{ACM!F=WN2VN=j44B&BSj(rM^iD32B1+VaO%L_i|*Y4 zY*t?&sLqff4*OA7!ZgPku1D6@utwCJ{WyPAO_H%kf$k=8h&W*C==PQYs~c!Wj2#U! zFn*)-F|TRRDm+6Dq3p;2+49V@!K-(?{xPPPoF1to z$x0H=yC}mJp~L3**vIz?8MOj$Qro8;i>#|LTTB(5kG`YF^a7^fmu>C|j@F))CsXdp z2*c0Hi~~%Z-PZrVI2D6HRvrQW5r+0;$An*<4jfMfb~Hxr6qu(0VIU{6XB%fdUt+7GKM$ZQ7d z+*G-q^3AhAkG6UGeKe43wk=Z~@{qi^8g4~a7kh3;^x0=fpYx@Ed05BU<|1?Y@y9GNH9cw6|*ydMtC~bu#Ur zW^%V9`U#e%tuqzfu>F?#-9|w@YT*rZk~0~*#cRn2ktxkSAW3Ed%?xnei<~%b>YUvy zQB0iuZb_Yd#{V~D+^D7_lR5mbj7|2~MWfx0!AN^YIy$^?2|Zp0fzVvE@~A_$*cnVA zMw#g)ypCq2vdiFXhx6E0)LqSNUxhI zVW-W=i}3ha-8{;~vjY#ZReptXbC!%U_7TS<<#h*49XcddFz8&+VQpzLHIvtFG}ukc ztmOZTJf~!aiH*rPc@pR;9nD7=JCGdVDq<116>`I1b5xT@tC-Dp5?2cO>`Zi$Oc?Cc z(=Nq~W}cBGvz~W!9>~};tnKM?az?r*E|O;jW_03+7UVQwICongNlHz~C-}PvCLZYw zR_qcowKa`$hP?y!^;8FkQe+UQgE~86O1M%&)(VWI%!rlfG4Y`wbreh^=ZP%0M8brg z;dU5oO-Jt}hg^{e*c8v~l#?WMUt?_~z?@+B^hF06nQ2~sj#!{Wam0bn8hwA4g(GPp zre)|l%aSOn8U*|Kj6IRW895IgvD0rHxqx+pbT_1PaWqhU>-R^eY8dPASqqQe_aWKy zbYM@gdG;KmUU;{SlVCmuzzWeg767aWXd_QWP{P+&9)h)*5Dlk z!wjP}|BcZa_lfvoG{C0G|7UodwcV@AJHfqqjue^oy9ceoY@nI}^Q?wH6;v~TLW`Kr zXy79tKO?#FmJgG$lhVOuZE*2ZjE(?$gwY2R3`cIyVJA+KNNfEK$gcDqZHkf0VMdOe zm>Iv^1hyK8I~oYO9l-Us@yB|M4gsFj<5}h%0zYagcd)ZD(q&^V&IE^>F~$_5al^!k4%1 zJn&9?;+~W-ewCt^;T`NeM?jwi+M(lXmEnk#nsGM*Cu2AujAFmD9g=3^cRpazg{)2P zn8^slCiA+?NR(!+NuZ1{S-MkuZF%6gv9{}!d*XLgzfH?4N!?6zAmK9F0seNx-8fs1 zXDviP*JZL(3;|+<;j`Pb3|s~}q7~H5vaL6j*f~=voG(jG12zp0Lhxjb*#NQD5r-zc z8>nBrJig*G4d%vKNVex5w1@9RM?K}U<_D?ky?<0-r@?(R`7p`ot`?H2s#>^rZ4^=FlN|z7;uANn-1>IN}N2Cr3Zk`BP^T*Bp+h=GXQ?n zq4@~xH~`i&0DT(!&VYJ`-9wFiKyS}TnG}0}0I747b%*zVRH^Xn>CK)NJe~mTrv#t_ zcabwXLIlFM0P-}L$AMa&#=dX$_}d`x3eTZ?RLY=?o8@$7*!k>srvp9PW)jSU?U;_9 z^Qe?K+IdESZGby%u+M1qd$#NeEItDAvw?m9$ftmLQX9{>7*l{gdPf)rHlFHin8at8 zf231nfja`;X`qjQ{TPtT2$-J+=#L;%GCuZM%zFe-GoTq|EqXG0J-rjFA!)YD@D%G+(%jVtWGl1QAU{d2%u&<<*Zbo86f4@e+txxnf@rS&tmU0L4FkI zvtVzu0H1hQIRnIJ0C_feJe#F6_kc5iO=q3M`0__VKFhGvjLYYO_Y5XJ1jJ{7c^Yep zHW&J!52nA`qtNH$?S3o4*oSLk&tTSPNrW?X?<5;9naK^$U}fVxx$Ap|$u2f@bg3gWkxHK%Fp4+8RMf$}i0&g=*$e&(C#qxaD0ZvpHl zv+I6`Mm!BUmxWOUFGBaUp^pXA9e5eL-vl3cNcl?@AS6vgTG5D@?CMq zTi=Sx2mN33JO2+a9~-FUJu&myl|RHap8Fr(82g7GfB2M~pO3%PF!NeM|wNi2*CXBkqA8W@y2&T>3yVv%g*IK)!uk)}MmImzx& dTmu6$gLVMJ@>Lg{{{wY0c)I$ztaD0e0szdFIV6h6*nD|EKy_G>T#efd;-TcIEZRG=3KG$^eF2Q{FAMV4*KY}f{qh`QSV zerz}DmTbC_Y|fEr#w0P0=t#CW_qsTZ+oCcxM!nmzgkYx0y)F9Qv+IxZJb6w|&dGC5 zaz;Z<^@~z7QUPF5prJObvq_J$hJ`xXo5wcl^n8zhtsmg}%|C)|K3%8x)wT6C_ipWb zw=>oa{%CJkw=1x%v!^@U-5DL&ajAP1z;mggH7#{nz-rJ$faL=7qA45La$rShQh@N! zu%sTCvXE1t{K=eCf%*<$g}~m_lTbYf%#DuhOcn)}oyL+UY!^T)N0SIlg&q}p70^Bg z#v`A*ftBD@6%H#L*N*0!pas#aR&fdVH33r!@M?%V4H}RB^=Q5i+Cy}fVbYD}B4EjH z?P{0x>Acg883%Oa|AzJ?B#N%FVmw`fKNY;g=C3&BXB;Z@Kam~dpydSE;!)KoPs+}MGZ#35TL&dgu1t8ZJCOzunMR5)=3wB`6<04>Wd>fEGNt=fUO7S z2UdorB;0d<%}W2%DB8|}rj&7Bd@G600GiIAl}DfA(T~fGjEtPSpMM-+!RdW!t0gq&tGw>1(Ck!bL+QCwfHM zFSfg6C%J1(_sXrL%2?h=Gs#tB`jY5~^n-B4=5yiEV7#4=o|0Az*Nu@}Ih_Oz$pHOG zC`&0{EO(L#V`PcEmKepS-spt1Gd{>irzEF%o|nyJB4uhF{YR*@P1evnVor$^%6<|| znF`WIVUCMc(=ZuIiR8<#kjLU}uWTnbQf7F06KORJtfO9XHgzgQe;2kI(+lL6NRM$K zObK})t}2X5(vY~u9{XN8DGugG$E0mSB^Mi(>V!GlYlD8E#--~|}G|8JkdYdiH90fD-v+HZu-d;bSJ8}W_+ literal 0 HcmV?d00001 diff --git a/lib/yui/colorpicker/assets/skins/sam/picker_mask.png b/lib/yui/colorpicker/assets/skins/sam/picker_mask.png new file mode 100755 index 0000000000000000000000000000000000000000..f8d91932b376af76ccfac030c12eb9fec7ee4c63 GIT binary patch literal 12174 zcmV;9FLBU`P)_6|b&%Dfjpyv}j54LBIXFZqhE-_t{2r7|?ya1%Cs>h{sswI&ir4|Fh z$jAgxe*E!Arq9Rc<1hC3+xpMn|Ni&&sREphKX2dqw+!rCg4fvHA{v>|sAOH9VUq1Wx=i{&V_yqRn;}h7QkI%<-7fW_4(VkZ}j!+ z*W3A4Q2+7AAN1S*{zm`&=RfJ^|M;1H`st@nDf0RFlp-IAiA&;HZ{w3b`^>wEDMb|H zcWo7$YKZ}V2ee&$PJPY#JEPa?S+a1^5~E@1g&W3xW#A&D$3t?w{=G7DSsA*r_4-%Y z`s|z_E&o@}NSYWQ_Q@Xg&3d|Ou zW&0J1V(Gn21@Ok$tl7ApUjkd|>Gf{~b_Mkc=*rd-*uVe&`%Pc}`s=SZK(DV?u$Q+4 zw*GP77{rl7z$bi8N=|4%dgnzQK{K@X9=v7^ctch^o|!a57b!8M)R5bd+^DZB*f)2h zXi(pP{pA7dU4m@DUcq}~?BDNws-MON*}ARvB9}^yYkUl^^T(x&iy;x&pXVP)oMH zG4>x1DYCNm`n+yi_f;$KX~32?&=bL&3KR!`?Ad)hXq&kbL*FF~DPi6Lgmfs6L(D+0 zND0vbo2}RNnI*FeDS>21aabAxyE61@^}W7lp{p^l|7WGkjF52;svSZcA8su7jAYiZ3LweO3*sn5! zSD>!n=?3mEUmKmhK6d%BxhCszn^Za-*h3D(8SY6kiNgaaXQX90(eY3K$c_zH0Bie! zBHJ2UyB-p(7Bef5YbLIag?2iM6)3&}lecGR>8-$C0bN;o1$K2uG_Y5@@20Q6ep|mt z*;#x0tH7=ryq?1awzczFEUg2jL1spUI~;shFFVJMWT3#Y2!p-uSjIu7V%f`fjs-Ap z^O>)I7X@&(g2WB97X@e*&x;21dj4(4t<5d)+aC4x2CzHGU+%zOzu(5F>;Cn4UV*tj zZ$V@8yjpp$fL&R8ZO0o+m)B>04HkLJJo2A^{CRu7ZvXb}emug@Fk>GfXvJPL@_-^q z01_^oksZ=)$m(QUUX;~R(;!CYEsBZDLoIZEb1~!wBOR^fg#bCy%lortW+6TF_FY@w z&6w46@B~bZ!ZnoFU!@$z>E}`k{^oUMnFB{O&3px81f^O z51QS()3a{J?CEH!+pUC&YHNa5>Eykw2XY`qJYY8f?~*Z#9Wbu!EB)#UYzgYy^IbES z3h4T`vT|kq^`Z574Oq_r_AIDJ0c{44L7>OU1PLbsz#Hu@vK`wj512a*;t0UHoeBa? zk6L-sMY|p{s1$`s7O*7~*BX(c{b~v9`g)Thw{{({Us@kq|5b2nV9S~lBm$l;MJBR- zSsN}46ctdtgi9+$xa(0`+j0;b5@@3(htB#Thl4>@u&CE;xE$KTV_CN$*;#_wksf7p zH>9;!8MRBwYyjM)2y#PKP>c6P+kZ7HSsw`0kDr;x8GBY&%c%cEP&e$K0;+W$c6Ga3 z-f4l|(a#9Tgjm>eL6n{@$mNioz>^;m>!~orEy~tWx3~ zOIPqpfCGkR(H?r%tE(Zjv@CMcj9p#<%|dfa05{ue+I>B?x*{YBs9Lr@sIdpzjet7C z(j3YXHqYbA7G>{gy$rQE(#f8iq4wzn3QC-$G_@y1j3806bjQvT*z2!Z!CPeq$}$Qt zKiFGHksaJG`+EfLE_ox5tq+;W^uV3*u}1^OjK^IhVL9wdjz0DhDyAkTJeq`!B#Pcg zhP)_7_7G+P^?uQ&deV!Q8k_%Iz3u(DO+Od8Pl9$mZo9rWlUfCjjYrK(<6~b$ZT0S1 zS3O;Ux%tu+)a&a-3?R6yAif2U*Sn8h->)oR%UIXfo6X1d@8#Re{rTQ*_p!In<@$MS zi0rd9cH9YgPHQJ6i50k+-%kgas7Aw(CeRhp9mnRTLOFML>EN7Z(g?zUW!g!Hg9HcE;V1EAh^ef|OhyG~Aswq6=s?q4)8Rd863y;SWj zSY7I8OIMc~2-fXFMwH5^wNOOZdAr8m>OGbX*q5qptG2GXdan<;-u3UQn|Fkfk?i04PcV*!JYNDjCSSa=A`)xBsyFVf!o zcEj3Z$<&e+vLHr0ak9iY3#aPde)nR zA-C1eupV=%_1K$crutm{Xra05zTK<7Zd!fooV!f@ zjN&Brbhe|X^)|DOW?&^TSXpb-J8|rPncYZ6g>MN)cr9$&910<@S`i zkQl{aQy;-2thth!_d8NT%MNOLaRo zCuFG|O0cz;&U9i--BvN-HZ`yK2WHwUjV^zvpBugv*x@U8x z({-K67HqPx8;i~;!e{od_khhIU{6k}7aYNF7KD;K_3|HlOG;X68|WyQts~R_Ey{93p$q#vLD)BBQJf!DrZ2nhQiG*TS=m|!i=sNPks~sAWNwo((+QeE z#&&JLOxr|mJq#Wvwe^U!h^q1|mxGNOYb!WJG9t^^ z7DMZKI!Lj#PN|b)?X9WqMFoppm0nG~SG!I#I0zVZ`DqtCYId&sD^t_0?Sst)+mcAN zUvx@c>}O&7-Gj-m-xe7Z%Keh9Wq_!IMZnTSjO}I%4>EJ4jWgw@5p#Q)LYiP`6fiQd z^$Ve27n-UX6~u~jBf+k#TtGMMS9dA;lIYZHi)4l30jO7QF&T(%QhouWT^ zynfVSX2S`ZnZPko&ykt#z}4MKa~F_k(OQ~~0%y}dDP!_F!}v#hlq(gM^>trIkoxdHpiniE-2)#zvMuOXYZ z@JTauPGdhoUrzx&2nsFzYz-P9uOq1X=#HU5Icmr1+m7`=TI)3+i)$@z)KfDUFrb|e zMgs?s-Dk1u&Z5gh$7`mpZ50a_t)I09Z_Y2;>j48bSd6fih|8uJJL^RwJv?I9MOj1S zdLU4vQqm5rNLt8_pn<5I7Sa+!IUbUAt>rFsNh$%|eUVd;2@Sq8wo0jAKq5vm`3kt3 z=3N~Rsk>_m9Wl3@TSRJXnS>Dm>Ye59TAeks*WX>pFw%@&JCaPu7;eaM#?H163Yxqm ziO1X{Y;1uY1)XquF~r!S{e#6HD+K5cU}@)0U+V%VRlwA-9$@K^y(J@8pB$}LpzaKz z#@63&zauQRhE`R26msV$Z^{OZT{Yqz~|MKp5@rfxL0c0%O-=ufe>>^uw{kcP3JqOoTg z+bjHcEIkgV+Xd`yFtrAF15DLXpaVjTJA-wc7@{Rz2CcE1z_Vdg<2a#%A@fTHRary$ zx^qPy{_{TkOX+1&?B6kR^}s#nLpfB<^+cJ+!)2=@cHV%N&a^i{jchr@!b(pU4J^^d zO17|ADFAxZ`eGm^1_e)qtT@Ery0EFfmaLv(=|+cN8%Rh$tyRdxLGaieqrB*@ zL#S!P*wWof-%8)Qb4e_g_L$k4z#SDq0S(+`G&PH>PTX|r+7{K~Ti3eID{{XsPtw=} z0bxo@dr1_)!UUvA#=f(B>9TP$k}MsN5fF`Yl1{Sda#ZD%T;wD_* zrR(uRL+ilL+JnOY9wm9-+$udbbEn?0(LOj>$r_hai=7gPtL*qQi|ZPXQR$29gp zkeHn=VZ^I8vx(Xr3C^*P2@HVj>StOa=0bwJ{*liQX>WaLOu?0&v$0Jsj zZGj8Z3^mjKv_3!Zt()Tzw)7pqx@$jMW2a1WYelRebzTA;ZOaH?FNSYztt>#^x{9&}1iB)CrBSv~c-4}XJO4VNu`kuHu8xMR`H+r@WMy3&f@(oD zV-IQUBfyT>ItFjOyTqV&0>y3{a4&QaiC7u|8A%bSB@^2+!6JcGyO0!VK!4kJZHk>1 znNk-3?ybKKaCMsmp|tx{qUMoqf7#pY9YA&lk%ZZwrPU|5J9327sG0NZzDc%Dr%025 zqCIwz@d$Rqv$k9j0=G{sMPM7F99180rOMfIOX{5lSZj~hBGDq+p)@>{DBd>D(nB2@ zz1GjEM9YEo=n!M0*-1Ij*Dw%_*w@JncJ0>&i~KC^eP`rF2U)|W{@J)VA!A!|1Qar* z*jjIw0i|Z_ef0$;GbCeMEUibRZ?mK78J{kaZ6ym=Hg~jl6AQ>=HEZjAwYpG94|(1j zW6N|q-Bz=DfN-cDdxU)xSwru&TsGqlj#fXTK+$96&LKfghSJ8J%i;Ld466Ic7^EwK zuHB7AWfjo^qGj`m7f~6w&sVL%jGPcDOR5_pYDq3q8i?$oc2L&4#06v<775i>3x}i}tq++VK{F93+C@%G zValBBMTkrmmI0*)W{`~}Bamck?hjo=AIT2H;zr=Ov-i5ctc-b|dO^D>y);olB4TMB zC|XiP28;VR$Cqm(8I)rp>kC5c^snH_B6o0E;XOGDq4mJAaYlw*nfA;o{!0X+V9n+`Q=20nuSDlk0 zdgAwJ=+@w{od%FmxoH4qYj6Ry<_6@487vZ>V-HCY_L4Ek;gHVAHhozyMcV2<0vW}W z{7{x50y!yd{Q&F2azst1q4hSTulr-+Tp`h%A*?MwAJ_+zEJ?ObOB4spn(@)R)X>2& zf=kQ!usm=ppk%N<3>mc_`qq7y4os*fgh3{fE%yV-ALNecQ9724spY3iR-n%;mLmd6 zE873Ja6=*qeEPg1Cyb7X=BtLlGg9Z#Gl5!Z*j^VXfzjv;q(@hx2?D~5Jdw7U_P2|X zXdzX>N67uq%&cTd!^|?#(m5pyv#$2jQbRr?MwiJL*{)@0>KMC94OKA3K#t72B8eGQ zho%5VV9w47VpMu*-A$wNL!A%GiU-iw7fW|M05Jh}mf1p5fbI&HM3Gac!nzy#;7ldzS7-AeZ2l+khNtzzZzBJg{dp zb~=mbyw7Y0_M9bK!fawT={_?Rk|qSC2C5A~wb;**BF6L!W`$oc0wS#Y$YvKE zd17j5OQIOlnsscaN0*DLL$AtD>*~b_1WCz@B5FbwppQe4OMr?AbDH21$qb#P1Oo$h z`Jrt*5Px-YLqh0lp~&%y-E2wy05*1A5Qnk%VHvfhCyH zC=hpY#SvhGb9KOVK)%&Y^RnGaB(p=7)*V4_v-Gn7YcXoCFRC_(RZ!S6b8Cfqwbxbv zIj6A?%91d9Xt1|+Of}XTw3;!B44<0% znWwtB|2&P4+P1NSp^2?K9QLkzeJ!ClT9SHNtqA8<27~p{mMh}O4{Na_#LV9CBRDWv z0#Jih47q~#9>@&J3tPNlQHDPawRfPgO~%%`y0s}74Z!7ym6a4BPiw1+ygEt-x+0)F zb#IHD5sR_Ifd)sVNL0&_vGT}Xc+?%csAYn*+Q^s#o56yZ9IR5MSuC&vo8!1&Bi#ab zqlFVvgjB+%|65pFi}1B2Pjo6A6*5T>N(ltKX>(B|m0NHnM|lj~Jr~#sRwic^FJ1-T`NnK`Sm1G_Iw#v}#|WQK-WlSrb8+AYnEC!}nrHzOofG;mq1M+5E# zF0gem)7`OLLSQ3s1BPWaokAx|WSl1)5O_Z6ba(|#QZlH~GNb{nI{^wDZ8k5vpDICX zWG18F@zH)Vr5-va5qopI{6+-mtjzF^x9ma0=x8jY25H&De=xXL-ukp$GA4EJ?nEl- zQ?{Ut(U?OkHjw~DK_d!wv%y_+E+_VTv|H%tHi!TN=lLhqd)(n^$wIw5XbX}6n z`wVcC!1m9<6ftn4w>5(+5MMNCf!6LiiE4Whw^Y6wQ<}v(+fAE42iREv2fEtS=E3Z# z5uh!P+mj_oiZsVqH6tECPhe|8cAs!~*a#jwEAVkGN;B?DgH?WY8pQ;Rv=0J-zk#a?d`U!O06|i&_pC0~% zs`H#tCai{-F-YNecP#Zgvjn-m4!WXHOEei+>hHL2yn0o89qjDD)2se_dhnP@n|qag zq7K&uG4;zpyE+``=ZwZifMAQ|GqM9DW;}m7&*Dql$%OnMBsqMELWGhrj(%q3(o|;F zm3fVvSr`q@)mGl(=b*|dsgt6oOp6bR~u`cPXan(Y?Gyewo|O!dC`^>(LOeEI&2wo%g8#w=7X*X=dws6C9Z=RM)P&R>XeWcW*}*S9|dBO z#E4vw6hn)0PQ$k*rB~U=N_Ki%gBgJqonHde7}bdbG3X-bM%8BGh!5%`glVkCChN}~g3BW$M}kFK2>ONsVtFvIPh8-j|! zP`X_o->~@7R1I1~_EP)g01;!(lkT_dq{zVuDO3BhOrBuw4xoebW0}oV0S%e1I!G@ zS(<=GAhvWhk}V>&+|*Y)b=L0-?9AW-BY4bAxj;rqE3At~Ky}WW0=SHa2iUo(K{h79 zoT?DC0FAa;NfwZ-@hm`!>^_u$QRi@h3rq?mNydOZGE=G{H&Tn{xCKvROl{R@LvI^( zB**_YItF)xh#kMXDH{M%hCO)$0MF=nR&EvuhTU2bMl1Q!wJQMKqreW=pfU8fHKC=;%8?Wy zW7a2QbPj5(!NIjz>u$oivp7#D1d0NoTZEjF9$;1MK(IMCCG zx#4mA491Rzkwx{-qhlU*CEw$JHpIZDM;^H+`-KBjpLq;>6vPe?U29I&lkB=&7dC0T zkL-zu_B9&G9&wIzIR`R>lTzb(!J|=U9R-`&X&KV;#bWceXp7Ay_biXxa!>Y)!Gw|^ zRzPXZRpL4+;23w5y4e9ilxJLLJ(vJZZMK~=hmp~M@T|Zw#n?zU2c03D=h^@)oM4jt zsnM*VVdlh?mfl95dUI}PN`okEK2kL0v3MjOvN9u+K?D|Fd;ZM@K@!6VE-4WpdRjVS z`e9&)&ImiJgbn!Hp)7H-n8gVs%>dH{es0F7IG{|}g8|!fpqD#of!gVkQq&1hX3_GZ z_3_C-5c<`Ii&6%I$Pr){sa-I;}6YGm*O`nF^QD6H`R=aiQ0s=u4 zTza2}Kqg;X`>lWu)lt7?a43FWI*YMWGq5^yjaX|lW+X^@MFS{LxLd9dEvFY2K>Mgp?OA;_w>u?86cFL0 zl^u|i`zRqxP>`3><7&bkb1pweD>LXk79h=KJ3K9)2o~)&cO%)=1g}F zezt&oXXmE4tL+eryM}%D`&caP0o?<5GC3n&x1^uY*oC}O)4&Ny&lDB0x4RvToOh&) zr$x!r&{le0YierKcvjGr`MhwQN2@c|(vL0gU66c2WH&Pd(};GS(b>6m9(kOx2U$5v z@|0jSjm6$YCkMz`nb*JIW&u`KPe-hr@wz*AM^1+0bSRGYKYlwV;Do^T4dXIFHa6J1 z)5oZS&(qlha)lDCehAo6iE0Y?R>0YuTY#ACrKQ=>*;xRyl>~C^y1g2X{k0@ro$W{? zwvM-s$pDz_i65J#OcG%Bz!;8vLC%YD?so%r2z*0VV~N1-I_u_z2H-X|cn0LCMglSM zk_53Mlgw>~!{KUf$8{>kWIt>;QEu|Y(%7QI@3#!A20N#nd+-LJ&->U1fju>|lm~u` zMVtiAa2v1VIPJr2mhANV{@gxO%YTY*rpumms_z`G6*Nz z@vOfDix06fV0>$B$utX(vNk(w-AuBv%gzxK2aX60xFRL6_ufZ}bZ!6>Cu>P8z_~%E zH<=FdoV||Vfm~{K063R%M}Vz=BS&@=XYTJbm>oS$PO`<-#+Jr*?hJ)Bt`PObM)kSZ8H|g?k<=*@;I^`DUND+wP){p6|2G-|G5*}WiV*^B=KId- z;G@Tf8k-jmEBQtPM31$T_1&(cVlBrp3fd&t$w|wntNq&V-IN5&It_E4@Imd|Kl?!< zfuUTc3zAHObCRvo`Z^&~rld%Ai4Mrxfz*f=J2kV1&iOMk#tIN2lVtAiQla>BXSp(9++bG|?7bP^y}FKW_JBeC3hEjw3ZfkQ=ooGj?Ibj8S#saVB*- z(a3wWYzYE&Mi#gdr2U=EcHfQNhXCmfHXuAzgA3lI-REUKqmoum9Ai$?F!CHEmD0~z zqF9XWl^>uxWn#1olpsOM+>$6(x}0oQrzmhdPl^o4kuac)((nmM5;-1}WlGssZT7om z&`$%t(;*_@Mk^abP-k3?V4{ACM!F=WN2VN=j44B&BSj(rM^iD32B1+VaO%L_i|*Y4 zY*t?&sLqff4*OA7!ZgPku1D6@utwCJ{WyPAO_H%kf$k=8h&W*C==PQYs~c!Wj2#U! zFn*)-F|TRRDm+6Dq3p;2+49V@!K-(?{xPPPoF1to z$x0H=yC}mJp~L3**vIz?8MOj$Qro8;i>#|LTTB(5kG`YF^a7^fmu>C|j@F))CsXdp z2*c0Hi~~%Z-PZrVI2D6HRvrQW5r+0;$An*<4jfMfb~Hxr6qu(0VIU{6XB%fdUt+7GKM$ZQ7d z+*G-q^3AhAkG6UGeKe43wk=Z~@{qi^8g4~a7kh3;^x0=fpYx@Ed05BU<|1?Y@y9GNH9cw6|*ydMtC~bu#Ur zW^%V9`U#e%tuqzfu>F?#-9|w@YT*rZk~0~*#cRn2ktxkSAW3Ed%?xnei<~%b>YUvy zQB0iuZb_Yd#{V~D+^D7_lR5mbj7|2~MWfx0!AN^YIy$^?2|Zp0fzVvE@~A_$*cnVA zMw#g)ypCq2vdiFXhx6E0)LqSNUxhI zVW-W=i}3ha-8{;~vjY#ZReptXbC!%U_7TS<<#h*49XcddFz8&+VQpzLHIvtFG}ukc ztmOZTJf~!aiH*rPc@pR;9nD7=JCGdVDq<116>`I1b5xT@tC-Dp5?2cO>`Zi$Oc?Cc z(=Nq~W}cBGvz~W!9>~};tnKM?az?r*E|O;jW_03+7UVQwICongNlHz~C-}PvCLZYw zR_qcowKa`$hP?y!^;8FkQe+UQgE~86O1M%&)(VWI%!rlfG4Y`wbreh^=ZP%0M8brg z;dU5oO-Jt}hg^{e*c8v~l#?WMUt?_~z?@+B^hF06nQ2~sj#!{Wam0bn8hwA4g(GPp zre)|l%aSOn8U*|Kj6IRW895IgvD0rHxqx+pbT_1PaWqhU>-R^eY8dPASqqQe_aWKy zbYM@gdG;KmUU;{SlVCmuzzWeg767aWXd_QWP{P+&9)h)*5Dlk z!wjP}|BcZa_lfvoG{C0G|7UodwcV@AJHfqqjue^oy9ceoY@nI}^Q?wH6;v~TLW`Kr zXy79tKO?#FmJgG$lhVOuZE*2ZjE(?$gwY2R3`cIyVJA+KNNfEK$gcDqZHkf0VMdOe zm>Iv^1hyK8I~oYO9l-Us@yB|M4gsFj<5}h%0zYagcd)ZD(q&^V&IE^>F~$_5al^!k4%1 zJn&9?;+~W-ewCt^;T`NeM?jwi+M(lXmEnk#nsGM*Cu2AujAFmD9g=3^cRpazg{)2P zn8^slCiA+?NR(!+NuZ1{S-MkuZF%6gv9{}!d*XLgzfH?4N!?6zAmK9F0seNx-8fs1 zXDviP*JZL(3;|+<;j`Pb3|s~}q7~H5vaL6j*f~=voG(jG12zp0Lhxjb*#NQD5r-zc z8>nBrJig*G4d%vKNVex5w1@9RM?K}U<_D?ky?<0-r@?(R`7p`ot`?H2s#>^rZ4^=FlN|z7;uANn-1>IN}N2Cr3Zk`BP^T*Bp+h=GXQ?n zq4@~xH~`i&0DT(!&VYJ`-9wFiKyS}TnG}0}0I747b%*zVRH^Xn>CK)NJe~mTrv#t_ zcabwXLIlFM0P-}L$AMa&#=dX$_}d`x3eTZ?RLY=?o8@$7*!k>srvp9PW)jSU?U;_9 z^Qe?K+IdESZGby%u+M1qd$#NeEItDAvw?m9$ftmLQX9{>7*l{gdPf)rHlFHin8at8 zf231nfja`;X`qjQ{TPtT2$-J+=#L;%GCuZM%zFe-GoTq|EqXG0J-rjFA!)YD@D%G+(%jVtWGl1QAU{d2%u&<<*Zbo86f4@e+txxnf@rS&tmU0L4FkI zvtVzu0H1hQIRnIJ0C_feJe#F6_kc5iO=q3M`0__VKFhGvjLYYO_Y5XJ1jJ{7c^Yep zHW&J!52nA`qtNH$?S3o4*oSLk&tTSPNrW?X?<5;9naK^$U}fVxx$Ap|$u2f@bg3gWkxHK%Fp4+8RMf$}i0&g=*$e&(C#qxaD0ZvpHl zv+I6`Mm!BUmxWOUFGBaUp^pXA9e5eL-vl3cNcl?@AS6vgTG5D@?CMq zTi=Sx2mN33JO2+a9~-FUJu&myl|RHap8Fr(82g7GfB2M~pO3%P FFFFFF + * @method rgb2hex + * @param r {int|[int, int, int]} the red value, or an + * array containing all three parameters + * @param g {int} the green value + * @param b {int} the blue value + * @return {string} the hex string + */ + rgb2hex: function(r, g, b) { + if (lang.isArray(r)) { + return this.rgb2hex.call(this, r[0], r[1], r[2]); + } + + var f=this.dec2hex; + return f(r) + f(g) + f(b); + }, + + /** + * Converts an int 0...255 to hex pair 00...FF + * @method dec2hex + * @param n {int} the number to convert + * @return {string} the hex equivalent + */ + dec2hex: function(n) { + n = parseInt(n, 10); + n = (lang.isNumber(n)) ? n : 0; + n = (n > 255 || n < 0) ? 0 : n; + + return HCHARS.charAt((n - n % 16) / 16) + HCHARS.charAt(n % 16); + }, + + /** + * Converts a hex pair 00...FF to an int 0...255 + * @method hex2dec + * @param str {string} the hex pair to convert + * @return {int} the decimal + */ + hex2dec: function(str) { + var f = function(c) { + return HCHARS.indexOf(c.toUpperCase()); + }; + + var s=str.split(''); + + return ((f(s[0]) * 16) + f(s[1])); + }, + + /** + * Converts a hex string to rgb + * @method hex2rgb + * @param str {string} the hex string + * @return {[int, int, int]} an array containing the rgb values + */ + hex2rgb: function(s) { + var f = this.hex2dec; + return [f(s.substr(0, 2)), f(s.substr(2, 2)), f(s.substr(4, 2))]; + }, + + /** + * Returns the closest websafe color to the supplied rgb value. + * @method websafe + * @param r {int|[int, int, int]} the red value, or an + * array containing all three parameters + * @param g {int} the green value + * @param b {int} the blue value + * @return {[int, int, int]} an array containing the closes + * websafe rgb colors. + */ + websafe: function(r, g, b) { + + if (lang.isArray(r)) { + return this.websafe.call(this, r[0], r[1], r[2]); + } + + // returns the closest match [0, 51, 102, 153, 204, 255] + var f = function(v) { + if (lang.isNumber(v)) { + v = Math.min(Math.max(0, v), 255); + var i, next; + for (i=0; i<256; i=i+51) { + next = i+51; + if (v >= i && v <= next) { + return (v-i > 25) ? next : i; + } + } + YAHOO.log("Error calculating the websafe value for " + v, "warn"); + } + + return v; + }; + + return [f(r), f(g), f(b)]; + } + }; +}(); + + +(function() { + + var pickercount = 0; + + /** + * The colorpicker module provides a widget for selecting colors + * @module colorpicker + * @requires yahoo, dom, event, element, slider + */ + + /** + * A widget to select colors + * @namespace YAHOO.widget + * @class YAHOO.widget.ColorPicker + * @extends YAHOO.util.Element + * @constructor + * @param {HTMLElement | String | Object} el(optional) The html + * element that represents the colorpicker, or the attribute object to use. + * An element will be created if none provided. + * @param {Object} attr (optional) A key map of the colorpicker's + * initial attributes. Ignored if first arg is attributes object. + */ + YAHOO.widget.ColorPicker = function(el, attr) { + pickercount = pickercount + 1; + this.logger = new YAHOO.widget.LogWriter("ColorPicker"); + attr = attr || {}; + if (arguments.length === 1 && !YAHOO.lang.isString(el) && !el.nodeName) { + attr = el; // treat first arg as attr object + el = attr.element || null; + } + + if (!el && !attr.element) { // create if we dont have one + this.logger.log("creating host element"); + el = _createHostElement.call(this, attr); + } + + YAHOO.widget.ColorPicker.superclass.constructor.call(this, el, attr); + }; + + YAHOO.extend(YAHOO.widget.ColorPicker, YAHOO.util.Element); + + var proto = YAHOO.widget.ColorPicker.prototype, + Slider=YAHOO.widget.Slider, + Color=YAHOO.util.Color, + Dom = YAHOO.util.Dom, + Event = YAHOO.util.Event, + lang = YAHOO.lang, + sub = lang.substitute; + + + var b = "yui-picker"; + + /** + * The element ids used by this control + * @property ID + * @final + */ + proto.ID = { + + /** + * The id for the "red" form field + * @property ID.R + * @type String + * @final + * @default yui-picker-r + */ + R: b + "-r", + + /** + * The id for the "red" hex pair output + * @property ID.R_HEX + * @type String + * @final + * @default yui-picker-rhex + */ + R_HEX: b + "-rhex", + + /** + * The id for the "green" form field + * @property ID.G + * @type String + * @final + * @default yui-picker-g + */ + G: b + "-g", + + /** + * The id for the "green" hex pair output + * @property ID.G_HEX + * @type String + * @final + * @default yui-picker-ghex + */ + G_HEX: b + "-ghex", + + + /** + * The id for the "blue" form field + * @property ID.B + * @type String + * @final + * @default yui-picker-b + */ + B: b + "-b", + + /** + * The id for the "blue" hex pair output + * @property ID.B_HEX + * @type String + * @final + * @default yui-picker-bhex + */ + B_HEX: b + "-bhex", + + /** + * The id for the "hue" form field + * @property ID.H + * @type String + * @final + * @default yui-picker-h + */ + H: b + "-h", + + /** + * The id for the "saturation" form field + * @property ID.S + * @type String + * @final + * @default yui-picker-s + */ + S: b + "-s", + + /** + * The id for the "value" form field + * @property ID.V + * @type String + * @final + * @default yui-picker-v + */ + V: b + "-v", + + /** + * The id for the picker region slider + * @property ID.PICKER_BG + * @type String + * @final + * @default yui-picker-bg + */ + PICKER_BG: b + "-bg", + + /** + * The id for the picker region thumb + * @property ID.PICKER_THUMB + * @type String + * @final + * @default yui-picker-thumb + */ + PICKER_THUMB: b + "-thumb", + + /** + * The id for the hue slider + * @property ID.HUE_BG + * @type String + * @final + * @default yui-picker-hue-bg + */ + HUE_BG: b + "-hue-bg", + + /** + * The id for the hue thumb + * @property ID.HUE_THUMB + * @type String + * @final + * @default yui-picker-hue-thumb + */ + HUE_THUMB: b + "-hue-thumb", + + /** + * The id for the hex value form field + * @property ID.HEX + * @type String + * @final + * @default yui-picker-hex + */ + HEX: b + "-hex", + + /** + * The id for the color swatch + * @property ID.SWATCH + * @type String + * @final + * @default yui-picker-swatch + */ + SWATCH: b + "-swatch", + + /** + * The id for the websafe color swatch + * @property ID.WEBSAFE_SWATCH + * @type String + * @final + * @default yui-picker-websafe-swatch + */ + WEBSAFE_SWATCH: b + "-websafe-swatch", + + /** + * The id for the control details + * @property ID.CONTROLS + * @final + * @default yui-picker-controls + */ + CONTROLS: b + "-controls", + + /** + * The id for the rgb controls + * @property ID.RGB_CONTROLS + * @final + * @default yui-picker-rgb-controls + */ + RGB_CONTROLS: b + "-rgb-controls", + + /** + * The id for the hsv controls + * @property ID.HSV_CONTROLS + * @final + * @default yui-picker-hsv-controls + */ + HSV_CONTROLS: b + "-hsv-controls", + + /** + * The id for the hsv controls + * @property ID.HEX_CONTROLS + * @final + * @default yui-picker-hex-controls + */ + HEX_CONTROLS: b + "-hex-controls", + + /** + * The id for the hex summary + * @property ID.HEX_SUMMARY + * @final + * @default yui-picker-hex-summary + */ + HEX_SUMMARY: b + "-hex-summary", + + /** + * The id for the controls section header + * @property ID.CONTROLS_LABEL + * @final + * @default yui-picker-controls-label + */ + CONTROLS_LABEL: b + "-controls-label" + }; + + /** + * Constants for any script-generated messages. The values here + * are the default messages. They can be updated by providing + * the complete list to the constructor for the "txt" attribute. + * @property TXT + * @final + */ + proto.TXT = { + ILLEGAL_HEX: "Illegal hex value entered", + SHOW_CONTROLS: "Show color details", + HIDE_CONTROLS: "Hide color details", + CURRENT_COLOR: "Currently selected color: {rgb}", + CLOSEST_WEBSAFE: "Closest websafe color: {rgb}. Click to select.", + R: "R", + G: "G", + B: "B", + H: "H", + S: "S", + V: "V", + HEX: "#", + DEG: "\u00B0", + PERCENT: "%" + }; + + /** + * Constants for the default image locations for img tags that are + * generated by the control. They can be modified by passing the + * complete list to the contructor for the "images" attribute + * @property IMAGE + * @final + */ + proto.IMAGE = { + PICKER_THUMB: "../../build/colorpicker/assets/picker_thumb.png", + HUE_THUMB: "../../build/colorpicker/assets/hue_thumb.png" + }; + + /* + * Constants for the control's custom event names. subscribe + * to the rgbChange event instead. + * @property EVENT + * @final + */ + //proto.EVENT = { + //CHANGE: "change" + //}; + + //proto.CSS = { }; + + /** + * Constants for the control's default default values + * @property DEFAULT + * @final + */ + proto.DEFAULT = { + PICKER_SIZE: 180 + }; + + /** + * Constants for the control's configuration attributes + * @property OPT + * @final + */ + proto.OPT = { + HUE: "hue", + SATURATION: "saturation", + VALUE: "value", + RED: "red", + GREEN: "green", + BLUE: "blue", + HSV: "hsv", + RGB: "rgb", + WEBSAFE: "websafe", + HEX: "hex", + PICKER_SIZE: "pickersize", + SHOW_CONTROLS: "showcontrols", + SHOW_RGB_CONTROLS: "showrgbcontrols", + SHOW_HSV_CONTROLS: "showhsvcontrols", + SHOW_HEX_CONTROLS: "showhexcontrols", + SHOW_HEX_SUMMARY: "showhexsummary", + SHOW_WEBSAFE: "showwebsafe", + //SHOW_SUBMIT: "showsubmit", + CONTAINER: "container", + IDS: "ids", + ELEMENTS: "elements", + TXT: "txt", + IMAGES: "images", + ANIMATE: "animate" + }; + + /** + * Sets the control to the specified rgb value and + * moves the sliders to the proper positions + * @method setValue + * @param rgb {[int, int, int]} the rgb value + * @param silent {boolean} whether or not to fire the change event + */ + proto.setValue = function(rgb, silent) { + silent = (silent) || false; + this.set(this.OPT.RGB, rgb, silent); + _updateSliders.call(this); + }; + + /** + * The hue slider + * @property hueSlider + * @type YAHOO.widget.Slider + */ + proto.hueSlider = null; + + /** + * The picker region + * @property pickerSlider + * @type YAHOO.widget.Slider + */ + proto.pickerSlider = null; + + /** + * Translates the slider value into hue, int[0,359] + * @method _getH + * @private + * @return {int} the hue from 0 to 359 + */ + var _getH = function() { + var size = this.get(this.OPT.PICKER_SIZE), + h = (size - this.hueSlider.getValue()) / size; + h = Math.round(h*360); + return (h === 360) ? 0 : h; + }; + + /** + * Translates the slider value into saturation, int[0,1], left to right + * @method _getS + * @private + * @return {int} the saturation from 0 to 1 + */ + var _getS = function() { + return this.pickerSlider.getXValue() / this.get(this.OPT.PICKER_SIZE); + }; + + /** + * Translates the slider value into value/brightness, int[0,1], top + * to bottom + * @method _getV + * @private + * @return {int} the value from 0 to 1 + */ + var _getV = function() { + var size = this.get(this.OPT.PICKER_SIZE); + return (size - this.pickerSlider.getYValue()) / size; + }; + + /** + * Updates the background of the swatch with the current rbg value. + * Also updates the websafe swatch to the closest websafe color + * @method _updateSwatch + * @private + */ + var _updateSwatch = function() { + var rgb = this.get(this.OPT.RGB), + websafe = this.get(this.OPT.WEBSAFE), + el = this.getElement(this.ID.SWATCH), + color = rgb.join(","), + txt = this.get(this.OPT.TXT); + + Dom.setStyle(el, "background-color", "rgb(" + color + ")"); + el.title = lang.substitute(txt.CURRENT_COLOR, { + "rgb": "#" + this.get(this.OPT.HEX) + }); + + + el = this.getElement(this.ID.WEBSAFE_SWATCH); + color = websafe.join(","); + + Dom.setStyle(el, "background-color", "rgb(" + color + ")"); + el.title = lang.substitute(txt.CLOSEST_WEBSAFE, { + "rgb": "#" + Color.rgb2hex(websafe) + }); + + }; + + /** + * Reads the sliders and converts the values to RGB, updating the + * internal state for all the individual form fields + * @method _getValuesFromSliders + * @private + */ + var _getValuesFromSliders = function() { + var h=_getH.call(this), s=_getS.call(this), v=_getV.call(this); + YAHOO.log("hsv " + [h, s, v]); + + rgb = Color.hsv2rgb(h, s, v); + var websafe = Color.websafe(rgb); + var hex = Color.rgb2hex(rgb[0], rgb[1], rgb[2]); + + this.set(this.OPT.RGB, rgb); + }; + + /** + * Updates the form field controls with the state data contained + * in the control. + * @method _updateFormFields + * @private + */ + var _updateFormFields = function() { + this.getElement(this.ID.H).value = this.get(this.OPT.HUE); + this.getElement(this.ID.S).value = this.get(this.OPT.SATURATION); + this.getElement(this.ID.V).value = this.get(this.OPT.VALUE); + this.getElement(this.ID.R).value = this.get(this.OPT.RED); + this.getElement(this.ID.R_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.RED)); + this.getElement(this.ID.G).value = this.get(this.OPT.GREEN); + this.getElement(this.ID.G_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.GREEN)); + this.getElement(this.ID.B).value = this.get(this.OPT.BLUE); + this.getElement(this.ID.B_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.BLUE)); + this.getElement(this.ID.HEX).value = this.get(this.OPT.HEX); + }; + + /** + * Event handler for the hue slider. + * @method _onHueSliderChange + * @param newOffset {int} pixels from the start position + * @private + */ + var _onHueSliderChange = function(newOffset) { + this.logger.log("hue update: " + newOffset , "warn"); + + var h = _getH.call(this); + this.set(this.OPT.HUE, h, true); + + // set picker background to the hue + var rgb = Color.hsv2rgb(h, 1, 1); + var styleDef = "rgb(" + rgb.join(",") + ")"; + + Dom.setStyle(this.getElement(this.ID.PICKER_BG), "background-color", styleDef); + + if (this.hueSlider.valueChangeSource === this.hueSlider.SOURCE_UI_EVENT) { + _getValuesFromSliders.call(this); + } + + _updateFormFields.call(this); + _updateSwatch.call(this); + }; + + /** + * Event handler for the picker slider, which controls the + * saturation and value/brightness. + * @method _onPickerSliderChange + * @param newOffset {{x: int, y: int}} x/y pixels from the start position + * @private + */ + var _onPickerSliderChange = function(newOffset) { + this.logger.log(sub("picker update [{x}, {y}]", newOffset)); + + var s=_getS.call(this), v=_getV.call(this); + this.set(this.OPT.SATURATION, Math.round(s*100), true); + this.set(this.OPT.VALUE, Math.round(v*100), true); + + if (this.pickerSlider.valueChangeSource === this.pickerSlider.SOURCE_UI_EVENT) { + _getValuesFromSliders.call(this); + } + + _updateFormFields.call(this); + _updateSwatch.call(this); + }; + + + /** + * Key map to well-known commands for txt field input + * @method _getCommand + * @param e {Event} the keypress or keydown event + * @return {int} a command code + *
    + *
  • 0 = not a number, letter in range, or special key
  • + *
  • 1 = number
  • + *
  • 2 = a-fA-F
  • + *
  • 3 = increment (up arrow)
  • + *
  • 4 = decrement (down arrow)
  • + *
  • 5 = special key (tab, delete, return, escape, left, right)
  • + *
  • 6 = return
  • + *
+ * @private + */ + var _getCommand = function(e) { + var c = Event.getCharCode(e); + + //alert(Event.getCharCode(e) + ", " + e.keyCode + ", " + e.charCode); + + // special keys + if (c === 38) { // up arrow + return 3; + } else if (c === 13) { // return + return 6; + } else if (c === 40) { // down array + return 4; + } else if (c >= 48 && c<=57) { // 0-9 + return 1; + } else if (c >= 97 && c<=102) { // a-f + return 2; + } else if (c >= 65 && c<=70) { // A-F + return 2; + //} else if ("8, 9, 13, 27, 37, 39".indexOf(c) > -1 || + // (c >= 112 && c <=123)) { // including F-keys + // tab, delete, return, escape, left, right + } else if ("8, 9, 13, 27, 37, 39".indexOf(c) > -1) { // special chars + return 5; + } else { // something we probably don't want + return 0; + } + }; + + /** + * Handle keypress on one of the rgb or hsv fields. + * @method _rgbFieldKeypress + * @param e {Event} the keypress event + * @param el {HTMLElement} the field + * @param prop {string} the key to the linked property + * @private + */ + var _rgbFieldKeypress = function(e, el, prop) { + var command = _getCommand(e); + var inc = (e.shiftKey) ? 10 : 1; + switch (command) { + case 6: // return, update the value + _useFieldValue.apply(this, arguments); + break; + + case 3: // up arrow, increment + this.set(prop, Math.min(this.get(prop)+inc, 255)); + _updateFormFields.call(this); + //Event.stopEvent(e); + break; + case 4: // down arrow, decrement + this.set(prop, Math.max(this.get(prop)-inc, 0)); + _updateFormFields.call(this); + //Event.stopEvent(e); + break; + + default: + } + + }; + + /** + * Handle keydown on the hex field + * @method _hexFieldKeypress + * @param e {Event} the keypress event + * @param el {HTMLElement} the field + * @param prop {string} the key to the linked property + * @private + */ + var _hexFieldKeypress = function(e, el, prop) { + var command = _getCommand(e); + if (command === 6) { // return, update the value + _useFieldValue.apply(this, arguments); + } + }; + + /** + * Use the value of the text field to update the control + * @method _hexFieldKeypress + * @param e {Event} an event + * @param el {HTMLElement} the field + * @param prop {string} the key to the linked property + * @private + */ + var _useFieldValue = function(e, el, prop) { + var val = el.value; + + if (prop !== this.OPT.HEX) { + val = parseInt(val, 10); + } + + if (val !== this.get(prop)) { + this.set(prop, val); + } + }; + + /** + * Allows numbers and special chars only. Used for the + * rgb and hsv fields keypress handler. + * @method _numbersOnly + * @param e {Event} the event + * @private + * @return {boolean} false if we are canceling the event + */ + var _numbersOnly = function(e) { + return _hexOnly(e, true); + }; + + /** + * Allows numbers and special chars, and by default allows a-f. + * Used for the hex field keypress handler. + * @method _hexOnly + * @param e {Event} the event + * @param numbersOnly omits a-f if set to true + * @private + * @return {boolean} false if we are canceling the event + */ + var _hexOnly = function(e, numbersOnly) { + var command = _getCommand(e); + switch (command) { + case 6: // return + case 5: // special char + case 1: // number + break; + case 2: // hex char (a-f) + if (numbersOnly !== true) { + break; + } + + // fallthrough is intentional + + default: // prevent alpha and punctuation + Event.stopEvent(e); + return false; + } + }; + + /** + * Returns the element reference that is saved. The id can be either + * the element id, or the key for this id in the "id" config attribute. + * For instance, the host element id can be obtained by passing its + * id (default: "yui_picker") or by its key "YUI_PICKER". + * @param id {string} the element id, or key + * @return {HTMLElement} a reference to the element + */ + proto.getElement = function(id) { + return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[id]]; + }; + + _createElements = function() { + this.logger.log("Building markup"); + var el, child, img, fld, i, + ids = this.get(this.OPT.IDS), + txt = this.get(this.OPT.TXT), + images = this.get(this.OPT.IMAGES), + Elem = function(type, o) { + var n = document.createElement(type); + if (o) { + lang.augmentObject(n, o, true); + } + return n; + }, + RGBElem = function(type, obj) { + var o = lang.merge({ + //type: "txt", + autocomplete: "off", + value: "0", + size: 3, + maxlength: 3 + }, obj); + + o.name = o.id; + return new Elem(type, o); + }; + + var p = this.get("element"); + + // Picker slider (S and V) --------------------------------------------- + + el = new Elem("div", { + id: ids[this.ID.PICKER_BG], + className: "yui-picker-bg", + tabIndex: -1, + hideFocus: true + }); + + child = new Elem("div", { + id: ids[this.ID.PICKER_THUMB], + className: "yui-picker-thumb" + }); + + img = new Elem("img", { + src: images.PICKER_THUMB + }); + + child.appendChild(img); + el.appendChild(child); + p.appendChild(el); + + // Hue slider --------------------------------------------- + el = new Elem("div", { + id: ids[this.ID.HUE_BG], + className: "yui-picker-hue-bg", + tabIndex: -1, + hideFocus: true + }); + + child = new Elem("div", { + id: ids[this.ID.HUE_THUMB], + className: "yui-picker-hue-thumb" + }); + + img = new Elem("img", { + src: images.HUE_THUMB + }); + + child.appendChild(img); + el.appendChild(child); + p.appendChild(el); + + + // controls --------------------------------------------- + + el = new Elem("div", { + id: ids[this.ID.CONTROLS], + className: "yui-picker-controls" + }); + + p.appendChild(el); + p = el; + + // controls header + el = new Elem("div", { + className: "hd" + }); + + child = new Elem("a", { + id: ids[this.ID.CONTROLS_LABEL], + //className: "yui-picker-controls-label", + href: "#" + }); + el.appendChild(child); + p.appendChild(el); + + // bd + el = new Elem("div", { + className: "bd" + }); + + p.appendChild(el); + p = el; + + // rgb + el = new Elem("ul", { + id: ids[this.ID.RGB_CONTROLS], + className: "yui-picker-rgb-controls" + }); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.R + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.R], + className: "yui-picker-r" + }); + + child.appendChild(fld); + el.appendChild(child); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.G + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.G], + className: "yui-picker-g" + }); + + child.appendChild(fld); + el.appendChild(child); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.B + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.B], + className: "yui-picker-b" + }); + + child.appendChild(fld); + el.appendChild(child); + + p.appendChild(el); + + // hsv + el = new Elem("ul", { + id: ids[this.ID.HSV_CONTROLS], + className: "yui-picker-hsv-controls" + }); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.H + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.H], + className: "yui-picker-h" + }); + + child.appendChild(fld); + child.appendChild(document.createTextNode(" " + txt.DEG)); + + el.appendChild(child); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.S + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.S], + className: "yui-picker-s" + }); + + child.appendChild(fld); + child.appendChild(document.createTextNode(" " + txt.PERCENT)); + + el.appendChild(child); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.V + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.V], + className: "yui-picker-v" + }); + + child.appendChild(fld); + child.appendChild(document.createTextNode(" " + txt.PERCENT)); + + el.appendChild(child); + p.appendChild(el); + + + // hex summary + + el = new Elem("ul", { + id: ids[this.ID.HEX_SUMMARY], + className: "yui-picker-hex_summary" + }); + + child = new Elem("li", { + id: ids[this.ID.R_HEX] + }); + el.appendChild(child); + + child = new Elem("li", { + id: ids[this.ID.G_HEX] + }); + el.appendChild(child); + + child = new Elem("li", { + id: ids[this.ID.B_HEX] + }); + el.appendChild(child); + p.appendChild(el); + + // hex field + el = new Elem("div", { + id: ids[this.ID.HEX_CONTROLS], + className: "yui-picker-hex-controls" + }); + el.appendChild(document.createTextNode(txt.HEX + " ")); + + child = new RGBElem("input", { + id: ids[this.ID.HEX], + className: "yui-picker-hex", + size: 6, + maxlength: 6 + }); + + el.appendChild(child); + p.appendChild(el); + + p = this.get("element"); + + // swatch + el = new Elem("div", { + id: ids[this.ID.SWATCH], + className: "yui-picker-swatch" + }); + + p.appendChild(el); + + // websafe swatch + el = new Elem("div", { + id: ids[this.ID.WEBSAFE_SWATCH], + className: "yui-picker-websafe-swatch" + }); + + p.appendChild(el); + + }; + + /** + * Sets the initial state of the sliders + * @method initPicker + */ + proto.initPicker = function () { + + // bind all of our elements + var o=this.OPT, + ids = this.get(o.IDS), + els = this.get(o.ELEMENTS), + i, el, id; + + // Add the default value as a key for each element for easier lookup + for (i in this.ID) { + if (lang.hasOwnProperty(this.ID, i)) { + ids[this.ID[i]] = ids[i]; + } + } + + // Check for picker element, if not there, create all of them + el = Dom.get(ids[this.ID.PICKER_BG]); + if (!el) { + _createElements.call(this); + } else { + this.logger.log("Using pre-existing markup"); + } + + for (i in ids) { + if (lang.hasOwnProperty(ids, i)) { + // look for element + el = Dom.get(ids[i]); + + // generate an id if the implementer passed in an element reference, + // and the element did not have an id already + id = Dom.generateId(el); + + // update the id in case we generated the id + ids[i] = id; // key is WEBSAFE_SWATCH + ids[ids[i]] = id; // key is websafe_swatch + + // store the dom ref + els[id] = el; + } + } + + // set the initial visibility state of our controls + els = [o.SHOW_CONTROLS, + o.SHOW_RGB_CONTROLS, + o.SHOW_HSV_CONTROLS, + o.SHOW_HEX_CONTROLS, + o.SHOW_HEX_SUMMARY, + o.SHOW_WEBSAFE + ]; + + for (i=0; i 1) { + for (var i in ids) { + if (lang.hasOwnProperty(ids, i)) { + ids[i] = ids[i] + pickercount; + } + } + } + + + /** + * A list of element ids and/or element references used by the + * control. The default is the this.ID list, and can be customized + * by passing a list in the contructor + * @config ids + * @type {referenceid: realid} + * @writeonce + */ + this.setAttributeConfig(this.OPT.IDS, { + value: ids, + writeonce: true + }); + + /** + * A list of txt strings for internationalization. Default + * is this.TXT + * @config txt + * @type {key: txt} + * @writeonce + */ + this.setAttributeConfig(this.OPT.TXT, { + value: attr.txt || this.TXT, + writeonce: true + }); + + /** + * The img src default list + * is this.IMAGES + * @config images + * @type {key: image} + * @writeonce + */ + this.setAttributeConfig(this.OPT.IMAGES, { + value: attr.images || this.IMAGE, + writeonce: true + }); + /** + * The element refs used by this control. Set at initialization + * @config elements + * @type {id: HTMLElement} + * @readonly + */ + this.setAttributeConfig(this.OPT.ELEMENTS, { + value: {}, + readonly: true + }); + + /** + * Returns the cached element reference. If the id is not a string, it + * is assumed that it is an element and this is returned. + * @param id {string|HTMLElement} the element key, id, or ref + * @param on {boolean} hide or show. If true, show + * @private */ + _hideShowEl = function(id, on) { + var el = (lang.isString(id) ? this.getElement(id) : id); + //Dom.setStyle(id, "visibility", (on) ? "" : "hidden"); + Dom.setStyle(el, "display", (on) ? "" : "none"); + }; + + /** + * Hide/show the entire set of controls + * @config showcontrols + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_CONTROLS, { + value: (attr.showcontrols) || true, + method: function(on) { + + var el = Dom.getElementsByClassName("bd", "div", + this.getElement(this.ID.CONTROLS))[0]; + + _hideShowEl.call(this, el, on); + + this.getElement(this.ID.CONTROLS_LABEL).innerHTML = + (on) ? this.get(this.OPT.TXT).HIDE_CONTROLS : + this.get(this.OPT.TXT).SHOW_CONTROLS; + + } + }); + + /** + * Hide/show the rgb controls + * @config showrgbcontrols + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS, { + value: (attr.showrgbcontrols) || true, + method: function(on) { + //Dom.setStyle(this.getElement(this.ID.RBG_CONTROLS), "visibility", (on) ? "" : "hidden"); + _hideShowEl.call(this, this.ID.RGB_CONTROLS, on); + } + }); + + /** + * Hide/show the hsv controls + * @config showhsvcontrols + * @type boolean + * @default false + */ + this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS, { + value: (attr.showhsvcontrols) || false, + method: function(on) { + //Dom.setStyle(this.getElement(this.ID.HSV_CONTROLS), "visibility", (on) ? "" : "hidden"); + _hideShowEl.call(this, this.ID.HSV_CONTROLS, on); + + // can't show both the hsv controls and the rbg hex summary + if (on && this.get(this.OPT.SHOW_HEX_SUMMARY)) { + this.set(this.OPT.SHOW_HEX_SUMMARY, false); + } + } + }); + + /** + * Hide/show the hex controls + * @config showhexcontrols + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS, { + value: (attr.showhexcontrols) || false, + method: function(on) { + _hideShowEl.call(this, this.ID.HEX_CONTROLS, on); + } + }); + + /** + * Hide/show the websafe swatch + * @config showwebsafe + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_WEBSAFE, { + value: (attr.showwebsafe) || true, + method: function(on) { + _hideShowEl.call(this, this.ID.WEBSAFE_SWATCH, on); + } + }); + + /** + * Hide/show the hex summary + * @config showhexsummary + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY, { + value: (attr.showhexsummary) || true, + method: function(on) { + _hideShowEl.call(this, this.ID.HEX_SUMMARY, on); + + // can't show both the hsv controls and the rbg hex summary + if (on && this.get(this.OPT.SHOW_HSV_CONTROLS)) { + this.set(this.OPT.SHOW_HSV_CONTROLS, false); + } + } + }); + this.setAttributeConfig(this.OPT.ANIMATE, { + value: (attr.animate) || true, + method: function(on) { + this.pickerSlider.animate = on; + this.hueSlider.animate = on; + } + }); + + this.on(this.OPT.HUE + "Change", _updateRGBFromHSV, this, true); + this.on(this.OPT.SATURATION + "Change", _updateRGBFromHSV, this, true); + this.on(this.OPT.VALUE + "Change", _updatePickerSlider, this, true); + + this.on(this.OPT.RED + "Change", _updateRGB, this, true); + this.on(this.OPT.GREEN + "Change", _updateRGB, this, true); + this.on(this.OPT.BLUE + "Change", _updateRGB, this, true); + + this.on(this.OPT.HEX + "Change", _updateHex, this, true); + + this.initPicker(); + }; + + /** + * Updates the rgb attribute with the current state of the r,g,b + * fields. This is invoked from change listeners on these + * attributes to facilitate updating these values from the + * individual form fields + * @method _updateRGB + * @private + */ + var _updateRGB = function() { + var rgb = [this.get(this.OPT.RED), + this.get(this.OPT.GREEN), + this.get(this.OPT.BLUE)]; + + this.logger.log("RGB value set to " + rgb); + this.set(this.OPT.RGB, rgb); + + _updateSliders.call(this); + }; + + /** + * Updates the RGB values from the current state of the HSV + * values. Executed when the one of the HSV form fields are + * updated + * _updateRGBFromHSV + * @private + */ + var _updateRGBFromHSV = function() { + var hsv = [this.get(this.OPT.HUE), + this.get(this.OPT.SATURATION)/100, + this.get(this.OPT.VALUE)/100]; + + var rgb = Color.hsv2rgb(hsv); + + this.logger.log("HSV converted to RGB " + hsv + " : " + rgb); + this.set(this.OPT.RGB, rgb); + + _updateSliders.call(this); + }; + + /** + * Parses the hex string to normalize shorthand values, converts + * the hex value to rgb and updates the rgb attribute (which + * updates the state for all of the other values) + * method _updateHex + * @private + */ + var _updateHex = function() { + + var hex = this.get(this.OPT.HEX), l=hex.length; + + // support #369 -> #336699 shorthand + if (l === 3) { + var c = hex.split(""), i; + for (i=0; i255||n<0)?0:n;return HCHARS.charAt((n-n%16)/16)+HCHARS.charAt(n%16);},hex2dec:function(str){var f=function(c){return HCHARS.indexOf(c.toUpperCase());};var s=str.split('');return((f(s[0])*16)+f(s[1]));},hex2rgb:function(s){var f=this.hex2dec;return[f(s.substr(0,2)),f(s.substr(2,2)),f(s.substr(4,2))];},websafe:function(r,g,b){if(lang.isArray(r)){return this.websafe.call(this,r[0],r[1],r[2]);} +var f=function(v){if(lang.isNumber(v)){v=Math.min(Math.max(0,v),255);var i,next;for(i=0;i<256;i=i+51){next=i+51;if(v>=i&&v<=next){return(v-i>25)?next:i;}}} +return v;};return[f(r),f(g),f(b)];}};}();(function(){var pickercount=0;YAHOO.widget.ColorPicker=function(el,attr){pickercount=pickercount+1;attr=attr||{};if(arguments.length===1&&!YAHOO.lang.isString(el)&&!el.nodeName){attr=el;el=attr.element||null;} +if(!el&&!attr.element){el=_createHostElement.call(this,attr);} +YAHOO.widget.ColorPicker.superclass.constructor.call(this,el,attr);};YAHOO.extend(YAHOO.widget.ColorPicker,YAHOO.util.Element);var proto=YAHOO.widget.ColorPicker.prototype,Slider=YAHOO.widget.Slider,Color=YAHOO.util.Color,Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,lang=YAHOO.lang,sub=lang.substitute;var b="yui-picker";proto.ID={R:b+"-r",R_HEX:b+"-rhex",G:b+"-g",G_HEX:b+"-ghex",B:b+"-b",B_HEX:b+"-bhex",H:b+"-h",S:b+"-s",V:b+"-v",PICKER_BG:b+"-bg",PICKER_THUMB:b+"-thumb",HUE_BG:b+"-hue-bg",HUE_THUMB:b+"-hue-thumb",HEX:b+"-hex",SWATCH:b+"-swatch",WEBSAFE_SWATCH:b+"-websafe-swatch",CONTROLS:b+"-controls",RGB_CONTROLS:b+"-rgb-controls",HSV_CONTROLS:b+"-hsv-controls",HEX_CONTROLS:b+"-hex-controls",HEX_SUMMARY:b+"-hex-summary",CONTROLS_LABEL:b+"-controls-label"};proto.TXT={ILLEGAL_HEX:"Illegal hex value entered",SHOW_CONTROLS:"Show color details",HIDE_CONTROLS:"Hide color details",CURRENT_COLOR:"Currently selected color: {rgb}",CLOSEST_WEBSAFE:"Closest websafe color: {rgb}. Click to select.",R:"R",G:"G",B:"B",H:"H",S:"S",V:"V",HEX:"#",DEG:"\u00B0",PERCENT:"%"};proto.IMAGE={PICKER_THUMB:"../../build/colorpicker/assets/picker_thumb.png",HUE_THUMB:"../../build/colorpicker/assets/hue_thumb.png"};proto.DEFAULT={PICKER_SIZE:180};proto.OPT={HUE:"hue",SATURATION:"saturation",VALUE:"value",RED:"red",GREEN:"green",BLUE:"blue",HSV:"hsv",RGB:"rgb",WEBSAFE:"websafe",HEX:"hex",PICKER_SIZE:"pickersize",SHOW_CONTROLS:"showcontrols",SHOW_RGB_CONTROLS:"showrgbcontrols",SHOW_HSV_CONTROLS:"showhsvcontrols",SHOW_HEX_CONTROLS:"showhexcontrols",SHOW_HEX_SUMMARY:"showhexsummary",SHOW_WEBSAFE:"showwebsafe",CONTAINER:"container",IDS:"ids",ELEMENTS:"elements",TXT:"txt",IMAGES:"images",ANIMATE:"animate"};proto.setValue=function(rgb,silent){silent=(silent)||false;this.set(this.OPT.RGB,rgb,silent);_updateSliders.call(this);};proto.hueSlider=null;proto.pickerSlider=null;var _getH=function(){var size=this.get(this.OPT.PICKER_SIZE),h=(size-this.hueSlider.getValue())/size;h=Math.round(h*360);return(h===360)?0:h;};var _getS=function(){return this.pickerSlider.getXValue()/this.get(this.OPT.PICKER_SIZE);};var _getV=function(){var size=this.get(this.OPT.PICKER_SIZE);return(size-this.pickerSlider.getYValue())/size;};var _updateSwatch=function(){var rgb=this.get(this.OPT.RGB),websafe=this.get(this.OPT.WEBSAFE),el=this.getElement(this.ID.SWATCH),color=rgb.join(","),txt=this.get(this.OPT.TXT);Dom.setStyle(el,"background-color","rgb("+color+")");el.title=lang.substitute(txt.CURRENT_COLOR,{"rgb":"#"+this.get(this.OPT.HEX)});el=this.getElement(this.ID.WEBSAFE_SWATCH);color=websafe.join(",");Dom.setStyle(el,"background-color","rgb("+color+")");el.title=lang.substitute(txt.CLOSEST_WEBSAFE,{"rgb":"#"+Color.rgb2hex(websafe)});};var _getValuesFromSliders=function(){var h=_getH.call(this),s=_getS.call(this),v=_getV.call(this);rgb=Color.hsv2rgb(h,s,v);var websafe=Color.websafe(rgb);var hex=Color.rgb2hex(rgb[0],rgb[1],rgb[2]);this.set(this.OPT.RGB,rgb);};var _updateFormFields=function(){this.getElement(this.ID.H).value=this.get(this.OPT.HUE);this.getElement(this.ID.S).value=this.get(this.OPT.SATURATION);this.getElement(this.ID.V).value=this.get(this.OPT.VALUE);this.getElement(this.ID.R).value=this.get(this.OPT.RED);this.getElement(this.ID.R_HEX).innerHTML=Color.dec2hex(this.get(this.OPT.RED));this.getElement(this.ID.G).value=this.get(this.OPT.GREEN);this.getElement(this.ID.G_HEX).innerHTML=Color.dec2hex(this.get(this.OPT.GREEN));this.getElement(this.ID.B).value=this.get(this.OPT.BLUE);this.getElement(this.ID.B_HEX).innerHTML=Color.dec2hex(this.get(this.OPT.BLUE));this.getElement(this.ID.HEX).value=this.get(this.OPT.HEX);};var _onHueSliderChange=function(newOffset){var h=_getH.call(this);this.set(this.OPT.HUE,h,true);var rgb=Color.hsv2rgb(h,1,1);var styleDef="rgb("+rgb.join(",")+")";Dom.setStyle(this.getElement(this.ID.PICKER_BG),"background-color",styleDef);if(this.hueSlider.valueChangeSource===this.hueSlider.SOURCE_UI_EVENT){_getValuesFromSliders.call(this);} +_updateFormFields.call(this);_updateSwatch.call(this);};var _onPickerSliderChange=function(newOffset){var s=_getS.call(this),v=_getV.call(this);this.set(this.OPT.SATURATION,Math.round(s*100),true);this.set(this.OPT.VALUE,Math.round(v*100),true);if(this.pickerSlider.valueChangeSource===this.pickerSlider.SOURCE_UI_EVENT){_getValuesFromSliders.call(this);} +_updateFormFields.call(this);_updateSwatch.call(this);};var _getCommand=function(e){var c=Event.getCharCode(e);if(c===38){return 3;}else if(c===13){return 6;}else if(c===40){return 4;}else if(c>=48&&c<=57){return 1;}else if(c>=97&&c<=102){return 2;}else if(c>=65&&c<=70){return 2;}else if("8, 9, 13, 27, 37, 39".indexOf(c)>-1){return 5;}else{return 0;}};var _rgbFieldKeypress=function(e,el,prop){var command=_getCommand(e);var inc=(e.shiftKey)?10:1;switch(command){case 6:_useFieldValue.apply(this,arguments);break;case 3:this.set(prop,Math.min(this.get(prop)+inc,255));_updateFormFields.call(this);break;case 4:this.set(prop,Math.max(this.get(prop)-inc,0));_updateFormFields.call(this);break;default:}};var _hexFieldKeypress=function(e,el,prop){var command=_getCommand(e);if(command===6){_useFieldValue.apply(this,arguments);}};var _useFieldValue=function(e,el,prop){var val=el.value;if(prop!==this.OPT.HEX){val=parseInt(val,10);} +if(val!==this.get(prop)){this.set(prop,val);}};var _numbersOnly=function(e){return _hexOnly(e,true);};var _hexOnly=function(e,numbersOnly){var command=_getCommand(e);switch(command){case 6:case 5:case 1:break;case 2:if(numbersOnly!==true){break;} +default:Event.stopEvent(e);return false;}};proto.getElement=function(id){return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[id]];};_createElements=function(){var el,child,img,fld,i,ids=this.get(this.OPT.IDS),txt=this.get(this.OPT.TXT),images=this.get(this.OPT.IMAGES),Elem=function(type,o){var n=document.createElement(type);if(o){lang.augmentObject(n,o,true);} +return n;},RGBElem=function(type,obj){var o=lang.merge({autocomplete:"off",value:"0",size:3,maxlength:3},obj);o.name=o.id;return new Elem(type,o);};var p=this.get("element");el=new Elem("div",{id:ids[this.ID.PICKER_BG],className:"yui-picker-bg",tabIndex:-1,hideFocus:true});child=new Elem("div",{id:ids[this.ID.PICKER_THUMB],className:"yui-picker-thumb"});img=new Elem("img",{src:images.PICKER_THUMB});child.appendChild(img);el.appendChild(child);p.appendChild(el);el=new Elem("div",{id:ids[this.ID.HUE_BG],className:"yui-picker-hue-bg",tabIndex:-1,hideFocus:true});child=new Elem("div",{id:ids[this.ID.HUE_THUMB],className:"yui-picker-hue-thumb"});img=new Elem("img",{src:images.HUE_THUMB});child.appendChild(img);el.appendChild(child);p.appendChild(el);el=new Elem("div",{id:ids[this.ID.CONTROLS],className:"yui-picker-controls"});p.appendChild(el);p=el;el=new Elem("div",{className:"hd"});child=new Elem("a",{id:ids[this.ID.CONTROLS_LABEL],href:"#"});el.appendChild(child);p.appendChild(el);el=new Elem("div",{className:"bd"});p.appendChild(el);p=el;el=new Elem("ul",{id:ids[this.ID.RGB_CONTROLS],className:"yui-picker-rgb-controls"});child=new Elem("li");child.appendChild(document.createTextNode(txt.R+" "));fld=new RGBElem("input",{id:ids[this.ID.R],className:"yui-picker-r"});child.appendChild(fld);el.appendChild(child);child=new Elem("li");child.appendChild(document.createTextNode(txt.G+" "));fld=new RGBElem("input",{id:ids[this.ID.G],className:"yui-picker-g"});child.appendChild(fld);el.appendChild(child);child=new Elem("li");child.appendChild(document.createTextNode(txt.B+" "));fld=new RGBElem("input",{id:ids[this.ID.B],className:"yui-picker-b"});child.appendChild(fld);el.appendChild(child);p.appendChild(el);el=new Elem("ul",{id:ids[this.ID.HSV_CONTROLS],className:"yui-picker-hsv-controls"});child=new Elem("li");child.appendChild(document.createTextNode(txt.H+" "));fld=new RGBElem("input",{id:ids[this.ID.H],className:"yui-picker-h"});child.appendChild(fld);child.appendChild(document.createTextNode(" "+txt.DEG));el.appendChild(child);child=new Elem("li");child.appendChild(document.createTextNode(txt.S+" "));fld=new RGBElem("input",{id:ids[this.ID.S],className:"yui-picker-s"});child.appendChild(fld);child.appendChild(document.createTextNode(" "+txt.PERCENT));el.appendChild(child);child=new Elem("li");child.appendChild(document.createTextNode(txt.V+" "));fld=new RGBElem("input",{id:ids[this.ID.V],className:"yui-picker-v"});child.appendChild(fld);child.appendChild(document.createTextNode(" "+txt.PERCENT));el.appendChild(child);p.appendChild(el);el=new Elem("ul",{id:ids[this.ID.HEX_SUMMARY],className:"yui-picker-hex_summary"});child=new Elem("li",{id:ids[this.ID.R_HEX]});el.appendChild(child);child=new Elem("li",{id:ids[this.ID.G_HEX]});el.appendChild(child);child=new Elem("li",{id:ids[this.ID.B_HEX]});el.appendChild(child);p.appendChild(el);el=new Elem("div",{id:ids[this.ID.HEX_CONTROLS],className:"yui-picker-hex-controls"});el.appendChild(document.createTextNode(txt.HEX+" "));child=new RGBElem("input",{id:ids[this.ID.HEX],className:"yui-picker-hex",size:6,maxlength:6});el.appendChild(child);p.appendChild(el);p=this.get("element");el=new Elem("div",{id:ids[this.ID.SWATCH],className:"yui-picker-swatch"});p.appendChild(el);el=new Elem("div",{id:ids[this.ID.WEBSAFE_SWATCH],className:"yui-picker-websafe-swatch"});p.appendChild(el);};proto.initPicker=function(){var o=this.OPT,ids=this.get(o.IDS),els=this.get(o.ELEMENTS),i,el,id;for(i in this.ID){if(lang.hasOwnProperty(this.ID,i)){ids[this.ID[i]]=ids[i];}} +el=Dom.get(ids[this.ID.PICKER_BG]);if(!el){_createElements.call(this);}else{} +for(i in ids){if(lang.hasOwnProperty(ids,i)){el=Dom.get(ids[i]);id=Dom.generateId(el);ids[i]=id;ids[ids[i]]=id;els[id]=el;}} +els=[o.SHOW_CONTROLS,o.SHOW_RGB_CONTROLS,o.SHOW_HSV_CONTROLS,o.SHOW_HEX_CONTROLS,o.SHOW_HEX_SUMMARY,o.SHOW_WEBSAFE];for(i=0;i1){for(var i in ids){if(lang.hasOwnProperty(ids,i)){ids[i]=ids[i]+pickercount;}}} +this.setAttributeConfig(this.OPT.IDS,{value:ids,writeonce:true});this.setAttributeConfig(this.OPT.TXT,{value:attr.txt||this.TXT,writeonce:true});this.setAttributeConfig(this.OPT.IMAGES,{value:attr.images||this.IMAGE,writeonce:true});this.setAttributeConfig(this.OPT.ELEMENTS,{value:{},readonly:true});_hideShowEl=function(id,on){var el=(lang.isString(id)?this.getElement(id):id);Dom.setStyle(el,"display",(on)?"":"none");};this.setAttributeConfig(this.OPT.SHOW_CONTROLS,{value:(attr.showcontrols)||true,method:function(on){var el=Dom.getElementsByClassName("bd","div",this.getElement(this.ID.CONTROLS))[0];_hideShowEl.call(this,el,on);this.getElement(this.ID.CONTROLS_LABEL).innerHTML=(on)?this.get(this.OPT.TXT).HIDE_CONTROLS:this.get(this.OPT.TXT).SHOW_CONTROLS;}});this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS,{value:(attr.showrgbcontrols)||true,method:function(on){_hideShowEl.call(this,this.ID.RGB_CONTROLS,on);}});this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS,{value:(attr.showhsvcontrols)||false,method:function(on){_hideShowEl.call(this,this.ID.HSV_CONTROLS,on);if(on&&this.get(this.OPT.SHOW_HEX_SUMMARY)){this.set(this.OPT.SHOW_HEX_SUMMARY,false);}}});this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS,{value:(attr.showhexcontrols)||false,method:function(on){_hideShowEl.call(this,this.ID.HEX_CONTROLS,on);}});this.setAttributeConfig(this.OPT.SHOW_WEBSAFE,{value:(attr.showwebsafe)||true,method:function(on){_hideShowEl.call(this,this.ID.WEBSAFE_SWATCH,on);}});this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY,{value:(attr.showhexsummary)||true,method:function(on){_hideShowEl.call(this,this.ID.HEX_SUMMARY,on);if(on&&this.get(this.OPT.SHOW_HSV_CONTROLS)){this.set(this.OPT.SHOW_HSV_CONTROLS,false);}}});this.setAttributeConfig(this.OPT.ANIMATE,{value:(attr.animate)||true,method:function(on){this.pickerSlider.animate=on;this.hueSlider.animate=on;}});this.on(this.OPT.HUE+"Change",_updateRGBFromHSV,this,true);this.on(this.OPT.SATURATION+"Change",_updateRGBFromHSV,this,true);this.on(this.OPT.VALUE+"Change",_updatePickerSlider,this,true);this.on(this.OPT.RED+"Change",_updateRGB,this,true);this.on(this.OPT.GREEN+"Change",_updateRGB,this,true);this.on(this.OPT.BLUE+"Change",_updateRGB,this,true);this.on(this.OPT.HEX+"Change",_updateHex,this,true);this.initPicker();};var _updateRGB=function(){var rgb=[this.get(this.OPT.RED),this.get(this.OPT.GREEN),this.get(this.OPT.BLUE)];this.set(this.OPT.RGB,rgb);_updateSliders.call(this);};var _updateRGBFromHSV=function(){var hsv=[this.get(this.OPT.HUE),this.get(this.OPT.SATURATION)/100,this.get(this.OPT.VALUE)/100];var rgb=Color.hsv2rgb(hsv);this.set(this.OPT.RGB,rgb);_updateSliders.call(this);};var _updateHex=function(){var hex=this.get(this.OPT.HEX),l=hex.length;if(l===3){var c=hex.split(""),i;for(i=0;i FFFFFF + * @method rgb2hex + * @param r {int|[int, int, int]} the red value, or an + * array containing all three parameters + * @param g {int} the green value + * @param b {int} the blue value + * @return {string} the hex string + */ + rgb2hex: function(r, g, b) { + if (lang.isArray(r)) { + return this.rgb2hex.call(this, r[0], r[1], r[2]); + } + + var f=this.dec2hex; + return f(r) + f(g) + f(b); + }, + + /** + * Converts an int 0...255 to hex pair 00...FF + * @method dec2hex + * @param n {int} the number to convert + * @return {string} the hex equivalent + */ + dec2hex: function(n) { + n = parseInt(n, 10); + n = (lang.isNumber(n)) ? n : 0; + n = (n > 255 || n < 0) ? 0 : n; + + return HCHARS.charAt((n - n % 16) / 16) + HCHARS.charAt(n % 16); + }, + + /** + * Converts a hex pair 00...FF to an int 0...255 + * @method hex2dec + * @param str {string} the hex pair to convert + * @return {int} the decimal + */ + hex2dec: function(str) { + var f = function(c) { + return HCHARS.indexOf(c.toUpperCase()); + }; + + var s=str.split(''); + + return ((f(s[0]) * 16) + f(s[1])); + }, + + /** + * Converts a hex string to rgb + * @method hex2rgb + * @param str {string} the hex string + * @return {[int, int, int]} an array containing the rgb values + */ + hex2rgb: function(s) { + var f = this.hex2dec; + return [f(s.substr(0, 2)), f(s.substr(2, 2)), f(s.substr(4, 2))]; + }, + + /** + * Returns the closest websafe color to the supplied rgb value. + * @method websafe + * @param r {int|[int, int, int]} the red value, or an + * array containing all three parameters + * @param g {int} the green value + * @param b {int} the blue value + * @return {[int, int, int]} an array containing the closes + * websafe rgb colors. + */ + websafe: function(r, g, b) { + + if (lang.isArray(r)) { + return this.websafe.call(this, r[0], r[1], r[2]); + } + + // returns the closest match [0, 51, 102, 153, 204, 255] + var f = function(v) { + if (lang.isNumber(v)) { + v = Math.min(Math.max(0, v), 255); + var i, next; + for (i=0; i<256; i=i+51) { + next = i+51; + if (v >= i && v <= next) { + return (v-i > 25) ? next : i; + } + } + } + + return v; + }; + + return [f(r), f(g), f(b)]; + } + }; +}(); + + +(function() { + + var pickercount = 0; + + /** + * The colorpicker module provides a widget for selecting colors + * @module colorpicker + * @requires yahoo, dom, event, element, slider + */ + + /** + * A widget to select colors + * @namespace YAHOO.widget + * @class YAHOO.widget.ColorPicker + * @extends YAHOO.util.Element + * @constructor + * @param {HTMLElement | String | Object} el(optional) The html + * element that represents the colorpicker, or the attribute object to use. + * An element will be created if none provided. + * @param {Object} attr (optional) A key map of the colorpicker's + * initial attributes. Ignored if first arg is attributes object. + */ + YAHOO.widget.ColorPicker = function(el, attr) { + pickercount = pickercount + 1; + attr = attr || {}; + if (arguments.length === 1 && !YAHOO.lang.isString(el) && !el.nodeName) { + attr = el; // treat first arg as attr object + el = attr.element || null; + } + + if (!el && !attr.element) { // create if we dont have one + el = _createHostElement.call(this, attr); + } + + YAHOO.widget.ColorPicker.superclass.constructor.call(this, el, attr); + }; + + YAHOO.extend(YAHOO.widget.ColorPicker, YAHOO.util.Element); + + var proto = YAHOO.widget.ColorPicker.prototype, + Slider=YAHOO.widget.Slider, + Color=YAHOO.util.Color, + Dom = YAHOO.util.Dom, + Event = YAHOO.util.Event, + lang = YAHOO.lang, + sub = lang.substitute; + + + var b = "yui-picker"; + + /** + * The element ids used by this control + * @property ID + * @final + */ + proto.ID = { + + /** + * The id for the "red" form field + * @property ID.R + * @type String + * @final + * @default yui-picker-r + */ + R: b + "-r", + + /** + * The id for the "red" hex pair output + * @property ID.R_HEX + * @type String + * @final + * @default yui-picker-rhex + */ + R_HEX: b + "-rhex", + + /** + * The id for the "green" form field + * @property ID.G + * @type String + * @final + * @default yui-picker-g + */ + G: b + "-g", + + /** + * The id for the "green" hex pair output + * @property ID.G_HEX + * @type String + * @final + * @default yui-picker-ghex + */ + G_HEX: b + "-ghex", + + + /** + * The id for the "blue" form field + * @property ID.B + * @type String + * @final + * @default yui-picker-b + */ + B: b + "-b", + + /** + * The id for the "blue" hex pair output + * @property ID.B_HEX + * @type String + * @final + * @default yui-picker-bhex + */ + B_HEX: b + "-bhex", + + /** + * The id for the "hue" form field + * @property ID.H + * @type String + * @final + * @default yui-picker-h + */ + H: b + "-h", + + /** + * The id for the "saturation" form field + * @property ID.S + * @type String + * @final + * @default yui-picker-s + */ + S: b + "-s", + + /** + * The id for the "value" form field + * @property ID.V + * @type String + * @final + * @default yui-picker-v + */ + V: b + "-v", + + /** + * The id for the picker region slider + * @property ID.PICKER_BG + * @type String + * @final + * @default yui-picker-bg + */ + PICKER_BG: b + "-bg", + + /** + * The id for the picker region thumb + * @property ID.PICKER_THUMB + * @type String + * @final + * @default yui-picker-thumb + */ + PICKER_THUMB: b + "-thumb", + + /** + * The id for the hue slider + * @property ID.HUE_BG + * @type String + * @final + * @default yui-picker-hue-bg + */ + HUE_BG: b + "-hue-bg", + + /** + * The id for the hue thumb + * @property ID.HUE_THUMB + * @type String + * @final + * @default yui-picker-hue-thumb + */ + HUE_THUMB: b + "-hue-thumb", + + /** + * The id for the hex value form field + * @property ID.HEX + * @type String + * @final + * @default yui-picker-hex + */ + HEX: b + "-hex", + + /** + * The id for the color swatch + * @property ID.SWATCH + * @type String + * @final + * @default yui-picker-swatch + */ + SWATCH: b + "-swatch", + + /** + * The id for the websafe color swatch + * @property ID.WEBSAFE_SWATCH + * @type String + * @final + * @default yui-picker-websafe-swatch + */ + WEBSAFE_SWATCH: b + "-websafe-swatch", + + /** + * The id for the control details + * @property ID.CONTROLS + * @final + * @default yui-picker-controls + */ + CONTROLS: b + "-controls", + + /** + * The id for the rgb controls + * @property ID.RGB_CONTROLS + * @final + * @default yui-picker-rgb-controls + */ + RGB_CONTROLS: b + "-rgb-controls", + + /** + * The id for the hsv controls + * @property ID.HSV_CONTROLS + * @final + * @default yui-picker-hsv-controls + */ + HSV_CONTROLS: b + "-hsv-controls", + + /** + * The id for the hsv controls + * @property ID.HEX_CONTROLS + * @final + * @default yui-picker-hex-controls + */ + HEX_CONTROLS: b + "-hex-controls", + + /** + * The id for the hex summary + * @property ID.HEX_SUMMARY + * @final + * @default yui-picker-hex-summary + */ + HEX_SUMMARY: b + "-hex-summary", + + /** + * The id for the controls section header + * @property ID.CONTROLS_LABEL + * @final + * @default yui-picker-controls-label + */ + CONTROLS_LABEL: b + "-controls-label" + }; + + /** + * Constants for any script-generated messages. The values here + * are the default messages. They can be updated by providing + * the complete list to the constructor for the "txt" attribute. + * @property TXT + * @final + */ + proto.TXT = { + ILLEGAL_HEX: "Illegal hex value entered", + SHOW_CONTROLS: "Show color details", + HIDE_CONTROLS: "Hide color details", + CURRENT_COLOR: "Currently selected color: {rgb}", + CLOSEST_WEBSAFE: "Closest websafe color: {rgb}. Click to select.", + R: "R", + G: "G", + B: "B", + H: "H", + S: "S", + V: "V", + HEX: "#", + DEG: "\u00B0", + PERCENT: "%" + }; + + /** + * Constants for the default image locations for img tags that are + * generated by the control. They can be modified by passing the + * complete list to the contructor for the "images" attribute + * @property IMAGE + * @final + */ + proto.IMAGE = { + PICKER_THUMB: "../../build/colorpicker/assets/picker_thumb.png", + HUE_THUMB: "../../build/colorpicker/assets/hue_thumb.png" + }; + + /* + * Constants for the control's custom event names. subscribe + * to the rgbChange event instead. + * @property EVENT + * @final + */ + //proto.EVENT = { + //CHANGE: "change" + //}; + + //proto.CSS = { }; + + /** + * Constants for the control's default default values + * @property DEFAULT + * @final + */ + proto.DEFAULT = { + PICKER_SIZE: 180 + }; + + /** + * Constants for the control's configuration attributes + * @property OPT + * @final + */ + proto.OPT = { + HUE: "hue", + SATURATION: "saturation", + VALUE: "value", + RED: "red", + GREEN: "green", + BLUE: "blue", + HSV: "hsv", + RGB: "rgb", + WEBSAFE: "websafe", + HEX: "hex", + PICKER_SIZE: "pickersize", + SHOW_CONTROLS: "showcontrols", + SHOW_RGB_CONTROLS: "showrgbcontrols", + SHOW_HSV_CONTROLS: "showhsvcontrols", + SHOW_HEX_CONTROLS: "showhexcontrols", + SHOW_HEX_SUMMARY: "showhexsummary", + SHOW_WEBSAFE: "showwebsafe", + //SHOW_SUBMIT: "showsubmit", + CONTAINER: "container", + IDS: "ids", + ELEMENTS: "elements", + TXT: "txt", + IMAGES: "images", + ANIMATE: "animate" + }; + + /** + * Sets the control to the specified rgb value and + * moves the sliders to the proper positions + * @method setValue + * @param rgb {[int, int, int]} the rgb value + * @param silent {boolean} whether or not to fire the change event + */ + proto.setValue = function(rgb, silent) { + silent = (silent) || false; + this.set(this.OPT.RGB, rgb, silent); + _updateSliders.call(this); + }; + + /** + * The hue slider + * @property hueSlider + * @type YAHOO.widget.Slider + */ + proto.hueSlider = null; + + /** + * The picker region + * @property pickerSlider + * @type YAHOO.widget.Slider + */ + proto.pickerSlider = null; + + /** + * Translates the slider value into hue, int[0,359] + * @method _getH + * @private + * @return {int} the hue from 0 to 359 + */ + var _getH = function() { + var size = this.get(this.OPT.PICKER_SIZE), + h = (size - this.hueSlider.getValue()) / size; + h = Math.round(h*360); + return (h === 360) ? 0 : h; + }; + + /** + * Translates the slider value into saturation, int[0,1], left to right + * @method _getS + * @private + * @return {int} the saturation from 0 to 1 + */ + var _getS = function() { + return this.pickerSlider.getXValue() / this.get(this.OPT.PICKER_SIZE); + }; + + /** + * Translates the slider value into value/brightness, int[0,1], top + * to bottom + * @method _getV + * @private + * @return {int} the value from 0 to 1 + */ + var _getV = function() { + var size = this.get(this.OPT.PICKER_SIZE); + return (size - this.pickerSlider.getYValue()) / size; + }; + + /** + * Updates the background of the swatch with the current rbg value. + * Also updates the websafe swatch to the closest websafe color + * @method _updateSwatch + * @private + */ + var _updateSwatch = function() { + var rgb = this.get(this.OPT.RGB), + websafe = this.get(this.OPT.WEBSAFE), + el = this.getElement(this.ID.SWATCH), + color = rgb.join(","), + txt = this.get(this.OPT.TXT); + + Dom.setStyle(el, "background-color", "rgb(" + color + ")"); + el.title = lang.substitute(txt.CURRENT_COLOR, { + "rgb": "#" + this.get(this.OPT.HEX) + }); + + + el = this.getElement(this.ID.WEBSAFE_SWATCH); + color = websafe.join(","); + + Dom.setStyle(el, "background-color", "rgb(" + color + ")"); + el.title = lang.substitute(txt.CLOSEST_WEBSAFE, { + "rgb": "#" + Color.rgb2hex(websafe) + }); + + }; + + /** + * Reads the sliders and converts the values to RGB, updating the + * internal state for all the individual form fields + * @method _getValuesFromSliders + * @private + */ + var _getValuesFromSliders = function() { + var h=_getH.call(this), s=_getS.call(this), v=_getV.call(this); + + rgb = Color.hsv2rgb(h, s, v); + var websafe = Color.websafe(rgb); + var hex = Color.rgb2hex(rgb[0], rgb[1], rgb[2]); + + this.set(this.OPT.RGB, rgb); + }; + + /** + * Updates the form field controls with the state data contained + * in the control. + * @method _updateFormFields + * @private + */ + var _updateFormFields = function() { + this.getElement(this.ID.H).value = this.get(this.OPT.HUE); + this.getElement(this.ID.S).value = this.get(this.OPT.SATURATION); + this.getElement(this.ID.V).value = this.get(this.OPT.VALUE); + this.getElement(this.ID.R).value = this.get(this.OPT.RED); + this.getElement(this.ID.R_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.RED)); + this.getElement(this.ID.G).value = this.get(this.OPT.GREEN); + this.getElement(this.ID.G_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.GREEN)); + this.getElement(this.ID.B).value = this.get(this.OPT.BLUE); + this.getElement(this.ID.B_HEX).innerHTML = Color.dec2hex(this.get(this.OPT.BLUE)); + this.getElement(this.ID.HEX).value = this.get(this.OPT.HEX); + }; + + /** + * Event handler for the hue slider. + * @method _onHueSliderChange + * @param newOffset {int} pixels from the start position + * @private + */ + var _onHueSliderChange = function(newOffset) { + + var h = _getH.call(this); + this.set(this.OPT.HUE, h, true); + + // set picker background to the hue + var rgb = Color.hsv2rgb(h, 1, 1); + var styleDef = "rgb(" + rgb.join(",") + ")"; + + Dom.setStyle(this.getElement(this.ID.PICKER_BG), "background-color", styleDef); + + if (this.hueSlider.valueChangeSource === this.hueSlider.SOURCE_UI_EVENT) { + _getValuesFromSliders.call(this); + } + + _updateFormFields.call(this); + _updateSwatch.call(this); + }; + + /** + * Event handler for the picker slider, which controls the + * saturation and value/brightness. + * @method _onPickerSliderChange + * @param newOffset {{x: int, y: int}} x/y pixels from the start position + * @private + */ + var _onPickerSliderChange = function(newOffset) { + + var s=_getS.call(this), v=_getV.call(this); + this.set(this.OPT.SATURATION, Math.round(s*100), true); + this.set(this.OPT.VALUE, Math.round(v*100), true); + + if (this.pickerSlider.valueChangeSource === this.pickerSlider.SOURCE_UI_EVENT) { + _getValuesFromSliders.call(this); + } + + _updateFormFields.call(this); + _updateSwatch.call(this); + }; + + + /** + * Key map to well-known commands for txt field input + * @method _getCommand + * @param e {Event} the keypress or keydown event + * @return {int} a command code + *
    + *
  • 0 = not a number, letter in range, or special key
  • + *
  • 1 = number
  • + *
  • 2 = a-fA-F
  • + *
  • 3 = increment (up arrow)
  • + *
  • 4 = decrement (down arrow)
  • + *
  • 5 = special key (tab, delete, return, escape, left, right)
  • + *
  • 6 = return
  • + *
+ * @private + */ + var _getCommand = function(e) { + var c = Event.getCharCode(e); + + //alert(Event.getCharCode(e) + ", " + e.keyCode + ", " + e.charCode); + + // special keys + if (c === 38) { // up arrow + return 3; + } else if (c === 13) { // return + return 6; + } else if (c === 40) { // down array + return 4; + } else if (c >= 48 && c<=57) { // 0-9 + return 1; + } else if (c >= 97 && c<=102) { // a-f + return 2; + } else if (c >= 65 && c<=70) { // A-F + return 2; + //} else if ("8, 9, 13, 27, 37, 39".indexOf(c) > -1 || + // (c >= 112 && c <=123)) { // including F-keys + // tab, delete, return, escape, left, right + } else if ("8, 9, 13, 27, 37, 39".indexOf(c) > -1) { // special chars + return 5; + } else { // something we probably don't want + return 0; + } + }; + + /** + * Handle keypress on one of the rgb or hsv fields. + * @method _rgbFieldKeypress + * @param e {Event} the keypress event + * @param el {HTMLElement} the field + * @param prop {string} the key to the linked property + * @private + */ + var _rgbFieldKeypress = function(e, el, prop) { + var command = _getCommand(e); + var inc = (e.shiftKey) ? 10 : 1; + switch (command) { + case 6: // return, update the value + _useFieldValue.apply(this, arguments); + break; + + case 3: // up arrow, increment + this.set(prop, Math.min(this.get(prop)+inc, 255)); + _updateFormFields.call(this); + //Event.stopEvent(e); + break; + case 4: // down arrow, decrement + this.set(prop, Math.max(this.get(prop)-inc, 0)); + _updateFormFields.call(this); + //Event.stopEvent(e); + break; + + default: + } + + }; + + /** + * Handle keydown on the hex field + * @method _hexFieldKeypress + * @param e {Event} the keypress event + * @param el {HTMLElement} the field + * @param prop {string} the key to the linked property + * @private + */ + var _hexFieldKeypress = function(e, el, prop) { + var command = _getCommand(e); + if (command === 6) { // return, update the value + _useFieldValue.apply(this, arguments); + } + }; + + /** + * Use the value of the text field to update the control + * @method _hexFieldKeypress + * @param e {Event} an event + * @param el {HTMLElement} the field + * @param prop {string} the key to the linked property + * @private + */ + var _useFieldValue = function(e, el, prop) { + var val = el.value; + + if (prop !== this.OPT.HEX) { + val = parseInt(val, 10); + } + + if (val !== this.get(prop)) { + this.set(prop, val); + } + }; + + /** + * Allows numbers and special chars only. Used for the + * rgb and hsv fields keypress handler. + * @method _numbersOnly + * @param e {Event} the event + * @private + * @return {boolean} false if we are canceling the event + */ + var _numbersOnly = function(e) { + return _hexOnly(e, true); + }; + + /** + * Allows numbers and special chars, and by default allows a-f. + * Used for the hex field keypress handler. + * @method _hexOnly + * @param e {Event} the event + * @param numbersOnly omits a-f if set to true + * @private + * @return {boolean} false if we are canceling the event + */ + var _hexOnly = function(e, numbersOnly) { + var command = _getCommand(e); + switch (command) { + case 6: // return + case 5: // special char + case 1: // number + break; + case 2: // hex char (a-f) + if (numbersOnly !== true) { + break; + } + + // fallthrough is intentional + + default: // prevent alpha and punctuation + Event.stopEvent(e); + return false; + } + }; + + /** + * Returns the element reference that is saved. The id can be either + * the element id, or the key for this id in the "id" config attribute. + * For instance, the host element id can be obtained by passing its + * id (default: "yui_picker") or by its key "YUI_PICKER". + * @param id {string} the element id, or key + * @return {HTMLElement} a reference to the element + */ + proto.getElement = function(id) { + return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[id]]; + }; + + _createElements = function() { + var el, child, img, fld, i, + ids = this.get(this.OPT.IDS), + txt = this.get(this.OPT.TXT), + images = this.get(this.OPT.IMAGES), + Elem = function(type, o) { + var n = document.createElement(type); + if (o) { + lang.augmentObject(n, o, true); + } + return n; + }, + RGBElem = function(type, obj) { + var o = lang.merge({ + //type: "txt", + autocomplete: "off", + value: "0", + size: 3, + maxlength: 3 + }, obj); + + o.name = o.id; + return new Elem(type, o); + }; + + var p = this.get("element"); + + // Picker slider (S and V) --------------------------------------------- + + el = new Elem("div", { + id: ids[this.ID.PICKER_BG], + className: "yui-picker-bg", + tabIndex: -1, + hideFocus: true + }); + + child = new Elem("div", { + id: ids[this.ID.PICKER_THUMB], + className: "yui-picker-thumb" + }); + + img = new Elem("img", { + src: images.PICKER_THUMB + }); + + child.appendChild(img); + el.appendChild(child); + p.appendChild(el); + + // Hue slider --------------------------------------------- + el = new Elem("div", { + id: ids[this.ID.HUE_BG], + className: "yui-picker-hue-bg", + tabIndex: -1, + hideFocus: true + }); + + child = new Elem("div", { + id: ids[this.ID.HUE_THUMB], + className: "yui-picker-hue-thumb" + }); + + img = new Elem("img", { + src: images.HUE_THUMB + }); + + child.appendChild(img); + el.appendChild(child); + p.appendChild(el); + + + // controls --------------------------------------------- + + el = new Elem("div", { + id: ids[this.ID.CONTROLS], + className: "yui-picker-controls" + }); + + p.appendChild(el); + p = el; + + // controls header + el = new Elem("div", { + className: "hd" + }); + + child = new Elem("a", { + id: ids[this.ID.CONTROLS_LABEL], + //className: "yui-picker-controls-label", + href: "#" + }); + el.appendChild(child); + p.appendChild(el); + + // bd + el = new Elem("div", { + className: "bd" + }); + + p.appendChild(el); + p = el; + + // rgb + el = new Elem("ul", { + id: ids[this.ID.RGB_CONTROLS], + className: "yui-picker-rgb-controls" + }); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.R + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.R], + className: "yui-picker-r" + }); + + child.appendChild(fld); + el.appendChild(child); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.G + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.G], + className: "yui-picker-g" + }); + + child.appendChild(fld); + el.appendChild(child); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.B + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.B], + className: "yui-picker-b" + }); + + child.appendChild(fld); + el.appendChild(child); + + p.appendChild(el); + + // hsv + el = new Elem("ul", { + id: ids[this.ID.HSV_CONTROLS], + className: "yui-picker-hsv-controls" + }); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.H + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.H], + className: "yui-picker-h" + }); + + child.appendChild(fld); + child.appendChild(document.createTextNode(" " + txt.DEG)); + + el.appendChild(child); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.S + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.S], + className: "yui-picker-s" + }); + + child.appendChild(fld); + child.appendChild(document.createTextNode(" " + txt.PERCENT)); + + el.appendChild(child); + + child = new Elem("li"); + child.appendChild(document.createTextNode(txt.V + " ")); + + fld = new RGBElem("input", { + id: ids[this.ID.V], + className: "yui-picker-v" + }); + + child.appendChild(fld); + child.appendChild(document.createTextNode(" " + txt.PERCENT)); + + el.appendChild(child); + p.appendChild(el); + + + // hex summary + + el = new Elem("ul", { + id: ids[this.ID.HEX_SUMMARY], + className: "yui-picker-hex_summary" + }); + + child = new Elem("li", { + id: ids[this.ID.R_HEX] + }); + el.appendChild(child); + + child = new Elem("li", { + id: ids[this.ID.G_HEX] + }); + el.appendChild(child); + + child = new Elem("li", { + id: ids[this.ID.B_HEX] + }); + el.appendChild(child); + p.appendChild(el); + + // hex field + el = new Elem("div", { + id: ids[this.ID.HEX_CONTROLS], + className: "yui-picker-hex-controls" + }); + el.appendChild(document.createTextNode(txt.HEX + " ")); + + child = new RGBElem("input", { + id: ids[this.ID.HEX], + className: "yui-picker-hex", + size: 6, + maxlength: 6 + }); + + el.appendChild(child); + p.appendChild(el); + + p = this.get("element"); + + // swatch + el = new Elem("div", { + id: ids[this.ID.SWATCH], + className: "yui-picker-swatch" + }); + + p.appendChild(el); + + // websafe swatch + el = new Elem("div", { + id: ids[this.ID.WEBSAFE_SWATCH], + className: "yui-picker-websafe-swatch" + }); + + p.appendChild(el); + + }; + + /** + * Sets the initial state of the sliders + * @method initPicker + */ + proto.initPicker = function () { + + // bind all of our elements + var o=this.OPT, + ids = this.get(o.IDS), + els = this.get(o.ELEMENTS), + i, el, id; + + // Add the default value as a key for each element for easier lookup + for (i in this.ID) { + if (lang.hasOwnProperty(this.ID, i)) { + ids[this.ID[i]] = ids[i]; + } + } + + // Check for picker element, if not there, create all of them + el = Dom.get(ids[this.ID.PICKER_BG]); + if (!el) { + _createElements.call(this); + } else { + } + + for (i in ids) { + if (lang.hasOwnProperty(ids, i)) { + // look for element + el = Dom.get(ids[i]); + + // generate an id if the implementer passed in an element reference, + // and the element did not have an id already + id = Dom.generateId(el); + + // update the id in case we generated the id + ids[i] = id; // key is WEBSAFE_SWATCH + ids[ids[i]] = id; // key is websafe_swatch + + // store the dom ref + els[id] = el; + } + } + + // set the initial visibility state of our controls + els = [o.SHOW_CONTROLS, + o.SHOW_RGB_CONTROLS, + o.SHOW_HSV_CONTROLS, + o.SHOW_HEX_CONTROLS, + o.SHOW_HEX_SUMMARY, + o.SHOW_WEBSAFE + ]; + + for (i=0; i 1) { + for (var i in ids) { + if (lang.hasOwnProperty(ids, i)) { + ids[i] = ids[i] + pickercount; + } + } + } + + + /** + * A list of element ids and/or element references used by the + * control. The default is the this.ID list, and can be customized + * by passing a list in the contructor + * @config ids + * @type {referenceid: realid} + * @writeonce + */ + this.setAttributeConfig(this.OPT.IDS, { + value: ids, + writeonce: true + }); + + /** + * A list of txt strings for internationalization. Default + * is this.TXT + * @config txt + * @type {key: txt} + * @writeonce + */ + this.setAttributeConfig(this.OPT.TXT, { + value: attr.txt || this.TXT, + writeonce: true + }); + + /** + * The img src default list + * is this.IMAGES + * @config images + * @type {key: image} + * @writeonce + */ + this.setAttributeConfig(this.OPT.IMAGES, { + value: attr.images || this.IMAGE, + writeonce: true + }); + /** + * The element refs used by this control. Set at initialization + * @config elements + * @type {id: HTMLElement} + * @readonly + */ + this.setAttributeConfig(this.OPT.ELEMENTS, { + value: {}, + readonly: true + }); + + /** + * Returns the cached element reference. If the id is not a string, it + * is assumed that it is an element and this is returned. + * @param id {string|HTMLElement} the element key, id, or ref + * @param on {boolean} hide or show. If true, show + * @private */ + _hideShowEl = function(id, on) { + var el = (lang.isString(id) ? this.getElement(id) : id); + //Dom.setStyle(id, "visibility", (on) ? "" : "hidden"); + Dom.setStyle(el, "display", (on) ? "" : "none"); + }; + + /** + * Hide/show the entire set of controls + * @config showcontrols + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_CONTROLS, { + value: (attr.showcontrols) || true, + method: function(on) { + + var el = Dom.getElementsByClassName("bd", "div", + this.getElement(this.ID.CONTROLS))[0]; + + _hideShowEl.call(this, el, on); + + this.getElement(this.ID.CONTROLS_LABEL).innerHTML = + (on) ? this.get(this.OPT.TXT).HIDE_CONTROLS : + this.get(this.OPT.TXT).SHOW_CONTROLS; + + } + }); + + /** + * Hide/show the rgb controls + * @config showrgbcontrols + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS, { + value: (attr.showrgbcontrols) || true, + method: function(on) { + //Dom.setStyle(this.getElement(this.ID.RBG_CONTROLS), "visibility", (on) ? "" : "hidden"); + _hideShowEl.call(this, this.ID.RGB_CONTROLS, on); + } + }); + + /** + * Hide/show the hsv controls + * @config showhsvcontrols + * @type boolean + * @default false + */ + this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS, { + value: (attr.showhsvcontrols) || false, + method: function(on) { + //Dom.setStyle(this.getElement(this.ID.HSV_CONTROLS), "visibility", (on) ? "" : "hidden"); + _hideShowEl.call(this, this.ID.HSV_CONTROLS, on); + + // can't show both the hsv controls and the rbg hex summary + if (on && this.get(this.OPT.SHOW_HEX_SUMMARY)) { + this.set(this.OPT.SHOW_HEX_SUMMARY, false); + } + } + }); + + /** + * Hide/show the hex controls + * @config showhexcontrols + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS, { + value: (attr.showhexcontrols) || false, + method: function(on) { + _hideShowEl.call(this, this.ID.HEX_CONTROLS, on); + } + }); + + /** + * Hide/show the websafe swatch + * @config showwebsafe + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_WEBSAFE, { + value: (attr.showwebsafe) || true, + method: function(on) { + _hideShowEl.call(this, this.ID.WEBSAFE_SWATCH, on); + } + }); + + /** + * Hide/show the hex summary + * @config showhexsummary + * @type boolean + * @default true + */ + this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY, { + value: (attr.showhexsummary) || true, + method: function(on) { + _hideShowEl.call(this, this.ID.HEX_SUMMARY, on); + + // can't show both the hsv controls and the rbg hex summary + if (on && this.get(this.OPT.SHOW_HSV_CONTROLS)) { + this.set(this.OPT.SHOW_HSV_CONTROLS, false); + } + } + }); + this.setAttributeConfig(this.OPT.ANIMATE, { + value: (attr.animate) || true, + method: function(on) { + this.pickerSlider.animate = on; + this.hueSlider.animate = on; + } + }); + + this.on(this.OPT.HUE + "Change", _updateRGBFromHSV, this, true); + this.on(this.OPT.SATURATION + "Change", _updateRGBFromHSV, this, true); + this.on(this.OPT.VALUE + "Change", _updatePickerSlider, this, true); + + this.on(this.OPT.RED + "Change", _updateRGB, this, true); + this.on(this.OPT.GREEN + "Change", _updateRGB, this, true); + this.on(this.OPT.BLUE + "Change", _updateRGB, this, true); + + this.on(this.OPT.HEX + "Change", _updateHex, this, true); + + this.initPicker(); + }; + + /** + * Updates the rgb attribute with the current state of the r,g,b + * fields. This is invoked from change listeners on these + * attributes to facilitate updating these values from the + * individual form fields + * @method _updateRGB + * @private + */ + var _updateRGB = function() { + var rgb = [this.get(this.OPT.RED), + this.get(this.OPT.GREEN), + this.get(this.OPT.BLUE)]; + + this.set(this.OPT.RGB, rgb); + + _updateSliders.call(this); + }; + + /** + * Updates the RGB values from the current state of the HSV + * values. Executed when the one of the HSV form fields are + * updated + * _updateRGBFromHSV + * @private + */ + var _updateRGBFromHSV = function() { + var hsv = [this.get(this.OPT.HUE), + this.get(this.OPT.SATURATION)/100, + this.get(this.OPT.VALUE)/100]; + + var rgb = Color.hsv2rgb(hsv); + + this.set(this.OPT.RGB, rgb); + + _updateSliders.call(this); + }; + + /** + * Parses the hex string to normalize shorthand values, converts + * the hex value to rgb and updates the rgb attribute (which + * updates the state for all of the other values) + * method _updateHex + * @private + */ + var _updateHex = function() { + + var hex = this.get(this.OPT.HEX), l=hex.length; + + // support #369 -> #336699 shorthand + if (l === 3) { + var c = hex.split(""), i; + for (i=0; i= 200 && httpStatus < 300){ + if(httpStatus >= 200 && httpStatus < 300 || httpStatus === 1223){ responseObject = this.createResponseObject(o, callback.argument); if(callback.success){ if(!callback.scope){ @@ -430,6 +672,14 @@ YAHOO.util.Connect = YAHOO.log('Success callback with scope. HTTP code is ' + httpStatus, 'info', 'Connection'); } } + + // Fire global custom event -- successEvent + this.successEvent.fire(responseObject); + + if(o.successEvent){ + // Fire transaction custom event -- successEvent + o.successEvent.fire(responseObject); + } } else{ switch(httpStatus){ @@ -465,6 +715,15 @@ YAHOO.util.Connect = } } } + + // Fire global custom event -- failureEvent + this.failureEvent.fire(responseObject); + + if(o.failureEvent){ + // Fire transaction custom event -- failureEvent + o.failureEvent.fire(responseObject); + } + } this.releaseObject(o); @@ -501,8 +760,10 @@ YAHOO.util.Connect = catch(e){} obj.tId = o.tId; - obj.status = o.conn.status; - obj.statusText = o.conn.statusText; + // Normalize IE's response to HTTP 204 when Win error 1223. + obj.status = (o.conn.status == 1223)?204:o.conn.status; + // Normalize IE's statusText to "No Content" instead of "Unknown". + obj.statusText = (o.conn.status == 1223)?"No Content":o.conn.statusText; obj.getResponseHeader = headerObj; obj.getAllResponseHeaders = headerStr; obj.responseText = o.conn.responseText; @@ -558,28 +819,38 @@ YAHOO.util.Connect = }, /** - * @description Public method that stores the custom HTTP headers for each transaction. + * @description Method that initializes the custom HTTP headers for the each transaction. * @method initHeader * @public * @static * @param {string} label The HTTP header label * @param {string} value The HTTP header value + * @param {string} isDefault Determines if the specific header is a default header + * automatically sent with each transaction. * @return {void} */ - initHeader:function(label,value) + initHeader:function(label,value,isDefault) { - if(this._http_header[label] === undefined){ - this._http_header[label] = value; + var headerObj = (isDefault)?this._default_headers:this._http_headers; + + if(headerObj[label] === undefined){ + headerObj[label] = value; } else{ // Concatenate multiple values, comma-delimited, // for the same header label, - this._http_header[label] = value + "," + this._http_header[label]; + headerObj[label] = value + "," + headerObj[label]; } - this._has_http_headers = true; + if(isDefault){ + this._has_default_headers = true; + } + else{ + this._has_http_headers = true; + } }, + /** * @description Accessor that sets the HTTP headers for each transaction. * @method setHeader @@ -590,30 +861,53 @@ YAHOO.util.Connect = */ setHeader:function(o) { - for(var prop in this._http_header){ - if(this._http_header.hasOwnProperty(prop)){ - o.conn.setRequestHeader(prop, this._http_header[prop]); - YAHOO.log('HTTP header ' + prop + ' set with value of ' + this._http_header[prop], 'info', 'Connection'); + if(this._has_default_headers){ + for(var prop in this._default_headers){ + if(YAHOO.lang.hasOwnProperty(this._default_headers, prop)){ + o.conn.setRequestHeader(prop, this._default_headers[prop]); + YAHOO.log('Default HTTP header ' + prop + ' set with value of ' + this._default_headers[prop], 'info', 'Connection'); + } } } - delete this._http_header; - this._http_header = {}; - this._has_http_headers = false; + if(this._has_http_headers){ + for(var prop in this._http_headers){ + if(YAHOO.lang.hasOwnProperty(this._http_headers, prop)){ + o.conn.setRequestHeader(prop, this._http_headers[prop]); + YAHOO.log('HTTP header ' + prop + ' set with value of ' + this._http_headers[prop], 'info', 'Connection'); + } + } + delete this._http_headers; + + this._http_headers = {}; + this._has_http_headers = false; + } + }, + + /** + * @description Resets the default HTTP headers object + * @method resetDefaultHeaders + * @public + * @static + * @return {void} + */ + resetDefaultHeaders:function(){ + delete this._default_headers; + this._default_headers = {}; + this._has_default_headers = false; }, /** * @description 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. + * asyncRequest() will automatically initialize the transaction with a + * a HTTP header Content-Type of application/x-www-form-urlencoded. * @method setForm * @public * @static * @param {string || object} form id or name attribute, or form object. - * @param {string} optional boolean to indicate SSL environment. - * @param {string || boolean} optional qualified path of iframe resource for SSL in IE. + * @param {boolean} optional enable file upload. + * @param {boolean} optional enable file upload over SSL in IE only. * @return {string} string of the HTML form field name and value pairs.. */ setForm:function(formId, isUpload, secureUri) @@ -644,14 +938,14 @@ YAHOO.util.Connect = if(isUpload){ // Create iframe in preparation for file upload. - this.createFrame(secureUri?secureUri:null); - + var io = this.createFrame(secureUri?secureUri:null); // Set form reference and file upload properties to true. this._isFormSubmit = true; this._isFileUpload = true; this._formNode = oForm; return; + } var oElement, oName, oValue, oDisabled; @@ -669,7 +963,7 @@ YAHOO.util.Connect = // do not have a name attribute value. if(!oDisabled && oName) { - switch (oElement.type) + switch(oElement.type) { case 'select-one': case 'select-multiple': @@ -681,7 +975,6 @@ YAHOO.util.Connect = else{ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text) + '&'; } - } } break; @@ -701,14 +994,19 @@ YAHOO.util.Connect = // stub case for input type button elements. break; case 'submit': - if(hasSubmit == false){ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; + if(hasSubmit === false){ + if(this._hasSubmitListener && this._submitElementValue){ + this._sFormData += this._submitElementValue + '&'; + } + else{ + this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; + } + hasSubmit = true; } break; default: this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; - break; } } } @@ -751,8 +1049,9 @@ YAHOO.util.Connect = // properties via createElement(). A different iframe creation // pattern is required for IE. var frameId = 'yuiIO' + this._transaction_id; + var io; if(window.ActiveXObject){ - var io = document.createElement('' ); + } else { + // This trick allows us to do without having to download + // the asset, saving one HTTP request... + document.write( '' ); + } + } + + // We have to wait for the window's onload handler. Otherwise, our + // hidden form field will always be empty (i.e. the browser won't + // have had enough time to restore the session) + YAHOO.util.Event.addListener( window, "load", _initialize ); + + _initialized = true; + }, + + /** + * Call this method when you want to store a new entry in the browser's history. + * + * @method navigate + * @param {string} module Non-empty string representing your module. + * @param {string} state String representing the new state of the specified module. + * @return {boolean} Indicates whether the new state was successfully added to the history. + * @public + */ + navigate: function ( module, state ) { + + var currentStates; + var moduleName; + var moduleObj; + var currentState; + var states; + + if ( typeof module !== "string" || typeof state !== "string" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.navigate" ); + } + + states = {}; + states[module] = state; + + return YAHOO.util.History.multiNavigate( states ); + }, + + /** + * Call this method when you want to store a new entry in the browser's history. + * + * @method multiNavigate + * @param {object} states Associative array of module-state pairs to set simultaneously. + * @return {boolean} Indicates whether the new state was successfully added to the history. + * @public + */ + multiNavigate: function ( states ) { + + var currentStates; + var moduleName; + var moduleObj; + var currentState; + var fqstate; + var html; + var doc; + + if ( typeof states !== "object" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.multiNavigate" ); + } + + if ( !_bhmReady ) { + throw new Error( "The Browser History Manager is not initialized" ); + } + + for ( moduleName in states ) { + if ( !_modules[moduleName] ) { + throw new Error( "The following module has not been registered: " + moduleName ); + } + } + + // Generate our new full state string mod1=xxx&mod2=yyy + currentStates = []; + + for ( moduleName in _modules ) { + if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) { + moduleObj = _modules[moduleName]; + if ( YAHOO.lang.hasOwnProperty( states, moduleName ) ) { + currentState = states[moduleName]; + } else { + currentState = moduleObj.currentState; + } + + // Make sure the strings passed in do not contain our separators "," and "|" + moduleName = escape( moduleName ); + currentState = escape( currentState ); + + currentStates.push( moduleName + "=" + currentState ); + } + } + + fqstate = currentStates.join( "&" ); + + if ( YAHOO.env.ua.ie ) { + + html = '
' + fqstate + '
'; + try { + doc = _iframe.contentWindow.document; + doc.open(); + doc.write( html ); + doc.close(); + } catch ( e ) { + return false; + } + + } else { + + // Known bug: On Safari 1.x and 2.0, if you have tab browsing + // enabled, Safari will show an endless loading icon in the + // tab. This has apparently been fixed in recent WebKit builds. + // One work around found by Dav Glass is to submit a form that + // points to the same document. This indeed works on Safari 1.x + // and 2.0 but creates bigger problems on WebKit. So for now, + // we'll consider this an acceptable bug, and hope that Apple + // comes out with their next version of Safari very soon. + top.location.hash = fqstate; + if ( YAHOO.env.ua.webkit ) { + // The following two lines are only useful for Safari 1.x + // and 2.0. Recent nightly builds of WebKit do not require + // that, but unfortunately, it is not easy to differentiate + // between the two. Once Safari 2.0 departs the A-grade + // list, we can remove the following two lines... + _fqstates[history.length] = fqstate; + _storeStates(); + } + + } + + return true; + }, + + /** + * Returns the current state of the specified module. + * + * @method getCurrentState + * @param {string} module Non-empty string representing your module. + * @return {string} The current state of the specified module. + * @public + */ + getCurrentState: function ( module ) { + + var moduleObj; + + if ( typeof module !== "string" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getCurrentState" ); + } + + if ( !_storageFieldReady ) { + throw new Error( "The Browser History Manager is not initialized" ); + } + + moduleObj = _modules[module]; + if ( !moduleObj ) { + throw new Error( "No such registered module: " + module ); + } + + return unescape( moduleObj.currentState ); + }, + + /** + * Returns the state of a module according to the URL fragment + * identifier. This method is useful to initialize your modules + * if your application was bookmarked from a particular state. + * + * @method getBookmarkedState + * @param {string} module Non-empty string representing your module. + * @return {string} The bookmarked state of the specified module. + * @public + */ + getBookmarkedState: function ( module ) { + + var i; + var len; + var hash; + var states; + var tokens; + var moduleName; + + if ( typeof module !== "string" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState" ); + } + + hash = top.location.hash.substr(1); + states = hash.split( "&" ); + for ( i = 0, len = states.length ; i < len ; i++ ) { + tokens = states[i].split( "=" ); + if ( tokens.length === 2 ) { + moduleName = tokens[0]; + if ( moduleName === module ) { + return unescape( tokens[1] ); + } + } + } + + return null; + }, + + /** + * Returns the value of the specified query string parameter. + * This method is not used internally by the Browser History Manager. + * However, it is provided here as a helper since many applications + * using the Browser History Manager will want to read the value of + * url parameters to initialize themselves. + * + * @method getQueryStringParameter + * @param {string} paramName Name of the parameter we want to look up. + * @param {string} queryString Optional URL to look at. If not specified, + * this method uses the URL in the address bar. + * @return {string} The value of the specified parameter, or null. + * @public + */ + getQueryStringParameter: function ( paramName, url ) { + + var i; + var len; + var idx; + var queryString; + var params; + var tokens; + + url = url || top.location.href; + + idx = url.indexOf( "?" ); + queryString = idx >= 0 ? url.substr( idx + 1 ) : url; + params = queryString.split( "&" ); + + for ( i = 0, len = params.length ; i < len ; i++ ) { + tokens = params[i].split( "=" ); + if ( tokens.length >= 2 ) { + if ( tokens[0] === paramName ) { + return unescape( tokens[1] ); + } + } + } + + return null; + } + + }; + +} )(); +YAHOO.register("history", YAHOO.util.History, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/history/history-beta-min.js b/lib/yui/history/history-beta-min.js new file mode 100755 index 0000000000..46620ec0c4 --- /dev/null +++ b/lib/yui/history/history-beta-min.js @@ -0,0 +1,45 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ + +YAHOO.util.History=(function(){var _iframe=null;var _storageField=null;var _initialized=false;var _storageFieldReady=false;var _bhmReady=false;var _modules=[];var _fqstates=[];function _trim(str){return str.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1");} +function _getHash(){var href;var i;href=top.location.href;i=href.indexOf("#");return i>=0?href.substr(i+1):null;} +function _storeStates(){var moduleName;var moduleObj;var initialStates=[];var currentStates=[];for(moduleName in _modules){if(YAHOO.lang.hasOwnProperty(_modules,moduleName)){moduleObj=_modules[moduleName];initialStates.push(moduleName+"="+moduleObj.initialState);currentStates.push(moduleName+"="+moduleObj.currentState);}} +_storageField.value=initialStates.join("&")+"|"+currentStates.join("&");if(YAHOO.env.ua.webkit){_storageField.value+="|"+_fqstates.join(",");}} +function _handleFQStateChange(fqstate){var i;var len;var moduleName;var moduleObj;var modules;var states;var tokens;var currentState;if(!fqstate){for(moduleName in _modules){if(YAHOO.lang.hasOwnProperty(_modules,moduleName)){moduleObj=_modules[moduleName];moduleObj.currentState=moduleObj.initialState;moduleObj.onStateChange(unescape(moduleObj.currentState));}} +return;} +modules=[];states=fqstate.split("&");for(i=0,len=states.length;i1){initialStates=parts[0].split("&");for(i=0,len=initialStates.length;i=2){moduleName=tokens[0];currentState=tokens[1];moduleObj=_modules[moduleName];if(moduleObj){moduleObj.currentState=currentState;}}}} +if(parts.length>2){_fqstates=parts[2].split(",");} +_storageFieldReady=true;if(YAHOO.env.ua.ie){_iframe=document.getElementById("yui_hist_iframe");_checkIframeLoaded();}else{counter=history.length;hash=_getHash();setInterval(function(){var state;var newHash;var newCounter;newHash=_getHash();newCounter=history.length;if(newHash!==hash){hash=newHash;counter=newCounter;_handleFQStateChange(hash);_storeStates();}else if(newCounter!==counter){hash=newHash;counter=newCounter;state=_fqstates[counter-1];_handleFQStateChange(state);_storeStates();}},50);_bhmReady=true;YAHOO.util.History.onLoadEvent.fire();}} +return{onLoadEvent:new YAHOO.util.CustomEvent("onLoad"),register:function(module,initialState,onStateChange,obj,override){var scope;var wrappedFn;if(typeof module!=="string"||_trim(module)===""||typeof initialState!=="string"||typeof onStateChange!=="function"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.register");} +if(_modules[module]){return;} +if(_initialized){throw new Error("All modules must be registered before calling YAHOO.util.History.initialize");} +module=escape(module);initialState=escape(initialState);scope=null;if(override===true){scope=obj;}else{scope=override;} +wrappedFn=function(state){return onStateChange.call(scope,state,obj);};_modules[module]={name:module,initialState:initialState,currentState:initialState,onStateChange:wrappedFn};},initialize:function(iframeTarget){if(_initialized){return;} +if(!iframeTarget){iframeTarget="blank.html";} +if(typeof iframeTarget!=="string"||_trim(iframeTarget)===""){throw new Error("Invalid argument passed to YAHOO.util.History.initialize");} +document.write('');if(YAHOO.env.ua.ie){if(location.protocol==="https:"){document.write('');}else{document.write('');}} +YAHOO.util.Event.addListener(window,"load",_initialize);_initialized=true;},navigate:function(module,state){var currentStates;var moduleName;var moduleObj;var currentState;var states;if(typeof module!=="string"||typeof state!=="string"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.navigate");} +states={};states[module]=state;return YAHOO.util.History.multiNavigate(states);},multiNavigate:function(states){var currentStates;var moduleName;var moduleObj;var currentState;var fqstate;var html;var doc;if(typeof states!=="object"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.multiNavigate");} +if(!_bhmReady){throw new Error("The Browser History Manager is not initialized");} +for(moduleName in states){if(!_modules[moduleName]){throw new Error("The following module has not been registered: "+moduleName);}} +currentStates=[];for(moduleName in _modules){if(YAHOO.lang.hasOwnProperty(_modules,moduleName)){moduleObj=_modules[moduleName];if(YAHOO.lang.hasOwnProperty(states,moduleName)){currentState=states[moduleName];}else{currentState=moduleObj.currentState;} +moduleName=escape(moduleName);currentState=escape(currentState);currentStates.push(moduleName+"="+currentState);}} +fqstate=currentStates.join("&");if(YAHOO.env.ua.ie){html='
'+fqstate+'
';try{doc=_iframe.contentWindow.document;doc.open();doc.write(html);doc.close();}catch(e){return false;}}else{top.location.hash=fqstate;if(YAHOO.env.ua.webkit){_fqstates[history.length]=fqstate;_storeStates();}} +return true;},getCurrentState:function(module){var moduleObj;if(typeof module!=="string"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.getCurrentState");} +if(!_storageFieldReady){throw new Error("The Browser History Manager is not initialized");} +moduleObj=_modules[module];if(!moduleObj){throw new Error("No such registered module: "+module);} +return unescape(moduleObj.currentState);},getBookmarkedState:function(module){var i;var len;var hash;var states;var tokens;var moduleName;if(typeof module!=="string"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState");} +hash=top.location.hash.substr(1);states=hash.split("&");for(i=0,len=states.length;i=0?url.substr(idx+1):url;params=queryString.split("&");for(i=0,len=params.length;i=2){if(tokens[0]===paramName){return unescape(tokens[1]);}}} +return null;}};})();YAHOO.register("history",YAHOO.util.History,{version:"2.3.0",build:"442"}); \ No newline at end of file diff --git a/lib/yui/history/history-beta.js b/lib/yui/history/history-beta.js new file mode 100755 index 0000000000..f3cf3b954b --- /dev/null +++ b/lib/yui/history/history-beta.js @@ -0,0 +1,768 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/** + * The Browser History Manager provides the ability to use the + * back/forward navigation buttons in a DHTML application. It also allows + * a DHTML application to be bookmarked in a specific state. + * + * @module history + * @requires yahoo,event + * @namespace YAHOO.util + * @title Browser History Manager + * @experimental + */ + +/** + * The History class provides the ability to use the back/forward navigation + * buttons in a DHTML application. It also allows a DHTML application to + * be bookmarked in a specific state. + * + * @class History + * @constructor + */ +YAHOO.util.History = ( function () { + + /** + * Our hidden IFrame used to store the browsing history. + * + * @property _iframe + * @type HTMLIFrameElement + * @default null + * @private + */ + var _iframe = null; + + /** + * INPUT field (with type="hidden" or type="text") or TEXTAREA. + * This field keeps the value of the initial state, current state + * the list of all states across pages within a single browser session. + * + * @property _storageField + * @type HTMLInputElement|HTMLTextAreaElement + * @default null + * @private + */ + var _storageField = null; + + /** + * Flag used to tell whether YAHOO.util.History.initialize has been called. + * + * @property _initialized + * @type boolean + * @default false + * @private + */ + var _initialized = false; + + /** + * Flag used to tell whether the storage field is ready to be used. + * + * @property _storageFieldReady + * @type boolean + * @default false + * @private + */ + var _storageFieldReady = false; + + /** + * Flag used to tell whether the Browser History Manager is ready. + * + * @property _bhmReady + * @type boolean + * @default false + * @private + */ + var _bhmReady = false; + + /** + * List of registered modules. + * + * @property _modules + * @type array + * @default [] + * @private + */ + var _modules = []; + + /** + * List of fully qualified states. This is used only by Safari. + * + * @property _fqstates + * @type array + * @default [] + * @private + */ + var _fqstates = []; + + /** + * Trims a string. + * + * @method _trim + * @param {string} str The string to be trimmed. + * @return {string} The trimmed string + * @private + */ + function _trim( str ) { + return str.replace( /^\s*(\S*(\s+\S+)*)\s*$/, "$1" ); + } + + /** + * location.hash is a bit buggy on Opera. I have seen instances where + * navigating the history using the back/forward buttons, and hence + * changing the URL, would not change location.hash. That's ok, the + * implementation of an equivalent is trivial. + * + * @method _getHash + * @return {string} The hash portion of the document's location + * @private + */ + function _getHash() { + + var href; + var i; + + href = top.location.href; + i = href.indexOf( "#" ); + return i >= 0 ? href.substr( i + 1 ) : null; + } + + /** + * Stores all the registered modules' initial state and current state. + * On Safari, we also store all the fully qualified states visited by + * the application within a single browser session. The storage takes + * place in the form field specified during initialization. + * + * @method _storeStates + * @private + */ + function _storeStates() { + + var moduleName; + var moduleObj; + var initialStates = []; + var currentStates = []; + + for ( moduleName in _modules ) { + if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) { + moduleObj = _modules[moduleName]; + initialStates.push( moduleName + "=" + moduleObj.initialState ); + currentStates.push( moduleName + "=" + moduleObj.currentState ); + } + } + + _storageField.value = initialStates.join( "&" ) + "|" + currentStates.join( "&" ); + + if ( YAHOO.env.ua.webkit ) { + _storageField.value += "|" + _fqstates.join( "," ); + } + } + + /** + * Sets the new currentState attribute of all modules depending on the new + * fully qualified state. Also notifies the modules which current state has + * changed. + * + * @method _handleFQStateChange + * @param {string} fqstate Fully qualified state + * @private + */ + function _handleFQStateChange( fqstate ) { + + var i; + var len; + var moduleName; + var moduleObj; + var modules; + var states; + var tokens; + var currentState; + + if ( !fqstate ) { + // Notifies all modules + for ( moduleName in _modules ) { + if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) { + moduleObj = _modules[moduleName]; + moduleObj.currentState = moduleObj.initialState; + moduleObj.onStateChange( unescape( moduleObj.currentState ) ); + } + } + return; + } + + modules = []; + states = fqstate.split( "&" ); + for ( i = 0, len = states.length ; i < len ; i++ ) { + tokens = states[i].split( "=" ); + if ( tokens.length === 2 ) { + moduleName = tokens[0]; + currentState = tokens[1]; + modules[moduleName] = currentState; + } + } + + for ( moduleName in _modules ) { + if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) { + moduleObj = _modules[moduleName]; + currentState = modules[moduleName]; + if ( !currentState || moduleObj.currentState !== currentState ) { + moduleObj.currentState = currentState || moduleObj.initialState; + moduleObj.onStateChange( unescape( moduleObj.currentState ) ); + } + } + } + } + + /** + * Periodically checks whether our internal IFrame is ready to be used. + * + * @method _checkIframeLoaded + * @private + */ + function _checkIframeLoaded() { + + var doc; + var elem; + var fqstate; + + if ( !_iframe.contentWindow || !_iframe.contentWindow.document ) { + // Check again in 10 msec... + setTimeout( _checkIframeLoaded, 10 ); + return; + } + + // Start the thread that will have the responsibility to + // periodically check whether a navigate operation has been + // requested on the main window. This will happen when + // YAHOO.util.History.navigate has been called or after + // the user has hit the back/forward button. + + doc = _iframe.contentWindow.document; + elem = doc.getElementById( "state" ); + // We must use innerText, and not innerHTML because our string contains + // the "&" character (which would end up being escaped as "&") and + // the string comparison would fail... + fqstate = elem ? elem.innerText : null; + + setInterval( function () { + + var newfqstate; + var hash; + var states; + var moduleName; + var moduleObj; + + doc = _iframe.contentWindow.document; + elem = doc.getElementById( "state" ); + // See my comment above about using innerText instead of innerHTML... + newfqstate = elem ? elem.innerText : null; + + if ( newfqstate !== fqstate ) { + fqstate = newfqstate; + _handleFQStateChange( fqstate ); + + if ( !fqstate ) { + states = []; + for ( moduleName in _modules ) { + if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) { + moduleObj = _modules[moduleName]; + states.push( moduleName + "=" + moduleObj.initialState ); + } + } + hash = states.join( "&" ); + } else { + hash = fqstate; + } + + // Allow the state to be bookmarked by setting the top window's + // URL fragment identifier. Note that here, we are on IE, and + // IE does not touch the browser history when setting the hash + // (unlike all the other browsers). I used to write: + // top.location.replace( "#" + hash ); + // but this had a side effect when the page was not the top frame. + top.location.hash = hash; + + _storeStates(); + } + }, 50 ); + + _bhmReady = true; + + YAHOO.util.History.onLoadEvent.fire(); + } + + /** + * Finish up the initialization of the Browser History Manager. + * + * @method _initialize + * @private + */ + function _initialize() { + + var i; + var len; + var parts; + var tokens; + var moduleName; + var moduleObj; + var initialStates; + var initialState; + var currentStates; + var currentState; + var counter; + var hash; + + _storageField = document.getElementById( "yui_hist_field" ); + + // Decode the content of our storage field... + parts = _storageField.value.split( "|" ); + + if ( parts.length > 1 ) { + + initialStates = parts[0].split( "&" ); + for ( i = 0, len = initialStates.length ; i < len ; i++ ) { + tokens = initialStates[i].split( "=" ); + if ( tokens.length === 2 ) { + moduleName = tokens[0]; + initialState = tokens[1]; + moduleObj = _modules[moduleName]; + if ( moduleObj ) { + moduleObj.initialState = initialState; + } + } + } + + currentStates = parts[1].split( "&" ); + for ( i = 0, len = currentStates.length ; i < len ; i++ ) { + tokens = currentStates[i].split( "=" ); + if ( tokens.length >= 2 ) { + moduleName = tokens[0]; + currentState = tokens[1]; + moduleObj = _modules[moduleName]; + if ( moduleObj ) { + moduleObj.currentState = currentState; + } + } + } + } + + if ( parts.length > 2 ) { + _fqstates = parts[2].split( "," ); + } + + _storageFieldReady = true; + + if ( YAHOO.env.ua.ie ) { + + _iframe = document.getElementById( "yui_hist_iframe" ); + _checkIframeLoaded(); + + } else { + + // Start the thread that will have the responsibility to + // periodically check whether a navigate operation has been + // requested on the main window. This will happen when + // YAHOO.util.History.navigate has been called or after + // the user has hit the back/forward button. + + // On Safari 1.x and 2.0, the only way to catch a back/forward + // operation is to watch history.length... We basically exploit + // what I consider to be a bug (history.length is not supposed + // to change when going back/forward in the history...) This is + // why, in the following thread, we first compare the hash, + // because the hash thing will be fixed in the next major + // version of Safari. So even if they fix the history.length + // bug, all this will still work! + counter = history.length; + + // On Gecko and Opera, we just need to watch the hash... + hash = _getHash(); + + setInterval( function () { + + var state; + var newHash; + var newCounter; + + newHash = _getHash(); + newCounter = history.length; + if ( newHash !== hash ) { + hash = newHash; + counter = newCounter; + _handleFQStateChange( hash ); + _storeStates(); + } else if ( newCounter !== counter ) { + // If we ever get here, we should be on Safari... + hash = newHash; + counter = newCounter; + state = _fqstates[counter - 1]; + _handleFQStateChange( state ); + _storeStates(); + } + }, 50 ); + + _bhmReady = true; + + YAHOO.util.History.onLoadEvent.fire(); + } + } + + return { + + /** + * Fired when the Browser History Manager is ready. + * + * @event onLoadEvent + */ + onLoadEvent: new YAHOO.util.CustomEvent( "onLoad" ), + + /** + * Registers a new module. + * + * @method register + * @param {string} module Non-empty string uniquely identifying the + * module you wish to register. + * @param {string} initialState The initial state of the specified + * module corresponding to its earliest history entry. + * @param {function} onStateChange Callback called when the + * state of the specified module has changed. + * @param {object} obj An arbitrary object that will be passed as a + * parameter to the handler. + * @param {boolean} override If true, the obj passed in becomes the + * execution scope of the listener. + */ + register: function ( module, initialState, onStateChange, obj, override ) { + + var scope; + var wrappedFn; + + if ( typeof module !== "string" || _trim( module ) === "" || + typeof initialState !== "string" || + typeof onStateChange !== "function" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.register" ); + } + + if ( _modules[module] ) { + // Here, we used to throw an exception. However, users have + // complained about this behavior, so we now just return. + return; + } + + // Note: A module CANNOT be registered after calling + // YAHOO.util.History.initialize. Indeed, we set the initial state + // of each registered module in YAHOO.util.History.initialize. + // If you could register a module after initializing the Browser + // History Manager, you would not read the correct state using + // YAHOO.util.History.getCurrentState when coming back to the + // page using the back button. + if ( _initialized ) { + throw new Error( "All modules must be registered before calling YAHOO.util.History.initialize" ); + } + + // Make sure the strings passed in do not contain our separators "," and "|" + module = escape( module ); + initialState = escape( initialState ); + + // If the user chooses to override the scope, we use the + // custom object passed in as the execution scope. + scope = null; + if ( override === true ) { + scope = obj; + } else { + scope = override; + } + + wrappedFn = function ( state ) { + return onStateChange.call( scope, state, obj ); + }; + + _modules[module] = { + name: module, + initialState: initialState, + currentState: initialState, + onStateChange: wrappedFn + }; + }, + + /** + * Initializes the Browser History Manager. Call this method + * from a script block located right after the opening body tag. + * + * @method initialize + * @param {string} iframeTarget Optional - Path to an existing + * HTML document accessible from the same domain. If not + * specified, defaults to "blank.html". This is only useful + * if you use https. + * @public + */ + initialize: function ( iframeTarget ) { + + // Return if the browser history manager has already been initialized + if ( _initialized ) { + return; + } + + if ( !iframeTarget ) { + iframeTarget = "blank.html"; + } + + if ( typeof iframeTarget !== "string" || _trim( iframeTarget ) === "" ) { + throw new Error( "Invalid argument passed to YAHOO.util.History.initialize" ); + } + + document.write( '' ); + + if ( YAHOO.env.ua.ie ) { + if ( location.protocol === "https:" ) { + // If we use https, we MUST point the IFrame to a valid + // document on the same server. If we don't, we will get + // a warning (do you want to display non secure items?) + document.write( '' ); + } else { + // This trick allows us to do without having to download + // the asset, saving one HTTP request... + document.write( '' ); + } + } + + // We have to wait for the window's onload handler. Otherwise, our + // hidden form field will always be empty (i.e. the browser won't + // have had enough time to restore the session) + YAHOO.util.Event.addListener( window, "load", _initialize ); + + _initialized = true; + }, + + /** + * Call this method when you want to store a new entry in the browser's history. + * + * @method navigate + * @param {string} module Non-empty string representing your module. + * @param {string} state String representing the new state of the specified module. + * @return {boolean} Indicates whether the new state was successfully added to the history. + * @public + */ + navigate: function ( module, state ) { + + var currentStates; + var moduleName; + var moduleObj; + var currentState; + var states; + + if ( typeof module !== "string" || typeof state !== "string" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.navigate" ); + } + + states = {}; + states[module] = state; + + return YAHOO.util.History.multiNavigate( states ); + }, + + /** + * Call this method when you want to store a new entry in the browser's history. + * + * @method multiNavigate + * @param {object} states Associative array of module-state pairs to set simultaneously. + * @return {boolean} Indicates whether the new state was successfully added to the history. + * @public + */ + multiNavigate: function ( states ) { + + var currentStates; + var moduleName; + var moduleObj; + var currentState; + var fqstate; + var html; + var doc; + + if ( typeof states !== "object" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.multiNavigate" ); + } + + if ( !_bhmReady ) { + throw new Error( "The Browser History Manager is not initialized" ); + } + + for ( moduleName in states ) { + if ( !_modules[moduleName] ) { + throw new Error( "The following module has not been registered: " + moduleName ); + } + } + + // Generate our new full state string mod1=xxx&mod2=yyy + currentStates = []; + + for ( moduleName in _modules ) { + if ( YAHOO.lang.hasOwnProperty( _modules, moduleName ) ) { + moduleObj = _modules[moduleName]; + if ( YAHOO.lang.hasOwnProperty( states, moduleName ) ) { + currentState = states[moduleName]; + } else { + currentState = moduleObj.currentState; + } + + // Make sure the strings passed in do not contain our separators "," and "|" + moduleName = escape( moduleName ); + currentState = escape( currentState ); + + currentStates.push( moduleName + "=" + currentState ); + } + } + + fqstate = currentStates.join( "&" ); + + if ( YAHOO.env.ua.ie ) { + + html = '
' + fqstate + '
'; + try { + doc = _iframe.contentWindow.document; + doc.open(); + doc.write( html ); + doc.close(); + } catch ( e ) { + return false; + } + + } else { + + // Known bug: On Safari 1.x and 2.0, if you have tab browsing + // enabled, Safari will show an endless loading icon in the + // tab. This has apparently been fixed in recent WebKit builds. + // One work around found by Dav Glass is to submit a form that + // points to the same document. This indeed works on Safari 1.x + // and 2.0 but creates bigger problems on WebKit. So for now, + // we'll consider this an acceptable bug, and hope that Apple + // comes out with their next version of Safari very soon. + top.location.hash = fqstate; + if ( YAHOO.env.ua.webkit ) { + // The following two lines are only useful for Safari 1.x + // and 2.0. Recent nightly builds of WebKit do not require + // that, but unfortunately, it is not easy to differentiate + // between the two. Once Safari 2.0 departs the A-grade + // list, we can remove the following two lines... + _fqstates[history.length] = fqstate; + _storeStates(); + } + + } + + return true; + }, + + /** + * Returns the current state of the specified module. + * + * @method getCurrentState + * @param {string} module Non-empty string representing your module. + * @return {string} The current state of the specified module. + * @public + */ + getCurrentState: function ( module ) { + + var moduleObj; + + if ( typeof module !== "string" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getCurrentState" ); + } + + if ( !_storageFieldReady ) { + throw new Error( "The Browser History Manager is not initialized" ); + } + + moduleObj = _modules[module]; + if ( !moduleObj ) { + throw new Error( "No such registered module: " + module ); + } + + return unescape( moduleObj.currentState ); + }, + + /** + * Returns the state of a module according to the URL fragment + * identifier. This method is useful to initialize your modules + * if your application was bookmarked from a particular state. + * + * @method getBookmarkedState + * @param {string} module Non-empty string representing your module. + * @return {string} The bookmarked state of the specified module. + * @public + */ + getBookmarkedState: function ( module ) { + + var i; + var len; + var hash; + var states; + var tokens; + var moduleName; + + if ( typeof module !== "string" ) { + throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState" ); + } + + hash = top.location.hash.substr(1); + states = hash.split( "&" ); + for ( i = 0, len = states.length ; i < len ; i++ ) { + tokens = states[i].split( "=" ); + if ( tokens.length === 2 ) { + moduleName = tokens[0]; + if ( moduleName === module ) { + return unescape( tokens[1] ); + } + } + } + + return null; + }, + + /** + * Returns the value of the specified query string parameter. + * This method is not used internally by the Browser History Manager. + * However, it is provided here as a helper since many applications + * using the Browser History Manager will want to read the value of + * url parameters to initialize themselves. + * + * @method getQueryStringParameter + * @param {string} paramName Name of the parameter we want to look up. + * @param {string} queryString Optional URL to look at. If not specified, + * this method uses the URL in the address bar. + * @return {string} The value of the specified parameter, or null. + * @public + */ + getQueryStringParameter: function ( paramName, url ) { + + var i; + var len; + var idx; + var queryString; + var params; + var tokens; + + url = url || top.location.href; + + idx = url.indexOf( "?" ); + queryString = idx >= 0 ? url.substr( idx + 1 ) : url; + params = queryString.split( "&" ); + + for ( i = 0, len = params.length ; i < len ; i++ ) { + tokens = params[i].split( "=" ); + if ( tokens.length >= 2 ) { + if ( tokens[0] === paramName ) { + return unescape( tokens[1] ); + } + } + } + + return null; + } + + }; + +} )(); +YAHOO.register("history", YAHOO.util.History, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/imageloader/README b/lib/yui/imageloader/README new file mode 100755 index 0000000000..b1d5eb8697 --- /dev/null +++ b/lib/yui/imageloader/README @@ -0,0 +1,4 @@ +ImageLoader - Release Notes + +2.3.0 + * Initial release diff --git a/lib/yui/imageloader/imageloader-experimental-debug.js b/lib/yui/imageloader/imageloader-experimental-debug.js new file mode 100755 index 0000000000..55b85c5efd --- /dev/null +++ b/lib/yui/imageloader/imageloader-experimental-debug.js @@ -0,0 +1,442 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/** + * The image loader is a framework to dynamically load images + * according to certain triggers, enabling faster load times + * and a more responsive UI. + * + * @module imageloader + * @namespace YAHOO.util + * @experimental + */ + +if (typeof(YAHOO.util.ImageLoader) == 'undefined') { + YAHOO.util.ImageLoader = {}; +} + +/** + * A group for images. A group can have one time limit and a series of triggers. Thus the images belonging to this group must share these constraints. + * @class YAHOO.util.ImageLoader.group + * @requires YAHOO.util.Dom + * @requires YAHOO.util.Event + * @constructor + * @param {String|HTMLElement} trigEl The HTML element id or reference to assign the trigger event to. Can be null for no trigger + * @param {String} trigAct The type of event to assign to trigEl. Can be null for no trigger + * @param {Number} timeout Timeout (time limit) length, in seconds. Can be undefined, or <= 0, for no time limit + */ +YAHOO.util.ImageLoader.group = function(trigEl, trigAct, timeout) { + /** + * Name for the group. Only used to identify the group in logging statements + * @property name + * @type String + */ + this.name = 'unnamed'; + + /** + * Collection of images registered with this group + * @property _imgObjs + * @private + * @type Object + */ + this._imgObjs = {}; + + /** + * Timeout (time limit) length, in seconds + * @property timeoutLen + * @type Number + */ + this.timeoutLen = timeout; + + /** + * Timeout object to keep a handle on the time limit + * @property _timeout + * @private + * @type Object + */ + this._timeout = null; + + /** + * Collection of triggers for this group. + * Keeps track of each trigger's element, event, and event-listener-callback "fetch" function + * @property _triggers + * @private + * @type Array + */ + this._triggers = []; + + /** + * Flag to check if images are above the fold. If foldConditional is true, the group will check each of its image locations at page load. If any part of the image is within the client viewport, the image is displayed immediately + * @property foldConditional + * @type Boolean + */ + this.foldConditional = false; + + /** + * Class name that will identify images belonging to the group. This class name will be removed from each element in order to fetch images. + * This class should have, in its CSS style definition, "background:none !important;" + * @property className + * @type String + */ + this.className = null; + + /** + * HTML elements having the class name that is associated with this group + * Elements are stored during the _foldCheck function and reused later during the fetch function. Gives a slight performance improvement when className and foldConditional are both used + * @property _classImageEls + * @private + * @type Array + */ + this._classImageEls = null; + + // add a listener to set the time limit in the onload + YAHOO.util.Event.addListener(window, 'load', this._onloadTasks, this, true); + // add the trigger + this.addTrigger(trigEl, trigAct); + +}; + +/** + * Adds a trigger to the group. Call this with the same style as YAHOO.util.Event.addListener + * @method addTrigger + * @param {String|HTMLElement} trigEl The HTML element id or reference to assign the trigger event to + * @param {String} trigAct The type of event to assign to trigEl + */ +YAHOO.util.ImageLoader.group.prototype.addTrigger = function(trigEl, trigAct) { + if (! trigEl || ! trigAct) { + return; + } + /* Need to wrap the fetch function. Event Util can't distinguish prototyped functions of different instantiations + * Leads to this scenario: groupA and groupZ both have window-scroll triggers. groupZ also has a 2-sec timeout (groupA has no timeout). + * groupZ's timeout fires; we remove the triggers. The removeListener call finds the first window-scroll event with Y.u.IL.p.fetch, which is groupA's. + * groupA's trigger is removed and never fires, leaving images unfetched + */ + var wrappedFetch = function() { + this.fetch(); + }; + this._triggers.push([trigEl, trigAct, wrappedFetch]); + YAHOO.util.Event.addListener(trigEl, trigAct, wrappedFetch, this, true); +}; + +/** + * Setup to do in the window's onload + * Initiates time limit for group; executes the fold check for the images + * @method _onloadTasks + * @private + */ +YAHOO.util.ImageLoader.group.prototype._onloadTasks = function() { + if (this.timeoutLen && typeof(this.timeoutLen) == 'number' && this.timeoutLen > 0) { + this._timeout = setTimeout(this._getFetchTimeout(), this.timeoutLen * 1000); + } + + if (this.foldConditional) { + this._foldCheck(); + } +}; + +/** + * Returns the group's fetch method, with the proper closure, for use with setTimeout + * @method _getFetchTimeout + * @return {Function} group's fetch method + * @private + */ +YAHOO.util.ImageLoader.group.prototype._getFetchTimeout = function() { + var self = this; + return function() { self.fetch(); }; +}; + +/** + * Registers a background image with the group + * @method registerBgImage + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + * @return {Object} bgImgObj that was registered, for modifying any attributes in the object + */ +YAHOO.util.ImageLoader.group.prototype.registerBgImage = function(domId, url) { + this._imgObjs[domId] = new YAHOO.util.ImageLoader.bgImgObj(domId, url); + return this._imgObjs[domId]; +}; +/** + * Registers a src image with the group + * @method registerSrcImage + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + * @param {Int} width pixel width of the image - defaults to image's natural size + * @param {Int} height pixel height of the image - defaults to image's natural size + * @return {Object} srcImgObj that was registered, for modifying any attributes in the object + */ +YAHOO.util.ImageLoader.group.prototype.registerSrcImage = function(domId, url, width, height) { + this._imgObjs[domId] = new YAHOO.util.ImageLoader.srcImgObj(domId, url, width, height); + return this._imgObjs[domId]; +}; +/** + * Registers an alpha-channel-type png background image with the group + * @method registerPngBgImage + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + * @return {Object} pngBgImgObj that was registered, for modifying any attributes in the object + */ +YAHOO.util.ImageLoader.group.prototype.registerPngBgImage = function(domId, url) { + this._imgObjs[domId] = new YAHOO.util.ImageLoader.pngBgImgObj(domId, url); + return this._imgObjs[domId]; +}; + +/** + * Displays the images in the group + * @method fetch + */ +YAHOO.util.ImageLoader.group.prototype.fetch = function() { + YAHOO.log('Fetching images in group: "' + this.name + '".', 'info', 'imageloader'); + + clearTimeout(this._timeout); + // remove all listeners + for (var i=0; i < this._triggers.length; i++) { + YAHOO.util.Event.removeListener(this._triggers[i][0], this._triggers[i][1], this._triggers[i][2]); + } + + // fetch whatever we need to by className + this._fetchByClass(); + + // fetch registered images + for (var id in this._imgObjs) { + if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) { + this._imgObjs[id].fetch(); + } + } +}; + +/** + * Checks the position of each image in the group. If any part of the image is within the client viewport, shows the image immediately. + * @method _foldCheck + * @private + */ +YAHOO.util.ImageLoader.group.prototype._foldCheck = function() { + YAHOO.log('Checking for images above the fold in group: "' + this.name + '"', 'info', 'imageloader'); + var scrollTop = (document.compatMode != 'CSS1Compat') ? document.body.scrollTop : document.documentElement.scrollTop; + var viewHeight = YAHOO.util.Dom.getViewportHeight(); + var hLimit = scrollTop + viewHeight; + var scrollLeft = (document.compatMode != 'CSS1Compat') ? document.body.scrollLeft : document.documentElement.scrollLeft; + var viewWidth = YAHOO.util.Dom.getViewportWidth(); + var wLimit = scrollLeft + viewWidth; + for (var id in this._imgObjs) { + if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) { + var elPos = YAHOO.util.Dom.getXY(this._imgObjs[id].domId); + if (elPos[1] < hLimit && elPos[0] < wLimit) { + YAHOO.log('Image with id "' + this._imgObjs[id].domId + '" is above the fold. Fetching image.', 'info', 'imageloader'); + this._imgObjs[id].fetch(); + } + } + } + // and by class + if (this.className) { + this._classImageEls = YAHOO.util.Dom.getElementsByClassName(this.className); + for (var i=0; i < this._classImageEls.length; i++) { + var elPos = YAHOO.util.Dom.getXY(this._classImageEls[i]); + if (elPos[1] < hLimit && elPos[0] < wLimit) { + YAHOO.log('Image with id "' + this._classImageEls[i].id + '" is above the fold. Fetching image. (Image registered by class name with the group - may not have an id.)', 'info', 'imageloader'); + YAHOO.util.Dom.removeClass(this._classImageEls[i], this.className); + } + } + } +}; + +/** + * Finds all elements in the Dom with the class name specified in the group. Removes the class from the element in order to let the style definitions trigger the image fetching + * @method _fetchByClass + * @private + */ +YAHOO.util.ImageLoader.group.prototype._fetchByClass = function() { + if (! this.className) { + return; + } + + YAHOO.log('Fetching all images with class "' + this.className + '" in group "' + this.name + '".', 'info', 'imageloader'); + // this._classImageEls may have been set during _foldCheck + if (this._classImageEls === null) { + this._classImageEls = YAHOO.util.Dom.getElementsByClassName(this.className); + } + YAHOO.util.Dom.removeClass(this._classImageEls, this.className); +}; + + +/** + * Base class for image objects to be registered with the groups + * @class YAHOO.util.ImageLoader.imgObj + * @constructor + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + */ +YAHOO.util.ImageLoader.imgObj = function(domId, url) { + /** + * HTML DOM id of the image element + * @property domId + * @type String + */ + this.domId = domId; + + /** + * URL for the image + * @property url + * @type String + */ + this.url = url; + + /** + * Pixel width of the image. Will be set as a "width" attribute after the image is fetched. + * Detaults to the natural width of the image. + * Only appropriate with src images + * @property width + * @type Int + */ + this.width = null; + + /** + * Pixel height of the image. Will be set as a "height" attribute after the image is fetched. + * Detaults to the natural height of the image. + * Only appropriate with src images + * @property height + * @type Int + */ + this.height = null; + + /** + * Whether the style.visibility should be set to "visible" after the image is fetched. + * Used when setting src images as visibility:hidden prior to image fetching + * @property setVisible + * @type Boolean + */ + this.setVisible = false; + + /** + * Whether the image has already been fetched. In the case of a foldCondional group, keeps track for when the trigger is fired so images aren't fetched twice + * @property _fetched + * @type Boolean + * @private + */ + this._fetched = false; +}; + +/** + * Displays the image; puts the URL into the DOM + * @method fetch + */ +YAHOO.util.ImageLoader.imgObj.prototype.fetch = function() { + if (this._fetched) { + return; + } + var el = document.getElementById(this.domId); + if (! el) { + return; + } + YAHOO.log('Fetching image with id "' + this.domId + '".', 'info', 'imageloader'); + this._applyUrl(el); + + if (this.setVisible) { + el.style.visibility = 'visible'; + } + if (this.width) { + el.width = this.width; + } + if (this.height) { + el.height = this.height; + } + this._fetched = true; +}; + +/** + * Inserts the image URL into the DOM so that the image is displayed. + * Must be overridden by child class + * @method _applyUrl + * @param {Object} el HTML DOM element + * @private + */ +YAHOO.util.ImageLoader.imgObj.prototype._applyUrl = function(el) { +}; + +/** + * Background image object. A background image is one whose URL is specified by "background-image" in the element's style + * @class YAHOO.util.ImageLoader.bgImgObj + * @constructor + * @extends YAHOO.util.ImageLoader.imgObj + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + */ +YAHOO.util.ImageLoader.bgImgObj = function(domId, url) { + YAHOO.util.ImageLoader.bgImgObj.superclass.constructor.call(this, domId, url); +}; + +YAHOO.lang.extend(YAHOO.util.ImageLoader.bgImgObj, YAHOO.util.ImageLoader.imgObj); + +/** + * Inserts the image URL into the DOM so that the image is displayed. + * Sets style.backgroundImage + * @method _applyUrl + * @param {Object} el HTML DOM element + * @private + */ +YAHOO.util.ImageLoader.bgImgObj.prototype._applyUrl = function(el) { + el.style.backgroundImage = "url('" + this.url + "')"; +}; + +/** + * Source image object. A source image is one whose URL is specified by a src attribute in the DOM element + * @class YAHOO.util.ImageLoader.srcImgObj + * @constructor + * @extends YAHOO.util.ImageLoader.imgObj + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + * @param {Int} width pixel width of the image - defaults to image's natural size + * @param {Int} height pixel height of the image - defaults to image's natural size + */ +YAHOO.util.ImageLoader.srcImgObj = function(domId, url, width, height) { + YAHOO.util.ImageLoader.srcImgObj.superclass.constructor.call(this, domId, url); + this.width = width; + this.height = height; +}; + +YAHOO.lang.extend(YAHOO.util.ImageLoader.srcImgObj, YAHOO.util.ImageLoader.imgObj); + +/** + * Inserts the image URL into the DOM so that the image is displayed. + * Sets src + * @method _applyUrl + * @param {Object} el HTML DOM element + * @private + */ +YAHOO.util.ImageLoader.srcImgObj.prototype._applyUrl = function(el) { + el.src = this.url; +}; + +/** + * PNG background image object. A PNG background image is one whose URL is specified through AlphaImageLoader or by "background-image" in the element's style + * @class YAHOO.util.ImageLoader.pngBgImgObj + * @constructor + * @extends YAHOO.util.ImageLoader.imgObj + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + */ +YAHOO.util.ImageLoader.pngBgImgObj = function(domId, url) { + YAHOO.util.ImageLoader.pngBgImgObj.superclass.constructor.call(this, domId, url); +}; + +YAHOO.lang.extend(YAHOO.util.ImageLoader.pngBgImgObj, YAHOO.util.ImageLoader.imgObj); + +/** + * Inserts the image URL into the DOM so that the image is displayed. + * If the browser is determined to be IE6 (or older), sets the AlphaImageLoader src; otherwise sets style.backgroundImage + * @method _applyUrl + * @param {Object} el HTML DOM element + * @private + */ +YAHOO.util.ImageLoader.pngBgImgObj.prototype._applyUrl = function(el) { + if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { + el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + this.url + '", sizingMethod="scale")'; + } + else { + el.style.backgroundImage = "url('" + this.url + "')"; + } +}; +YAHOO.register("imageloader", YAHOO.util.ImageLoader, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/imageloader/imageloader-experimental-min.js b/lib/yui/imageloader/imageloader-experimental-min.js new file mode 100755 index 0000000000..da9a4758f0 --- /dev/null +++ b/lib/yui/imageloader/imageloader-experimental-min.js @@ -0,0 +1,21 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ + +if(typeof(YAHOO.util.ImageLoader)=='undefined'){YAHOO.util.ImageLoader={};} +YAHOO.util.ImageLoader.group=function(trigEl,trigAct,timeout){this.name='unnamed';this._imgObjs={};this.timeoutLen=timeout;this._timeout=null;this._triggers=[];this.foldConditional=false;this.className=null;this._classImageEls=null;YAHOO.util.Event.addListener(window,'load',this._onloadTasks,this,true);this.addTrigger(trigEl,trigAct);};YAHOO.util.ImageLoader.group.prototype.addTrigger=function(trigEl,trigAct){if(!trigEl||!trigAct){return;} +var wrappedFetch=function(){this.fetch();};this._triggers.push([trigEl,trigAct,wrappedFetch]);YAHOO.util.Event.addListener(trigEl,trigAct,wrappedFetch,this,true);};YAHOO.util.ImageLoader.group.prototype._onloadTasks=function(){if(this.timeoutLen&&typeof(this.timeoutLen)=='number'&&this.timeoutLen>0){this._timeout=setTimeout(this._getFetchTimeout(),this.timeoutLen*1000);} +if(this.foldConditional){this._foldCheck();}};YAHOO.util.ImageLoader.group.prototype._getFetchTimeout=function(){var self=this;return function(){self.fetch();};};YAHOO.util.ImageLoader.group.prototype.registerBgImage=function(domId,url){this._imgObjs[domId]=new YAHOO.util.ImageLoader.bgImgObj(domId,url);return this._imgObjs[domId];};YAHOO.util.ImageLoader.group.prototype.registerSrcImage=function(domId,url,width,height){this._imgObjs[domId]=new YAHOO.util.ImageLoader.srcImgObj(domId,url,width,height);return this._imgObjs[domId];};YAHOO.util.ImageLoader.group.prototype.registerPngBgImage=function(domId,url){this._imgObjs[domId]=new YAHOO.util.ImageLoader.pngBgImgObj(domId,url);return this._imgObjs[domId];};YAHOO.util.ImageLoader.group.prototype.fetch=function(){YAHOO.log('Fetching images in group: "'+this.name+'".','info','imageloader');clearTimeout(this._timeout);for(var i=0;i 0) { + this._timeout = setTimeout(this._getFetchTimeout(), this.timeoutLen * 1000); + } + + if (this.foldConditional) { + this._foldCheck(); + } +}; + +/** + * Returns the group's fetch method, with the proper closure, for use with setTimeout + * @method _getFetchTimeout + * @return {Function} group's fetch method + * @private + */ +YAHOO.util.ImageLoader.group.prototype._getFetchTimeout = function() { + var self = this; + return function() { self.fetch(); }; +}; + +/** + * Registers a background image with the group + * @method registerBgImage + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + * @return {Object} bgImgObj that was registered, for modifying any attributes in the object + */ +YAHOO.util.ImageLoader.group.prototype.registerBgImage = function(domId, url) { + this._imgObjs[domId] = new YAHOO.util.ImageLoader.bgImgObj(domId, url); + return this._imgObjs[domId]; +}; +/** + * Registers a src image with the group + * @method registerSrcImage + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + * @param {Int} width pixel width of the image - defaults to image's natural size + * @param {Int} height pixel height of the image - defaults to image's natural size + * @return {Object} srcImgObj that was registered, for modifying any attributes in the object + */ +YAHOO.util.ImageLoader.group.prototype.registerSrcImage = function(domId, url, width, height) { + this._imgObjs[domId] = new YAHOO.util.ImageLoader.srcImgObj(domId, url, width, height); + return this._imgObjs[domId]; +}; +/** + * Registers an alpha-channel-type png background image with the group + * @method registerPngBgImage + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + * @return {Object} pngBgImgObj that was registered, for modifying any attributes in the object + */ +YAHOO.util.ImageLoader.group.prototype.registerPngBgImage = function(domId, url) { + this._imgObjs[domId] = new YAHOO.util.ImageLoader.pngBgImgObj(domId, url); + return this._imgObjs[domId]; +}; + +/** + * Displays the images in the group + * @method fetch + */ +YAHOO.util.ImageLoader.group.prototype.fetch = function() { + YAHOO.log('Fetching images in group: "' + this.name + '".', 'info', 'imageloader'); + + clearTimeout(this._timeout); + // remove all listeners + for (var i=0; i < this._triggers.length; i++) { + YAHOO.util.Event.removeListener(this._triggers[i][0], this._triggers[i][1], this._triggers[i][2]); + } + + // fetch whatever we need to by className + this._fetchByClass(); + + // fetch registered images + for (var id in this._imgObjs) { + if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) { + this._imgObjs[id].fetch(); + } + } +}; + +/** + * Checks the position of each image in the group. If any part of the image is within the client viewport, shows the image immediately. + * @method _foldCheck + * @private + */ +YAHOO.util.ImageLoader.group.prototype._foldCheck = function() { + YAHOO.log('Checking for images above the fold in group: "' + this.name + '"', 'info', 'imageloader'); + var scrollTop = (document.compatMode != 'CSS1Compat') ? document.body.scrollTop : document.documentElement.scrollTop; + var viewHeight = YAHOO.util.Dom.getViewportHeight(); + var hLimit = scrollTop + viewHeight; + var scrollLeft = (document.compatMode != 'CSS1Compat') ? document.body.scrollLeft : document.documentElement.scrollLeft; + var viewWidth = YAHOO.util.Dom.getViewportWidth(); + var wLimit = scrollLeft + viewWidth; + for (var id in this._imgObjs) { + if (YAHOO.lang.hasOwnProperty(this._imgObjs, id)) { + var elPos = YAHOO.util.Dom.getXY(this._imgObjs[id].domId); + if (elPos[1] < hLimit && elPos[0] < wLimit) { + YAHOO.log('Image with id "' + this._imgObjs[id].domId + '" is above the fold. Fetching image.', 'info', 'imageloader'); + this._imgObjs[id].fetch(); + } + } + } + // and by class + if (this.className) { + this._classImageEls = YAHOO.util.Dom.getElementsByClassName(this.className); + for (var i=0; i < this._classImageEls.length; i++) { + var elPos = YAHOO.util.Dom.getXY(this._classImageEls[i]); + if (elPos[1] < hLimit && elPos[0] < wLimit) { + YAHOO.log('Image with id "' + this._classImageEls[i].id + '" is above the fold. Fetching image. (Image registered by class name with the group - may not have an id.)', 'info', 'imageloader'); + YAHOO.util.Dom.removeClass(this._classImageEls[i], this.className); + } + } + } +}; + +/** + * Finds all elements in the Dom with the class name specified in the group. Removes the class from the element in order to let the style definitions trigger the image fetching + * @method _fetchByClass + * @private + */ +YAHOO.util.ImageLoader.group.prototype._fetchByClass = function() { + if (! this.className) { + return; + } + + YAHOO.log('Fetching all images with class "' + this.className + '" in group "' + this.name + '".', 'info', 'imageloader'); + // this._classImageEls may have been set during _foldCheck + if (this._classImageEls === null) { + this._classImageEls = YAHOO.util.Dom.getElementsByClassName(this.className); + } + YAHOO.util.Dom.removeClass(this._classImageEls, this.className); +}; + + +/** + * Base class for image objects to be registered with the groups + * @class YAHOO.util.ImageLoader.imgObj + * @constructor + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + */ +YAHOO.util.ImageLoader.imgObj = function(domId, url) { + /** + * HTML DOM id of the image element + * @property domId + * @type String + */ + this.domId = domId; + + /** + * URL for the image + * @property url + * @type String + */ + this.url = url; + + /** + * Pixel width of the image. Will be set as a "width" attribute after the image is fetched. + * Detaults to the natural width of the image. + * Only appropriate with src images + * @property width + * @type Int + */ + this.width = null; + + /** + * Pixel height of the image. Will be set as a "height" attribute after the image is fetched. + * Detaults to the natural height of the image. + * Only appropriate with src images + * @property height + * @type Int + */ + this.height = null; + + /** + * Whether the style.visibility should be set to "visible" after the image is fetched. + * Used when setting src images as visibility:hidden prior to image fetching + * @property setVisible + * @type Boolean + */ + this.setVisible = false; + + /** + * Whether the image has already been fetched. In the case of a foldCondional group, keeps track for when the trigger is fired so images aren't fetched twice + * @property _fetched + * @type Boolean + * @private + */ + this._fetched = false; +}; + +/** + * Displays the image; puts the URL into the DOM + * @method fetch + */ +YAHOO.util.ImageLoader.imgObj.prototype.fetch = function() { + if (this._fetched) { + return; + } + var el = document.getElementById(this.domId); + if (! el) { + return; + } + YAHOO.log('Fetching image with id "' + this.domId + '".', 'info', 'imageloader'); + this._applyUrl(el); + + if (this.setVisible) { + el.style.visibility = 'visible'; + } + if (this.width) { + el.width = this.width; + } + if (this.height) { + el.height = this.height; + } + this._fetched = true; +}; + +/** + * Inserts the image URL into the DOM so that the image is displayed. + * Must be overridden by child class + * @method _applyUrl + * @param {Object} el HTML DOM element + * @private + */ +YAHOO.util.ImageLoader.imgObj.prototype._applyUrl = function(el) { +}; + +/** + * Background image object. A background image is one whose URL is specified by "background-image" in the element's style + * @class YAHOO.util.ImageLoader.bgImgObj + * @constructor + * @extends YAHOO.util.ImageLoader.imgObj + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + */ +YAHOO.util.ImageLoader.bgImgObj = function(domId, url) { + YAHOO.util.ImageLoader.bgImgObj.superclass.constructor.call(this, domId, url); +}; + +YAHOO.lang.extend(YAHOO.util.ImageLoader.bgImgObj, YAHOO.util.ImageLoader.imgObj); + +/** + * Inserts the image URL into the DOM so that the image is displayed. + * Sets style.backgroundImage + * @method _applyUrl + * @param {Object} el HTML DOM element + * @private + */ +YAHOO.util.ImageLoader.bgImgObj.prototype._applyUrl = function(el) { + el.style.backgroundImage = "url('" + this.url + "')"; +}; + +/** + * Source image object. A source image is one whose URL is specified by a src attribute in the DOM element + * @class YAHOO.util.ImageLoader.srcImgObj + * @constructor + * @extends YAHOO.util.ImageLoader.imgObj + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + * @param {Int} width pixel width of the image - defaults to image's natural size + * @param {Int} height pixel height of the image - defaults to image's natural size + */ +YAHOO.util.ImageLoader.srcImgObj = function(domId, url, width, height) { + YAHOO.util.ImageLoader.srcImgObj.superclass.constructor.call(this, domId, url); + this.width = width; + this.height = height; +}; + +YAHOO.lang.extend(YAHOO.util.ImageLoader.srcImgObj, YAHOO.util.ImageLoader.imgObj); + +/** + * Inserts the image URL into the DOM so that the image is displayed. + * Sets src + * @method _applyUrl + * @param {Object} el HTML DOM element + * @private + */ +YAHOO.util.ImageLoader.srcImgObj.prototype._applyUrl = function(el) { + el.src = this.url; +}; + +/** + * PNG background image object. A PNG background image is one whose URL is specified through AlphaImageLoader or by "background-image" in the element's style + * @class YAHOO.util.ImageLoader.pngBgImgObj + * @constructor + * @extends YAHOO.util.ImageLoader.imgObj + * @param {String} domId HTML DOM id of the image element + * @param {String} url URL for the image + */ +YAHOO.util.ImageLoader.pngBgImgObj = function(domId, url) { + YAHOO.util.ImageLoader.pngBgImgObj.superclass.constructor.call(this, domId, url); +}; + +YAHOO.lang.extend(YAHOO.util.ImageLoader.pngBgImgObj, YAHOO.util.ImageLoader.imgObj); + +/** + * Inserts the image URL into the DOM so that the image is displayed. + * If the browser is determined to be IE6 (or older), sets the AlphaImageLoader src; otherwise sets style.backgroundImage + * @method _applyUrl + * @param {Object} el HTML DOM element + * @private + */ +YAHOO.util.ImageLoader.pngBgImgObj.prototype._applyUrl = function(el) { + if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { + el.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + this.url + '", sizingMethod="scale")'; + } + else { + el.style.backgroundImage = "url('" + this.url + "')"; + } +}; +YAHOO.register("imageloader", YAHOO.util.ImageLoader, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/logger/README b/lib/yui/logger/README index 2443d04545..478f308a7e 100755 --- a/lib/yui/logger/README +++ b/lib/yui/logger/README @@ -1,5 +1,41 @@ Logger Release Notes +**** version 2.3.0 **** + +* Applied new skinning model. +* Logger singleton no longer clobbers itself. +* Fixed issues when setting LogReader property footerEnabled to false. + + + +**** version 2.2.2 **** + +* No changes. + + + +*** version 2.2.1 *** + +* Updated default ".yui-log-hd h4" font-size to "107%". +* Fixed synchronicity issue with pause()/resume() calls and the corresponding +LogReader button state. +* Better support for "\n" newlines in log messages, while wrapping long lines in +verboseOutput mode. +* Added draggable and outputBuffer properties to LogReader. +* Added showCategory(), hideCategory(), showSource(), hideSource(), and +clearConsole() methods to LogReader. +* Support for multiple freestanding LogReader instances. +* Improved type checking with YAHOO.lang. + + + +**** version 2.2.0 *** + +* Implemented expand() and collapse() in LogReader class. +* Better internal browser detection. + + + *** version 0.12.2 *** * No changes. @@ -23,17 +59,13 @@ for output to a LogReader. * The Logger static method enableFirebug() has been RENAMED to enableBrowserConsole(). - * The Logger static method disableFirebug() has been RENAMED to disableBrowserConsole(). - * By default, the Logger will not automatically output to Firebug or Safari's JavaScript console. To enable this feature, implementers should now explicitly call YAHOO.widget.Logger.enableBrowserConsole(). - * Implementers may now cap the size of the YAHOO.widget.Logger stack by setting the property YAHOO.widget.Logger.maxStackEntries. - * Implementers may now control the number of items displayed in each console by setting the LogReader properties thresholdMax and thresholdMin. diff --git a/lib/yui/logger/assets/logger-core.css b/lib/yui/logger/assets/logger-core.css new file mode 100755 index 0000000000..921fad9617 --- /dev/null +++ b/lib/yui/logger/assets/logger-core.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/* This file intentionally left blank */ diff --git a/lib/yui/logger/assets/logger.css b/lib/yui/logger/assets/logger.css index 2e1cf51089..0d41c177a1 100755 --- a/lib/yui/logger/assets/logger.css +++ b/lib/yui/logger/assets/logger.css @@ -1,18 +1,55 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ /* 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;} +/* default width: 31em */ +/* default font-size 77% */ +.yui-log {padding:1em;width:31em;background-color:#AAA;color:#000;border:1px solid black;font-family:monospace;font-size:77%;text-align:left;z-index:9000;} + +/* for containers built from scratch */ +.yui-log-container {position:absolute;top:1em;right:1em;} + +/* buttons */ +.yui-log input { + margin:0;padding:0; + font-family:arial; + font-size:100%; + font-weight:normal; +} +.yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;} + +/* header */ +.yui-log .yui-log-hd {margin-top:1em;padding:.5em;background-color:#575757;} +.yui-log .yui-log-hd h4 {margin:0;padding:0;font-size:107%;font-weight:bold;color:#FFF;} + +/* body */ + +.yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;} /* height is controlled here: default 20em*/ .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 pre {margin:0;padding:0;} + +/* for pre to respect newlines yet wrap long lines */ +/* http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/ */ +.yui-log pre.yui-log-verbose { + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ +} + +/* footer */ +.yui-log .yui-log-ft {margin-top:.5em;} .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 .yui-log-ft ul {margin:0;padding:0;line-height:1.8} +.yui-log .yui-log-ft li {list-style:none;display:inline;white-space:nowrap;}*/ + +/* logs */ .yui-log .info {background-color:#A7CC25;} /* A7CC25 green */ .yui-log .warn {background-color:#F58516;} /* F58516 orange */ .yui-log .error {background-color:#E32F0B;} /* E32F0B red */ diff --git a/lib/yui/logger/assets/skins/sam/logger-skin.css b/lib/yui/logger/assets/skins/sam/logger-skin.css new file mode 100755 index 0000000000..de83af6fa9 --- /dev/null +++ b/lib/yui/logger/assets/skins/sam/logger-skin.css @@ -0,0 +1,55 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/* logger default styles */ +/* default width: 31em */ +/* default font-size 77% */ +.yui-skin-sam .yui-log { padding:1em;width:31em;background-color:#AAA;color:#000;border:1px solid black;font-family:monospace;font-size:77%;text-align:left;z-index:9000; } + +/* for containers built from scratch */ +.yui-skin-sam .yui-log-container { position:absolute;top:1em;right:1em; } + +/* buttons */ +.yui-skin-sam .yui-log input { + margin:0;padding:0; + font-family:arial; + font-size:100%; + font-weight:normal; +} +.yui-skin-sam .yui-log .yui-log-btns { position:relative;float:right;bottom:.25em; } + +/* header */ +.yui-skin-sam .yui-log .yui-log-hd { margin-top:1em;padding:.5em;background-color:#575757; } +.yui-skin-sam .yui-log .yui-log-hd h4 { margin:0;padding:0;font-size:108%;font-weight:bold;color:#FFF; } + +/* body */ + +.yui-skin-sam .yui-log .yui-log-bd { width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto; } /* height is controlled here: default 20em*/ +.yui-skin-sam .yui-log p { margin:1px;padding:.1em; } +.yui-skin-sam .yui-log pre { margin:0;padding:0; } + +/* for pre to respect newlines yet wrap long lines */ +/* http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/ */ +.yui-skin-sam .yui-log pre.yui-log-verbose { + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ +} + +/* footer */ +.yui-skin-sam .yui-log .yui-log-ft { margin-top:.5em; } +.yui-skin-sam .yui-log .yui-log-ft .yui-log-categoryfilters { } +.yui-skin-sam .yui-log .yui-log-ft .yui-log-sourcefilters { width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em; } +.yui-skin-sam .yui-log .yui-log-filtergrp { margin-right:.5em; } + +/* logs */ +.yui-skin-sam .yui-log .info { background-color:#A7CC25; } /* A7CC25 green */ +.yui-skin-sam .yui-log .warn { background-color:#F58516; } /* F58516 orange */ +.yui-skin-sam .yui-log .error { background-color:#E32F0B; } /* E32F0B red */ +.yui-skin-sam .yui-log .time { background-color:#A6C9D7; } /* A6C9D7 blue */ +.yui-skin-sam .yui-log .window { background-color:#F2E886; } /* F2E886 tan */ diff --git a/lib/yui/logger/assets/skins/sam/logger.css b/lib/yui/logger/assets/skins/sam/logger.css new file mode 100755 index 0000000000..5b8077f184 --- /dev/null +++ b/lib/yui/logger/assets/skins/sam/logger.css @@ -0,0 +1,7 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +.yui-skin-sam .yui-log{padding:1em;width:31em;background-color:#AAA;color:#000;border:1px solid black;font-family:monospace;font-size:77%;text-align:left;z-index:9000;}.yui-skin-sam .yui-log-container{position:absolute;top:1em;right:1em;}.yui-skin-sam .yui-log input{margin:0;padding:0;font-family:arial;font-size:100%;font-weight:normal;}.yui-skin-sam .yui-log .yui-log-btns{position:relative;float:right;bottom:.25em;}.yui-skin-sam .yui-log .yui-log-hd{margin-top:1em;padding:.5em;background-color:#575757;}.yui-skin-sam .yui-log .yui-log-hd h4{margin:0;padding:0;font-size:108%;font-weight:bold;color:#FFF;}.yui-skin-sam .yui-log .yui-log-bd{width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}.yui-skin-sam .yui-log p{margin:1px;padding:.1em;}.yui-skin-sam .yui-log pre{margin:0;padding:0;}.yui-skin-sam .yui-log pre.yui-log-verbose{white-space:pre-wrap;white-space:-moz-pre-wrap !important;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;}.yui-skin-sam .yui-log .yui-log-ft{margin-top:.5em;}.yui-skin-sam .yui-log .yui-log-ft .yui-log-categoryfilters{}.yui-skin-sam .yui-log .yui-log-ft .yui-log-sourcefilters{width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}.yui-skin-sam .yui-log .yui-log-filtergrp{margin-right:.5em;}.yui-skin-sam .yui-log .info{background-color:#A7CC25;}.yui-skin-sam .yui-log .warn{background-color:#F58516;}.yui-skin-sam .yui-log .error{background-color:#E32F0B;}.yui-skin-sam .yui-log .time{background-color:#A6C9D7;}.yui-skin-sam .yui-log .window{background-color:#F2E886;} diff --git a/lib/yui/logger/logger-debug.js b/lib/yui/logger/logger-debug.js index 3134716e59..583eda200f 100755 --- a/lib/yui/logger/logger-debug.js +++ b/lib/yui/logger/logger-debug.js @@ -1,1563 +1,1945 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 +version: 2.3.0 */ -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The LogMsg class defines a single log message. - * - * @class LogMsg - * @constructor - * @param oConfigs {Object} Object literal of configuration params. - */ - YAHOO.widget.LogMsg = function(oConfigs) { - // Parse configs - if (typeof oConfigs == "object") { - for(var param in oConfigs) { - this[param] = oConfigs[param]; - } - } - }; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Log message. - * - * @property msg - * @type String - */ -YAHOO.widget.LogMsg.prototype.msg = null; - -/** - * Log timestamp. - * - * @property time - * @type Date - */ -YAHOO.widget.LogMsg.prototype.time = null; - -/** - * Log category. - * - * @property category - * @type String - */ -YAHOO.widget.LogMsg.prototype.category = null; - -/** - * Log source. The first word passed in as the source argument. - * - * @property source - * @type String - */ -YAHOO.widget.LogMsg.prototype.source = null; - -/** - * Log source detail. The remainder of the string passed in as the source argument, not - * including the first word (if any). - * - * @property sourceDetail - * @type String - */ -YAHOO.widget.LogMsg.prototype.sourceDetail = null; - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The LogWriter class provides a mechanism to log messages through - * YAHOO.widget.Logger from a named source. - * - * @class LogWriter - * @constructor - * @param sSource {String} 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. - * - * @method toString - * @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. - * - * @method log - * @param sMsg {String} The log message. - * @param sCategory {String} 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. - * - * @method getSource - * @return {String} The LogWriter source. - */ -YAHOO.widget.LogWriter.prototype.getSource = function() { - return this._sSource; -}; - -/** - * Public accessor to set the source name. - * - * @method setSource - * @param sSource {String} 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 member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Source of the LogWriter instance. - * - * @property _source - * @type String - * @private - */ -YAHOO.widget.LogWriter.prototype._source = null; - - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The LogReader class provides UI to read messages logged to YAHOO.widget.Logger. - * - * @class LogReader - * @constructor - * @param elContainer {HTMLElement} (optional) DOM element reference of an existing DIV. - * @param elContainer {String} (optional) String ID of an existing DIV. - * @param oConfigs {Object} (optional) Object literal of configuration params. - */ -YAHOO.widget.LogReader = function(elContainer, oConfigs) { - var oSelf = this; - this._sName = YAHOO.widget.LogReader._index; - YAHOO.widget.LogReader._index++; - - // Parse config vars here - if (typeof oConfigs == "object") { - for(var param in oConfigs) { - this[param] = oConfigs[param]; - } - } - - // Attach container... - if(elContainer) { - if(typeof elContainer == "string") { - this._elContainer = document.getElementById(elContainer); - } - else if(elContainer.tagName) { - this._elContainer = elContainer; - } - this._elContainer.className = "yui-log"; - } - // ...or create container from scratch - if(!this._elContainer) { - if(YAHOO.widget.LogReader._elDefaultContainer) { - this._elContainer = YAHOO.widget.LogReader._elDefaultContainer; - } - else { - this._elContainer = document.body.appendChild(document.createElement("div")); - this._elContainer.id = "yui-log"; - this._elContainer.className = "yui-log"; - - YAHOO.widget.LogReader._elDefaultContainer = this._elContainer; - } - - // If implementer has provided container values, trust and set those - var containerStyle = this._elContainer.style; - if(this.width) { - containerStyle.width = this.width; - } - if(this.right) { - containerStyle.right = this.right; - } - if(this.top) { - containerStyle.top = this.top; - } - if(this.left) { - containerStyle.left = this.left; - containerStyle.right = "auto"; - } - if(this.bottom) { - containerStyle.bottom = this.bottom; - containerStyle.top = "auto"; - } - if(this.fontSize) { - containerStyle.fontSize = this.fontSize; - } - if(window.opera) { - document.body.style += ''; - } - } - - if(this._elContainer) { - // Create header - if(!this._elHd) { - this._elHd = this._elContainer.appendChild(document.createElement("div")); - this._elHd.id = "yui-log-hd" + this._sName; - this._elHd.className = "yui-log-hd"; - - this._elCollapse = this._elHd.appendChild(document.createElement("div")); - this._elCollapse.className = "yui-log-btns"; - - this._btnCollapse = document.createElement("input"); - this._btnCollapse.type = "button"; - this._btnCollapse.style.fontSize = - YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); - this._btnCollapse.className = "yui-log-button"; - this._btnCollapse.value = "Collapse"; - this._btnCollapse = this._elCollapse.appendChild(this._btnCollapse); - YAHOO.util.Event.addListener( - oSelf._btnCollapse,'click',oSelf._onClickCollapseBtn,oSelf); - - this._title = this._elHd.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._elDefaultContainer == this._elContainer)) { - var ylog_dd = new YAHOO.util.DD(this._elContainer.id); - ylog_dd.setHandleElId(this._elHd.id); - this._elHd.style.cursor = "move"; - } - } - // Ceate console - if(!this._elConsole) { - this._elConsole = - this._elContainer.appendChild(document.createElement("div")); - this._elConsole.className = "yui-log-bd"; - - // If implementer has provided console, trust and set those - if(this.height) { - this._elConsole.style.height = this.height; - } - } - // Don't create footer if disabled - if(!this._elFt && this.footerEnabled) { - this._elFt = this._elContainer.appendChild(document.createElement("div")); - this._elFt.className = "yui-log-ft"; - - this._elBtns = this._elFt.appendChild(document.createElement("div")); - this._elBtns.className = "yui-log-btns"; - - this._btnPause = document.createElement("input"); - this._btnPause.type = "button"; - this._btnPause.style.fontSize = - YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); - this._btnPause.className = "yui-log-button"; - this._btnPause.value = "Pause"; - this._btnPause = this._elBtns.appendChild(this._btnPause); - YAHOO.util.Event.addListener( - oSelf._btnPause,'click',oSelf._onClickPauseBtn,oSelf); - - this._btnClear = document.createElement("input"); - this._btnClear.type = "button"; - this._btnClear.style.fontSize = - YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); - this._btnClear.className = "yui-log-button"; - this._btnClear.value = "Clear"; - this._btnClear = this._elBtns.appendChild(this._btnClear); - YAHOO.util.Event.addListener( - oSelf._btnClear,'click',oSelf._onClickClearBtn,oSelf); - - this._elCategoryFilters = this._elFt.appendChild(document.createElement("div")); - this._elCategoryFilters.className = "yui-log-categoryfilters"; - this._elSourceFilters = this._elFt.appendChild(document.createElement("div")); - this._elSourceFilters.className = "yui-log-sourcefilters"; - } - } - - // Initialize internal vars - if(!this._buffer) { - this._buffer = []; // output buffer - } - // Timestamp of last log message to console - this._lastTime = YAHOO.widget.Logger.getStartTime(); - - // Subscribe to Logger custom events - YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog, this); - YAHOO.widget.Logger.logResetEvent.subscribe(this._onReset, this); - - // Initialize category filters - this._categoryFilters = []; - var catsLen = YAHOO.widget.Logger.categories.length; - if(this._elCategoryFilters) { - 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._elSourceFilters) { - 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); - - this._filterLogs(); - YAHOO.log("LogReader initialized", null, this.toString()); -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Whether or not the log reader is enabled to output log messages. - * - * @property logReaderEnabled - * @type Boolean - * @default true - */ -YAHOO.widget.LogReader.prototype.logReaderEnabled = true; - -/** - * Public member to access CSS width of the log reader container. - * - * @property width - * @type String - */ -YAHOO.widget.LogReader.prototype.width = null; - -/** - * Public member to access CSS height of the log reader container. - * - * @property height - * @type String - */ -YAHOO.widget.LogReader.prototype.height = null; - -/** - * Public member to access CSS top position of the log reader container. - * - * @property top - * @type String - */ -YAHOO.widget.LogReader.prototype.top = null; - -/** - * Public member to access CSS left position of the log reader container. - * - * @property left - * @type String - */ -YAHOO.widget.LogReader.prototype.left = null; - -/** - * Public member to access CSS right position of the log reader container. - * - * @property right - * @type String - */ -YAHOO.widget.LogReader.prototype.right = null; - -/** - * Public member to access CSS bottom position of the log reader container. - * - * @property bottom - * @type String - */ -YAHOO.widget.LogReader.prototype.bottom = null; - -/** - * Public member to access CSS font size of the log reader container. - * - * @property fontSize - * @type String - */ -YAHOO.widget.LogReader.prototype.fontSize = null; - -/** - * Whether or not the footer UI is enabled for the log reader. - * - * @property footerEnabled - * @type Boolean - * @default true - */ -YAHOO.widget.LogReader.prototype.footerEnabled = true; - -/** - * Whether or not output is verbose (more readable). Setting to true will make - * output more compact (less readable). - * - * @property verboseOutput - * @type Boolean - * @default true - */ -YAHOO.widget.LogReader.prototype.verboseOutput = true; - -/** - * Whether or not newest message is printed on top. - * - * @property newestOnTop - * @type Boolean - */ -YAHOO.widget.LogReader.prototype.newestOnTop = true; - -/** - * Maximum number of messages a LogReader console will display. - * - * @property thresholdMax - * @type Number - * @default 500 - */ -YAHOO.widget.LogReader.prototype.thresholdMax = 500; - -/** - * When a LogReader console reaches its thresholdMax, it will clear out messages - * and print out the latest thresholdMin number of messages. - * - * @property thresholdMin - * @type Number - * @default 100 - */ -YAHOO.widget.LogReader.prototype.thresholdMin = 100; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - - /** - * Public accessor to the unique name of the LogReader instance. - * - * @method toString - * @return {String} Unique name of the LogReader instance. - */ -YAHOO.widget.LogReader.prototype.toString = function() { - return "LogReader instance" + this._sName; -}; -/** - * 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. - * - * @method pause - */ -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. - * - * @method resume - */ -YAHOO.widget.LogReader.prototype.resume = function() { - this.logReaderEnabled = true; - this._printBuffer(); -}; - -/** - * Hides UI of log reader. Logging functionality is not disrupted. - * - * @method hide - */ -YAHOO.widget.LogReader.prototype.hide = function() { - this._elContainer.style.display = "none"; -}; - -/** - * Shows UI of log reader. Logging functionality is not disrupted. - * - * @method show - */ -YAHOO.widget.LogReader.prototype.show = function() { - this._elContainer.style.display = "block"; -}; - -/** - * Updates title to given string. - * - * @method setTitle - * @param sTitle {String} New title. - */ -YAHOO.widget.LogReader.prototype.setTitle = function(sTitle) { - this._title.innerHTML = this.html2Text(sTitle); -}; - -/** - * Gets timestamp of the last log. - * - * @method getLastTime - * @return {Date} Timestamp of the last log. - */ -YAHOO.widget.LogReader.prototype.getLastTime = function() { - return this._lastTime; -}; - -/** - * Formats message string to HTML for output to console. - * - * @method formatMsg - * @param oLogMsg {Object} Log message object. - * @return {String} HTML-formatted message for output to console. - */ -YAHOO.widget.LogReader.prototype.formatMsg = function(oLogMsg) { - var category = oLogMsg.category; - - // Label for color-coded display - var label = category.substring(0,4).toUpperCase(); - - // Calculate the elapsed time to be from the last item that passed through the filter, - // not the absolute previous item in the stack - - var time = oLogMsg.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.getLastTime(); - - var source = oLogMsg.source; - var sourceDetail = oLogMsg.sourceDetail; - var sourceAndDetail = (sourceDetail) ? - source + " " + sourceDetail : source; - - // Escape HTML entities in the log message itself for output to console - var msg = this.html2Text(oLogMsg.msg); - - // Verbose output includes extra line breaks - var output = (this.verboseOutput) ? - ["

", label, " ", - totalTime, "ms (+", elapsedTime, ") ", - localTime, ": ", - "

", - sourceAndDetail, - ":

", - msg, - "

"] : - - ["

", label, " ", - totalTime, "ms (+", elapsedTime, ") ", - localTime, ": ", - sourceAndDetail, ": ", - msg,"

"]; - - return output.join(""); -}; - -/** - * Converts input chars "<", ">", and "&" to HTML entities. - * - * @method html2Text - * @param sHtml {String} String to convert. - * @private - */ -YAHOO.widget.LogReader.prototype.html2Text = function(sHtml) { - if(sHtml) { - sHtml += ""; - return sHtml.replace(/&/g, "&").replace(//g, ">"); - } - return ""; -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class member to index multiple log reader instances. - * - * @property _memberName - * @static - * @type Number - * @default 0 - * @private - */ -YAHOO.widget.LogReader._index = 0; - -/** - * Name of LogReader instance. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.LogReader.prototype._sName = null; - -/** - * 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. - * - * @property _elDefaultContainer - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader._elDefaultContainer = null; - -/** - * Buffer of log message objects for batch output. - * - * @property _buffer - * @type Object[] - * @private - */ -YAHOO.widget.LogReader.prototype._buffer = null; - -/** - * Number of log messages output to console. - * - * @property _consoleMsgCount - * @type Number - * @default 0 - * @private - */ -YAHOO.widget.LogReader.prototype._consoleMsgCount = 0; - -/** - * Date of last output log message. - * - * @property _lastTime - * @type Date - * @private - */ -YAHOO.widget.LogReader.prototype._lastTime = null; - -/** - * Batched output timeout ID. - * - * @property _timeout - * @type Number - * @private - */ -YAHOO.widget.LogReader.prototype._timeout = null; - -/** - * Array of filters for log message categories. - * - * @property _categoryFilters - * @type String[] - * @private - */ -YAHOO.widget.LogReader.prototype._categoryFilters = null; - -/** - * Array of filters for log message sources. - * - * @property _sourceFilters - * @type String[] - * @private - */ -YAHOO.widget.LogReader.prototype._sourceFilters = null; - -/** - * Log reader container element. - * - * @property _elContainer - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elContainer = null; - -/** - * Log reader header element. - * - * @property _elHd - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elHd = null; - -/** - * Log reader collapse element. - * - * @property _elCollapse - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elCollapse = null; - -/** - * Log reader collapse button element. - * - * @property _btnCollapse - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._btnCollapse = null; - -/** - * Log reader title header element. - * - * @property _title - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._title = null; - -/** - * Log reader console element. - * - * @property _elConsole - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elConsole = null; - -/** - * Log reader footer element. - * - * @property _elFt - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elFt = null; - -/** - * Log reader buttons container element. - * - * @property _elBtns - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elBtns = null; - -/** - * Container element for log reader category filter checkboxes. - * - * @property _elCategoryFilters - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elCategoryFilters = null; - -/** - * Container element for log reader source filter checkboxes. - * - * @property _elSourceFilters - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elSourceFilters = null; - -/** - * Log reader pause button element. - * - * @property _btnPause - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._btnPause = null; - -/** - * Clear button element. - * - * @property _btnClear - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._btnClear = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Creates the UI for a category filter in the log reader footer element. - * - * @method _createCategoryCheckbox - * @param sCategory {String} Category name. - * @private - */ -YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(sCategory) { - var oSelf = this; - - if(this._elFt) { - var elParent = this._elCategoryFilters; - var filters = this._categoryFilters; - - var elFilter = elParent.appendChild(document.createElement("span")); - elFilter.className = "yui-log-filtergrp"; - // Append el at the end so IE 5.5 can set "type" attribute - // and THEN set checked property - var chkCategory = document.createElement("input"); - chkCategory.id = "yui-log-filter-" + sCategory + this._sName; - chkCategory.className = "yui-log-filter-" + sCategory; - chkCategory.type = "checkbox"; - chkCategory.category = sCategory; - chkCategory = elFilter.appendChild(chkCategory); - chkCategory.checked = true; - - // Add this checked filter to the internal array of filters - filters.push(sCategory); - // Subscribe to the click event - YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf); - - // Create and class the text label - var lblCategory = elFilter.appendChild(document.createElement("label")); - lblCategory.htmlFor = chkCategory.id; - lblCategory.className = sCategory; - lblCategory.innerHTML = sCategory; - } -}; - -/** - * Creates a checkbox in the log reader footer element to filter by source. - * - * @method _createSourceCheckbox - * @param sSource {String} Source name. - * @private - */ -YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(sSource) { - var oSelf = this; - - if(this._elFt) { - var elParent = this._elSourceFilters; - var filters = this._sourceFilters; - - var elFilter = elParent.appendChild(document.createElement("span")); - elFilter.className = "yui-log-filtergrp"; - - // Append el at the end so IE 5.5 can set "type" attribute - // and THEN set checked property - var chkSource = document.createElement("input"); - chkSource.id = "yui-log-filter" + sSource + this._sName; - chkSource.className = "yui-log-filter" + sSource; - chkSource.type = "checkbox"; - chkSource.source = sSource; - chkSource = elFilter.appendChild(chkSource); - chkSource.checked = true; - - // Add this checked filter to the internal array of filters - filters.push(sSource); - // Subscribe to the click event - YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf); - - // Create and class the text label - var lblSource = elFilter.appendChild(document.createElement("label")); - lblSource.htmlFor = chkSource.id; - lblSource.className = sSource; - lblSource.innerHTML = sSource; - } -}; - -/** - * Reprints all log messages in the stack through filters. - * - * @method _filterLogs - * @private - */ -YAHOO.widget.LogReader.prototype._filterLogs = function() { - // Reprint stack with new filters - if (this._elConsole !== 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. - * - * @method _clearConsole - * @private - */ -YAHOO.widget.LogReader.prototype._clearConsole = function() { - // Clear the buffer of any pending messages - this._timeout = null; - this._buffer = []; - this._consoleMsgCount = 0; - - // Reset the rolling timer - this._lastTime = YAHOO.widget.Logger.getStartTime(); - - var elConsole = this._elConsole; - while(elConsole.hasChildNodes()) { - elConsole.removeChild(elConsole.firstChild); - } -}; - -/** - * Sends buffer of log messages to output and clears buffer. - * - * @method _printBuffer - * @private - */ -YAHOO.widget.LogReader.prototype._printBuffer = function() { - this._timeout = null; - - if(this._elConsole !== null) { - var thresholdMax = this.thresholdMax; - thresholdMax = (thresholdMax && !isNaN(thresholdMax)) ? thresholdMax : 500; - if(this._consoleMsgCount < thresholdMax) { - var entries = []; - for (var i=0; i this.thresholdMax)) { - thresholdMin = 0; - } - var entriesStartIndex = (entriesLen > thresholdMin) ? (entriesLen - thresholdMin) : 0; - - // Iterate through all log entries - var sourceFiltersLen = this._sourceFilters.length; - var categoryFiltersLen = this._categoryFilters.length; - for(var i=entriesStartIndex; i tag instead of
 tag (for wrapping)
-            var container = (this.verboseOutput) ? "CODE" : "PRE";
-            var oNewElement = (this.newestOnTop) ?
-                this._elConsole.insertBefore(
-                    document.createElement(container),this._elConsole.firstChild):
-                this._elConsole.appendChild(document.createElement(container));
-
-            oNewElement.innerHTML = output;
-            this._consoleMsgCount++;
-            this._lastTime = entry.time.getTime();
-        }
-    }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles Logger's categoryCreateEvent.
- *
- * @method _onCategoryCreate
- * @param sType {String} The event.
- * @param aArgs {Object[]} Data passed from event firer.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onCategoryCreate = function(sType, aArgs, oSelf) {
-    var category = aArgs[0];
-    if(oSelf._elFt) {
-        oSelf._createCategoryCheckbox(category);
-    }
-};
-
-/**
- * Handles Logger's sourceCreateEvent.
- *
- * @method _onSourceCreate
- * @param sType {String} The event.
- * @param aArgs {Object[]} Data passed from event firer.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onSourceCreate = function(sType, aArgs, oSelf) {
-    var source = aArgs[0];
-    if(oSelf._elFt) {
-        oSelf._createSourceCheckbox(source);
-    }
-};
-
-/**
- * Handles check events on the category filter checkboxes.
- *
- * @method _onCheckCategory
- * @param v {HTMLEvent} The click event.
- * @param oSelf {Object} The LogReader 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 0) {
-                // Substring until first space
-                sClass = sSource.substring(0,spaceIndex);
-                // The rest of the source
-                sDetail = sSource.substring(spaceIndex,sSource.length);
-            }
-            else {
-                sClass = sSource;
-            }
-            if(this._isNewSource(sClass)) {
-                this._createNewSource(sClass);
-            }
-        }
-
-        var timestamp = new Date();
-        var logEntry = new YAHOO.widget.LogMsg({
-            msg: sMsg,
-            time: timestamp,
-            category: sCategory,
-            source: sClass,
-            sourceDetail: sDetail
-        });
-
-        var stack = this._stack;
-        var maxStackEntries = this.maxStackEntries;
-        if(maxStackEntries && !isNaN(maxStackEntries) &&
-            (stack.length >= maxStackEntries)) {
-            stack.shift();
-        }
-        stack.push(logEntry);
-        this.newLogEvent.fire(logEntry);
-
-        if(this._browserConsoleEnabled) {
-            this._printToBrowserConsole(logEntry);
-        }
-        return true;
-    }
-    else {
-        return false;
-    }
-};
-
-/**
- * Resets internal stack and startTime, enables Logger, and fires logResetEvent.
- *
- * @method reset
- */
-YAHOO.widget.Logger.reset = function() {
-    this._stack = [];
-    this._startTime = new Date().getTime();
-    this.loggerEnabled = true;
-    this.log("Logger reset");
-    this.logResetEvent.fire();
-};
-
-/**
- * Public accessor to internal stack of log message objects.
- *
- * @method getStack
- * @return {Object[]} Array of log message objects.
- */
-YAHOO.widget.Logger.getStack = function() {
-    return this._stack;
-};
-
-/**
- * Public accessor to internal start time.
- *
- * @method getStartTime
- * @return {Date} Internal date of when Logger singleton was initialized.
- */
-YAHOO.widget.Logger.getStartTime = function() {
-    return this._startTime;
-};
-
-/**
- * Disables output to the browser's global console.log() function, which is used
- * by the Firebug extension to Firefox as well as Safari.
- *
- * @method disableBrowserConsole
- */
-YAHOO.widget.Logger.disableBrowserConsole = function() {
-    YAHOO.log("Logger output to the function console.log() has been disabled.");
-    this._browserConsoleEnabled = false;
-};
-
-/**
- * Enables output to the browser's global console.log() function, which is used
- * by the Firebug extension to Firefox as well as Safari.
- *
- * @method enableBrowserConsole
- */
-YAHOO.widget.Logger.enableBrowserConsole = function() {
-    this._browserConsoleEnabled = true;
-    YAHOO.log("Logger output to the function console.log() has been enabled.");
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Fired when a new category has been created.
- *
- * @event categoryCreateEvent
- * @param sCategory {String} Category name.
- */
-YAHOO.widget.Logger.categoryCreateEvent =
-    new YAHOO.util.CustomEvent("categoryCreate", this, true);
-
- /**
- * Fired when a new source has been named.
- *
- * @event sourceCreateEvent
- * @param sSource {String} Source name.
- */
-YAHOO.widget.Logger.sourceCreateEvent =
-    new YAHOO.util.CustomEvent("sourceCreate", this, true);
-
- /**
- * Fired when a new log message has been created.
- *
- * @event newLogEvent
- * @param sMsg {String} Log message.
- */
-YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true);
-
-/**
- * Fired when the Logger has been reset has been created.
- *
- * @event logResetEvent
- */
-YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true);
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Creates a new category of log messages and fires categoryCreateEvent.
- *
- * @method _createNewCategory
- * @param sCategory {String} Category name.
- * @private
- */
-YAHOO.widget.Logger._createNewCategory = function(sCategory) {
-    this.categories.push(sCategory);
-    this.categoryCreateEvent.fire(sCategory);
-};
-
-/**
- * Checks to see if a category has already been created.
- *
- * @method _isNewCategory
- * @param sCategory {String} Category name.
- * @return {Boolean} Returns true if category is unknown, else returns false.
- * @private
- */
-YAHOO.widget.Logger._isNewCategory = function(sCategory) {
-    for(var i=0; i < this.categories.length; i++) {
-        if(sCategory == this.categories[i]) {
-            return false;
-        }
-    }
-    return true;
-};
-
-/**
- * Creates a new source of log messages and fires sourceCreateEvent.
- *
- * @method _createNewSource
- * @param sSource {String} Source name.
- * @private
- */
-YAHOO.widget.Logger._createNewSource = function(sSource) {
-    this.sources.push(sSource);
-    this.sourceCreateEvent.fire(sSource);
-};
-
-/**
- * Checks to see if a source already exists.
- *
- * @method _isNewSource
- * @param sSource {String} Source name.
- * @return {Boolean} Returns true if source is unknown, else returns false.
- * @private
- */
-YAHOO.widget.Logger._isNewSource = function(sSource) {
-    if(sSource) {
-        for(var i=0; i < this.sources.length; i++) {
-            if(sSource == this.sources[i]) {
-                return false;
-            }
-        }
-        return true;
-    }
-};
-
-/**
- * Outputs a log message to global console.log() function.
- *
- * @method _printToBrowserConsole
- * @param oEntry {Object} Log entry object.
- * @private
- */
-YAHOO.widget.Logger._printToBrowserConsole = function(oEntry) {
-    if(window.console && console.log) {
-        var category = oEntry.category;
-        var label = oEntry.category.substring(0,4).toUpperCase();
-
-        var time = oEntry.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): " +
-            oEntry.source + ": " +
-            oEntry.msg;
-
-        console.log(output);
-    }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles logging of messages due to window error events.
- *
- * @method _onWindowError
- * @param sMsg {String} The error message.
- * @param sUrl {String} URL of the error.
- * @param sLine {String} Line number of the error.
- * @private
- */
-YAHOO.widget.Logger._onWindowError = function(sMsg,sUrl,sLine) {
-    // Logger is not in scope of this event handler
-    try {
-        YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')', "window");
-        if(YAHOO.widget.Logger._origOnWindowError) {
-            YAHOO.widget.Logger._origOnWindowError();
-        }
-    }
-    catch(e) {
-        return false;
-    }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Enable handling of 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");
-
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogMsg class defines a single log message.
+ *
+ * @class LogMsg
+ * @constructor
+ * @param oConfigs {Object} Object literal of configuration params.
+ */
+ YAHOO.widget.LogMsg = function(oConfigs) {
+    // Parse configs
+    if (oConfigs && (oConfigs.constructor == Object)) {
+        for(var param in oConfigs) {
+            this[param] = oConfigs[param];
+        }
+    }
+ };
+ 
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Log message.
+ *
+ * @property msg
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.msg = null;
+ 
+/**
+ * Log timestamp.
+ *
+ * @property time
+ * @type Date
+ */
+YAHOO.widget.LogMsg.prototype.time = null;
+
+/**
+ * Log category.
+ *
+ * @property category
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.category = null;
+
+/**
+ * Log source. The first word passed in as the source argument.
+ *
+ * @property source
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.source = null;
+
+/**
+ * Log source detail. The remainder of the string passed in as the source argument, not
+ * including the first word (if any).
+ *
+ * @property sourceDetail
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.sourceDetail = null;
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogWriter class provides a mechanism to log messages through
+ * YAHOO.widget.Logger from a named source.
+ *
+ * @class LogWriter
+ * @constructor
+ * @param sSource {String} 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.
+ *
+ * @method toString
+ * @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.
+ *
+ * @method log
+ * @param sMsg {String} The log message.
+ * @param sCategory {String} 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.
+ *
+ * @method getSource
+ * @return {String} The LogWriter source.
+ */
+YAHOO.widget.LogWriter.prototype.getSource = function() {
+    return this._sSource;
+};
+
+/**
+ * Public accessor to set the source name.
+ *
+ * @method setSource
+ * @param sSource {String} 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 member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Source of the LogWriter instance.
+ *
+ * @property _source
+ * @type String
+ * @private
+ */
+YAHOO.widget.LogWriter.prototype._source = null;
+
+
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogReader class provides UI to read messages logged to YAHOO.widget.Logger.
+ *
+ * @class LogReader
+ * @constructor
+ * @param elContainer {HTMLElement} (optional) DOM element reference of an existing DIV.
+ * @param elContainer {String} (optional) String ID of an existing DIV.
+ * @param oConfigs {Object} (optional) Object literal of configuration params.
+ */
+YAHOO.widget.LogReader = function(elContainer, oConfigs) {
+    this._sName = YAHOO.widget.LogReader._index;
+    YAHOO.widget.LogReader._index++;
+    
+    // Internal vars
+    this._buffer = []; // output buffer
+    this._filterCheckboxes = {}; // pointers to checkboxes
+    this._lastTime = YAHOO.widget.Logger.getStartTime(); // timestamp of last log message to console
+
+    // Parse config vars here
+    if (oConfigs && (oConfigs.constructor == Object)) {
+        for(var param in oConfigs) {
+            this[param] = oConfigs[param];
+        }
+    }
+
+    this._initContainerEl(elContainer);
+    if(!this._elContainer) {
+        YAHOO.log("Could not instantiate LogReader due to an invalid container element " +
+                elContainer, "error", this.toString());
+        return;
+    }
+    
+    this._initHeaderEl();
+    this._initConsoleEl();
+    this._initFooterEl();
+
+    this._initDragDrop();
+
+    this._initCategories();
+    this._initSources();
+
+    // Subscribe to Logger custom events
+    YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog, this);
+    YAHOO.widget.Logger.logResetEvent.subscribe(this._onReset, this);
+
+    YAHOO.widget.Logger.categoryCreateEvent.subscribe(this._onCategoryCreate, this);
+    YAHOO.widget.Logger.sourceCreateEvent.subscribe(this._onSourceCreate, this);
+
+    this._filterLogs();
+    YAHOO.log("LogReader initialized", null, this.toString());
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Whether or not LogReader is enabled to output log messages.
+ *
+ * @property logReaderEnabled
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.logReaderEnabled = true;
+
+/**
+ * Public member to access CSS width of the LogReader container.
+ *
+ * @property width
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.width = null;
+
+/**
+ * Public member to access CSS height of the LogReader container.
+ *
+ * @property height
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.height = null;
+
+/**
+ * Public member to access CSS top position of the LogReader container.
+ *
+ * @property top
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.top = null;
+
+/**
+ * Public member to access CSS left position of the LogReader container.
+ *
+ * @property left
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.left = null;
+
+/**
+ * Public member to access CSS right position of the LogReader container.
+ *
+ * @property right
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.right = null;
+
+/**
+ * Public member to access CSS bottom position of the LogReader container.
+ *
+ * @property bottom
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.bottom = null;
+
+/**
+ * Public member to access CSS font size of the LogReader container.
+ *
+ * @property fontSize
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.fontSize = null;
+
+/**
+ * Whether or not the footer UI is enabled for the LogReader.
+ *
+ * @property footerEnabled
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.footerEnabled = true;
+
+/**
+ * Whether or not output is verbose (more readable). Setting to true will make
+ * output more compact (less readable).
+ *
+ * @property verboseOutput
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.verboseOutput = true;
+
+/**
+ * Whether or not newest message is printed on top.
+ *
+ * @property newestOnTop
+ * @type Boolean
+ */
+YAHOO.widget.LogReader.prototype.newestOnTop = true;
+
+/**
+ * Output timeout buffer in milliseconds.
+ *
+ * @property outputBuffer
+ * @type Number
+ * @default 100
+ */
+YAHOO.widget.LogReader.prototype.outputBuffer = 100;
+
+/**
+ * Maximum number of messages a LogReader console will display.
+ *
+ * @property thresholdMax
+ * @type Number
+ * @default 500
+ */
+YAHOO.widget.LogReader.prototype.thresholdMax = 500;
+
+/**
+ * When a LogReader console reaches its thresholdMax, it will clear out messages
+ * and print out the latest thresholdMin number of messages.
+ *
+ * @property thresholdMin
+ * @type Number
+ * @default 100
+ */
+YAHOO.widget.LogReader.prototype.thresholdMin = 100;
+
+/**
+ * True when LogReader is in a collapsed state, false otherwise.
+ *
+ * @property isCollapsed
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.LogReader.prototype.isCollapsed = false;
+
+/**
+ * True when LogReader is in a paused state, false otherwise.
+ *
+ * @property isPaused
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.LogReader.prototype.isPaused = false;
+
+/**
+ * Enables draggable LogReader if DragDrop Utility is present.
+ *
+ * @property draggable
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.draggable = true;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the LogReader instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the LogReader instance.
+ */
+YAHOO.widget.LogReader.prototype.toString = function() {
+    return "LogReader instance" + this._sName;
+};
+/**
+ * Pauses output of log messages. While paused, log messages are not lost, but
+ * get saved to a buffer and then output upon resume of LogReader.
+ *
+ * @method pause
+ */
+YAHOO.widget.LogReader.prototype.pause = function() {
+    this.isPaused = true;
+    this._btnPause.value = "Resume";
+    this._timeout = null;
+    this.logReaderEnabled = false;
+};
+
+/**
+ * Resumes output of log messages, including outputting any log messages that
+ * have been saved to buffer while paused.
+ *
+ * @method resume
+ */
+YAHOO.widget.LogReader.prototype.resume = function() {
+    this.isPaused = false;
+    this._btnPause.value = "Pause";
+    this.logReaderEnabled = true;
+    this._printBuffer();
+};
+
+/**
+ * Hides UI of LogReader. Logging functionality is not disrupted.
+ *
+ * @method hide
+ */
+YAHOO.widget.LogReader.prototype.hide = function() {
+    this._elContainer.style.display = "none";
+};
+
+/**
+ * Shows UI of LogReader. Logging functionality is not disrupted.
+ *
+ * @method show
+ */
+YAHOO.widget.LogReader.prototype.show = function() {
+    this._elContainer.style.display = "block";
+};
+
+/**
+ * Collapses UI of LogReader. Logging functionality is not disrupted.
+ *
+ * @method collapse
+ */
+YAHOO.widget.LogReader.prototype.collapse = function() {
+    this._elConsole.style.display = "none";
+    if(this._elFt) {
+        this._elFt.style.display = "none";
+    }
+    this._btnCollapse.value = "Expand";
+    this.isCollapsed = true;
+};
+
+/**
+ * Expands UI of LogReader. Logging functionality is not disrupted.
+ *
+ * @method expand
+ */
+YAHOO.widget.LogReader.prototype.expand = function() {
+    this._elConsole.style.display = "block";
+    if(this._elFt) {
+        this._elFt.style.display = "block";
+    }
+    this._btnCollapse.value = "Collapse";
+    this.isCollapsed = false;
+};
+
+/**
+ * Returns related checkbox element for given filter (i.e., category or source).
+ *
+ * @method getCheckbox
+ * @param {String} Category or source name.
+ * @return {Array} Array of all filter checkboxes.
+ */
+YAHOO.widget.LogReader.prototype.getCheckbox = function(filter) {
+    return this._filterCheckboxes[filter];
+};
+
+/**
+ * Returns array of enabled categories.
+ *
+ * @method getCategories
+ * @return {String[]} Array of enabled categories.
+ */
+YAHOO.widget.LogReader.prototype.getCategories = function() {
+    return this._categoryFilters;
+};
+
+/**
+ * Shows log messages associated with given category.
+ *
+ * @method showCategory
+ * @param {String} Category name.
+ */
+YAHOO.widget.LogReader.prototype.showCategory = function(sCategory) {
+    var filtersArray = this._categoryFilters;
+    // Don't do anything if category is already enabled
+    // Use Array.indexOf if available...
+    if(filtersArray.indexOf) {
+         if(filtersArray.indexOf(sCategory) >  -1) {
+            return;
+        }
+    }
+    // ...or do it the old-fashioned way
+    else {
+        for(var i=0; i  -1) {
+            return;
+        }
+    }
+    // ...or do it the old-fashioned way
+    else {
+        for(var i=0; i

", label, " ", + totalTime, "ms (+", elapsedTime, ") ", + localTime, ": ", + "

", + sourceAndDetail, + ":

", + msg, + "

"] : + + ["

", label, " ", + totalTime, "ms (+", elapsedTime, ") ", + localTime, ": ", + sourceAndDetail, ": ", + msg, "

"]; + + return output.join(""); +}; + +/** + * Converts input chars "<", ">", and "&" to HTML entities. + * + * @method html2Text + * @param sHtml {String} String to convert. + * @private + */ +YAHOO.widget.LogReader.prototype.html2Text = function(sHtml) { + if(sHtml) { + sHtml += ""; + return sHtml.replace(/&/g, "&").replace(//g, ">"); + } + return ""; +}; + +///////////////////////////////////////////////////////////////////////////// +// +// Private member variables +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Internal class member to index multiple LogReader instances. + * + * @property _memberName + * @static + * @type Number + * @default 0 + * @private + */ +YAHOO.widget.LogReader._index = 0; + +/** + * Name of LogReader instance. + * + * @property _sName + * @type String + * @private + */ +YAHOO.widget.LogReader.prototype._sName = null; + +//TODO: remove +/** + * A class member shared by all LogReaders 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. + * + * @property _elDefaultContainer + * @type HTMLElement + * @private + */ +//YAHOO.widget.LogReader._elDefaultContainer = null; + +/** + * Buffer of log message objects for batch output. + * + * @property _buffer + * @type Object[] + * @private + */ +YAHOO.widget.LogReader.prototype._buffer = null; + +/** + * Number of log messages output to console. + * + * @property _consoleMsgCount + * @type Number + * @default 0 + * @private + */ +YAHOO.widget.LogReader.prototype._consoleMsgCount = 0; + +/** + * Date of last output log message. + * + * @property _lastTime + * @type Date + * @private + */ +YAHOO.widget.LogReader.prototype._lastTime = null; + +/** + * Batched output timeout ID. + * + * @property _timeout + * @type Number + * @private + */ +YAHOO.widget.LogReader.prototype._timeout = null; + +/** + * Hash of filters and their related checkbox elements. + * + * @property _filterCheckboxes + * @type Object + * @private + */ +YAHOO.widget.LogReader.prototype._filterCheckboxes = null; + +/** + * Array of filters for log message categories. + * + * @property _categoryFilters + * @type String[] + * @private + */ +YAHOO.widget.LogReader.prototype._categoryFilters = null; + +/** + * Array of filters for log message sources. + * + * @property _sourceFilters + * @type String[] + * @private + */ +YAHOO.widget.LogReader.prototype._sourceFilters = null; + +/** + * LogReader container element. + * + * @property _elContainer + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elContainer = null; + +/** + * LogReader header element. + * + * @property _elHd + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elHd = null; + +/** + * LogReader collapse element. + * + * @property _elCollapse + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elCollapse = null; + +/** + * LogReader collapse button element. + * + * @property _btnCollapse + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._btnCollapse = null; + +/** + * LogReader title header element. + * + * @property _title + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._title = null; + +/** + * LogReader console element. + * + * @property _elConsole + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elConsole = null; + +/** + * LogReader footer element. + * + * @property _elFt + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elFt = null; + +/** + * LogReader buttons container element. + * + * @property _elBtns + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elBtns = null; + +/** + * Container element for LogReader category filter checkboxes. + * + * @property _elCategoryFilters + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elCategoryFilters = null; + +/** + * Container element for LogReader source filter checkboxes. + * + * @property _elSourceFilters + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elSourceFilters = null; + +/** + * LogReader pause button element. + * + * @property _btnPause + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._btnPause = null; + +/** + * Clear button element. + * + * @property _btnClear + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._btnClear = null; + +///////////////////////////////////////////////////////////////////////////// +// +// Private methods +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Initializes the primary container element. + * + * @method _initContainerEl + * @param elContainer {HTMLElement} Container element by reference or string ID. + * @private + */ +YAHOO.widget.LogReader.prototype._initContainerEl = function(elContainer) { + // Validate container + elContainer = YAHOO.util.Dom.get(elContainer); + // Attach to existing container... + if(elContainer && elContainer.tagName && (elContainer.tagName.toLowerCase() == "div")) { + this._elContainer = elContainer; + YAHOO.util.Dom.addClass(this._elContainer,"yui-log"); + } + // ...or create container from scratch + else { + this._elContainer = document.body.appendChild(document.createElement("div")); + //this._elContainer.id = "yui-log" + this._sName; + YAHOO.util.Dom.addClass(this._elContainer,"yui-log"); + YAHOO.util.Dom.addClass(this._elContainer,"yui-log-container"); + + //YAHOO.widget.LogReader._elDefaultContainer = this._elContainer; + + // If implementer has provided container values, trust and set those + var containerStyle = this._elContainer.style; + if(this.width) { + containerStyle.width = this.width; + } + if(this.right) { + containerStyle.right = this.right; + } + if(this.top) { + containerStyle.top = this.top; + } + if(this.left) { + containerStyle.left = this.left; + containerStyle.right = "auto"; + } + if(this.bottom) { + containerStyle.bottom = this.bottom; + containerStyle.top = "auto"; + } + if(this.fontSize) { + containerStyle.fontSize = this.fontSize; + } + // For Opera + if(navigator.userAgent.toLowerCase().indexOf("opera") != -1) { + document.body.style += ''; + } + } +}; + +/** + * Initializes the header element. + * + * @method _initHeaderEl + * @private + */ +YAHOO.widget.LogReader.prototype._initHeaderEl = function() { + var oSelf = this; + + // Destroy header + if(this._elHd) { + // Unhook DOM events + YAHOO.util.Event.purgeElement(this._elHd, true); + + // Remove DOM elements + this._elHd.innerHTML = ""; + } + + // Create header + this._elHd = this._elContainer.appendChild(document.createElement("div")); + this._elHd.id = "yui-log-hd" + this._sName; + this._elHd.className = "yui-log-hd"; + + this._elCollapse = this._elHd.appendChild(document.createElement("div")); + this._elCollapse.className = "yui-log-btns"; + + this._btnCollapse = document.createElement("input"); + this._btnCollapse.type = "button"; + //this._btnCollapse.style.fontSize = + // YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); + this._btnCollapse.className = "yui-log-button"; + this._btnCollapse.value = "Collapse"; + this._btnCollapse = this._elCollapse.appendChild(this._btnCollapse); + YAHOO.util.Event.addListener( + oSelf._btnCollapse,'click',oSelf._onClickCollapseBtn,oSelf); + + this._title = this._elHd.appendChild(document.createElement("h4")); + this._title.innerHTML = "Logger Console"; +}; + +/** + * Initializes the console element. + * + * @method _initConsoleEl + * @private + */ +YAHOO.widget.LogReader.prototype._initConsoleEl = function() { + // Destroy console + if(this._elConsole) { + // Unhook DOM events + YAHOO.util.Event.purgeElement(this._elConsole, true); + + // Remove DOM elements + this._elConsole.innerHTML = ""; + } + + // Ceate console + this._elConsole = this._elContainer.appendChild(document.createElement("div")); + this._elConsole.className = "yui-log-bd"; + + // If implementer has provided console, trust and set those + if(this.height) { + this._elConsole.style.height = this.height; + } +}; + +/** + * Initializes the footer element. + * + * @method _initFooterEl + * @private + */ +YAHOO.widget.LogReader.prototype._initFooterEl = function() { + var oSelf = this; + + // Don't create footer elements if footer is disabled + if(this.footerEnabled) { + // Destroy console + if(this._elFt) { + // Unhook DOM events + YAHOO.util.Event.purgeElement(this._elFt, true); + + // Remove DOM elements + this._elFt.innerHTML = ""; + } + + this._elFt = this._elContainer.appendChild(document.createElement("div")); + this._elFt.className = "yui-log-ft"; + + this._elBtns = this._elFt.appendChild(document.createElement("div")); + this._elBtns.className = "yui-log-btns"; + + this._btnPause = document.createElement("input"); + this._btnPause.type = "button"; + //this._btnPause.style.fontSize = + // YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); + this._btnPause.className = "yui-log-button"; + this._btnPause.value = "Pause"; + this._btnPause = this._elBtns.appendChild(this._btnPause); + YAHOO.util.Event.addListener( + oSelf._btnPause,'click',oSelf._onClickPauseBtn,oSelf); + + this._btnClear = document.createElement("input"); + this._btnClear.type = "button"; + //this._btnClear.style.fontSize = + // YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); + this._btnClear.className = "yui-log-button"; + this._btnClear.value = "Clear"; + this._btnClear = this._elBtns.appendChild(this._btnClear); + YAHOO.util.Event.addListener( + oSelf._btnClear,'click',oSelf._onClickClearBtn,oSelf); + + this._elCategoryFilters = this._elFt.appendChild(document.createElement("div")); + this._elCategoryFilters.className = "yui-log-categoryfilters"; + this._elSourceFilters = this._elFt.appendChild(document.createElement("div")); + this._elSourceFilters.className = "yui-log-sourcefilters"; + } +}; + +/** + * Initializes Drag and Drop on the header element. + * + * @method _initDragDrop + * @private + */ +YAHOO.widget.LogReader.prototype._initDragDrop = function() { + // If Drag and Drop utility is available... + // ...and draggable is true... + // ...then make the header draggable + if(YAHOO.util.DD && this.draggable && this._elHd) { + var ylog_dd = new YAHOO.util.DD(this._elContainer); + ylog_dd.setHandleElId(this._elHd.id); + //TODO: use class name + this._elHd.style.cursor = "move"; + } +}; + +/** + * Initializes category filters. + * + * @method _initCategories + * @private + */ +YAHOO.widget.LogReader.prototype._initCategories = function() { + // Initialize category filters + this._categoryFilters = []; + var aInitialCategories = YAHOO.widget.Logger.categories; + + for(var j=0; j < aInitialCategories.length; j++) { + var sCategory = aInitialCategories[j]; + + // Add category to the internal array of filters + this._categoryFilters.push(sCategory); + + // Add checkbox element if UI is enabled + if(this._elCategoryFilters) { + this._createCategoryCheckbox(sCategory); + } + } +}; + +/** + * Initializes source filters. + * + * @method _initSources + * @private + */ +YAHOO.widget.LogReader.prototype._initSources = function() { + // Initialize source filters + this._sourceFilters = []; + var aInitialSources = YAHOO.widget.Logger.sources; + + for(var j=0; j < aInitialSources.length; j++) { + var sSource = aInitialSources[j]; + + // Add source to the internal array of filters + this._sourceFilters.push(sSource); + + // Add checkbox element if UI is enabled + if(this._elSourceFilters) { + this._createSourceCheckbox(sSource); + } + }} +; + +/** + * Creates the UI for a category filter in the LogReader footer element. + * + * @method _createCategoryCheckbox + * @param sCategory {String} Category name. + * @private + */ +YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(sCategory) { + var oSelf = this; + + if(this._elFt) { + var elParent = this._elCategoryFilters; + var elFilter = elParent.appendChild(document.createElement("span")); + elFilter.className = "yui-log-filtergrp"; + + // Append el at the end so IE 5.5 can set "type" attribute + // and THEN set checked property + var chkCategory = document.createElement("input"); + chkCategory.id = "yui-log-filter-" + sCategory + this._sName; + chkCategory.className = "yui-log-filter-" + sCategory; + chkCategory.type = "checkbox"; + chkCategory.category = sCategory; + chkCategory = elFilter.appendChild(chkCategory); + chkCategory.checked = true; + + // Subscribe to the click event + YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf); + + // Create and class the text label + var lblCategory = elFilter.appendChild(document.createElement("label")); + lblCategory.htmlFor = chkCategory.id; + lblCategory.className = sCategory; + lblCategory.innerHTML = sCategory; + + this._filterCheckboxes[sCategory] = chkCategory; + } +}; + +/** + * Creates a checkbox in the LogReader footer element to filter by source. + * + * @method _createSourceCheckbox + * @param sSource {String} Source name. + * @private + */ +YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(sSource) { + var oSelf = this; + + if(this._elFt) { + var elParent = this._elSourceFilters; + var elFilter = elParent.appendChild(document.createElement("span")); + elFilter.className = "yui-log-filtergrp"; + + // Append el at the end so IE 5.5 can set "type" attribute + // and THEN set checked property + var chkSource = document.createElement("input"); + chkSource.id = "yui-log-filter" + sSource + this._sName; + chkSource.className = "yui-log-filter" + sSource; + chkSource.type = "checkbox"; + chkSource.source = sSource; + chkSource = elFilter.appendChild(chkSource); + chkSource.checked = true; + + // Subscribe to the click event + YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf); + + // Create and class the text label + var lblSource = elFilter.appendChild(document.createElement("label")); + lblSource.htmlFor = chkSource.id; + lblSource.className = sSource; + lblSource.innerHTML = sSource; + + this._filterCheckboxes[sSource] = chkSource; + } +}; + +/** + * Reprints all log messages in the stack through filters. + * + * @method _filterLogs + * @private + */ +YAHOO.widget.LogReader.prototype._filterLogs = function() { + // Reprint stack with new filters + if (this._elConsole !== null) { + this.clearConsole(); + this._printToConsole(YAHOO.widget.Logger.getStack()); + } +}; + +/** + * Sends buffer of log messages to output and clears buffer. + * + * @method _printBuffer + * @private + */ +YAHOO.widget.LogReader.prototype._printBuffer = function() { + this._timeout = null; + + if(this._elConsole !== null) { + var thresholdMax = this.thresholdMax; + thresholdMax = (thresholdMax && !isNaN(thresholdMax)) ? thresholdMax : 500; + if(this._consoleMsgCount < thresholdMax) { + var entries = []; + for (var i=0; i this.thresholdMax)) { + thresholdMin = 0; + } + var entriesStartIndex = (entriesLen > thresholdMin) ? (entriesLen - thresholdMin) : 0; + + // Iterate through all log entries + var sourceFiltersLen = this._sourceFilters.length; + var categoryFiltersLen = this._categoryFilters.length; + for(var i=entriesStartIndex; i 0) { + // Substring until first space + sClass = sSource.substring(0,spaceIndex); + // The rest of the source + sDetail = sSource.substring(spaceIndex,sSource.length); + } + else { + sClass = sSource; + } + if(this._isNewSource(sClass)) { + this._createNewSource(sClass); + } + } + + var timestamp = new Date(); + var logEntry = new YAHOO.widget.LogMsg({ + msg: sMsg, + time: timestamp, + category: sCategory, + source: sClass, + sourceDetail: sDetail + }); + + var stack = this._stack; + var maxStackEntries = this.maxStackEntries; + if(maxStackEntries && !isNaN(maxStackEntries) && + (stack.length >= maxStackEntries)) { + stack.shift(); + } + stack.push(logEntry); + this.newLogEvent.fire(logEntry); + + if(this._browserConsoleEnabled) { + this._printToBrowserConsole(logEntry); + } + return true; + } + else { + return false; + } + }; + + /** + * Resets internal stack and startTime, enables Logger, and fires logResetEvent. + * + * @method reset + */ + YAHOO.widget.Logger.reset = function() { + this._stack = []; + this._startTime = new Date().getTime(); + this.loggerEnabled = true; + this.log("Logger reset"); + this.logResetEvent.fire(); + }; + + /** + * Public accessor to internal stack of log message objects. + * + * @method getStack + * @return {Object[]} Array of log message objects. + */ + YAHOO.widget.Logger.getStack = function() { + return this._stack; + }; + + /** + * Public accessor to internal start time. + * + * @method getStartTime + * @return {Date} Internal date of when Logger singleton was initialized. + */ + YAHOO.widget.Logger.getStartTime = function() { + return this._startTime; + }; + + /** + * Disables output to the browser's global console.log() function, which is used + * by the Firebug extension to Firefox as well as Safari. + * + * @method disableBrowserConsole + */ + YAHOO.widget.Logger.disableBrowserConsole = function() { + YAHOO.log("Logger output to the function console.log() has been disabled."); + this._browserConsoleEnabled = false; + }; + + /** + * Enables output to the browser's global console.log() function, which is used + * by the Firebug extension to Firefox as well as Safari. + * + * @method enableBrowserConsole + */ + YAHOO.widget.Logger.enableBrowserConsole = function() { + this._browserConsoleEnabled = true; + YAHOO.log("Logger output to the function console.log() has been enabled."); + }; + + ///////////////////////////////////////////////////////////////////////////// + // + // Public events + // + ///////////////////////////////////////////////////////////////////////////// + + /** + * Fired when a new category has been created. + * + * @event categoryCreateEvent + * @param sCategory {String} Category name. + */ + YAHOO.widget.Logger.categoryCreateEvent = + new YAHOO.util.CustomEvent("categoryCreate", this, true); + + /** + * Fired when a new source has been named. + * + * @event sourceCreateEvent + * @param sSource {String} Source name. + */ + YAHOO.widget.Logger.sourceCreateEvent = + new YAHOO.util.CustomEvent("sourceCreate", this, true); + + /** + * Fired when a new log message has been created. + * + * @event newLogEvent + * @param sMsg {String} Log message. + */ + YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true); + + /** + * Fired when the Logger has been reset has been created. + * + * @event logResetEvent + */ + YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true); + + ///////////////////////////////////////////////////////////////////////////// + // + // Private methods + // + ///////////////////////////////////////////////////////////////////////////// + + /** + * Creates a new category of log messages and fires categoryCreateEvent. + * + * @method _createNewCategory + * @param sCategory {String} Category name. + * @private + */ + YAHOO.widget.Logger._createNewCategory = function(sCategory) { + this.categories.push(sCategory); + this.categoryCreateEvent.fire(sCategory); + }; + + /** + * Checks to see if a category has already been created. + * + * @method _isNewCategory + * @param sCategory {String} Category name. + * @return {Boolean} Returns true if category is unknown, else returns false. + * @private + */ + YAHOO.widget.Logger._isNewCategory = function(sCategory) { + for(var i=0; i < this.categories.length; i++) { + if(sCategory == this.categories[i]) { + return false; + } + } + return true; + }; + + /** + * Creates a new source of log messages and fires sourceCreateEvent. + * + * @method _createNewSource + * @param sSource {String} Source name. + * @private + */ + YAHOO.widget.Logger._createNewSource = function(sSource) { + this.sources.push(sSource); + this.sourceCreateEvent.fire(sSource); + }; + + /** + * Checks to see if a source already exists. + * + * @method _isNewSource + * @param sSource {String} Source name. + * @return {Boolean} Returns true if source is unknown, else returns false. + * @private + */ + YAHOO.widget.Logger._isNewSource = function(sSource) { + if(sSource) { + for(var i=0; i < this.sources.length; i++) { + if(sSource == this.sources[i]) { + return false; + } + } + return true; + } + }; + + /** + * Outputs a log message to global console.log() function. + * + * @method _printToBrowserConsole + * @param oEntry {Object} Log entry object. + * @private + */ + YAHOO.widget.Logger._printToBrowserConsole = function(oEntry) { + if(window.console && console.log) { + var category = oEntry.category; + var label = oEntry.category.substring(0,4).toUpperCase(); + + var time = oEntry.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): " + + oEntry.source + ": " + + oEntry.msg; + + console.log(output); + } + }; + + ///////////////////////////////////////////////////////////////////////////// + // + // Private event handlers + // + ///////////////////////////////////////////////////////////////////////////// + + /** + * Handles logging of messages due to window error events. + * + * @method _onWindowError + * @param sMsg {String} The error message. + * @param sUrl {String} URL of the error. + * @param sLine {String} Line number of the error. + * @private + */ + YAHOO.widget.Logger._onWindowError = function(sMsg,sUrl,sLine) { + // Logger is not in scope of this event handler + try { + YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')', "window"); + if(YAHOO.widget.Logger._origOnWindowError) { + YAHOO.widget.Logger._origOnWindowError(); + } + } + catch(e) { + return false; + } + }; + + ///////////////////////////////////////////////////////////////////////////// + // + // Enable handling of 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"); +} + + +YAHOO.register("logger", YAHOO.widget.Logger, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/logger/logger-min.js b/lib/yui/logger/logger-min.js index f41d323f30..ceddbdade3 100755 --- a/lib/yui/logger/logger-min.js +++ b/lib/yui/logger/logger-min.js @@ -1,63 +1,64 @@ /* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt -version: 0.12.2 +version: 2.3.0 */ - -YAHOO.widget.LogMsg=function(oConfigs){if(typeof oConfigs=="object"){for(var param in oConfigs){this[param]=oConfigs[param];}}};YAHOO.widget.LogMsg.prototype.msg=null;YAHOO.widget.LogMsg.prototype.time=null;YAHOO.widget.LogMsg.prototype.category=null;YAHOO.widget.LogMsg.prototype.source=null;YAHOO.widget.LogMsg.prototype.sourceDetail=null;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(elContainer,oConfigs){var oSelf=this;this._sName=YAHOO.widget.LogReader._index;YAHOO.widget.LogReader._index++;if(typeof oConfigs=="object"){for(var param in oConfigs){this[param]=oConfigs[param];}} -if(elContainer){if(typeof elContainer=="string"){this._elContainer=document.getElementById(elContainer);} -else if(elContainer.tagName){this._elContainer=elContainer;} -this._elContainer.className="yui-log";} -if(!this._elContainer){if(YAHOO.widget.LogReader._elDefaultContainer){this._elContainer=YAHOO.widget.LogReader._elDefaultContainer;} -else{this._elContainer=document.body.appendChild(document.createElement("div"));this._elContainer.id="yui-log";this._elContainer.className="yui-log";YAHOO.widget.LogReader._elDefaultContainer=this._elContainer;} -var containerStyle=this._elContainer.style;if(this.width){containerStyle.width=this.width;} -if(this.right){containerStyle.right=this.right;} -if(this.top){containerStyle.top=this.top;} -if(this.left){containerStyle.left=this.left;containerStyle.right="auto";} -if(this.bottom){containerStyle.bottom=this.bottom;containerStyle.top="auto";} -if(this.fontSize){containerStyle.fontSize=this.fontSize;} -if(window.opera){document.body.style+='';}} -if(this._elContainer){if(!this._elHd){this._elHd=this._elContainer.appendChild(document.createElement("div"));this._elHd.id="yui-log-hd"+this._sName;this._elHd.className="yui-log-hd";this._elCollapse=this._elHd.appendChild(document.createElement("div"));this._elCollapse.className="yui-log-btns";this._btnCollapse=document.createElement("input");this._btnCollapse.type="button";this._btnCollapse.style.fontSize=YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");this._btnCollapse.className="yui-log-button";this._btnCollapse.value="Collapse";this._btnCollapse=this._elCollapse.appendChild(this._btnCollapse);YAHOO.util.Event.addListener(oSelf._btnCollapse,'click',oSelf._onClickCollapseBtn,oSelf);this._title=this._elHd.appendChild(document.createElement("h4"));this._title.innerHTML="Logger Console";if(YAHOO.util.DD&&(YAHOO.widget.LogReader._elDefaultContainer==this._elContainer)){var ylog_dd=new YAHOO.util.DD(this._elContainer.id);ylog_dd.setHandleElId(this._elHd.id);this._elHd.style.cursor="move";}} -if(!this._elConsole){this._elConsole=this._elContainer.appendChild(document.createElement("div"));this._elConsole.className="yui-log-bd";if(this.height){this._elConsole.style.height=this.height;}} -if(!this._elFt&&this.footerEnabled){this._elFt=this._elContainer.appendChild(document.createElement("div"));this._elFt.className="yui-log-ft";this._elBtns=this._elFt.appendChild(document.createElement("div"));this._elBtns.className="yui-log-btns";this._btnPause=document.createElement("input");this._btnPause.type="button";this._btnPause.style.fontSize=YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");this._btnPause.className="yui-log-button";this._btnPause.value="Pause";this._btnPause=this._elBtns.appendChild(this._btnPause);YAHOO.util.Event.addListener(oSelf._btnPause,'click',oSelf._onClickPauseBtn,oSelf);this._btnClear=document.createElement("input");this._btnClear.type="button";this._btnClear.style.fontSize=YAHOO.util.Dom.getStyle(this._elContainer,"fontSize");this._btnClear.className="yui-log-button";this._btnClear.value="Clear";this._btnClear=this._elBtns.appendChild(this._btnClear);YAHOO.util.Event.addListener(oSelf._btnClear,'click',oSelf._onClickClearBtn,oSelf);this._elCategoryFilters=this._elFt.appendChild(document.createElement("div"));this._elCategoryFilters.className="yui-log-categoryfilters";this._elSourceFilters=this._elFt.appendChild(document.createElement("div"));this._elSourceFilters.className="yui-log-sourcefilters";}} -if(!this._buffer){this._buffer=[];} -this._lastTime=YAHOO.widget.Logger.getStartTime();YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog,this);YAHOO.widget.Logger.logResetEvent.subscribe(this._onReset,this);this._categoryFilters=[];var catsLen=YAHOO.widget.Logger.categories.length;if(this._elCategoryFilters){for(var i=0;i",label," ",totalTime,"ms (+",elapsedTime,") ",localTime,": ","

",sourceAndDetail,":

",msg,"

"]:["

",label," ",totalTime,"ms (+",elapsedTime,") ",localTime,": ",sourceAndDetail,": ",msg,"

"];return output.join("");};YAHOO.widget.LogReader.prototype.html2Text=function(sHtml){if(sHtml){sHtml+="";return sHtml.replace(/&/g,"&").replace(//g,">");} -return"";};YAHOO.widget.LogReader._index=0;YAHOO.widget.LogReader.prototype._sName=null;YAHOO.widget.LogReader._elDefaultContainer=null;YAHOO.widget.LogReader.prototype._buffer=null;YAHOO.widget.LogReader.prototype._consoleMsgCount=0;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._elContainer=null;YAHOO.widget.LogReader.prototype._elHd=null;YAHOO.widget.LogReader.prototype._elCollapse=null;YAHOO.widget.LogReader.prototype._btnCollapse=null;YAHOO.widget.LogReader.prototype._title=null;YAHOO.widget.LogReader.prototype._elConsole=null;YAHOO.widget.LogReader.prototype._elFt=null;YAHOO.widget.LogReader.prototype._elBtns=null;YAHOO.widget.LogReader.prototype._elCategoryFilters=null;YAHOO.widget.LogReader.prototype._elSourceFilters=null;YAHOO.widget.LogReader.prototype._btnPause=null;YAHOO.widget.LogReader.prototype._btnClear=null;YAHOO.widget.LogReader.prototype._createCategoryCheckbox=function(sCategory){var oSelf=this;if(this._elFt){var elParent=this._elCategoryFilters;var filters=this._categoryFilters;var elFilter=elParent.appendChild(document.createElement("span"));elFilter.className="yui-log-filtergrp";var chkCategory=document.createElement("input");chkCategory.id="yui-log-filter-"+sCategory+this._sName;chkCategory.className="yui-log-filter-"+sCategory;chkCategory.type="checkbox";chkCategory.category=sCategory;chkCategory=elFilter.appendChild(chkCategory);chkCategory.checked=true;filters.push(sCategory);YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf);var lblCategory=elFilter.appendChild(document.createElement("label"));lblCategory.htmlFor=chkCategory.id;lblCategory.className=sCategory;lblCategory.innerHTML=sCategory;}};YAHOO.widget.LogReader.prototype._createSourceCheckbox=function(sSource){var oSelf=this;if(this._elFt){var elParent=this._elSourceFilters;var filters=this._sourceFilters;var elFilter=elParent.appendChild(document.createElement("span"));elFilter.className="yui-log-filtergrp";var chkSource=document.createElement("input");chkSource.id="yui-log-filter"+sSource+this._sName;chkSource.className="yui-log-filter"+sSource;chkSource.type="checkbox";chkSource.source=sSource;chkSource=elFilter.appendChild(chkSource);chkSource.checked=true;filters.push(sSource);YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf);var lblSource=elFilter.appendChild(document.createElement("label"));lblSource.htmlFor=chkSource.id;lblSource.className=sSource;lblSource.innerHTML=sSource;}};YAHOO.widget.LogReader.prototype._filterLogs=function(){if(this._elConsole!==null){this._clearConsole();this._printToConsole(YAHOO.widget.Logger.getStack());}};YAHOO.widget.LogReader.prototype._clearConsole=function(){this._timeout=null;this._buffer=[];this._consoleMsgCount=0;this._lastTime=YAHOO.widget.Logger.getStartTime();var elConsole=this._elConsole;while(elConsole.hasChildNodes()){elConsole.removeChild(elConsole.firstChild);}};YAHOO.widget.LogReader.prototype._printBuffer=function(){this._timeout=null;if(this._elConsole!==null){var thresholdMax=this.thresholdMax;thresholdMax=(thresholdMax&&!isNaN(thresholdMax))?thresholdMax:500;if(this._consoleMsgCountthis.thresholdMax)){thresholdMin=0;} -var entriesStartIndex=(entriesLen>thresholdMin)?(entriesLen-thresholdMin):0;var sourceFiltersLen=this._sourceFilters.length;var categoryFiltersLen=this._categoryFilters.length;for(var i=entriesStartIndex;i0){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=new YAHOO.widget.LogMsg({msg:sMsg,time:timestamp,category:sCategory,source:sClass,sourceDetail:sDetail});var stack=this._stack;var maxStackEntries=this.maxStackEntries;if(maxStackEntries&&!isNaN(maxStackEntries)&&(stack.length>=maxStackEntries)){stack.shift();} -stack.push(logEntry);this.newLogEvent.fire(logEntry);if(this._browserConsoleEnabled){this._printToBrowserConsole(logEntry);} -return true;} -else{return false;}};YAHOO.widget.Logger.reset=function(){this._stack=[];this._startTime=new Date().getTime();this.loggerEnabled=true;this.log("Logger reset");this.logResetEvent.fire();};YAHOO.widget.Logger.getStack=function(){return this._stack;};YAHOO.widget.Logger.getStartTime=function(){return this._startTime;};YAHOO.widget.Logger.disableBrowserConsole=function(){YAHOO.log("Logger output to the function console.log() has been disabled.");this._browserConsoleEnabled=false;};YAHOO.widget.Logger.enableBrowserConsole=function(){this._browserConsoleEnabled=true;YAHOO.log("Logger output to the function console.log() has been enabled.");};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._createNewCategory=function(sCategory){this.categories.push(sCategory);this.categoryCreateEvent.fire(sCategory);};YAHOO.widget.Logger._isNewCategory=function(sCategory){for(var i=0;i-1){return;}} +else{for(var i=0;i-1){return;}} +else{for(var i=0;i

",label," ",totalTime,"ms (+",elapsedTime,") ",localTime,": ","

",sourceAndDetail,":

",msg,"

"]:["

",label," ",totalTime,"ms (+",elapsedTime,") ",localTime,": ",sourceAndDetail,": ",msg,"

"];return output.join("");};YAHOO.widget.LogReader.prototype.html2Text=function(sHtml){if(sHtml){sHtml+="";return sHtml.replace(/&/g,"&").replace(//g,">");} +return"";};YAHOO.widget.LogReader._index=0;YAHOO.widget.LogReader.prototype._sName=null;YAHOO.widget.LogReader.prototype._buffer=null;YAHOO.widget.LogReader.prototype._consoleMsgCount=0;YAHOO.widget.LogReader.prototype._lastTime=null;YAHOO.widget.LogReader.prototype._timeout=null;YAHOO.widget.LogReader.prototype._filterCheckboxes=null;YAHOO.widget.LogReader.prototype._categoryFilters=null;YAHOO.widget.LogReader.prototype._sourceFilters=null;YAHOO.widget.LogReader.prototype._elContainer=null;YAHOO.widget.LogReader.prototype._elHd=null;YAHOO.widget.LogReader.prototype._elCollapse=null;YAHOO.widget.LogReader.prototype._btnCollapse=null;YAHOO.widget.LogReader.prototype._title=null;YAHOO.widget.LogReader.prototype._elConsole=null;YAHOO.widget.LogReader.prototype._elFt=null;YAHOO.widget.LogReader.prototype._elBtns=null;YAHOO.widget.LogReader.prototype._elCategoryFilters=null;YAHOO.widget.LogReader.prototype._elSourceFilters=null;YAHOO.widget.LogReader.prototype._btnPause=null;YAHOO.widget.LogReader.prototype._btnClear=null;YAHOO.widget.LogReader.prototype._initContainerEl=function(elContainer){elContainer=YAHOO.util.Dom.get(elContainer);if(elContainer&&elContainer.tagName&&(elContainer.tagName.toLowerCase()=="div")){this._elContainer=elContainer;YAHOO.util.Dom.addClass(this._elContainer,"yui-log");} +else{this._elContainer=document.body.appendChild(document.createElement("div"));YAHOO.util.Dom.addClass(this._elContainer,"yui-log");YAHOO.util.Dom.addClass(this._elContainer,"yui-log-container");var containerStyle=this._elContainer.style;if(this.width){containerStyle.width=this.width;} +if(this.right){containerStyle.right=this.right;} +if(this.top){containerStyle.top=this.top;} +if(this.left){containerStyle.left=this.left;containerStyle.right="auto";} +if(this.bottom){containerStyle.bottom=this.bottom;containerStyle.top="auto";} +if(this.fontSize){containerStyle.fontSize=this.fontSize;} +if(navigator.userAgent.toLowerCase().indexOf("opera")!=-1){document.body.style+='';}}};YAHOO.widget.LogReader.prototype._initHeaderEl=function(){var oSelf=this;if(this._elHd){YAHOO.util.Event.purgeElement(this._elHd,true);this._elHd.innerHTML="";} +this._elHd=this._elContainer.appendChild(document.createElement("div"));this._elHd.id="yui-log-hd"+this._sName;this._elHd.className="yui-log-hd";this._elCollapse=this._elHd.appendChild(document.createElement("div"));this._elCollapse.className="yui-log-btns";this._btnCollapse=document.createElement("input");this._btnCollapse.type="button";this._btnCollapse.className="yui-log-button";this._btnCollapse.value="Collapse";this._btnCollapse=this._elCollapse.appendChild(this._btnCollapse);YAHOO.util.Event.addListener(oSelf._btnCollapse,'click',oSelf._onClickCollapseBtn,oSelf);this._title=this._elHd.appendChild(document.createElement("h4"));this._title.innerHTML="Logger Console";};YAHOO.widget.LogReader.prototype._initConsoleEl=function(){if(this._elConsole){YAHOO.util.Event.purgeElement(this._elConsole,true);this._elConsole.innerHTML="";} +this._elConsole=this._elContainer.appendChild(document.createElement("div"));this._elConsole.className="yui-log-bd";if(this.height){this._elConsole.style.height=this.height;}};YAHOO.widget.LogReader.prototype._initFooterEl=function(){var oSelf=this;if(this.footerEnabled){if(this._elFt){YAHOO.util.Event.purgeElement(this._elFt,true);this._elFt.innerHTML="";} +this._elFt=this._elContainer.appendChild(document.createElement("div"));this._elFt.className="yui-log-ft";this._elBtns=this._elFt.appendChild(document.createElement("div"));this._elBtns.className="yui-log-btns";this._btnPause=document.createElement("input");this._btnPause.type="button";this._btnPause.className="yui-log-button";this._btnPause.value="Pause";this._btnPause=this._elBtns.appendChild(this._btnPause);YAHOO.util.Event.addListener(oSelf._btnPause,'click',oSelf._onClickPauseBtn,oSelf);this._btnClear=document.createElement("input");this._btnClear.type="button";this._btnClear.className="yui-log-button";this._btnClear.value="Clear";this._btnClear=this._elBtns.appendChild(this._btnClear);YAHOO.util.Event.addListener(oSelf._btnClear,'click',oSelf._onClickClearBtn,oSelf);this._elCategoryFilters=this._elFt.appendChild(document.createElement("div"));this._elCategoryFilters.className="yui-log-categoryfilters";this._elSourceFilters=this._elFt.appendChild(document.createElement("div"));this._elSourceFilters.className="yui-log-sourcefilters";}};YAHOO.widget.LogReader.prototype._initDragDrop=function(){if(YAHOO.util.DD&&this.draggable&&this._elHd){var ylog_dd=new YAHOO.util.DD(this._elContainer);ylog_dd.setHandleElId(this._elHd.id);this._elHd.style.cursor="move";}};YAHOO.widget.LogReader.prototype._initCategories=function(){this._categoryFilters=[];var aInitialCategories=YAHOO.widget.Logger.categories;for(var j=0;jthis.thresholdMax)){thresholdMin=0;} +var entriesStartIndex=(entriesLen>thresholdMin)?(entriesLen-thresholdMin):0;var sourceFiltersLen=this._sourceFilters.length;var categoryFiltersLen=this._categoryFilters.length;for(var i=entriesStartIndex;i0){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=new YAHOO.widget.LogMsg({msg:sMsg,time:timestamp,category:sCategory,source:sClass,sourceDetail:sDetail});var stack=this._stack;var maxStackEntries=this.maxStackEntries;if(maxStackEntries&&!isNaN(maxStackEntries)&&(stack.length>=maxStackEntries)){stack.shift();} +stack.push(logEntry);this.newLogEvent.fire(logEntry);if(this._browserConsoleEnabled){this._printToBrowserConsole(logEntry);} +return true;} +else{return false;}};YAHOO.widget.Logger.reset=function(){this._stack=[];this._startTime=new Date().getTime();this.loggerEnabled=true;this.log("Logger reset");this.logResetEvent.fire();};YAHOO.widget.Logger.getStack=function(){return this._stack;};YAHOO.widget.Logger.getStartTime=function(){return this._startTime;};YAHOO.widget.Logger.disableBrowserConsole=function(){YAHOO.log("Logger output to the function console.log() has been disabled.");this._browserConsoleEnabled=false;};YAHOO.widget.Logger.enableBrowserConsole=function(){this._browserConsoleEnabled=true;YAHOO.log("Logger output to the function console.log() has been enabled.");};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._createNewCategory=function(sCategory){this.categories.push(sCategory);this.categoryCreateEvent.fire(sCategory);};YAHOO.widget.Logger._isNewCategory=function(sCategory){for(var i=0;i", label, " ", - totalTime, "ms (+", elapsedTime, ") ", - localTime, ": ", - "

", - sourceAndDetail, - ":

", - msg, - "

"] : - - ["

", label, " ", - totalTime, "ms (+", elapsedTime, ") ", - localTime, ": ", - sourceAndDetail, ": ", - msg,"

"]; - - return output.join(""); -}; - -/** - * Converts input chars "<", ">", and "&" to HTML entities. - * - * @method html2Text - * @param sHtml {String} String to convert. - * @private - */ -YAHOO.widget.LogReader.prototype.html2Text = function(sHtml) { - if(sHtml) { - sHtml += ""; - return sHtml.replace(/&/g, "&").replace(//g, ">"); - } - return ""; -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class member to index multiple log reader instances. - * - * @property _memberName - * @static - * @type Number - * @default 0 - * @private - */ -YAHOO.widget.LogReader._index = 0; - -/** - * Name of LogReader instance. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.LogReader.prototype._sName = null; - -/** - * 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. - * - * @property _elDefaultContainer - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader._elDefaultContainer = null; - -/** - * Buffer of log message objects for batch output. - * - * @property _buffer - * @type Object[] - * @private - */ -YAHOO.widget.LogReader.prototype._buffer = null; - -/** - * Number of log messages output to console. - * - * @property _consoleMsgCount - * @type Number - * @default 0 - * @private - */ -YAHOO.widget.LogReader.prototype._consoleMsgCount = 0; - -/** - * Date of last output log message. - * - * @property _lastTime - * @type Date - * @private - */ -YAHOO.widget.LogReader.prototype._lastTime = null; - -/** - * Batched output timeout ID. - * - * @property _timeout - * @type Number - * @private - */ -YAHOO.widget.LogReader.prototype._timeout = null; - -/** - * Array of filters for log message categories. - * - * @property _categoryFilters - * @type String[] - * @private - */ -YAHOO.widget.LogReader.prototype._categoryFilters = null; - -/** - * Array of filters for log message sources. - * - * @property _sourceFilters - * @type String[] - * @private - */ -YAHOO.widget.LogReader.prototype._sourceFilters = null; - -/** - * Log reader container element. - * - * @property _elContainer - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elContainer = null; - -/** - * Log reader header element. - * - * @property _elHd - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elHd = null; - -/** - * Log reader collapse element. - * - * @property _elCollapse - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elCollapse = null; - -/** - * Log reader collapse button element. - * - * @property _btnCollapse - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._btnCollapse = null; - -/** - * Log reader title header element. - * - * @property _title - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._title = null; - -/** - * Log reader console element. - * - * @property _elConsole - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elConsole = null; - -/** - * Log reader footer element. - * - * @property _elFt - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elFt = null; - -/** - * Log reader buttons container element. - * - * @property _elBtns - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elBtns = null; - -/** - * Container element for log reader category filter checkboxes. - * - * @property _elCategoryFilters - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elCategoryFilters = null; - -/** - * Container element for log reader source filter checkboxes. - * - * @property _elSourceFilters - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._elSourceFilters = null; - -/** - * Log reader pause button element. - * - * @property _btnPause - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._btnPause = null; - -/** - * Clear button element. - * - * @property _btnClear - * @type HTMLElement - * @private - */ -YAHOO.widget.LogReader.prototype._btnClear = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Creates the UI for a category filter in the log reader footer element. - * - * @method _createCategoryCheckbox - * @param sCategory {String} Category name. - * @private - */ -YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(sCategory) { - var oSelf = this; - - if(this._elFt) { - var elParent = this._elCategoryFilters; - var filters = this._categoryFilters; - - var elFilter = elParent.appendChild(document.createElement("span")); - elFilter.className = "yui-log-filtergrp"; - // Append el at the end so IE 5.5 can set "type" attribute - // and THEN set checked property - var chkCategory = document.createElement("input"); - chkCategory.id = "yui-log-filter-" + sCategory + this._sName; - chkCategory.className = "yui-log-filter-" + sCategory; - chkCategory.type = "checkbox"; - chkCategory.category = sCategory; - chkCategory = elFilter.appendChild(chkCategory); - chkCategory.checked = true; - - // Add this checked filter to the internal array of filters - filters.push(sCategory); - // Subscribe to the click event - YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf); - - // Create and class the text label - var lblCategory = elFilter.appendChild(document.createElement("label")); - lblCategory.htmlFor = chkCategory.id; - lblCategory.className = sCategory; - lblCategory.innerHTML = sCategory; - } -}; - -/** - * Creates a checkbox in the log reader footer element to filter by source. - * - * @method _createSourceCheckbox - * @param sSource {String} Source name. - * @private - */ -YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(sSource) { - var oSelf = this; - - if(this._elFt) { - var elParent = this._elSourceFilters; - var filters = this._sourceFilters; - - var elFilter = elParent.appendChild(document.createElement("span")); - elFilter.className = "yui-log-filtergrp"; - - // Append el at the end so IE 5.5 can set "type" attribute - // and THEN set checked property - var chkSource = document.createElement("input"); - chkSource.id = "yui-log-filter" + sSource + this._sName; - chkSource.className = "yui-log-filter" + sSource; - chkSource.type = "checkbox"; - chkSource.source = sSource; - chkSource = elFilter.appendChild(chkSource); - chkSource.checked = true; - - // Add this checked filter to the internal array of filters - filters.push(sSource); - // Subscribe to the click event - YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf); - - // Create and class the text label - var lblSource = elFilter.appendChild(document.createElement("label")); - lblSource.htmlFor = chkSource.id; - lblSource.className = sSource; - lblSource.innerHTML = sSource; - } -}; - -/** - * Reprints all log messages in the stack through filters. - * - * @method _filterLogs - * @private - */ -YAHOO.widget.LogReader.prototype._filterLogs = function() { - // Reprint stack with new filters - if (this._elConsole !== 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. - * - * @method _clearConsole - * @private - */ -YAHOO.widget.LogReader.prototype._clearConsole = function() { - // Clear the buffer of any pending messages - this._timeout = null; - this._buffer = []; - this._consoleMsgCount = 0; - - // Reset the rolling timer - this._lastTime = YAHOO.widget.Logger.getStartTime(); - - var elConsole = this._elConsole; - while(elConsole.hasChildNodes()) { - elConsole.removeChild(elConsole.firstChild); - } -}; - -/** - * Sends buffer of log messages to output and clears buffer. - * - * @method _printBuffer - * @private - */ -YAHOO.widget.LogReader.prototype._printBuffer = function() { - this._timeout = null; - - if(this._elConsole !== null) { - var thresholdMax = this.thresholdMax; - thresholdMax = (thresholdMax && !isNaN(thresholdMax)) ? thresholdMax : 500; - if(this._consoleMsgCount < thresholdMax) { - var entries = []; - for (var i=0; i this.thresholdMax)) { - thresholdMin = 0; - } - var entriesStartIndex = (entriesLen > thresholdMin) ? (entriesLen - thresholdMin) : 0; - - // Iterate through all log entries - var sourceFiltersLen = this._sourceFilters.length; - var categoryFiltersLen = this._categoryFilters.length; - for(var i=entriesStartIndex; i tag instead of
 tag (for wrapping)
-            var container = (this.verboseOutput) ? "CODE" : "PRE";
-            var oNewElement = (this.newestOnTop) ?
-                this._elConsole.insertBefore(
-                    document.createElement(container),this._elConsole.firstChild):
-                this._elConsole.appendChild(document.createElement(container));
-
-            oNewElement.innerHTML = output;
-            this._consoleMsgCount++;
-            this._lastTime = entry.time.getTime();
-        }
-    }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles Logger's categoryCreateEvent.
- *
- * @method _onCategoryCreate
- * @param sType {String} The event.
- * @param aArgs {Object[]} Data passed from event firer.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onCategoryCreate = function(sType, aArgs, oSelf) {
-    var category = aArgs[0];
-    if(oSelf._elFt) {
-        oSelf._createCategoryCheckbox(category);
-    }
-};
-
-/**
- * Handles Logger's sourceCreateEvent.
- *
- * @method _onSourceCreate
- * @param sType {String} The event.
- * @param aArgs {Object[]} Data passed from event firer.
- * @param oSelf {Object} The LogReader instance.
- * @private
- */
-YAHOO.widget.LogReader.prototype._onSourceCreate = function(sType, aArgs, oSelf) {
-    var source = aArgs[0];
-    if(oSelf._elFt) {
-        oSelf._createSourceCheckbox(source);
-    }
-};
-
-/**
- * Handles check events on the category filter checkboxes.
- *
- * @method _onCheckCategory
- * @param v {HTMLEvent} The click event.
- * @param oSelf {Object} The LogReader 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 0) {
-                // Substring until first space
-                sClass = sSource.substring(0,spaceIndex);
-                // The rest of the source
-                sDetail = sSource.substring(spaceIndex,sSource.length);
-            }
-            else {
-                sClass = sSource;
-            }
-            if(this._isNewSource(sClass)) {
-                this._createNewSource(sClass);
-            }
-        }
-
-        var timestamp = new Date();
-        var logEntry = new YAHOO.widget.LogMsg({
-            msg: sMsg,
-            time: timestamp,
-            category: sCategory,
-            source: sClass,
-            sourceDetail: sDetail
-        });
-
-        var stack = this._stack;
-        var maxStackEntries = this.maxStackEntries;
-        if(maxStackEntries && !isNaN(maxStackEntries) &&
-            (stack.length >= maxStackEntries)) {
-            stack.shift();
-        }
-        stack.push(logEntry);
-        this.newLogEvent.fire(logEntry);
-
-        if(this._browserConsoleEnabled) {
-            this._printToBrowserConsole(logEntry);
-        }
-        return true;
-    }
-    else {
-        return false;
-    }
-};
-
-/**
- * Resets internal stack and startTime, enables Logger, and fires logResetEvent.
- *
- * @method reset
- */
-YAHOO.widget.Logger.reset = function() {
-    this._stack = [];
-    this._startTime = new Date().getTime();
-    this.loggerEnabled = true;
-    this.log("Logger reset");
-    this.logResetEvent.fire();
-};
-
-/**
- * Public accessor to internal stack of log message objects.
- *
- * @method getStack
- * @return {Object[]} Array of log message objects.
- */
-YAHOO.widget.Logger.getStack = function() {
-    return this._stack;
-};
-
-/**
- * Public accessor to internal start time.
- *
- * @method getStartTime
- * @return {Date} Internal date of when Logger singleton was initialized.
- */
-YAHOO.widget.Logger.getStartTime = function() {
-    return this._startTime;
-};
-
-/**
- * Disables output to the browser's global console.log() function, which is used
- * by the Firebug extension to Firefox as well as Safari.
- *
- * @method disableBrowserConsole
- */
-YAHOO.widget.Logger.disableBrowserConsole = function() {
-    YAHOO.log("Logger output to the function console.log() has been disabled.");
-    this._browserConsoleEnabled = false;
-};
-
-/**
- * Enables output to the browser's global console.log() function, which is used
- * by the Firebug extension to Firefox as well as Safari.
- *
- * @method enableBrowserConsole
- */
-YAHOO.widget.Logger.enableBrowserConsole = function() {
-    this._browserConsoleEnabled = true;
-    YAHOO.log("Logger output to the function console.log() has been enabled.");
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Public events
-//
-/////////////////////////////////////////////////////////////////////////////
-
- /**
- * Fired when a new category has been created.
- *
- * @event categoryCreateEvent
- * @param sCategory {String} Category name.
- */
-YAHOO.widget.Logger.categoryCreateEvent =
-    new YAHOO.util.CustomEvent("categoryCreate", this, true);
-
- /**
- * Fired when a new source has been named.
- *
- * @event sourceCreateEvent
- * @param sSource {String} Source name.
- */
-YAHOO.widget.Logger.sourceCreateEvent =
-    new YAHOO.util.CustomEvent("sourceCreate", this, true);
-
- /**
- * Fired when a new log message has been created.
- *
- * @event newLogEvent
- * @param sMsg {String} Log message.
- */
-YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true);
-
-/**
- * Fired when the Logger has been reset has been created.
- *
- * @event logResetEvent
- */
-YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true);
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private methods
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Creates a new category of log messages and fires categoryCreateEvent.
- *
- * @method _createNewCategory
- * @param sCategory {String} Category name.
- * @private
- */
-YAHOO.widget.Logger._createNewCategory = function(sCategory) {
-    this.categories.push(sCategory);
-    this.categoryCreateEvent.fire(sCategory);
-};
-
-/**
- * Checks to see if a category has already been created.
- *
- * @method _isNewCategory
- * @param sCategory {String} Category name.
- * @return {Boolean} Returns true if category is unknown, else returns false.
- * @private
- */
-YAHOO.widget.Logger._isNewCategory = function(sCategory) {
-    for(var i=0; i < this.categories.length; i++) {
-        if(sCategory == this.categories[i]) {
-            return false;
-        }
-    }
-    return true;
-};
-
-/**
- * Creates a new source of log messages and fires sourceCreateEvent.
- *
- * @method _createNewSource
- * @param sSource {String} Source name.
- * @private
- */
-YAHOO.widget.Logger._createNewSource = function(sSource) {
-    this.sources.push(sSource);
-    this.sourceCreateEvent.fire(sSource);
-};
-
-/**
- * Checks to see if a source already exists.
- *
- * @method _isNewSource
- * @param sSource {String} Source name.
- * @return {Boolean} Returns true if source is unknown, else returns false.
- * @private
- */
-YAHOO.widget.Logger._isNewSource = function(sSource) {
-    if(sSource) {
-        for(var i=0; i < this.sources.length; i++) {
-            if(sSource == this.sources[i]) {
-                return false;
-            }
-        }
-        return true;
-    }
-};
-
-/**
- * Outputs a log message to global console.log() function.
- *
- * @method _printToBrowserConsole
- * @param oEntry {Object} Log entry object.
- * @private
- */
-YAHOO.widget.Logger._printToBrowserConsole = function(oEntry) {
-    if(window.console && console.log) {
-        var category = oEntry.category;
-        var label = oEntry.category.substring(0,4).toUpperCase();
-
-        var time = oEntry.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): " +
-            oEntry.source + ": " +
-            oEntry.msg;
-
-        console.log(output);
-    }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Private event handlers
-//
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Handles logging of messages due to window error events.
- *
- * @method _onWindowError
- * @param sMsg {String} The error message.
- * @param sUrl {String} URL of the error.
- * @param sLine {String} Line number of the error.
- * @private
- */
-YAHOO.widget.Logger._onWindowError = function(sMsg,sUrl,sLine) {
-    // Logger is not in scope of this event handler
-    try {
-        YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')', "window");
-        if(YAHOO.widget.Logger._origOnWindowError) {
-            YAHOO.widget.Logger._origOnWindowError();
-        }
-    }
-    catch(e) {
-        return false;
-    }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Enable handling of 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");
-
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogMsg class defines a single log message.
+ *
+ * @class LogMsg
+ * @constructor
+ * @param oConfigs {Object} Object literal of configuration params.
+ */
+ YAHOO.widget.LogMsg = function(oConfigs) {
+    // Parse configs
+    if (oConfigs && (oConfigs.constructor == Object)) {
+        for(var param in oConfigs) {
+            this[param] = oConfigs[param];
+        }
+    }
+ };
+ 
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Log message.
+ *
+ * @property msg
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.msg = null;
+ 
+/**
+ * Log timestamp.
+ *
+ * @property time
+ * @type Date
+ */
+YAHOO.widget.LogMsg.prototype.time = null;
+
+/**
+ * Log category.
+ *
+ * @property category
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.category = null;
+
+/**
+ * Log source. The first word passed in as the source argument.
+ *
+ * @property source
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.source = null;
+
+/**
+ * Log source detail. The remainder of the string passed in as the source argument, not
+ * including the first word (if any).
+ *
+ * @property sourceDetail
+ * @type String
+ */
+YAHOO.widget.LogMsg.prototype.sourceDetail = null;
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogWriter class provides a mechanism to log messages through
+ * YAHOO.widget.Logger from a named source.
+ *
+ * @class LogWriter
+ * @constructor
+ * @param sSource {String} 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.
+ *
+ * @method toString
+ * @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.
+ *
+ * @method log
+ * @param sMsg {String} The log message.
+ * @param sCategory {String} 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.
+ *
+ * @method getSource
+ * @return {String} The LogWriter source.
+ */
+YAHOO.widget.LogWriter.prototype.getSource = function() {
+    return this._sSource;
+};
+
+/**
+ * Public accessor to set the source name.
+ *
+ * @method setSource
+ * @param sSource {String} 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 member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Source of the LogWriter instance.
+ *
+ * @property _source
+ * @type String
+ * @private
+ */
+YAHOO.widget.LogWriter.prototype._source = null;
+
+
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * The LogReader class provides UI to read messages logged to YAHOO.widget.Logger.
+ *
+ * @class LogReader
+ * @constructor
+ * @param elContainer {HTMLElement} (optional) DOM element reference of an existing DIV.
+ * @param elContainer {String} (optional) String ID of an existing DIV.
+ * @param oConfigs {Object} (optional) Object literal of configuration params.
+ */
+YAHOO.widget.LogReader = function(elContainer, oConfigs) {
+    this._sName = YAHOO.widget.LogReader._index;
+    YAHOO.widget.LogReader._index++;
+    
+    // Internal vars
+    this._buffer = []; // output buffer
+    this._filterCheckboxes = {}; // pointers to checkboxes
+    this._lastTime = YAHOO.widget.Logger.getStartTime(); // timestamp of last log message to console
+
+    // Parse config vars here
+    if (oConfigs && (oConfigs.constructor == Object)) {
+        for(var param in oConfigs) {
+            this[param] = oConfigs[param];
+        }
+    }
+
+    this._initContainerEl(elContainer);
+    if(!this._elContainer) {
+        YAHOO.log("Could not instantiate LogReader due to an invalid container element " +
+                elContainer, "error", this.toString());
+        return;
+    }
+    
+    this._initHeaderEl();
+    this._initConsoleEl();
+    this._initFooterEl();
+
+    this._initDragDrop();
+
+    this._initCategories();
+    this._initSources();
+
+    // Subscribe to Logger custom events
+    YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog, this);
+    YAHOO.widget.Logger.logResetEvent.subscribe(this._onReset, this);
+
+    YAHOO.widget.Logger.categoryCreateEvent.subscribe(this._onCategoryCreate, this);
+    YAHOO.widget.Logger.sourceCreateEvent.subscribe(this._onSourceCreate, this);
+
+    this._filterLogs();
+    YAHOO.log("LogReader initialized", null, this.toString());
+};
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public member variables
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Whether or not LogReader is enabled to output log messages.
+ *
+ * @property logReaderEnabled
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.logReaderEnabled = true;
+
+/**
+ * Public member to access CSS width of the LogReader container.
+ *
+ * @property width
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.width = null;
+
+/**
+ * Public member to access CSS height of the LogReader container.
+ *
+ * @property height
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.height = null;
+
+/**
+ * Public member to access CSS top position of the LogReader container.
+ *
+ * @property top
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.top = null;
+
+/**
+ * Public member to access CSS left position of the LogReader container.
+ *
+ * @property left
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.left = null;
+
+/**
+ * Public member to access CSS right position of the LogReader container.
+ *
+ * @property right
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.right = null;
+
+/**
+ * Public member to access CSS bottom position of the LogReader container.
+ *
+ * @property bottom
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.bottom = null;
+
+/**
+ * Public member to access CSS font size of the LogReader container.
+ *
+ * @property fontSize
+ * @type String
+ */
+YAHOO.widget.LogReader.prototype.fontSize = null;
+
+/**
+ * Whether or not the footer UI is enabled for the LogReader.
+ *
+ * @property footerEnabled
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.footerEnabled = true;
+
+/**
+ * Whether or not output is verbose (more readable). Setting to true will make
+ * output more compact (less readable).
+ *
+ * @property verboseOutput
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.verboseOutput = true;
+
+/**
+ * Whether or not newest message is printed on top.
+ *
+ * @property newestOnTop
+ * @type Boolean
+ */
+YAHOO.widget.LogReader.prototype.newestOnTop = true;
+
+/**
+ * Output timeout buffer in milliseconds.
+ *
+ * @property outputBuffer
+ * @type Number
+ * @default 100
+ */
+YAHOO.widget.LogReader.prototype.outputBuffer = 100;
+
+/**
+ * Maximum number of messages a LogReader console will display.
+ *
+ * @property thresholdMax
+ * @type Number
+ * @default 500
+ */
+YAHOO.widget.LogReader.prototype.thresholdMax = 500;
+
+/**
+ * When a LogReader console reaches its thresholdMax, it will clear out messages
+ * and print out the latest thresholdMin number of messages.
+ *
+ * @property thresholdMin
+ * @type Number
+ * @default 100
+ */
+YAHOO.widget.LogReader.prototype.thresholdMin = 100;
+
+/**
+ * True when LogReader is in a collapsed state, false otherwise.
+ *
+ * @property isCollapsed
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.LogReader.prototype.isCollapsed = false;
+
+/**
+ * True when LogReader is in a paused state, false otherwise.
+ *
+ * @property isPaused
+ * @type Boolean
+ * @default false
+ */
+YAHOO.widget.LogReader.prototype.isPaused = false;
+
+/**
+ * Enables draggable LogReader if DragDrop Utility is present.
+ *
+ * @property draggable
+ * @type Boolean
+ * @default true
+ */
+YAHOO.widget.LogReader.prototype.draggable = true;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Public methods
+//
+/////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Public accessor to the unique name of the LogReader instance.
+ *
+ * @method toString
+ * @return {String} Unique name of the LogReader instance.
+ */
+YAHOO.widget.LogReader.prototype.toString = function() {
+    return "LogReader instance" + this._sName;
+};
+/**
+ * Pauses output of log messages. While paused, log messages are not lost, but
+ * get saved to a buffer and then output upon resume of LogReader.
+ *
+ * @method pause
+ */
+YAHOO.widget.LogReader.prototype.pause = function() {
+    this.isPaused = true;
+    this._btnPause.value = "Resume";
+    this._timeout = null;
+    this.logReaderEnabled = false;
+};
+
+/**
+ * Resumes output of log messages, including outputting any log messages that
+ * have been saved to buffer while paused.
+ *
+ * @method resume
+ */
+YAHOO.widget.LogReader.prototype.resume = function() {
+    this.isPaused = false;
+    this._btnPause.value = "Pause";
+    this.logReaderEnabled = true;
+    this._printBuffer();
+};
+
+/**
+ * Hides UI of LogReader. Logging functionality is not disrupted.
+ *
+ * @method hide
+ */
+YAHOO.widget.LogReader.prototype.hide = function() {
+    this._elContainer.style.display = "none";
+};
+
+/**
+ * Shows UI of LogReader. Logging functionality is not disrupted.
+ *
+ * @method show
+ */
+YAHOO.widget.LogReader.prototype.show = function() {
+    this._elContainer.style.display = "block";
+};
+
+/**
+ * Collapses UI of LogReader. Logging functionality is not disrupted.
+ *
+ * @method collapse
+ */
+YAHOO.widget.LogReader.prototype.collapse = function() {
+    this._elConsole.style.display = "none";
+    if(this._elFt) {
+        this._elFt.style.display = "none";
+    }
+    this._btnCollapse.value = "Expand";
+    this.isCollapsed = true;
+};
+
+/**
+ * Expands UI of LogReader. Logging functionality is not disrupted.
+ *
+ * @method expand
+ */
+YAHOO.widget.LogReader.prototype.expand = function() {
+    this._elConsole.style.display = "block";
+    if(this._elFt) {
+        this._elFt.style.display = "block";
+    }
+    this._btnCollapse.value = "Collapse";
+    this.isCollapsed = false;
+};
+
+/**
+ * Returns related checkbox element for given filter (i.e., category or source).
+ *
+ * @method getCheckbox
+ * @param {String} Category or source name.
+ * @return {Array} Array of all filter checkboxes.
+ */
+YAHOO.widget.LogReader.prototype.getCheckbox = function(filter) {
+    return this._filterCheckboxes[filter];
+};
+
+/**
+ * Returns array of enabled categories.
+ *
+ * @method getCategories
+ * @return {String[]} Array of enabled categories.
+ */
+YAHOO.widget.LogReader.prototype.getCategories = function() {
+    return this._categoryFilters;
+};
+
+/**
+ * Shows log messages associated with given category.
+ *
+ * @method showCategory
+ * @param {String} Category name.
+ */
+YAHOO.widget.LogReader.prototype.showCategory = function(sCategory) {
+    var filtersArray = this._categoryFilters;
+    // Don't do anything if category is already enabled
+    // Use Array.indexOf if available...
+    if(filtersArray.indexOf) {
+         if(filtersArray.indexOf(sCategory) >  -1) {
+            return;
+        }
+    }
+    // ...or do it the old-fashioned way
+    else {
+        for(var i=0; i  -1) {
+            return;
+        }
+    }
+    // ...or do it the old-fashioned way
+    else {
+        for(var i=0; i

", label, " ", + totalTime, "ms (+", elapsedTime, ") ", + localTime, ": ", + "

", + sourceAndDetail, + ":

", + msg, + "

"] : + + ["

", label, " ", + totalTime, "ms (+", elapsedTime, ") ", + localTime, ": ", + sourceAndDetail, ": ", + msg, "

"]; + + return output.join(""); +}; + +/** + * Converts input chars "<", ">", and "&" to HTML entities. + * + * @method html2Text + * @param sHtml {String} String to convert. + * @private + */ +YAHOO.widget.LogReader.prototype.html2Text = function(sHtml) { + if(sHtml) { + sHtml += ""; + return sHtml.replace(/&/g, "&").replace(//g, ">"); + } + return ""; +}; + +///////////////////////////////////////////////////////////////////////////// +// +// Private member variables +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Internal class member to index multiple LogReader instances. + * + * @property _memberName + * @static + * @type Number + * @default 0 + * @private + */ +YAHOO.widget.LogReader._index = 0; + +/** + * Name of LogReader instance. + * + * @property _sName + * @type String + * @private + */ +YAHOO.widget.LogReader.prototype._sName = null; + +//TODO: remove +/** + * A class member shared by all LogReaders 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. + * + * @property _elDefaultContainer + * @type HTMLElement + * @private + */ +//YAHOO.widget.LogReader._elDefaultContainer = null; + +/** + * Buffer of log message objects for batch output. + * + * @property _buffer + * @type Object[] + * @private + */ +YAHOO.widget.LogReader.prototype._buffer = null; + +/** + * Number of log messages output to console. + * + * @property _consoleMsgCount + * @type Number + * @default 0 + * @private + */ +YAHOO.widget.LogReader.prototype._consoleMsgCount = 0; + +/** + * Date of last output log message. + * + * @property _lastTime + * @type Date + * @private + */ +YAHOO.widget.LogReader.prototype._lastTime = null; + +/** + * Batched output timeout ID. + * + * @property _timeout + * @type Number + * @private + */ +YAHOO.widget.LogReader.prototype._timeout = null; + +/** + * Hash of filters and their related checkbox elements. + * + * @property _filterCheckboxes + * @type Object + * @private + */ +YAHOO.widget.LogReader.prototype._filterCheckboxes = null; + +/** + * Array of filters for log message categories. + * + * @property _categoryFilters + * @type String[] + * @private + */ +YAHOO.widget.LogReader.prototype._categoryFilters = null; + +/** + * Array of filters for log message sources. + * + * @property _sourceFilters + * @type String[] + * @private + */ +YAHOO.widget.LogReader.prototype._sourceFilters = null; + +/** + * LogReader container element. + * + * @property _elContainer + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elContainer = null; + +/** + * LogReader header element. + * + * @property _elHd + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elHd = null; + +/** + * LogReader collapse element. + * + * @property _elCollapse + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elCollapse = null; + +/** + * LogReader collapse button element. + * + * @property _btnCollapse + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._btnCollapse = null; + +/** + * LogReader title header element. + * + * @property _title + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._title = null; + +/** + * LogReader console element. + * + * @property _elConsole + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elConsole = null; + +/** + * LogReader footer element. + * + * @property _elFt + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elFt = null; + +/** + * LogReader buttons container element. + * + * @property _elBtns + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elBtns = null; + +/** + * Container element for LogReader category filter checkboxes. + * + * @property _elCategoryFilters + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elCategoryFilters = null; + +/** + * Container element for LogReader source filter checkboxes. + * + * @property _elSourceFilters + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._elSourceFilters = null; + +/** + * LogReader pause button element. + * + * @property _btnPause + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._btnPause = null; + +/** + * Clear button element. + * + * @property _btnClear + * @type HTMLElement + * @private + */ +YAHOO.widget.LogReader.prototype._btnClear = null; + +///////////////////////////////////////////////////////////////////////////// +// +// Private methods +// +///////////////////////////////////////////////////////////////////////////// + +/** + * Initializes the primary container element. + * + * @method _initContainerEl + * @param elContainer {HTMLElement} Container element by reference or string ID. + * @private + */ +YAHOO.widget.LogReader.prototype._initContainerEl = function(elContainer) { + // Validate container + elContainer = YAHOO.util.Dom.get(elContainer); + // Attach to existing container... + if(elContainer && elContainer.tagName && (elContainer.tagName.toLowerCase() == "div")) { + this._elContainer = elContainer; + YAHOO.util.Dom.addClass(this._elContainer,"yui-log"); + } + // ...or create container from scratch + else { + this._elContainer = document.body.appendChild(document.createElement("div")); + //this._elContainer.id = "yui-log" + this._sName; + YAHOO.util.Dom.addClass(this._elContainer,"yui-log"); + YAHOO.util.Dom.addClass(this._elContainer,"yui-log-container"); + + //YAHOO.widget.LogReader._elDefaultContainer = this._elContainer; + + // If implementer has provided container values, trust and set those + var containerStyle = this._elContainer.style; + if(this.width) { + containerStyle.width = this.width; + } + if(this.right) { + containerStyle.right = this.right; + } + if(this.top) { + containerStyle.top = this.top; + } + if(this.left) { + containerStyle.left = this.left; + containerStyle.right = "auto"; + } + if(this.bottom) { + containerStyle.bottom = this.bottom; + containerStyle.top = "auto"; + } + if(this.fontSize) { + containerStyle.fontSize = this.fontSize; + } + // For Opera + if(navigator.userAgent.toLowerCase().indexOf("opera") != -1) { + document.body.style += ''; + } + } +}; + +/** + * Initializes the header element. + * + * @method _initHeaderEl + * @private + */ +YAHOO.widget.LogReader.prototype._initHeaderEl = function() { + var oSelf = this; + + // Destroy header + if(this._elHd) { + // Unhook DOM events + YAHOO.util.Event.purgeElement(this._elHd, true); + + // Remove DOM elements + this._elHd.innerHTML = ""; + } + + // Create header + this._elHd = this._elContainer.appendChild(document.createElement("div")); + this._elHd.id = "yui-log-hd" + this._sName; + this._elHd.className = "yui-log-hd"; + + this._elCollapse = this._elHd.appendChild(document.createElement("div")); + this._elCollapse.className = "yui-log-btns"; + + this._btnCollapse = document.createElement("input"); + this._btnCollapse.type = "button"; + //this._btnCollapse.style.fontSize = + // YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); + this._btnCollapse.className = "yui-log-button"; + this._btnCollapse.value = "Collapse"; + this._btnCollapse = this._elCollapse.appendChild(this._btnCollapse); + YAHOO.util.Event.addListener( + oSelf._btnCollapse,'click',oSelf._onClickCollapseBtn,oSelf); + + this._title = this._elHd.appendChild(document.createElement("h4")); + this._title.innerHTML = "Logger Console"; +}; + +/** + * Initializes the console element. + * + * @method _initConsoleEl + * @private + */ +YAHOO.widget.LogReader.prototype._initConsoleEl = function() { + // Destroy console + if(this._elConsole) { + // Unhook DOM events + YAHOO.util.Event.purgeElement(this._elConsole, true); + + // Remove DOM elements + this._elConsole.innerHTML = ""; + } + + // Ceate console + this._elConsole = this._elContainer.appendChild(document.createElement("div")); + this._elConsole.className = "yui-log-bd"; + + // If implementer has provided console, trust and set those + if(this.height) { + this._elConsole.style.height = this.height; + } +}; + +/** + * Initializes the footer element. + * + * @method _initFooterEl + * @private + */ +YAHOO.widget.LogReader.prototype._initFooterEl = function() { + var oSelf = this; + + // Don't create footer elements if footer is disabled + if(this.footerEnabled) { + // Destroy console + if(this._elFt) { + // Unhook DOM events + YAHOO.util.Event.purgeElement(this._elFt, true); + + // Remove DOM elements + this._elFt.innerHTML = ""; + } + + this._elFt = this._elContainer.appendChild(document.createElement("div")); + this._elFt.className = "yui-log-ft"; + + this._elBtns = this._elFt.appendChild(document.createElement("div")); + this._elBtns.className = "yui-log-btns"; + + this._btnPause = document.createElement("input"); + this._btnPause.type = "button"; + //this._btnPause.style.fontSize = + // YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); + this._btnPause.className = "yui-log-button"; + this._btnPause.value = "Pause"; + this._btnPause = this._elBtns.appendChild(this._btnPause); + YAHOO.util.Event.addListener( + oSelf._btnPause,'click',oSelf._onClickPauseBtn,oSelf); + + this._btnClear = document.createElement("input"); + this._btnClear.type = "button"; + //this._btnClear.style.fontSize = + // YAHOO.util.Dom.getStyle(this._elContainer,"fontSize"); + this._btnClear.className = "yui-log-button"; + this._btnClear.value = "Clear"; + this._btnClear = this._elBtns.appendChild(this._btnClear); + YAHOO.util.Event.addListener( + oSelf._btnClear,'click',oSelf._onClickClearBtn,oSelf); + + this._elCategoryFilters = this._elFt.appendChild(document.createElement("div")); + this._elCategoryFilters.className = "yui-log-categoryfilters"; + this._elSourceFilters = this._elFt.appendChild(document.createElement("div")); + this._elSourceFilters.className = "yui-log-sourcefilters"; + } +}; + +/** + * Initializes Drag and Drop on the header element. + * + * @method _initDragDrop + * @private + */ +YAHOO.widget.LogReader.prototype._initDragDrop = function() { + // If Drag and Drop utility is available... + // ...and draggable is true... + // ...then make the header draggable + if(YAHOO.util.DD && this.draggable && this._elHd) { + var ylog_dd = new YAHOO.util.DD(this._elContainer); + ylog_dd.setHandleElId(this._elHd.id); + //TODO: use class name + this._elHd.style.cursor = "move"; + } +}; + +/** + * Initializes category filters. + * + * @method _initCategories + * @private + */ +YAHOO.widget.LogReader.prototype._initCategories = function() { + // Initialize category filters + this._categoryFilters = []; + var aInitialCategories = YAHOO.widget.Logger.categories; + + for(var j=0; j < aInitialCategories.length; j++) { + var sCategory = aInitialCategories[j]; + + // Add category to the internal array of filters + this._categoryFilters.push(sCategory); + + // Add checkbox element if UI is enabled + if(this._elCategoryFilters) { + this._createCategoryCheckbox(sCategory); + } + } +}; + +/** + * Initializes source filters. + * + * @method _initSources + * @private + */ +YAHOO.widget.LogReader.prototype._initSources = function() { + // Initialize source filters + this._sourceFilters = []; + var aInitialSources = YAHOO.widget.Logger.sources; + + for(var j=0; j < aInitialSources.length; j++) { + var sSource = aInitialSources[j]; + + // Add source to the internal array of filters + this._sourceFilters.push(sSource); + + // Add checkbox element if UI is enabled + if(this._elSourceFilters) { + this._createSourceCheckbox(sSource); + } + }} +; + +/** + * Creates the UI for a category filter in the LogReader footer element. + * + * @method _createCategoryCheckbox + * @param sCategory {String} Category name. + * @private + */ +YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(sCategory) { + var oSelf = this; + + if(this._elFt) { + var elParent = this._elCategoryFilters; + var elFilter = elParent.appendChild(document.createElement("span")); + elFilter.className = "yui-log-filtergrp"; + + // Append el at the end so IE 5.5 can set "type" attribute + // and THEN set checked property + var chkCategory = document.createElement("input"); + chkCategory.id = "yui-log-filter-" + sCategory + this._sName; + chkCategory.className = "yui-log-filter-" + sCategory; + chkCategory.type = "checkbox"; + chkCategory.category = sCategory; + chkCategory = elFilter.appendChild(chkCategory); + chkCategory.checked = true; + + // Subscribe to the click event + YAHOO.util.Event.addListener(chkCategory,'click',oSelf._onCheckCategory,oSelf); + + // Create and class the text label + var lblCategory = elFilter.appendChild(document.createElement("label")); + lblCategory.htmlFor = chkCategory.id; + lblCategory.className = sCategory; + lblCategory.innerHTML = sCategory; + + this._filterCheckboxes[sCategory] = chkCategory; + } +}; + +/** + * Creates a checkbox in the LogReader footer element to filter by source. + * + * @method _createSourceCheckbox + * @param sSource {String} Source name. + * @private + */ +YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(sSource) { + var oSelf = this; + + if(this._elFt) { + var elParent = this._elSourceFilters; + var elFilter = elParent.appendChild(document.createElement("span")); + elFilter.className = "yui-log-filtergrp"; + + // Append el at the end so IE 5.5 can set "type" attribute + // and THEN set checked property + var chkSource = document.createElement("input"); + chkSource.id = "yui-log-filter" + sSource + this._sName; + chkSource.className = "yui-log-filter" + sSource; + chkSource.type = "checkbox"; + chkSource.source = sSource; + chkSource = elFilter.appendChild(chkSource); + chkSource.checked = true; + + // Subscribe to the click event + YAHOO.util.Event.addListener(chkSource,'click',oSelf._onCheckSource,oSelf); + + // Create and class the text label + var lblSource = elFilter.appendChild(document.createElement("label")); + lblSource.htmlFor = chkSource.id; + lblSource.className = sSource; + lblSource.innerHTML = sSource; + + this._filterCheckboxes[sSource] = chkSource; + } +}; + +/** + * Reprints all log messages in the stack through filters. + * + * @method _filterLogs + * @private + */ +YAHOO.widget.LogReader.prototype._filterLogs = function() { + // Reprint stack with new filters + if (this._elConsole !== null) { + this.clearConsole(); + this._printToConsole(YAHOO.widget.Logger.getStack()); + } +}; + +/** + * Sends buffer of log messages to output and clears buffer. + * + * @method _printBuffer + * @private + */ +YAHOO.widget.LogReader.prototype._printBuffer = function() { + this._timeout = null; + + if(this._elConsole !== null) { + var thresholdMax = this.thresholdMax; + thresholdMax = (thresholdMax && !isNaN(thresholdMax)) ? thresholdMax : 500; + if(this._consoleMsgCount < thresholdMax) { + var entries = []; + for (var i=0; i this.thresholdMax)) { + thresholdMin = 0; + } + var entriesStartIndex = (entriesLen > thresholdMin) ? (entriesLen - thresholdMin) : 0; + + // Iterate through all log entries + var sourceFiltersLen = this._sourceFilters.length; + var categoryFiltersLen = this._categoryFilters.length; + for(var i=entriesStartIndex; i 0) { + // Substring until first space + sClass = sSource.substring(0,spaceIndex); + // The rest of the source + sDetail = sSource.substring(spaceIndex,sSource.length); + } + else { + sClass = sSource; + } + if(this._isNewSource(sClass)) { + this._createNewSource(sClass); + } + } + + var timestamp = new Date(); + var logEntry = new YAHOO.widget.LogMsg({ + msg: sMsg, + time: timestamp, + category: sCategory, + source: sClass, + sourceDetail: sDetail + }); + + var stack = this._stack; + var maxStackEntries = this.maxStackEntries; + if(maxStackEntries && !isNaN(maxStackEntries) && + (stack.length >= maxStackEntries)) { + stack.shift(); + } + stack.push(logEntry); + this.newLogEvent.fire(logEntry); + + if(this._browserConsoleEnabled) { + this._printToBrowserConsole(logEntry); + } + return true; + } + else { + return false; + } + }; + + /** + * Resets internal stack and startTime, enables Logger, and fires logResetEvent. + * + * @method reset + */ + YAHOO.widget.Logger.reset = function() { + this._stack = []; + this._startTime = new Date().getTime(); + this.loggerEnabled = true; + this.log("Logger reset"); + this.logResetEvent.fire(); + }; + + /** + * Public accessor to internal stack of log message objects. + * + * @method getStack + * @return {Object[]} Array of log message objects. + */ + YAHOO.widget.Logger.getStack = function() { + return this._stack; + }; + + /** + * Public accessor to internal start time. + * + * @method getStartTime + * @return {Date} Internal date of when Logger singleton was initialized. + */ + YAHOO.widget.Logger.getStartTime = function() { + return this._startTime; + }; + + /** + * Disables output to the browser's global console.log() function, which is used + * by the Firebug extension to Firefox as well as Safari. + * + * @method disableBrowserConsole + */ + YAHOO.widget.Logger.disableBrowserConsole = function() { + YAHOO.log("Logger output to the function console.log() has been disabled."); + this._browserConsoleEnabled = false; + }; + + /** + * Enables output to the browser's global console.log() function, which is used + * by the Firebug extension to Firefox as well as Safari. + * + * @method enableBrowserConsole + */ + YAHOO.widget.Logger.enableBrowserConsole = function() { + this._browserConsoleEnabled = true; + YAHOO.log("Logger output to the function console.log() has been enabled."); + }; + + ///////////////////////////////////////////////////////////////////////////// + // + // Public events + // + ///////////////////////////////////////////////////////////////////////////// + + /** + * Fired when a new category has been created. + * + * @event categoryCreateEvent + * @param sCategory {String} Category name. + */ + YAHOO.widget.Logger.categoryCreateEvent = + new YAHOO.util.CustomEvent("categoryCreate", this, true); + + /** + * Fired when a new source has been named. + * + * @event sourceCreateEvent + * @param sSource {String} Source name. + */ + YAHOO.widget.Logger.sourceCreateEvent = + new YAHOO.util.CustomEvent("sourceCreate", this, true); + + /** + * Fired when a new log message has been created. + * + * @event newLogEvent + * @param sMsg {String} Log message. + */ + YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true); + + /** + * Fired when the Logger has been reset has been created. + * + * @event logResetEvent + */ + YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true); + + ///////////////////////////////////////////////////////////////////////////// + // + // Private methods + // + ///////////////////////////////////////////////////////////////////////////// + + /** + * Creates a new category of log messages and fires categoryCreateEvent. + * + * @method _createNewCategory + * @param sCategory {String} Category name. + * @private + */ + YAHOO.widget.Logger._createNewCategory = function(sCategory) { + this.categories.push(sCategory); + this.categoryCreateEvent.fire(sCategory); + }; + + /** + * Checks to see if a category has already been created. + * + * @method _isNewCategory + * @param sCategory {String} Category name. + * @return {Boolean} Returns true if category is unknown, else returns false. + * @private + */ + YAHOO.widget.Logger._isNewCategory = function(sCategory) { + for(var i=0; i < this.categories.length; i++) { + if(sCategory == this.categories[i]) { + return false; + } + } + return true; + }; + + /** + * Creates a new source of log messages and fires sourceCreateEvent. + * + * @method _createNewSource + * @param sSource {String} Source name. + * @private + */ + YAHOO.widget.Logger._createNewSource = function(sSource) { + this.sources.push(sSource); + this.sourceCreateEvent.fire(sSource); + }; + + /** + * Checks to see if a source already exists. + * + * @method _isNewSource + * @param sSource {String} Source name. + * @return {Boolean} Returns true if source is unknown, else returns false. + * @private + */ + YAHOO.widget.Logger._isNewSource = function(sSource) { + if(sSource) { + for(var i=0; i < this.sources.length; i++) { + if(sSource == this.sources[i]) { + return false; + } + } + return true; + } + }; + + /** + * Outputs a log message to global console.log() function. + * + * @method _printToBrowserConsole + * @param oEntry {Object} Log entry object. + * @private + */ + YAHOO.widget.Logger._printToBrowserConsole = function(oEntry) { + if(window.console && console.log) { + var category = oEntry.category; + var label = oEntry.category.substring(0,4).toUpperCase(); + + var time = oEntry.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): " + + oEntry.source + ": " + + oEntry.msg; + + console.log(output); + } + }; + + ///////////////////////////////////////////////////////////////////////////// + // + // Private event handlers + // + ///////////////////////////////////////////////////////////////////////////// + + /** + * Handles logging of messages due to window error events. + * + * @method _onWindowError + * @param sMsg {String} The error message. + * @param sUrl {String} URL of the error. + * @param sLine {String} Line number of the error. + * @private + */ + YAHOO.widget.Logger._onWindowError = function(sMsg,sUrl,sLine) { + // Logger is not in scope of this event handler + try { + YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')', "window"); + if(YAHOO.widget.Logger._origOnWindowError) { + YAHOO.widget.Logger._origOnWindowError(); + } + } + catch(e) { + return false; + } + }; + + ///////////////////////////////////////////////////////////////////////////// + // + // Enable handling of 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"); +} + + +YAHOO.register("logger", YAHOO.widget.Logger, {version: "2.3.0", build: "442"}); diff --git a/lib/yui/menu/README b/lib/yui/menu/README index 30e675ccb9..ee978b3037 100755 --- a/lib/yui/menu/README +++ b/lib/yui/menu/README @@ -1,4 +1,523 @@ -Menu Release Notes +*** version 2.3.0 *** + +Fixed the following bugs: +------------------------- + ++ Pressing the Esc key when an item in a MenuBar has focus will now result + in the item blurring in IE. + ++ Clicking a YAHOO.widget.MenuItem instance with a "url" configuration property + set will now result in the hiding of its parent YAHOO.widget.Menu instance. + ++ Creating an empty YAHOO.widget.Menu instance from existing markup will no + longer result in a JavaScript error. + ++ The "constraintoviewport" configuration property now correctly keeps a + YAHOO.widget.Menu instance inside the boundaries of the browser viewport. + ++ Tuned scrolling behavior so that when the user has scrolled to the bottom of + a YAHOO.widget.Menu instance and starts pressing the up arrow key, the + contents begin scrolling only when the next item to be selected is out of + view of the scrollable area. + ++ Modified "removeMenu" method of YAHOO.widget.MenuManager so that it removes + the specified YAHOO.widget.Menu instance from the collection of visible menus. + ++ Calling the "destroy" method of a visible YAHOO.widget.Menu instance now + purges it from the YAHOO.widget.Manager's collection of visible Menus. + ++ YAHOO.widget.Menu instances now blur before hiding. + ++ The debug version of YAHOO.widget.Menu now correctly logs as "Menu" rather + than "Overlay" in IE. + ++ Setting a YAHOO.widget.MenuItem instance's "checked" configuration property + to "true" two or more times followed by "false" will no longer result in some + of the DOM elements used to render the checkmark icon will no longer remain + in the item's DOM. + ++ It is now possible to click anywhere on a YAHOO.widget.MenuItem instance + and have it navigate to the URL specified by its "url" configuration property + - even if the MenuItem has a value specified for its "target" + configuation property. + ++ The "toString" method of YAHOO.widget.MenuItem now returns the instance's id. + ++ Setting the YAHOO.widget.MenuItem.prototype.COLLAPSED_SUBMENU_INDICATOR_TEXT + constant to empty string no longer results in JavaScript error. + ++ YAHOO.widget.MenuBar instances behave the same regardless of the value + of their "position" configuration property. + ++ It is now possible to ctr or shift-click on YAHOO.widget.MenuItem instances + without the browser automatically redirecting to the URL specified by the + MenuItem's "url" configuration property. + + +Added the following features: +----------------------------- + ++ Prototype of all classes (Menu, ContextMenu, MenuBar, MenuItem, + ContextMenuItem, MenuBarItem) are augmented with YAHOO.util.EventProvider. + ++ Added the following methods to YAHOO.widget.MenuManager: + + - "getMenuItem" + - "getMenuItemGroup" + ++ Added the following methods to YAHOO.widget.Menu: + + - "subscribe" + - "getSubmenus" + - "onRender" + ++ Added a "disabled" configuration property to YAHOO.widget.Menu. + ++ Added the constant "CSS_LABEL_CLASS_NAME" to YAHOO.widget.MenuItem that + represents the name of the CSS class applied to the node that is the + first child of its root
  • node. + ++ Added the constant "CSS_LABEL_CLASS_NAME" to YAHOO.widget.MenuBarItem that + represents the name of the CSS class applied to the node that is the + first child of its root
  • node. + ++ Added ability for YAHOO.widget.Menu instances to have shadow: + + - The shadow for a Menu is implemented by appending a new element as the + last child of its root
    element: + +
    +
    +
      +
    • +
    • +
    • +
    +
    +
    +
    + + - The code that creates the shadow element resides inside the Menu's + public "onRender" prototype method. To disable the creation of a Menu's + shadow override the prototype of the "onRender" method: + + YAHOO.widget.Menu.prototype.onRender = function () { }; + + - The actual creation of the shadow element is deferred until the Menu is + made visible for the first time. + + - The shadow element is only created for Menu instances whose + "position" configuration property is set to "dynamic." + + - A Menu's shadow element can be styled via two CSS classes: + + + "yui-menu-shadow" - Applied to the shadow element when it is created. + + "yui-menu-shadow-visible" - Applied to the shadow element when the + Menu is visible; it is removed when hidden. + + - The shadow element is only styled when using the new "Sam" skin, for + the previous default skin its "display" property is set to "none." + + +Changes: +-------- + ++ Deprecated "browser" property of YAHOO.widget.MenuItem in favor + of the YAHOO.env.ua. + ++ Modified the DOM structure for a YAHOO.widget.MenuItem instance so that its + root
  • node only has only two direct descendants: + + - The node for its text label + - The
    node for its submenu + + The submenu indicator node (), checked + indicator node (), and help text node + () that were previously direct descendants of a + YAHOO.widget.MenuItem instance's root
  • are now direct descendants of + its node: + +
  • + + + + Text Label + + Help Text (Optional) + ... (Optional) + ... (Optional) + + + +
    ...
    (Optional submenu node) + +
  • + ++ As a result of the DOM structure changes for YAHOO.widget.MenuItem, the + following CSS class are now only applied to a YAHOO.widget.MenuItem + instance's node: + + - "selected" + - "disabled" + - "checked" + - "hashelptext" + - "hassubmenu" + ++ The "text" configuration property of YAHOO.widget.MenuItem now accepts a + string of HTML (previously only accepted plain text). + ++ The "emphasis" and "strongemphasis" configuration properties of + YAHOO.widget.MenuItem are no longer interpreted when building from + existing markup. + ++ All YAHOO.widget.MenuItem instances built from markup must have an node + as the first child of its root
  • node. + ++ When building YAHOO.widget.MenuItem instances from existing markup, the value + of the "text" property is set to the innerHTML of the menu item's node. + ++ Deprecated the following YAHOO.widget.MenuItem configuration properties: + + - "strongemphasis" + - "emphasis" + - "helptext" + + +Known Issues +------------ + ++ ContextMenu works differently in Opera + -------------------------------------- + Opera doesn't support the "contextmenu" DOM event used to trigger the display + of YAHOO.widget.ContextMenu instances. As a result, clicking the right mouse + button in Opera will not result in the display of a ContextMenu instance + as it would in IE, Gecko, and Safari. To work around this shortcoming, users + will need to do the following to trigger the display of + YAHOO.widget.ContextMenu instances in Opera: + + - Opera for Windows: Hold down the control key while clicking with the + left mouse button. + + - Opera for Mac OS X: Hold down the command/Apple key while clicking with + the left mouse button. + ++ Focus highlight sticks in Opera + ------------------------------- + In Opera focus is designated via the application of a background color + to an element's text node. When a Menu instance has focus in Opera, the + focus highlight can remain on a MenuItem instance even after it has blurred. + ++ ContextMenu instances cannot be invoked by clicking on Java Applets + ------------------------------------------------------------------- + When a Java Applet is specified as the "trigger" element for a ContextMenu + instance it will not display when the Applet is clicked. This is not a + bug in the ContextMenu class, but rather a result of DOM events not bubbling + up from inside Java Applets. For more information on this issue see: + http://tech.groups.yahoo.com/group/ydn-javascript/message/12128 + ++ Flash Movies appear on top of Menu instances + -------------------------------------------- + Flash movies can appear on top of Menu instances in IE and Gecko-based + browsers. To fix this problem, set the "wmode" of the Flash movie to either + "transparent" or "opaque" as indicated below: + + Via the tag: + + + + + + + + + + Via the tag: + + ... + ... + + ** For more information see + http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15523 + ++ Menu instances not rendered at correct z-index in IE + ------------------------------------------------------- + In IE, when a Menu instance is rendered inside a relatively positioned + element the z-index of the Menu instance is now relative to its + relatively positioned parent element. This is not a bug in the + Menu class, but rather a bug in IE where relatively positioned elements + establish a new stacking context for their child nodes. To avoid this + bug is recommend that all Menu instances that need to be able to float + above any other element in the document be made direct descendants of the + element. + + ** For more information see + http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html + ++ Elements with scrollbars poke through Menu instances floating above them + ------------------------------------------------------------------------ + There is a bug in Gecko-based browsers for Mac OS X where an element's + scrollbars will poke through absolutely positioned elements floating above + them. To fix this problem the "overflow" property of a Menu instance's + shadow element is toggled between "hidden" and "auto" (through the application + and removal of the "hide-scrollbars" and "show-scrollbars" CSS classes) as its + "visibility" configuration property is toggled between "false" and "true." + Therefore, the shadow element acts like a shim, blocking scrollbars from + poking through the Menu. + + PLEASE NOTE: + + 1) The "hide-scrollbars" and "show-scrollbars" CSS classes classes are + applied only for Gecko on Mac OS X and are added/removed to/from the + Menu's root HTML element (DIV) via the "hideMacGeckoScrollbars" and + "showMacGeckoScrollbars" methods of YAHOO.widget.Overlay. + + 2) This fix is only applied when using the "Sam" skin; the CSS for the + original Menu skin does not contain any rules for rendering the + shadow element. + + 3) Once the fix is applied the bug will reappear if the window loses focus. + This can be fixed via Javascript by hiding and showing the Menu instance + when the window receives focus: + + YAHOO.util.Event.on(window, "focus", function () { + + oMyMenu.hide(); + oMyMenu.show(); + + }); + + ** For more information see + https://bugzilla.mozilla.org/show_bug.cgi?id=187435 + + +*** version 2.2.2 *** + +Fixed the following bugs: +------------------------- + ++ "toString" method of MenuItem, MenuBarItem and ContextMenuItem classes will + no longer throw a JavaScript error when using the debug version + of the Event utility. + ++ "toString" method of Menu, MenuBar and ContextMenu classes will + no longer attempt to output the instance's id if it is not available. + ++ Logger statements output by debug version of MenuManager are now properly + categorized as "MenuManager" + + + +*** version 2.2.1 *** + +Added the following features: +----------------------------- + ++ Added the following methods to YAHOO.widget.Menu: + - "focus" + - "blur" + - "hasFocus" + ++ Added the following Custom Events to YAHOO.widget.Menu: + + "focusEvent" + + "blurEvent" + ++ Added the following methods to YAHOO.widget.MenuManager: + - "getFocusedMenuItem" + - "getFocusedMenu" + ++ Added "hasFocus" method to YAHOO.widget.MenuItem + + +Fixed the following bugs: +------------------------- + ++ Menu instances no longer set focus to themselves by default when made + visible. Menus only receive focus in response to the following events: + - The user mouses down on a MenuItem instance + - The user tabs into a MenuItem instance + ++ Application of the "maxheight" configuration property is now correctly + deferred until the "render" event fires when Menu instance is being + lazy loaded. + ++ The "maxheight" configuration property can now be set multiple times without + a Menu instance restoring itself to its original default height. + ++ The "maxheight" configuration property can now be set on hidden Menu + instances that use lazy loading. + ++ Menu instances with a "width" configuration property set will now render + at the specified width rather than shrink wrapping to their contents. + ++ Menu item help text no longer wraps to the next line in Opera 9. + ++ Immediate submenus of a Menubar instance will no longer shift their position + to try and remain inside the confines of the browser's viewport. + ++ Lazy loaded ContextMenu instances now appear in the correct position when + they are made visible for the first time. + ++ MenuBar instances no longer throw JavaScript errors when navigating items with + submenus containing no active items using the keyboard. + ++ Replaced use of native "hasOwnProperty" method + with YAHOO.lang.hasOwnProperty. + ++ Rendered Menu instances will now update their width when items are added + or removed. + ++ Mousing over a Menu instance in an IE window that does not have focus will + no longer cause the window to receive focus. + + +Changes: +-------- + ++ "activeItem" property of YAHOO.widget.Menu now returns a reference to the + Menu's currently selected item. + ++ Added a "visible" CSS class that is applied to visible Menu instances. + ++ Refactored the Menu family to improve performance, especially when working + with a large number of instances in IE6. + + + +*** version 2.2.0 *** + +Added the following features: +----------------------------- + +* Added two new methods to YAHOO.widget.Menu: + + * "getItems" - Returns a flat array of the items in a menu. + + * "clearContent" - Removes all of the content from the menu, including the + menu items, group titles, header and footer. + + +* Added three new configuration attributes to YAHOO.widget.Menu: + + * "submenuhidedelay" - Number indicating the time (in milliseconds) that + should expire before a submenu is hidden when the user mouses out of a + menu item heading in the direction of a submenu. The value must be + greater than or equal to the value specified for the "showdelay" + configuration property. + + * "maxheight" - Defines the maximum height (in pixels) for a menu before + the contents of the body are scrolled. + + * "classname" - CSS class to be applied to the menu's root
    element. + The specified class(es) are appended in addition to the default class as + specified by the menu's CSS_CLASS_NAME constant. + + +* Added new constants to YAHOO.widget.MenuItem: + + * COLLAPSED_SUBMENU_INDICATOR_TEXT - String representing the text for the + element used for the submenu arrow indicator. + + * EXPANDED_SUBMENU_INDICATOR_TEXT - String representing the text for the + submenu arrow indicator element () when the submenu is visible. + + * DISABLED_SUBMENU_INDICATOR_ALT_TEXT - String representing the text for + the submenu arrow indicator element () when the menu item is disabled. + + * CHECKED_TEXT - String representing the text to be used for the checked + indicator element (). + + * DISABLED_CHECKED_TEXT - String representing the text to be used for the + checked indicator element () when the menu item is disabled. + + +* Added two new configuration attributes to YAHOO.widget.MenuItem: + + * "onclick" - Object literal representing the code to be executed when the + button is clicked. Format: + + { + fn: Function, // The handler to call when the event fires. + obj: Object, // An object to pass back to the handler. + scope: Object // The object to use for the scope of the handler. + } + + * "classname" - CSS class to be applied to the menu item's root
  • + element. The specified class(es) are appended in addition to the default + class as specified by the menu item's CSS_CLASS_NAME constant. + + +* Added an "id" property to YAHOO.widget.MenuItem that represents the id of + the menu item's root
  • node. Although not a configuration attribute, this + property should be set via the object literal of configuration attributes + passed as the second argument to the constructor. If no value is + specified, then one will be generated using the "generateId" method of the + Dom utility (YAHOO.widget.Dom). + +* Added a "trigger context menu event" + (YAHOO.widget.ContextMenu.triggerContextMenuEvent) that fires when the DOM + "contextmenu" event ("mousedown" for Opera) is fired by one of the elemeents + defined as a YAHOO.widget.ContextMenu instance's trigger. + +* Added a "cancel" method to YAHOO.widget.ContextMenu that can be used to + cancel the display of a YAHOO.widget.ContextMen instance. This method + should be called within the scope of a "context menu" event handler for + one of the context menu's triggers + (YAHOO.widget.ContextMenu.triggerContextMenuEvent). + + +Fixed the following bugs: +------------------------- + +* Users can now move diagonally from a menu item to its corresponding submenu + without the submenu hiding immediately. + +* "destroy" method of YAHOO.widget.Menu now unsubscribes from the "text resize" + event (YAHOO.widget.Module.textResizeEvent). + +* Browser progress bar no longer flashes when hovering over checked menu items + or menu items with submenus. + +* Menu item submenu indicator image no longer jumps to the next line in + quirks mode. + +* Mouse events no longer fire in Firefox if a YAHOO.widget.Menu instance is + moved by script into a stationary mouse pointer. + +* Modified "toString" method of YAHOO.widget.ContextMenuItem to return the + correct class name, as it was reporting as YAHOO.widget.MenuBarItem. + + +Changes: +-------- + +* Default value for the "showdelay" configuration attribute is now 250 + +* Modified code so that all Menu images are added via CSS background images. + As a result, the following constants and properties have been deprecated: + + * YAHOO.widget.MenuItem.SUBMENU_INDICATOR_IMAGE_PATH + * YAHOO.widget.MenuItem.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH + * YAHOO.widget.MenuItem.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH + * YAHOO.widget.MenuItem.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT + * YAHOO.widget.MenuItem.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT + * YAHOO.widget.MenuItem.DISABLED_SUBMENU_INDICATOR_ALT_TEXT + * YAHOO.widget.MenuItem.CHECKED_IMAGE_PATH + * YAHOO.widget.MenuItem.SELECTED_CHECKED_IMAGE_PATH + * YAHOO.widget.MenuItem.DISABLED_CHECKED_IMAGE_PATH + * YAHOO.widget.MenuItem.CHECKED_IMAGE_ALT_TEXT + * YAHOO.widget.MenuItem.DISABLED_CHECKED_IMAGE_ALT_TEXT + * YAHOO.widget.MenuItem.IMG_ROOT + * YAHOO.widget.MenuItem.IMG_ROOT_SSL + * YAHOO.widget.MenuItem.imageRoot + * YAHOO.widget.MenuItem.isSecure + + + +*** version 0.12.2 *** + +* No changes + + *** version 0.12.1 *** @@ -20,9 +539,9 @@ Fixed the following bugs: mouse simultaneously. * Calling the "destory" method on a menu will now unregister all of the menu's - submenus from the MenuManager. - - + submenus from the MenuManager. + + *** version 0.12 *** diff --git a/lib/yui/menu/assets/map.gif b/lib/yui/menu/assets/map.gif new file mode 100755 index 0000000000000000000000000000000000000000..88dae00fff9b68736d37ce05e40763f00a77d411 GIT binary patch literal 236 zcmV)qTr*l;LA1QRv_!2I4-AaH#>cc-H(OpnLCwgr2>?6TmR*Yg literal 0 HcmV?d00001 diff --git a/lib/yui/menu/assets/menu-core.css b/lib/yui/menu/assets/menu-core.css new file mode 100755 index 0000000000..5dee704b2a --- /dev/null +++ b/lib/yui/menu/assets/menu-core.css @@ -0,0 +1,142 @@ +/* +Copyright (c) 2007, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +version: 2.3.0 +*/ +/* Menu & MenuBar styles */ + +.yuimenu .yuimenu, +.yuimenubar .yuimenu { + + position: absolute; + visibility: hidden; + +} + +.yuimenubar ul, +.yuimenu ul { + + list-style-type: none; + +} + +.yuimenubar ul, +.yuimenu ul, +.yuimenubar li, +.yuimenu li, +.yuimenu h6, +.yuimenubar h6 { + + margin: 0; + padding: 0; + +} + +.yuimenuitemlabel, +.yuimenubaritemlabel { + + white-space: nowrap; + +} + + +/* + PLEASE NOTE: The
    element used for a menu's shadow is appended + to its root element via JavaScript once it has been rendered. The + code that creates the shadow lives in the menu's public "onRender" + event handler that is a prototype method of YAHOO.widget.Menu. + Implementers wishing to remove a menu's shadow or add any other markup + required for a given skin for menu should override the "onRender" method. +*/ + +.yui-menu-shadow { + + position: absolute; + +} + + + +/* + +There are two known issues with YAHOO.widget.Overlay (the superclass class of +Menu) that manifest in Gecko-based browsers on Mac OS X: + + 1) Elements with scrollbars will poke through Overlay instances floating + above them. + + 2) An Overlay's scrollbars and the scrollbars of its child nodes remain + visible when the Overlay is hidden. + +To fix these bugs in Menu (a subclass of YAHOO.widget.Overlay): + + 1) The "overflow" property of a Menu instance's shadow element and child + nodes is toggled between "hidden" and "auto" (through the application + and removal of the "hide-scrollbars" and "show-scrollbars" CSS classes) + as its "visibility" configuration property is toggled between + "false" and "true." + + 2) The "display" property of