From 0ae8da5c37cea9841359d7d39e758f0a077e9c37 Mon Sep 17 00:00:00 2001 From: ftimme <ft@falkotimme.com> Date: Thu, 15 Sep 2011 12:11:40 +0000 Subject: [PATCH] - Added nginx support. - Fixed FS#1745. --- .../web/admin/form/server_config.tform.php | 30 +- .../web/admin/lib/lang/de_server_config.lng | 7 +- .../web/admin/lib/lang/en_server_config.lng | 3 + .../templates/server_config_web_edit.htm | 54 +- interface/web/js/yui-combo.js | 26 - interface/web/js/yui/animation/README | 45 - .../web/js/yui/animation/animation-debug.js | 1361 --- .../web/js/yui/animation/animation-min.js | 75 - interface/web/js/yui/animation/animation.js | 1358 --- interface/web/js/yui/autocomplete/README | 77 - .../js/yui/autocomplete/autocomplete-debug.js | 3100 ------ .../js/yui/autocomplete/autocomplete-min.js | 183 - .../web/js/yui/autocomplete/autocomplete.js | 3071 ------ interface/web/js/yui/button/README | 3 - .../web/js/yui/button/assets/background.png | Bin 185 -> 0 bytes interface/web/js/yui/button/assets/button.css | 217 - .../web/js/yui/button/assets/menuarrow.gif | Bin 67 -> 0 bytes .../web/js/yui/button/assets/splitarrow.gif | Bin 145 -> 0 bytes .../yui/button/assets/splitarrow_active.gif | Bin 145 -> 0 bytes .../web/js/yui/button/button-beta-debug.js | 4061 -------- .../web/js/yui/button/button-beta-min.js | 126 - interface/web/js/yui/button/button-beta.js | 3949 -------- interface/web/js/yui/calendar/README | 88 - .../web/js/yui/calendar/assets/calendar.css | 197 - .../web/js/yui/calendar/assets/callt.gif | Bin 93 -> 0 bytes .../web/js/yui/calendar/assets/calrt.gif | Bin 94 -> 0 bytes interface/web/js/yui/calendar/assets/calx.gif | Bin 88 -> 0 bytes .../web/js/yui/calendar/calendar-debug.js | 4331 --------- interface/web/js/yui/calendar/calendar-min.js | 116 - interface/web/js/yui/calendar/calendar.js | 4309 --------- interface/web/js/yui/connection/README | 182 - .../web/js/yui/connection/connection-debug.js | 1082 --- .../web/js/yui/connection/connection-min.js | 104 - interface/web/js/yui/connection/connection.js | 1054 --- interface/web/js/yui/container/README | 207 - .../web/js/yui/container/assets/alrt16_1.gif | Bin 971 -> 0 bytes .../web/js/yui/container/assets/blck16_1.gif | Bin 591 -> 0 bytes .../web/js/yui/container/assets/close12_1.gif | Bin 85 -> 0 bytes .../web/js/yui/container/assets/container.css | 230 - .../web/js/yui/container/assets/hlp16_1.gif | Bin 928 -> 0 bytes .../web/js/yui/container/assets/info16_1.gif | Bin 601 -> 0 bytes .../web/js/yui/container/assets/tip16_1.gif | Bin 552 -> 0 bytes .../web/js/yui/container/assets/warn16_1.gif | Bin 580 -> 0 bytes .../web/js/yui/container/container-debug.js | 4752 ---------- .../web/js/yui/container/container-min.js | 159 - interface/web/js/yui/container/container.js | 4727 ---------- .../js/yui/container/container_core-debug.js | 2932 ------ .../js/yui/container/container_core-min.js | 109 - .../web/js/yui/container/container_core.js | 2919 ------ interface/web/js/yui/datasource/README | 5 - .../yui/datasource/datasource-beta-debug.js | 912 -- .../js/yui/datasource/datasource-beta-min.js | 59 - .../web/js/yui/datasource/datasource-beta.js | 902 -- interface/web/js/yui/datatable/README | 9 - .../web/js/yui/datatable/assets/datatable.css | 82 - .../js/yui/datatable/datatable-beta-debug.js | 4956 ---------- .../js/yui/datatable/datatable-beta-min.js | 214 - .../web/js/yui/datatable/datatable-beta.js | 4930 ---------- interface/web/js/yui/dom/README | 79 - interface/web/js/yui/dom/dom-debug.js | 935 -- interface/web/js/yui/dom/dom-min.js | 59 - interface/web/js/yui/dom/dom.js | 901 -- interface/web/js/yui/dragdrop/README | 118 - .../web/js/yui/dragdrop/dragdrop-debug.js | 3068 ------ interface/web/js/yui/dragdrop/dragdrop-min.js | 93 - interface/web/js/yui/dragdrop/dragdrop.js | 2958 ------ interface/web/js/yui/element/README | 7 - .../web/js/yui/element/element-beta-debug.js | 906 -- .../web/js/yui/element/element-beta-min.js | 30 - interface/web/js/yui/element/element-beta.js | 896 -- interface/web/js/yui/event/README | 161 - interface/web/js/yui/event/event-debug.js | 2076 ---- interface/web/js/yui/event/event-min.js | 84 - interface/web/js/yui/event/event.js | 2054 ---- interface/web/js/yui/fonts/README | 13 - interface/web/js/yui/fonts/fonts-min.css | 7 - interface/web/js/yui/fonts/fonts.css | 29 - interface/web/js/yui/grids/README | 48 - interface/web/js/yui/grids/grids-min.css | 7 - interface/web/js/yui/grids/grids.css | 129 - interface/web/js/yui/history/README | 11 - .../web/js/yui/history/assets/blank.html | 1 - .../yui/history/history-experimental-debug.js | 649 -- .../yui/history/history-experimental-min.js | 44 - .../js/yui/history/history-experimental.js | 649 -- interface/web/js/yui/logger/README | 51 - interface/web/js/yui/logger/assets/logger.css | 26 - interface/web/js/yui/logger/logger-debug.js | 1597 ---- interface/web/js/yui/logger/logger-min.js | 63 - interface/web/js/yui/logger/logger.js | 1597 ---- interface/web/js/yui/menu/README | 385 - interface/web/js/yui/menu/assets/map.gif | Bin 264 -> 0 bytes interface/web/js/yui/menu/assets/menu.css | 384 - .../js/yui/menu/assets/menuarodwn8_dim_1.gif | Bin 53 -> 0 bytes .../js/yui/menu/assets/menuarodwn8_hov_1.gif | Bin 53 -> 0 bytes .../js/yui/menu/assets/menuarodwn8_nrm_1.gif | Bin 53 -> 0 bytes .../js/yui/menu/assets/menuarorght8_dim_1.gif | Bin 54 -> 0 bytes .../js/yui/menu/assets/menuarorght8_hov_1.gif | Bin 54 -> 0 bytes .../js/yui/menu/assets/menuarorght8_nrm_1.gif | Bin 54 -> 0 bytes .../js/yui/menu/assets/menuaroup8_dim_1.gif | Bin 53 -> 0 bytes .../js/yui/menu/assets/menuaroup8_nrm_1.gif | Bin 53 -> 0 bytes .../web/js/yui/menu/assets/menuchk8_dim_1.gif | Bin 65 -> 0 bytes .../web/js/yui/menu/assets/menuchk8_hov_1.gif | Bin 67 -> 0 bytes .../web/js/yui/menu/assets/menuchk8_nrm_1.gif | Bin 67 -> 0 bytes interface/web/js/yui/menu/menu-debug.js | 8317 ----------------- interface/web/js/yui/menu/menu-min.js | 260 - interface/web/js/yui/menu/menu.js | 8265 ---------------- interface/web/js/yui/reset-fonts-grids/README | 24 - .../reset-fonts-grids/reset-fonts-grids.css | 9 - interface/web/js/yui/reset/README | 25 - interface/web/js/yui/reset/reset-min.css | 7 - interface/web/js/yui/reset/reset.css | 15 - interface/web/js/yui/slider/README | 69 - interface/web/js/yui/slider/slider-debug.js | 1259 --- interface/web/js/yui/slider/slider-min.js | 36 - interface/web/js/yui/slider/slider.js | 1222 --- interface/web/js/yui/tabview/README | 21 - .../web/js/yui/tabview/assets/border_tabs.css | 54 - .../web/js/yui/tabview/assets/tabview.css | 75 - interface/web/js/yui/tabview/tabview-debug.js | 1025 -- interface/web/js/yui/tabview/tabview-min.js | 35 - interface/web/js/yui/tabview/tabview.js | 1021 -- interface/web/js/yui/treeview/README | 147 - interface/web/js/yui/treeview/assets/lm.gif | Bin 94 -> 0 bytes interface/web/js/yui/treeview/assets/lmh.gif | Bin 106 -> 0 bytes interface/web/js/yui/treeview/assets/ln.gif | Bin 142 -> 0 bytes .../web/js/yui/treeview/assets/loading.gif | Bin 2673 -> 0 bytes interface/web/js/yui/treeview/assets/lp.gif | Bin 130 -> 0 bytes interface/web/js/yui/treeview/assets/lph.gif | Bin 111 -> 0 bytes interface/web/js/yui/treeview/assets/tm.gif | Bin 545 -> 0 bytes interface/web/js/yui/treeview/assets/tmh.gif | Bin 563 -> 0 bytes interface/web/js/yui/treeview/assets/tn.gif | Bin 504 -> 0 bytes interface/web/js/yui/treeview/assets/tp.gif | Bin 539 -> 0 bytes interface/web/js/yui/treeview/assets/tph.gif | Bin 568 -> 0 bytes interface/web/js/yui/treeview/assets/tree.css | 102 - .../web/js/yui/treeview/assets/vline.gif | Bin 503 -> 0 bytes .../web/js/yui/treeview/treeview-debug.js | 2287 ----- interface/web/js/yui/treeview/treeview-min.js | 70 - interface/web/js/yui/treeview/treeview.js | 2248 ----- interface/web/js/yui/utilities/README | 36 - interface/web/js/yui/utilities/utilities.js | 418 - interface/web/js/yui/yahoo-dom-event/README | 35 - .../js/yui/yahoo-dom-event/yahoo-dom-event.js | 144 - interface/web/js/yui/yahoo/README | 64 - interface/web/js/yui/yahoo/yahoo-debug.js | 433 - interface/web/js/yui/yahoo/yahoo-min.js | 15 - interface/web/js/yui/yahoo/yahoo.js | 433 - interface/web/sites/ajax_get_json.php | 66 + .../web/sites/lib/lang/de_web_domain.lng | 1 + .../web/sites/lib/lang/en_web_domain.lng | 3 +- .../sites/templates/web_domain_advanced.htm | 25 + .../web/sites/templates/web_domain_edit.htm | 42 +- ...> nginx_reverseproxy_rewrites.conf.master} | 0 .../conf/nginx_reverseproxy_vhost.conf.master | 69 + server/conf/nginx_vhost.conf.master | 140 +- server/mods-available/web_module.inc.php | 18 +- server/plugins-available/nginx_plugin.inc.php | 1029 +- .../nginx_reverseproxy_plugin.inc.php | 368 + 158 files changed, 1629 insertions(+), 105731 deletions(-) delete mode 100644 interface/web/js/yui-combo.js delete mode 100644 interface/web/js/yui/animation/README delete mode 100644 interface/web/js/yui/animation/animation-debug.js delete mode 100644 interface/web/js/yui/animation/animation-min.js delete mode 100644 interface/web/js/yui/animation/animation.js delete mode 100644 interface/web/js/yui/autocomplete/README delete mode 100644 interface/web/js/yui/autocomplete/autocomplete-debug.js delete mode 100644 interface/web/js/yui/autocomplete/autocomplete-min.js delete mode 100644 interface/web/js/yui/autocomplete/autocomplete.js delete mode 100644 interface/web/js/yui/button/README delete mode 100644 interface/web/js/yui/button/assets/background.png delete mode 100644 interface/web/js/yui/button/assets/button.css delete mode 100644 interface/web/js/yui/button/assets/menuarrow.gif delete mode 100644 interface/web/js/yui/button/assets/splitarrow.gif delete mode 100644 interface/web/js/yui/button/assets/splitarrow_active.gif delete mode 100644 interface/web/js/yui/button/button-beta-debug.js delete mode 100644 interface/web/js/yui/button/button-beta-min.js delete mode 100644 interface/web/js/yui/button/button-beta.js delete mode 100644 interface/web/js/yui/calendar/README delete mode 100644 interface/web/js/yui/calendar/assets/calendar.css delete mode 100644 interface/web/js/yui/calendar/assets/callt.gif delete mode 100644 interface/web/js/yui/calendar/assets/calrt.gif delete mode 100644 interface/web/js/yui/calendar/assets/calx.gif delete mode 100644 interface/web/js/yui/calendar/calendar-debug.js delete mode 100644 interface/web/js/yui/calendar/calendar-min.js delete mode 100644 interface/web/js/yui/calendar/calendar.js delete mode 100644 interface/web/js/yui/connection/README delete mode 100644 interface/web/js/yui/connection/connection-debug.js delete mode 100644 interface/web/js/yui/connection/connection-min.js delete mode 100644 interface/web/js/yui/connection/connection.js delete mode 100644 interface/web/js/yui/container/README delete mode 100644 interface/web/js/yui/container/assets/alrt16_1.gif delete mode 100644 interface/web/js/yui/container/assets/blck16_1.gif delete mode 100644 interface/web/js/yui/container/assets/close12_1.gif delete mode 100644 interface/web/js/yui/container/assets/container.css delete mode 100644 interface/web/js/yui/container/assets/hlp16_1.gif delete mode 100644 interface/web/js/yui/container/assets/info16_1.gif delete mode 100644 interface/web/js/yui/container/assets/tip16_1.gif delete mode 100644 interface/web/js/yui/container/assets/warn16_1.gif delete mode 100644 interface/web/js/yui/container/container-debug.js delete mode 100644 interface/web/js/yui/container/container-min.js delete mode 100644 interface/web/js/yui/container/container.js delete mode 100644 interface/web/js/yui/container/container_core-debug.js delete mode 100644 interface/web/js/yui/container/container_core-min.js delete mode 100644 interface/web/js/yui/container/container_core.js delete mode 100644 interface/web/js/yui/datasource/README delete mode 100644 interface/web/js/yui/datasource/datasource-beta-debug.js delete mode 100644 interface/web/js/yui/datasource/datasource-beta-min.js delete mode 100644 interface/web/js/yui/datasource/datasource-beta.js delete mode 100644 interface/web/js/yui/datatable/README delete mode 100644 interface/web/js/yui/datatable/assets/datatable.css delete mode 100644 interface/web/js/yui/datatable/datatable-beta-debug.js delete mode 100644 interface/web/js/yui/datatable/datatable-beta-min.js delete mode 100644 interface/web/js/yui/datatable/datatable-beta.js delete mode 100644 interface/web/js/yui/dom/README delete mode 100644 interface/web/js/yui/dom/dom-debug.js delete mode 100644 interface/web/js/yui/dom/dom-min.js delete mode 100644 interface/web/js/yui/dom/dom.js delete mode 100644 interface/web/js/yui/dragdrop/README delete mode 100644 interface/web/js/yui/dragdrop/dragdrop-debug.js delete mode 100644 interface/web/js/yui/dragdrop/dragdrop-min.js delete mode 100644 interface/web/js/yui/dragdrop/dragdrop.js delete mode 100644 interface/web/js/yui/element/README delete mode 100644 interface/web/js/yui/element/element-beta-debug.js delete mode 100644 interface/web/js/yui/element/element-beta-min.js delete mode 100644 interface/web/js/yui/element/element-beta.js delete mode 100644 interface/web/js/yui/event/README delete mode 100644 interface/web/js/yui/event/event-debug.js delete mode 100644 interface/web/js/yui/event/event-min.js delete mode 100644 interface/web/js/yui/event/event.js delete mode 100644 interface/web/js/yui/fonts/README delete mode 100644 interface/web/js/yui/fonts/fonts-min.css delete mode 100644 interface/web/js/yui/fonts/fonts.css delete mode 100644 interface/web/js/yui/grids/README delete mode 100644 interface/web/js/yui/grids/grids-min.css delete mode 100644 interface/web/js/yui/grids/grids.css delete mode 100644 interface/web/js/yui/history/README delete mode 100644 interface/web/js/yui/history/assets/blank.html delete mode 100644 interface/web/js/yui/history/history-experimental-debug.js delete mode 100644 interface/web/js/yui/history/history-experimental-min.js delete mode 100644 interface/web/js/yui/history/history-experimental.js delete mode 100644 interface/web/js/yui/logger/README delete mode 100644 interface/web/js/yui/logger/assets/logger.css delete mode 100644 interface/web/js/yui/logger/logger-debug.js delete mode 100644 interface/web/js/yui/logger/logger-min.js delete mode 100644 interface/web/js/yui/logger/logger.js delete mode 100644 interface/web/js/yui/menu/README delete mode 100644 interface/web/js/yui/menu/assets/map.gif delete mode 100644 interface/web/js/yui/menu/assets/menu.css delete mode 100644 interface/web/js/yui/menu/assets/menuarodwn8_dim_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuarodwn8_hov_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuarodwn8_nrm_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuarorght8_dim_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuarorght8_hov_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuarorght8_nrm_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuaroup8_dim_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuaroup8_nrm_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuchk8_dim_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuchk8_hov_1.gif delete mode 100644 interface/web/js/yui/menu/assets/menuchk8_nrm_1.gif delete mode 100644 interface/web/js/yui/menu/menu-debug.js delete mode 100644 interface/web/js/yui/menu/menu-min.js delete mode 100644 interface/web/js/yui/menu/menu.js delete mode 100644 interface/web/js/yui/reset-fonts-grids/README delete mode 100644 interface/web/js/yui/reset-fonts-grids/reset-fonts-grids.css delete mode 100644 interface/web/js/yui/reset/README delete mode 100644 interface/web/js/yui/reset/reset-min.css delete mode 100644 interface/web/js/yui/reset/reset.css delete mode 100644 interface/web/js/yui/slider/README delete mode 100644 interface/web/js/yui/slider/slider-debug.js delete mode 100644 interface/web/js/yui/slider/slider-min.js delete mode 100644 interface/web/js/yui/slider/slider.js delete mode 100644 interface/web/js/yui/tabview/README delete mode 100644 interface/web/js/yui/tabview/assets/border_tabs.css delete mode 100644 interface/web/js/yui/tabview/assets/tabview.css delete mode 100644 interface/web/js/yui/tabview/tabview-debug.js delete mode 100644 interface/web/js/yui/tabview/tabview-min.js delete mode 100644 interface/web/js/yui/tabview/tabview.js delete mode 100644 interface/web/js/yui/treeview/README delete mode 100644 interface/web/js/yui/treeview/assets/lm.gif delete mode 100644 interface/web/js/yui/treeview/assets/lmh.gif delete mode 100644 interface/web/js/yui/treeview/assets/ln.gif delete mode 100644 interface/web/js/yui/treeview/assets/loading.gif delete mode 100644 interface/web/js/yui/treeview/assets/lp.gif delete mode 100644 interface/web/js/yui/treeview/assets/lph.gif delete mode 100644 interface/web/js/yui/treeview/assets/tm.gif delete mode 100644 interface/web/js/yui/treeview/assets/tmh.gif delete mode 100644 interface/web/js/yui/treeview/assets/tn.gif delete mode 100644 interface/web/js/yui/treeview/assets/tp.gif delete mode 100644 interface/web/js/yui/treeview/assets/tph.gif delete mode 100644 interface/web/js/yui/treeview/assets/tree.css delete mode 100644 interface/web/js/yui/treeview/assets/vline.gif delete mode 100644 interface/web/js/yui/treeview/treeview-debug.js delete mode 100644 interface/web/js/yui/treeview/treeview-min.js delete mode 100644 interface/web/js/yui/treeview/treeview.js delete mode 100644 interface/web/js/yui/utilities/README delete mode 100644 interface/web/js/yui/utilities/utilities.js delete mode 100644 interface/web/js/yui/yahoo-dom-event/README delete mode 100644 interface/web/js/yui/yahoo-dom-event/yahoo-dom-event.js delete mode 100644 interface/web/js/yui/yahoo/README delete mode 100644 interface/web/js/yui/yahoo/yahoo-debug.js delete mode 100644 interface/web/js/yui/yahoo/yahoo-min.js delete mode 100644 interface/web/js/yui/yahoo/yahoo.js create mode 100644 interface/web/sites/ajax_get_json.php rename server/conf/{nginx_rewrites.conf.master => nginx_reverseproxy_rewrites.conf.master} (100%) create mode 100644 server/conf/nginx_reverseproxy_vhost.conf.master create mode 100644 server/plugins-available/nginx_reverseproxy_plugin.inc.php diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index 9a80aa0a6c..9a36919351 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -321,6 +321,12 @@ $form["tabs"]['web'] = array( ################################## # Begin Datatable fields ################################## + 'server_type' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => 'apache', + 'value' => array('apache' => 'Apache', 'nginx' => 'nginx') + ), 'website_basedir' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -382,6 +388,28 @@ $form["tabs"]['web'] = array( 'width' => '40', 'maxlength' => '255' ), + 'nginx_vhost_conf_dir' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'validators' => array(0 => array('type' => 'NOTEMPTY', + 'errmsg' => 'nginx_vhost_conf_dir_error_empty'), + ), + 'value' => '', + 'width' => '40', + 'maxlength' => '255' + ), + 'nginx_vhost_conf_enabled_dir' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'validators' => array(0 => array('type' => 'NOTEMPTY', + 'errmsg' => 'nginx_vhost_conf_enabled_dir_error_empty'), + ), + 'value' => '', + 'width' => '40', + 'maxlength' => '255' + ), 'CA_path' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -463,7 +491,7 @@ $form["tabs"]['web'] = array( ), 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '4000' ), 'htaccess_allow_override' => array( 'datatype' => 'VARCHAR', diff --git a/interface/web/admin/lib/lang/de_server_config.lng b/interface/web/admin/lib/lang/de_server_config.lng index 1ec85d3aa9..cf2491b903 100644 --- a/interface/web/admin/lib/lang/de_server_config.lng +++ b/interface/web/admin/lib/lang/de_server_config.lng @@ -5,7 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted Anwendungen'; $wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted Anwendungen'; $wb['website_path_txt'] = 'Website Pfad'; $wb['website_symlinks_txt'] = 'Website Symlinks'; -$wb['website_symlinks_rel_txt'] = 'Make relative symlinks'; +$wb['website_symlinks_rel_txt'] = 'Erstelle relative Symlinks'; $wb['vhost_conf_dir_txt'] = 'Vhost config dir'; $wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir'; $wb['getmail_config_dir_txt'] = 'Getmail config dir'; @@ -85,5 +85,8 @@ $wb['ufw_default_output_policy_txt'] = 'Default Output Policy'; $wb['ufw_default_forward_policy_txt'] = 'Default Forward Policy'; $wb['ufw_default_application_policy_txt'] = 'Default Application Policy'; $wb['ufw_log_level_txt'] = 'Log Level'; -$wb['network_config_warning_txt'] = 'The network configuration option is only available for Debian and Ubuntu Servers. Do not enable this option if your network interface is not eth0.'; +$wb['network_config_warning_txt'] = 'Die Netzwerk-Konfiguration-Option ist nur auf Debian- und Ubuntu-Servern verfügbar. Aktivieren Sie diese Option nicht, falls Ihr Netzwerk-Interface nicht eth0 heißt.'; +$wb["server_type_txt"] = 'Server-Typ'; +$wb["nginx_vhost_conf_dir_txt"] = 'nginx Vhost config dir'; +$wb["nginx_vhost_conf_enabled_dir_txt"] = 'nginx Vhost config enabled dir'; ?> diff --git a/interface/web/admin/lib/lang/en_server_config.lng b/interface/web/admin/lib/lang/en_server_config.lng index abf946bb77..9b08de4772 100644 --- a/interface/web/admin/lib/lang/en_server_config.lng +++ b/interface/web/admin/lib/lang/en_server_config.lng @@ -88,4 +88,7 @@ $wb["CA_path_txt"] = 'CA Path'; $wb["CA_pass_txt"] = 'CA passphrase'; $wb["fastcgi_config_syntax_txt"] = 'FastCGI config syntax'; $wb["backup_dir_ftpread_txt"] = 'Backup dir. readable for website FTP users.'; +$wb["server_type_txt"] = 'Server Type'; +$wb["nginx_vhost_conf_dir_txt"] = 'nginx Vhost config dir'; +$wb["nginx_vhost_conf_enabled_dir_txt"] = 'nginx Vhost config enabled dir'; ?> \ No newline at end of file diff --git a/interface/web/admin/templates/server_config_web_edit.htm b/interface/web/admin/templates/server_config_web_edit.htm index 56ea0b7956..f22583f3f8 100644 --- a/interface/web/admin/templates/server_config_web_edit.htm +++ b/interface/web/admin/templates/server_config_web_edit.htm @@ -5,6 +5,14 @@ <div class="pnl_formsarea"> <fieldset class="inlineLabels"> + <div class="ctrlHolder"> + <p class="label">{tmpl_var name='server_type_txt'}</p> + <div class="multiField"> + <select name="server_type" id="server_type" class="selectInput"> + {tmpl_var name='server_type'} + </select> + </div> + </div> <div class="ctrlHolder"> <label for="website_basedir">{tmpl_var name='website_basedir_txt'}</label> <input name="website_basedir" id="website_basedir" value="{tmpl_var name='website_basedir'}" size="40" maxlength="255" type="text" class="textInput" /> @@ -31,6 +39,14 @@ <label for="vhost_conf_enabled_dir">{tmpl_var name='vhost_conf_enabled_dir_txt'}</label> <input name="vhost_conf_enabled_dir" id="vhost_conf_enabled_dir" value="{tmpl_var name='vhost_conf_enabled_dir'}" size="40" maxlength="255" type="text" class="textInput" /> </div> + <div class="ctrlHolder"> + <label for="nginx_vhost_conf_dir">{tmpl_var name='nginx_vhost_conf_dir_txt'}</label> + <input name="nginx_vhost_conf_dir" id="nginx_vhost_conf_dir" value="{tmpl_var name='nginx_vhost_conf_dir'}" size="40" maxlength="255" type="text" class="textInput" /> + </div> + <div class="ctrlHolder"> + <label for="nginx_vhost_conf_enabled_dir">{tmpl_var name='nginx_vhost_conf_enabled_dir_txt'}</label> + <input name="nginx_vhost_conf_enabled_dir" id="nginx_vhost_conf_enabled_dir" value="{tmpl_var name='nginx_vhost_conf_enabled_dir'}" size="40" maxlength="255" type="text" class="textInput" /> + </div> <div class="ctrlHolder"> <label for="CA_path">{tmpl_var name='CA_path_txt'}</label> <input name="CA_path" id="CA_path" value="{tmpl_var name='CA_path'}" size="40" maxlength="255" type="text" class="textInput" /> @@ -71,7 +87,7 @@ </div> <div class="ctrlHolder"> <label for="php_open_basedir">{tmpl_var name='php_open_basedir_txt'}</label> - <input name="php_open_basedir" id="php_open_basedir" value="{tmpl_var name='php_open_basedir'}" size="40" maxlength="255" type="text" class="textInput" /> + <input name="php_open_basedir" id="php_open_basedir" value="{tmpl_var name='php_open_basedir'}" size="40" type="text" class="textInput" /> </div> <div class="ctrlHolder"> <label for="htaccess_allow_override">{tmpl_var name='htaccess_allow_override_txt'}</label> @@ -116,3 +132,39 @@ </div> </div> +<script language="JavaScript" type="text/javascript"> + var serverType = jQuery('#server_type').val(); + adjustForm(serverType); + jQuery('#server_type').change(function(){ + serverType = $(this).val(); + adjustForm(serverType); + }); + + function adjustForm(serverType){ + if(serverType == "nginx"){ + jQuery('#vhost_conf_dir').closest('div.ctrlHolder').hide(); + jQuery('#vhost_conf_enabled_dir').closest('div.ctrlHolder').hide(); + jQuery('#nginx_vhost_conf_dir').closest('div.ctrlHolder').show(); + jQuery('#nginx_vhost_conf_enabled_dir').closest('div.ctrlHolder').show(); + + jQuery('#security_level').closest('div.ctrlHolder').hide(); + jQuery('#check_apache_config').closest('div.ctrlHolder').hide(); + jQuery('#user').closest('div.ctrlHolder').hide(); + jQuery('#group').closest('div.ctrlHolder').hide(); + jQuery('#php_ini_path_apache').closest('div.ctrlHolder').hide(); + jQuery('#htaccess_allow_override').closest('div.ctrlHolder').hide(); + } else { + jQuery('#vhost_conf_dir').closest('div.ctrlHolder').show(); + jQuery('#vhost_conf_enabled_dir').closest('div.ctrlHolder').show(); + jQuery('#nginx_vhost_conf_dir').closest('div.ctrlHolder').hide(); + jQuery('#nginx_vhost_conf_enabled_dir').closest('div.ctrlHolder').hide(); + + jQuery('#security_level').closest('div.ctrlHolder').show(); + jQuery('#check_apache_config').closest('div.ctrlHolder').show(); + jQuery('#user').closest('div.ctrlHolder').show(); + jQuery('#group').closest('div.ctrlHolder').show(); + jQuery('#php_ini_path_apache').closest('div.ctrlHolder').show(); + jQuery('#htaccess_allow_override').closest('div.ctrlHolder').show(); + } + } +</script> \ No newline at end of file diff --git a/interface/web/js/yui-combo.js b/interface/web/js/yui-combo.js deleted file mode 100644 index 3aa72452bf..0000000000 --- a/interface/web/js/yui-combo.js +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(typeof YAHOO=="undefined"||!YAHOO){var YAHOO={};}YAHOO.namespace=function(){var b=arguments,g=null,e,c,f;for(e=0;e<b.length;e=e+1){f=(""+b[e]).split(".");g=YAHOO;for(c=(f[0]=="YAHOO")?1:0;c<f.length;c=c+1){g[f[c]]=g[f[c]]||{};g=g[f[c]];}}return g;};YAHOO.log=function(d,a,c){var b=YAHOO.widget.Logger;if(b&&b.log){return b.log(d,a,c);}else{return false;}};YAHOO.register=function(a,f,e){var k=YAHOO.env.modules,c,j,h,g,d;if(!k[a]){k[a]={versions:[],builds:[]};}c=k[a];j=e.version;h=e.build;g=YAHOO.env.listeners;c.name=a;c.version=j;c.build=h;c.versions.push(j);c.builds.push(h);c.mainClass=f;for(d=0;d<g.length;d=d+1){g[d](c);}if(f){f.VERSION=j;f.BUILD=h;}else{YAHOO.log("mainClass is undefined for module "+a,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[]};YAHOO.env.getVersion=function(a){return YAHOO.env.modules[a]||null;};YAHOO.env.parseUA=function(d){var e=function(i){var j=0;return parseFloat(i.replace(/\./g,function(){return(j++==1)?"":".";}));},h=navigator,g={ie:0,opera:0,gecko:0,webkit:0,chrome:0,mobile:null,air:0,ipad:0,iphone:0,ipod:0,ios:null,android:0,webos:0,caja:h&&h.cajaVersion,secure:false,os:null},c=d||(navigator&&navigator.userAgent),f=window&&window.location,b=f&&f.href,a;g.secure=b&&(b.toLowerCase().indexOf("https")===0);if(c){if((/windows|win32/i).test(c)){g.os="windows";}else{if((/macintosh/i).test(c)){g.os="macintosh";}else{if((/rhino/i).test(c)){g.os="rhino";}}}if((/KHTML/).test(c)){g.webkit=1;}a=c.match(/AppleWebKit\/([^\s]*)/);if(a&&a[1]){g.webkit=e(a[1]);if(/ Mobile\//.test(c)){g.mobile="Apple";a=c.match(/OS ([^\s]*)/);if(a&&a[1]){a=e(a[1].replace("_","."));}g.ios=a;g.ipad=g.ipod=g.iphone=0;a=c.match(/iPad|iPod|iPhone/);if(a&&a[0]){g[a[0].toLowerCase()]=g.ios;}}else{a=c.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/);if(a){g.mobile=a[0];}if(/webOS/.test(c)){g.mobile="WebOS";a=c.match(/webOS\/([^\s]*);/);if(a&&a[1]){g.webos=e(a[1]);}}if(/ Android/.test(c)){g.mobile="Android";a=c.match(/Android ([^\s]*);/);if(a&&a[1]){g.android=e(a[1]);}}}a=c.match(/Chrome\/([^\s]*)/);if(a&&a[1]){g.chrome=e(a[1]);}else{a=c.match(/AdobeAIR\/([^\s]*)/);if(a){g.air=a[0];}}}if(!g.webkit){a=c.match(/Opera[\s\/]([^\s]*)/);if(a&&a[1]){g.opera=e(a[1]);a=c.match(/Version\/([^\s]*)/);if(a&&a[1]){g.opera=e(a[1]);}a=c.match(/Opera Mini[^;]*/);if(a){g.mobile=a[0];}}else{a=c.match(/MSIE\s([^;]*)/);if(a&&a[1]){g.ie=e(a[1]);}else{a=c.match(/Gecko\/([^\s]*)/);if(a){g.gecko=1;a=c.match(/rv:([^\s\)]*)/);if(a&&a[1]){g.gecko=e(a[1]);}}}}}}return g;};YAHOO.env.ua=YAHOO.env.parseUA();(function(){YAHOO.namespace("util","widget","example");if("undefined"!==typeof YAHOO_config){var b=YAHOO_config.listener,a=YAHOO.env.listeners,d=true,c;if(b){for(c=0;c<a.length;c++){if(a[c]==b){d=false;break;}}if(d){a.push(b);}}}})();YAHOO.lang=YAHOO.lang||{};(function(){var f=YAHOO.lang,a=Object.prototype,c="[object Array]",h="[object Function]",i="[object Object]",b=[],g={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`"},d=["toString","valueOf"],e={isArray:function(j){return a.toString.apply(j)===c;},isBoolean:function(j){return typeof j==="boolean";},isFunction:function(j){return(typeof j==="function")||a.toString.apply(j)===h;},isNull:function(j){return j===null;},isNumber:function(j){return typeof j==="number"&&isFinite(j);},isObject:function(j){return(j&&(typeof j==="object"||f.isFunction(j)))||false;},isString:function(j){return typeof j==="string";},isUndefined:function(j){return typeof j==="undefined";},_IEEnumFix:(YAHOO.env.ua.ie)?function(l,k){var j,n,m;for(j=0;j<d.length;j=j+1){n=d[j];m=k[n];if(f.isFunction(m)&&m!=a[n]){l[n]=m;}}}:function(){},escapeHTML:function(j){return j.replace(/[&<>"'\/`]/g,function(k){return g[k];});},extend:function(m,n,l){if(!n||!m){throw new Error("extend failed, please check that "+"all dependencies are included.");}var k=function(){},j;k.prototype=n.prototype;m.prototype=new k();m.prototype.constructor=m;m.superclass=n.prototype;if(n.prototype.constructor==a.constructor){n.prototype.constructor=n;}if(l){for(j in l){if(f.hasOwnProperty(l,j)){m.prototype[j]=l[j];}}f._IEEnumFix(m.prototype,l);}},augmentObject:function(n,m){if(!m||!n){throw new Error("Absorb failed, verify dependencies.");}var j=arguments,l,o,k=j[2];if(k&&k!==true){for(l=2;l<j.length;l=l+1){n[j[l]]=m[j[l]];}}else{for(o in m){if(k||!(o in n)){n[o]=m[o];}}f._IEEnumFix(n,m);}return n;},augmentProto:function(m,l){if(!l||!m){throw new Error("Augment failed, verify dependencies.");}var j=[m.prototype,l.prototype],k;for(k=2;k<arguments.length;k=k+1){j.push(arguments[k]);}f.augmentObject.apply(this,j);return m;},dump:function(j,p){var l,n,r=[],t="{...}",k="f(){...}",q=", ",m=" => ";if(!f.isObject(j)){return j+"";}else{if(j instanceof Date||("nodeType" in j&&"tagName" in j)){return j;}else{if(f.isFunction(j)){return k;}}}p=(f.isNumber(p))?p:3;if(f.isArray(j)){r.push("[");for(l=0,n=j.length;l<n;l=l+1){if(f.isObject(j[l])){r.push((p>0)?f.dump(j[l],p-1):t);}else{r.push(j[l]);}r.push(q);}if(r.length>1){r.pop();}r.push("]");}else{r.push("{");for(l in j){if(f.hasOwnProperty(j,l)){r.push(l+m);if(f.isObject(j[l])){r.push((p>0)?f.dump(j[l],p-1):t);}else{r.push(j[l]);}r.push(q);}}if(r.length>1){r.pop();}r.push("}");}return r.join("");},substitute:function(x,y,E,l){var D,C,B,G,t,u,F=[],p,z=x.length,A="dump",r=" ",q="{",m="}",n,w;for(;;){D=x.lastIndexOf(q,z);if(D<0){break;}C=x.indexOf(m,D);if(D+1>C){break;}p=x.substring(D+1,C);G=p;u=null;B=G.indexOf(r);if(B>-1){u=G.substring(B+1);G=G.substring(0,B);}t=y[G];if(E){t=E(G,t,u);}if(f.isObject(t)){if(f.isArray(t)){t=f.dump(t,parseInt(u,10));}else{u=u||"";n=u.indexOf(A);if(n>-1){u=u.substring(4);}w=t.toString();if(w===i||n>-1){t=f.dump(t,parseInt(u,10));}else{t=w;}}}else{if(!f.isString(t)&&!f.isNumber(t)){t="~-"+F.length+"-~";F[F.length]=p;}}x=x.substring(0,D)+t+x.substring(C+1);if(l===false){z=D-1;}}for(D=F.length-1;D>=0;D=D-1){x=x.replace(new RegExp("~-"+D+"-~"),"{"+F[D]+"}","g");}return x;},trim:function(j){try{return j.replace(/^\s+|\s+$/g,"");}catch(k){return j; -}},merge:function(){var n={},k=arguments,j=k.length,m;for(m=0;m<j;m=m+1){f.augmentObject(n,k[m],true);}return n;},later:function(t,k,u,n,p){t=t||0;k=k||{};var l=u,s=n,q,j;if(f.isString(u)){l=k[u];}if(!l){throw new TypeError("method undefined");}if(!f.isUndefined(n)&&!f.isArray(s)){s=[n];}q=function(){l.apply(k,s||b);};j=(p)?setInterval(q,t):setTimeout(q,t);return{interval:p,cancel:function(){if(this.interval){clearInterval(j);}else{clearTimeout(j);}}};},isValue:function(j){return(f.isObject(j)||f.isString(j)||f.isNumber(j)||f.isBoolean(j));}};f.hasOwnProperty=(a.hasOwnProperty)?function(j,k){return j&&j.hasOwnProperty&&j.hasOwnProperty(k);}:function(j,k){return !f.isUndefined(j[k])&&j.constructor.prototype[k]!==j[k];};e.augmentObject(f,e,true);YAHOO.util.Lang=f;f.augment=f.augmentProto;YAHOO.augment=f.augmentProto;YAHOO.extend=f.extend;})();YAHOO.register("yahoo",YAHOO,{version:"2.9.0",build:"2800"});/* -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -YAHOO.util.CustomEvent=function(d,c,b,a,e){this.type=d;this.scope=c||window;this.silent=b;this.fireOnce=e;this.fired=false;this.firedWith=null;this.signature=a||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){}var f="_YUICEOnSubscribe";if(d!==f){this.subscribeEvent=new YAHOO.util.CustomEvent(f,this,true);}this.lastError=null;};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(b,c,d){if(!b){throw new Error("Invalid callback for subscriber to '"+this.type+"'");}if(this.subscribeEvent){this.subscribeEvent.fire(b,c,d);}var a=new YAHOO.util.Subscriber(b,c,d);if(this.fireOnce&&this.fired){this.notify(a,this.firedWith);}else{this.subscribers.push(a);}},unsubscribe:function(d,f){if(!d){return this.unsubscribeAll();}var e=false;for(var b=0,a=this.subscribers.length;b<a;++b){var c=this.subscribers[b];if(c&&c.contains(d,f)){this._delete(b);e=true;}}return e;},fire:function(){this.lastError=null;var h=[],a=this.subscribers.length;var d=[].slice.call(arguments,0),c=true,f,b=false;if(this.fireOnce){if(this.fired){return true;}else{this.firedWith=d;}}this.fired=true;if(!a&&this.silent){return true;}if(!this.silent){}var e=this.subscribers.slice();for(f=0;f<a;++f){var g=e[f];if(!g||!g.fn){b=true;}else{c=this.notify(g,d);if(false===c){if(!this.silent){}break;}}}return(c!==false);},notify:function(g,c){var b,i=null,f=g.getScope(this.scope),a=YAHOO.util.Event.throwErrors;if(!this.silent){}if(this.signature==YAHOO.util.CustomEvent.FLAT){if(c.length>0){i=c[0];}try{b=g.fn.call(f,i,g.obj);}catch(h){this.lastError=h;if(a){throw h;}}}else{try{b=g.fn.call(f,this.type,c,g.obj);}catch(d){this.lastError=d;if(a){throw d;}}}return b;},unsubscribeAll:function(){var a=this.subscribers.length,b;for(b=a-1;b>-1;b--){this._delete(b);}this.subscribers=[];return a;},_delete:function(a){var b=this.subscribers[a];if(b){delete b.fn;delete b.obj;}this.subscribers.splice(a,1);},toString:function(){return"CustomEvent: "+"'"+this.type+"', "+"context: "+this.scope;}};YAHOO.util.Subscriber=function(a,b,c){this.fn=a;this.obj=YAHOO.lang.isUndefined(b)?null:b;this.overrideContext=c;};YAHOO.util.Subscriber.prototype.getScope=function(a){if(this.overrideContext){if(this.overrideContext===true){return this.obj;}else{return this.overrideContext;}}return a;};YAHOO.util.Subscriber.prototype.contains=function(a,b){if(b){return(this.fn==a&&this.obj==b);}else{return(this.fn==a);}};YAHOO.util.Subscriber.prototype.toString=function(){return"Subscriber { obj: "+this.obj+", overrideContext: "+(this.overrideContext||"no")+" }";};if(!YAHOO.util.Event){YAHOO.util.Event=function(){var g=false,h=[],j=[],a=0,e=[],b=0,c={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9},d=YAHOO.env.ua.ie,f="focusin",i="focusout";return{POLL_RETRYS:500,POLL_INTERVAL:40,EL:0,TYPE:1,FN:2,WFN:3,UNLOAD_OBJ:3,ADJ_SCOPE:4,OBJ:5,OVERRIDE:6,CAPTURE:7,lastError:null,isSafari:YAHOO.env.ua.webkit,webkit:YAHOO.env.ua.webkit,isIE:d,_interval:null,_dri:null,_specialTypes:{focusin:(d?"focusin":"focus"),focusout:(d?"focusout":"blur")},DOMReady:false,throwErrors:false,startInterval:function(){if(!this._interval){this._interval=YAHOO.lang.later(this.POLL_INTERVAL,this,this._tryPreloadAttach,null,true);}},onAvailable:function(q,m,o,p,n){var k=(YAHOO.lang.isString(q))?[q]:q;for(var l=0;l<k.length;l=l+1){e.push({id:k[l],fn:m,obj:o,overrideContext:p,checkReady:n});}a=this.POLL_RETRYS;this.startInterval();},onContentReady:function(n,k,l,m){this.onAvailable(n,k,l,m,true);},onDOMReady:function(){this.DOMReadyEvent.subscribe.apply(this.DOMReadyEvent,arguments);},_addListener:function(m,k,v,p,t,y){if(!v||!v.call){return false;}if(this._isValidCollection(m)){var w=true;for(var q=0,s=m.length;q<s;++q){w=this.on(m[q],k,v,p,t)&&w;}return w;}else{if(YAHOO.lang.isString(m)){var o=this.getEl(m);if(o){m=o;}else{this.onAvailable(m,function(){YAHOO.util.Event._addListener(m,k,v,p,t,y);});return true;}}}if(!m){return false;}if("unload"==k&&p!==this){j[j.length]=[m,k,v,p,t];return true;}var l=m;if(t){if(t===true){l=p;}else{l=t;}}var n=function(z){return v.call(l,YAHOO.util.Event.getEvent(z,m),p);};var x=[m,k,v,n,l,p,t,y];var r=h.length;h[r]=x;try{this._simpleAdd(m,k,n,y);}catch(u){this.lastError=u;this.removeListener(m,k,v);return false;}return true;},_getType:function(k){return this._specialTypes[k]||k;},addListener:function(m,p,l,n,o){var k=((p==f||p==i)&&!YAHOO.env.ua.ie)?true:false;return this._addListener(m,this._getType(p),l,n,o,k);},addFocusListener:function(l,k,m,n){return this.on(l,f,k,m,n);},removeFocusListener:function(l,k){return this.removeListener(l,f,k);},addBlurListener:function(l,k,m,n){return this.on(l,i,k,m,n);},removeBlurListener:function(l,k){return this.removeListener(l,i,k);},removeListener:function(l,k,r){var m,p,u;k=this._getType(k);if(typeof l=="string"){l=this.getEl(l);}else{if(this._isValidCollection(l)){var s=true;for(m=l.length-1;m>-1;m--){s=(this.removeListener(l[m],k,r)&&s);}return s;}}if(!r||!r.call){return this.purgeElement(l,false,k);}if("unload"==k){for(m=j.length-1;m>-1;m--){u=j[m];if(u&&u[0]==l&&u[1]==k&&u[2]==r){j.splice(m,1);return true;}}return false;}var n=null;var o=arguments[3];if("undefined"===typeof o){o=this._getCacheIndex(h,l,k,r);}if(o>=0){n=h[o];}if(!l||!n){return false;}var t=n[this.CAPTURE]===true?true:false;try{this._simpleRemove(l,k,n[this.WFN],t);}catch(q){this.lastError=q;return false;}delete h[o][this.WFN];delete h[o][this.FN];h.splice(o,1);return true;},getTarget:function(m,l){var k=m.target||m.srcElement;return this.resolveTextNode(k);},resolveTextNode:function(l){try{if(l&&3==l.nodeType){return l.parentNode;}}catch(k){return null;}return l;},getPageX:function(l){var k=l.pageX;if(!k&&0!==k){k=l.clientX||0;if(this.isIE){k+=this._getScrollLeft();}}return k;},getPageY:function(k){var l=k.pageY;if(!l&&0!==l){l=k.clientY||0;if(this.isIE){l+=this._getScrollTop();}}return l;},getXY:function(k){return[this.getPageX(k),this.getPageY(k)];},getRelatedTarget:function(l){var k=l.relatedTarget; -if(!k){if(l.type=="mouseout"){k=l.toElement;}else{if(l.type=="mouseover"){k=l.fromElement;}}}return this.resolveTextNode(k);},getTime:function(m){if(!m.time){var l=new Date().getTime();try{m.time=l;}catch(k){this.lastError=k;return l;}}return m.time;},stopEvent:function(k){this.stopPropagation(k);this.preventDefault(k);},stopPropagation:function(k){if(k.stopPropagation){k.stopPropagation();}else{k.cancelBubble=true;}},preventDefault:function(k){if(k.preventDefault){k.preventDefault();}else{k.returnValue=false;}},getEvent:function(m,k){var l=m||window.event;if(!l){var n=this.getEvent.caller;while(n){l=n.arguments[0];if(l&&Event==l.constructor){break;}n=n.caller;}}return l;},getCharCode:function(l){var k=l.keyCode||l.charCode||0;if(YAHOO.env.ua.webkit&&(k in c)){k=c[k];}return k;},_getCacheIndex:function(n,q,r,p){for(var o=0,m=n.length;o<m;o=o+1){var k=n[o];if(k&&k[this.FN]==p&&k[this.EL]==q&&k[this.TYPE]==r){return o;}}return -1;},generateId:function(k){var l=k.id;if(!l){l="yuievtautoid-"+b;++b;k.id=l;}return l;},_isValidCollection:function(l){try{return(l&&typeof l!=="string"&&l.length&&!l.tagName&&!l.alert&&typeof l[0]!=="undefined");}catch(k){return false;}},elCache:{},getEl:function(k){return(typeof k==="string")?document.getElementById(k):k;},clearCache:function(){},DOMReadyEvent:new YAHOO.util.CustomEvent("DOMReady",YAHOO,0,0,1),_load:function(l){if(!g){g=true;var k=YAHOO.util.Event;k._ready();k._tryPreloadAttach();}},_ready:function(l){var k=YAHOO.util.Event;if(!k.DOMReady){k.DOMReady=true;k.DOMReadyEvent.fire();k._simpleRemove(document,"DOMContentLoaded",k._ready);}},_tryPreloadAttach:function(){if(e.length===0){a=0;if(this._interval){this._interval.cancel();this._interval=null;}return;}if(this.locked){return;}if(this.isIE){if(!this.DOMReady){this.startInterval();return;}}this.locked=true;var q=!g;if(!q){q=(a>0&&e.length>0);}var p=[];var r=function(t,u){var s=t;if(u.overrideContext){if(u.overrideContext===true){s=u.obj;}else{s=u.overrideContext;}}u.fn.call(s,u.obj);};var l,k,o,n,m=[];for(l=0,k=e.length;l<k;l=l+1){o=e[l];if(o){n=this.getEl(o.id);if(n){if(o.checkReady){if(g||n.nextSibling||!q){m.push(o);e[l]=null;}}else{r(n,o);e[l]=null;}}else{p.push(o);}}}for(l=0,k=m.length;l<k;l=l+1){o=m[l];r(this.getEl(o.id),o);}a--;if(q){for(l=e.length-1;l>-1;l--){o=e[l];if(!o||!o.id){e.splice(l,1);}}this.startInterval();}else{if(this._interval){this._interval.cancel();this._interval=null;}}this.locked=false;},purgeElement:function(p,q,s){var n=(YAHOO.lang.isString(p))?this.getEl(p):p;var r=this.getListeners(n,s),o,k;if(r){for(o=r.length-1;o>-1;o--){var m=r[o];this.removeListener(n,m.type,m.fn);}}if(q&&n&&n.childNodes){for(o=0,k=n.childNodes.length;o<k;++o){this.purgeElement(n.childNodes[o],q,s);}}},getListeners:function(n,k){var q=[],m;if(!k){m=[h,j];}else{if(k==="unload"){m=[j];}else{k=this._getType(k);m=[h];}}var s=(YAHOO.lang.isString(n))?this.getEl(n):n;for(var p=0;p<m.length;p=p+1){var u=m[p];if(u){for(var r=0,t=u.length;r<t;++r){var o=u[r];if(o&&o[this.EL]===s&&(!k||k===o[this.TYPE])){q.push({type:o[this.TYPE],fn:o[this.FN],obj:o[this.OBJ],adjust:o[this.OVERRIDE],scope:o[this.ADJ_SCOPE],index:r});}}}}return(q.length)?q:null;},_unload:function(s){var m=YAHOO.util.Event,p,o,n,r,q,t=j.slice(),k;for(p=0,r=j.length;p<r;++p){n=t[p];if(n){try{k=window;if(n[m.ADJ_SCOPE]){if(n[m.ADJ_SCOPE]===true){k=n[m.UNLOAD_OBJ];}else{k=n[m.ADJ_SCOPE];}}n[m.FN].call(k,m.getEvent(s,n[m.EL]),n[m.UNLOAD_OBJ]);}catch(w){}t[p]=null;}}n=null;k=null;j=null;if(h){for(o=h.length-1;o>-1;o--){n=h[o];if(n){try{m.removeListener(n[m.EL],n[m.TYPE],n[m.FN],o);}catch(v){}}}n=null;}try{m._simpleRemove(window,"unload",m._unload);m._simpleRemove(window,"load",m._load);}catch(u){}},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var k=document.documentElement,l=document.body;if(k&&(k.scrollTop||k.scrollLeft)){return[k.scrollTop,k.scrollLeft];}else{if(l){return[l.scrollTop,l.scrollLeft];}else{return[0,0];}}},regCE:function(){},_simpleAdd:function(){if(window.addEventListener){return function(m,n,l,k){m.addEventListener(n,l,(k));};}else{if(window.attachEvent){return function(m,n,l,k){m.attachEvent("on"+n,l);};}else{return function(){};}}}(),_simpleRemove:function(){if(window.removeEventListener){return function(m,n,l,k){m.removeEventListener(n,l,(k));};}else{if(window.detachEvent){return function(l,m,k){l.detachEvent("on"+m,k);};}else{return function(){};}}}()};}();(function(){var a=YAHOO.util.Event;a.on=a.addListener;a.onFocus=a.addFocusListener;a.onBlur=a.addBlurListener; -/*! DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */ -if(a.isIE){if(self!==self.top){document.onreadystatechange=function(){if(document.readyState=="complete"){document.onreadystatechange=null;a._ready();}};}else{YAHOO.util.Event.onDOMReady(YAHOO.util.Event._tryPreloadAttach,YAHOO.util.Event,true);var b=document.createElement("p");a._dri=setInterval(function(){try{b.doScroll("left");clearInterval(a._dri);a._dri=null;a._ready();b=null;}catch(c){}},a.POLL_INTERVAL);}}else{if(a.webkit&&a.webkit<525){a._dri=setInterval(function(){var c=document.readyState;if("loaded"==c||"complete"==c){clearInterval(a._dri);a._dri=null;a._ready();}},a.POLL_INTERVAL);}else{a._simpleAdd(document,"DOMContentLoaded",a._ready);}}a._simpleAdd(window,"load",a._load);a._simpleAdd(window,"unload",a._unload);a._tryPreloadAttach();})();}YAHOO.util.EventProvider=function(){};YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(a,c,f,e){this.__yui_events=this.__yui_events||{};var d=this.__yui_events[a];if(d){d.subscribe(c,f,e);}else{this.__yui_subscribers=this.__yui_subscribers||{};var b=this.__yui_subscribers;if(!b[a]){b[a]=[];}b[a].push({fn:c,obj:f,overrideContext:e});}},unsubscribe:function(c,e,g){this.__yui_events=this.__yui_events||{};var a=this.__yui_events;if(c){var f=a[c];if(f){return f.unsubscribe(e,g);}}else{var b=true;for(var d in a){if(YAHOO.lang.hasOwnProperty(a,d)){b=b&&a[d].unsubscribe(e,g); -}}return b;}return false;},unsubscribeAll:function(a){return this.unsubscribe(a);},createEvent:function(b,g){this.__yui_events=this.__yui_events||{};var e=g||{},d=this.__yui_events,f;if(d[b]){}else{f=new YAHOO.util.CustomEvent(b,e.scope||this,e.silent,YAHOO.util.CustomEvent.FLAT,e.fireOnce);d[b]=f;if(e.onSubscribeCallback){f.subscribeEvent.subscribe(e.onSubscribeCallback);}this.__yui_subscribers=this.__yui_subscribers||{};var a=this.__yui_subscribers[b];if(a){for(var c=0;c<a.length;++c){f.subscribe(a[c].fn,a[c].obj,a[c].overrideContext);}}}return d[b];},fireEvent:function(b){this.__yui_events=this.__yui_events||{};var d=this.__yui_events[b];if(!d){return null;}var a=[];for(var c=1;c<arguments.length;++c){a.push(arguments[c]);}return d.fire.apply(d,a);},hasEvent:function(a){if(this.__yui_events){if(this.__yui_events[a]){return true;}}return false;}};(function(){var a=YAHOO.util.Event,c=YAHOO.lang;YAHOO.util.KeyListener=function(d,i,e,f){if(!d){}else{if(!i){}else{if(!e){}}}if(!f){f=YAHOO.util.KeyListener.KEYDOWN;}var g=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(c.isString(d)){d=document.getElementById(d);}if(c.isFunction(e)){g.subscribe(e);}else{g.subscribe(e.fn,e.scope,e.correctScope);}function h(o,n){if(!i.shift){i.shift=false;}if(!i.alt){i.alt=false;}if(!i.ctrl){i.ctrl=false;}if(o.shiftKey==i.shift&&o.altKey==i.alt&&o.ctrlKey==i.ctrl){var j,m=i.keys,l;if(YAHOO.lang.isArray(m)){for(var k=0;k<m.length;k++){j=m[k];l=a.getCharCode(o);if(j==l){g.fire(l,o);break;}}}else{l=a.getCharCode(o);if(m==l){g.fire(l,o);}}}}this.enable=function(){if(!this.enabled){a.on(d,f,h);this.enabledEvent.fire(i);}this.enabled=true;};this.disable=function(){if(this.enabled){a.removeListener(d,f,h);this.disabledEvent.fire(i);}this.enabled=false;};this.toString=function(){return"KeyListener ["+i.keys+"] "+d.tagName+(d.id?"["+d.id+"]":"");};};var b=YAHOO.util.KeyListener;b.KEYDOWN="keydown";b.KEYUP="keyup";b.KEY={ALT:18,BACK_SPACE:8,CAPS_LOCK:20,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,META:224,NUM_LOCK:144,PAGE_DOWN:34,PAGE_UP:33,PAUSE:19,PRINTSCREEN:44,RIGHT:39,SCROLL_LOCK:145,SHIFT:16,SPACE:32,TAB:9,UP:38};})();YAHOO.register("event",YAHOO.util.Event,{version:"2.9.0",build:"2800"});/* -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -YAHOO.util.Connect={_msxml_progid:["Microsoft.XMLHTTP","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"],_http_headers:{},_has_http_headers:false,_use_default_post_header:true,_default_post_header:"application/x-www-form-urlencoded; charset=UTF-8",_default_form_header:"application/x-www-form-urlencoded",_use_default_xhr_header:true,_default_xhr_header:"XMLHttpRequest",_has_default_headers:true,_isFormSubmit:false,_default_headers:{},_poll:{},_timeOut:{},_polling_interval:50,_transaction_id:0,startEvent:new YAHOO.util.CustomEvent("start"),completeEvent:new YAHOO.util.CustomEvent("complete"),successEvent:new YAHOO.util.CustomEvent("success"),failureEvent:new YAHOO.util.CustomEvent("failure"),abortEvent:new YAHOO.util.CustomEvent("abort"),_customEvents:{onStart:["startEvent","start"],onComplete:["completeEvent","complete"],onSuccess:["successEvent","success"],onFailure:["failureEvent","failure"],onUpload:["uploadEvent","upload"],onAbort:["abortEvent","abort"]},setProgId:function(a){this._msxml_progid.unshift(a);},setDefaultPostHeader:function(a){if(typeof a=="string"){this._default_post_header=a;this._use_default_post_header=true;}else{if(typeof a=="boolean"){this._use_default_post_header=a;}}},setDefaultXhrHeader:function(a){if(typeof a=="string"){this._default_xhr_header=a;}else{this._use_default_xhr_header=a;}},setPollingInterval:function(a){if(typeof a=="number"&&isFinite(a)){this._polling_interval=a;}},createXhrObject:function(g){var d,a,b;try{a=new XMLHttpRequest();d={conn:a,tId:g,xhr:true};}catch(c){for(b=0;b<this._msxml_progid.length;++b){try{a=new ActiveXObject(this._msxml_progid[b]);d={conn:a,tId:g,xhr:true};break;}catch(f){}}}finally{return d;}},getConnectionObject:function(a){var c,d=this._transaction_id;try{if(!a){c=this.createXhrObject(d);}else{c={tId:d};if(a==="xdr"){c.conn=this._transport;c.xdr=true;}else{if(a==="upload"){c.upload=true;}}}if(c){this._transaction_id++;}}catch(b){}return c;},asyncRequest:function(h,d,g,a){var b=g&&g.argument?g.argument:null,e=this,f,c;if(this._isFileUpload){c="upload";}else{if(g&&g.xdr){c="xdr";}}f=this.getConnectionObject(c);if(!f){return null;}else{if(g&&g.customevents){this.initCustomEvents(f,g);}if(this._isFormSubmit){if(this._isFileUpload){window.setTimeout(function(){e.uploadFile(f,g,d,a);},10);return f;}if(h.toUpperCase()=="GET"){if(this._sFormData.length!==0){d+=((d.indexOf("?")==-1)?"?":"&")+this._sFormData;}}else{if(h.toUpperCase()=="POST"){a=a?this._sFormData+"&"+a:this._sFormData;}}}if(h.toUpperCase()=="GET"&&(g&&g.cache===false)){d+=((d.indexOf("?")==-1)?"?":"&")+"rnd="+new Date().valueOf().toString();}if(this._use_default_xhr_header){if(!this._default_headers["X-Requested-With"]){this.initHeader("X-Requested-With",this._default_xhr_header,true);}}if((h.toUpperCase()==="POST"&&this._use_default_post_header)&&this._isFormSubmit===false){this.initHeader("Content-Type",this._default_post_header);}if(f.xdr){this.xdr(f,h,d,g,a);return f;}f.conn.open(h,d,true);if(this._has_default_headers||this._has_http_headers){this.setHeader(f);}this.handleReadyState(f,g);f.conn.send(a||"");if(this._isFormSubmit===true){this.resetFormState();}this.startEvent.fire(f,b);if(f.startEvent){f.startEvent.fire(f,b);}return f;}},initCustomEvents:function(a,c){var b;for(b in c.customevents){if(this._customEvents[b][0]){a[this._customEvents[b][0]]=new YAHOO.util.CustomEvent(this._customEvents[b][1],(c.scope)?c.scope:null);a[this._customEvents[b][0]].subscribe(c.customevents[b]);}}},handleReadyState:function(c,d){var b=this,a=(d&&d.argument)?d.argument:null;if(d&&d.timeout){this._timeOut[c.tId]=window.setTimeout(function(){b.abort(c,d,true);},d.timeout);}this._poll[c.tId]=window.setInterval(function(){if(c.conn&&c.conn.readyState===4){window.clearInterval(b._poll[c.tId]);delete b._poll[c.tId];if(d&&d.timeout){window.clearTimeout(b._timeOut[c.tId]);delete b._timeOut[c.tId];}b.completeEvent.fire(c,a);if(c.completeEvent){c.completeEvent.fire(c,a);}b.handleTransactionResponse(c,d);}},this._polling_interval);},handleTransactionResponse:function(b,j,d){var f,a,h=(j&&j.argument)?j.argument:null,c=(b.r&&b.r.statusText==="xdr:success")?true:false,i=(b.r&&b.r.statusText==="xdr:failure")?true:false,k=d;try{if((b.conn.status!==undefined&&b.conn.status!==0)||c){f=b.conn.status;}else{if(i&&!k){f=0;}else{f=13030;}}}catch(g){f=13030;}if((f>=200&&f<300)||f===1223||c){a=b.xdr?b.r:this.createResponseObject(b,h);if(j&&j.success){if(!j.scope){j.success(a);}else{j.success.apply(j.scope,[a]);}}this.successEvent.fire(a);if(b.successEvent){b.successEvent.fire(a);}}else{switch(f){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:a=this.createExceptionObject(b.tId,h,(d?d:false));if(j&&j.failure){if(!j.scope){j.failure(a);}else{j.failure.apply(j.scope,[a]);}}break;default:a=(b.xdr)?b.response:this.createResponseObject(b,h);if(j&&j.failure){if(!j.scope){j.failure(a);}else{j.failure.apply(j.scope,[a]);}}}this.failureEvent.fire(a);if(b.failureEvent){b.failureEvent.fire(a);}}this.releaseObject(b);a=null;},createResponseObject:function(a,h){var d={},k={},f,c,g,b;try{c=a.conn.getAllResponseHeaders();g=c.split("\n");for(f=0;f<g.length;f++){b=g[f].indexOf(":");if(b!=-1){k[g[f].substring(0,b)]=YAHOO.lang.trim(g[f].substring(b+2));}}}catch(j){}d.tId=a.tId;d.status=(a.conn.status==1223)?204:a.conn.status;d.statusText=(a.conn.status==1223)?"No Content":a.conn.statusText;d.getResponseHeader=k;d.getAllResponseHeaders=c;d.responseText=a.conn.responseText;d.responseXML=a.conn.responseXML;if(h){d.argument=h;}return d;},createExceptionObject:function(h,d,a){var f=0,g="communication failure",c=-1,b="transaction aborted",e={};e.tId=h;if(a){e.status=c;e.statusText=b;}else{e.status=f;e.statusText=g;}if(d){e.argument=d;}return e;},initHeader:function(a,d,c){var b=(c)?this._default_headers:this._http_headers;b[a]=d;if(c){this._has_default_headers=true;}else{this._has_http_headers=true;}},setHeader:function(a){var b;if(this._has_default_headers){for(b in this._default_headers){if(YAHOO.lang.hasOwnProperty(this._default_headers,b)){a.conn.setRequestHeader(b,this._default_headers[b]); -}}}if(this._has_http_headers){for(b in this._http_headers){if(YAHOO.lang.hasOwnProperty(this._http_headers,b)){a.conn.setRequestHeader(b,this._http_headers[b]);}}this._http_headers={};this._has_http_headers=false;}},resetDefaultHeaders:function(){this._default_headers={};this._has_default_headers=false;},abort:function(e,g,a){var d,b=(g&&g.argument)?g.argument:null;e=e||{};if(e.conn){if(e.xhr){if(this.isCallInProgress(e)){e.conn.abort();window.clearInterval(this._poll[e.tId]);delete this._poll[e.tId];if(a){window.clearTimeout(this._timeOut[e.tId]);delete this._timeOut[e.tId];}d=true;}}else{if(e.xdr){e.conn.abort(e.tId);d=true;}}}else{if(e.upload){var c="yuiIO"+e.tId;var f=document.getElementById(c);if(f){YAHOO.util.Event.removeListener(f,"load");document.body.removeChild(f);if(a){window.clearTimeout(this._timeOut[e.tId]);delete this._timeOut[e.tId];}d=true;}}else{d=false;}}if(d===true){this.abortEvent.fire(e,b);if(e.abortEvent){e.abortEvent.fire(e,b);}this.handleTransactionResponse(e,g,true);}return d;},isCallInProgress:function(a){a=a||{};if(a.xhr&&a.conn){return a.conn.readyState!==4&&a.conn.readyState!==0;}else{if(a.xdr&&a.conn){return a.conn.isCallInProgress(a.tId);}else{if(a.upload===true){return document.getElementById("yuiIO"+a.tId)?true:false;}else{return false;}}}},releaseObject:function(a){if(a&&a.conn){a.conn=null;a=null;}}};(function(){var g=YAHOO.util.Connect,h={};function d(i){var j='<object id="YUIConnectionSwf" type="application/x-shockwave-flash" data="'+i+'" width="0" height="0">'+'<param name="movie" value="'+i+'">'+'<param name="allowScriptAccess" value="always">'+"</object>",k=document.createElement("div");document.body.appendChild(k);k.innerHTML=j;}function b(l,i,j,n,k){h[parseInt(l.tId)]={"o":l,"c":n};if(k){n.method=i;n.data=k;}l.conn.send(j,n,l.tId);}function e(i){d(i);g._transport=document.getElementById("YUIConnectionSwf");}function c(){g.xdrReadyEvent.fire();}function a(j,i){if(j){g.startEvent.fire(j,i.argument);if(j.startEvent){j.startEvent.fire(j,i.argument);}}}function f(j){var k=h[j.tId].o,i=h[j.tId].c;if(j.statusText==="xdr:start"){a(k,i);return;}j.responseText=decodeURI(j.responseText);k.r=j;if(i.argument){k.r.argument=i.argument;}this.handleTransactionResponse(k,i,j.statusText==="xdr:abort"?true:false);delete h[j.tId];}g.xdr=b;g.swf=d;g.transport=e;g.xdrReadyEvent=new YAHOO.util.CustomEvent("xdrReady");g.xdrReady=c;g.handleXdrResponse=f;})();(function(){var e=YAHOO.util.Connect,g=YAHOO.util.Event,a=document.documentMode?document.documentMode:false;e._isFileUpload=false;e._formNode=null;e._sFormData=null;e._submitElementValue=null;e.uploadEvent=new YAHOO.util.CustomEvent("upload");e._hasSubmitListener=function(){if(g){g.addListener(document,"click",function(k){var j=g.getTarget(k),i=j.nodeName.toLowerCase();if((i==="input"||i==="button")&&(j.type&&j.type.toLowerCase()=="submit")){e._submitElementValue=encodeURIComponent(j.name)+"="+encodeURIComponent(j.value);}});return true;}return false;}();function h(w,r,m){var v,l,u,s,z,t=false,p=[],y=0,o,q,n,x,k;this.resetFormState();if(typeof w=="string"){v=(document.getElementById(w)||document.forms[w]);}else{if(typeof w=="object"){v=w;}else{return;}}if(r){this.createFrame(m?m:null);this._isFormSubmit=true;this._isFileUpload=true;this._formNode=v;return;}for(o=0,q=v.elements.length;o<q;++o){l=v.elements[o];z=l.disabled;u=l.name;if(!z&&u){u=encodeURIComponent(u)+"=";s=encodeURIComponent(l.value);switch(l.type){case"select-one":if(l.selectedIndex>-1){k=l.options[l.selectedIndex];p[y++]=u+encodeURIComponent((k.attributes.value&&k.attributes.value.specified)?k.value:k.text);}break;case"select-multiple":if(l.selectedIndex>-1){for(n=l.selectedIndex,x=l.options.length;n<x;++n){k=l.options[n];if(k.selected){p[y++]=u+encodeURIComponent((k.attributes.value&&k.attributes.value.specified)?k.value:k.text);}}}break;case"radio":case"checkbox":if(l.checked){p[y++]=u+s;}break;case"file":case undefined:case"reset":case"button":break;case"submit":if(t===false){if(this._hasSubmitListener&&this._submitElementValue){p[y++]=this._submitElementValue;}t=true;}break;default:p[y++]=u+s;}}}this._isFormSubmit=true;this._sFormData=p.join("&");this.initHeader("Content-Type",this._default_form_header);return this._sFormData;}function d(){this._isFormSubmit=false;this._isFileUpload=false;this._formNode=null;this._sFormData="";}function c(i){var j="yuiIO"+this._transaction_id,l=(a===9)?true:false,k;if(YAHOO.env.ua.ie&&!l){k=document.createElement('<iframe id="'+j+'" name="'+j+'" />');if(typeof i=="boolean"){k.src="javascript:false";}}else{k=document.createElement("iframe");k.id=j;k.name=j;}k.style.position="absolute";k.style.top="-1000px";k.style.left="-1000px";document.body.appendChild(k);}function f(j){var m=[],k=j.split("&"),l,n;for(l=0;l<k.length;l++){n=k[l].indexOf("=");if(n!=-1){m[l]=document.createElement("input");m[l].type="hidden";m[l].name=decodeURIComponent(k[l].substring(0,n));m[l].value=decodeURIComponent(k[l].substring(n+1));this._formNode.appendChild(m[l]);}}return m;}function b(m,y,n,l){var t="yuiIO"+m.tId,u="multipart/form-data",w=document.getElementById(t),p=(a>=8)?true:false,z=this,v=(y&&y.argument)?y.argument:null,x,s,k,r,j,q;j={action:this._formNode.getAttribute("action"),method:this._formNode.getAttribute("method"),target:this._formNode.getAttribute("target")};this._formNode.setAttribute("action",n);this._formNode.setAttribute("method","POST");this._formNode.setAttribute("target",t);if(YAHOO.env.ua.ie&&!p){this._formNode.setAttribute("encoding",u);}else{this._formNode.setAttribute("enctype",u);}if(l){x=this.appendPostData(l);}this._formNode.submit();this.startEvent.fire(m,v);if(m.startEvent){m.startEvent.fire(m,v);}if(y&&y.timeout){this._timeOut[m.tId]=window.setTimeout(function(){z.abort(m,y,true);},y.timeout);}if(x&&x.length>0){for(s=0;s<x.length;s++){this._formNode.removeChild(x[s]);}}for(k in j){if(YAHOO.lang.hasOwnProperty(j,k)){if(j[k]){this._formNode.setAttribute(k,j[k]);}else{this._formNode.removeAttribute(k);}}}this.resetFormState(); -q=function(){var i,A,B;if(y&&y.timeout){window.clearTimeout(z._timeOut[m.tId]);delete z._timeOut[m.tId];}z.completeEvent.fire(m,v);if(m.completeEvent){m.completeEvent.fire(m,v);}r={tId:m.tId,argument:v};try{i=w.contentWindow.document.getElementsByTagName("body")[0];A=w.contentWindow.document.getElementsByTagName("pre")[0];if(i){if(A){B=A.textContent?A.textContent:A.innerText;}else{B=i.textContent?i.textContent:i.innerText;}}r.responseText=B;r.responseXML=w.contentWindow.document.XMLDocument?w.contentWindow.document.XMLDocument:w.contentWindow.document;}catch(o){}if(y&&y.upload){if(!y.scope){y.upload(r);}else{y.upload.apply(y.scope,[r]);}}z.uploadEvent.fire(r);if(m.uploadEvent){m.uploadEvent.fire(r);}g.removeListener(w,"load",q);setTimeout(function(){document.body.removeChild(w);z.releaseObject(m);},100);};g.addListener(w,"load",q);}e.setForm=h;e.resetFormState=d;e.createFrame=c;e.appendPostData=f;e.uploadFile=b;})();YAHOO.register("connection",YAHOO.util.Connect,{version:"2.9.0",build:"2800"}); \ No newline at end of file diff --git a/interface/web/js/yui/animation/README b/interface/web/js/yui/animation/README deleted file mode 100644 index a3160f62d8..0000000000 --- a/interface/web/js/yui/animation/README +++ /dev/null @@ -1,45 +0,0 @@ -Animation Release Notes - -*** version 2.2.0 ** - -* Fixed AnimMgr.stop() when called without tween - -*** version 0.12.2 *** - -* raised AnimMgr.fps to 1000 - -*** version 0.12.1 *** -* minified version no longer strips line breaks - -*** version 0.12.0 *** - -* added boolean finish argument to Anim.stop() - -*** version 0.11.3 *** - -* no changes - -*** version 0.11.1 *** - -* changed "prototype" shorthand to "proto" (workaround firefox < 1.5 scoping -bug) - -*** version 0.11.0 *** - -* ColorAnim subclass added -* Motion and Scroll now inherit from ColorAnim -* getDefaultUnit method added -* defaultUnit and defaultUnits deprecated -* getDefault and setDefault methods deprecated - -*** version 0.10.0 *** - -* Scroll now handles relative ("by") animation correctly - -* Now converts "auto" values of "from" to appropriate initial values - -*** version 0.9.0 *** - -* Initial release - - diff --git a/interface/web/js/yui/animation/animation-debug.js b/interface/web/js/yui/animation/animation-debug.js deleted file mode 100644 index 818c192e0c..0000000000 --- a/interface/web/js/yui/animation/animation-debug.js +++ /dev/null @@ -1,1361 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -*/ - -/** - * The animation module provides allows effects to be added to HTMLElements. - * @module animation - * @requires yahoo, event, dom - */ - -/** - * - * Base animation class that provides the interface for building animated effects. - * <p>Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);</p> - * @class Anim - * @namespace YAHOO.util - * @requires YAHOO.util.AnimMgr - * @requires YAHOO.util.Easing - * @requires YAHOO.util.Dom - * @requires YAHOO.util.Event - * @requires YAHOO.util.CustomEvent - * @constructor - * @param {String | HTMLElement} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - -YAHOO.util.Anim = function(el, attributes, duration, method) { - if (el) { - this.init(el, attributes, duration, method); - } -}; - -YAHOO.util.Anim.prototype = { - /** - * Provides a readable name for the Anim instance. - * @method toString - * @return {String} - */ - toString: function() { - var el = this.getEl(); - var id = el.id || el.tagName; - return ("Anim " + id); - }, - - patterns: { // cached for performance - noNegatives: /width|height|opacity|padding/i, // keep at zero or above - offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default - defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default - offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset - }, - - /** - * Returns the value computed by the animation's "method". - * @method doMethod - * @param {String} attr The name of the attribute. - * @param {Number} start The value this attribute should start from for this animation. - * @param {Number} end The value this attribute should end at for this animation. - * @return {Number} The Value to be applied to the attribute. - */ - doMethod: function(attr, start, end) { - return this.method(this.currentFrame, start, end - start, this.totalFrames); - }, - - /** - * Applies a value to an attribute. - * @method setAttribute - * @param {String} attr The name of the attribute. - * @param {Number} val The value to be applied to the attribute. - * @param {String} unit The unit ('px', '%', etc.) of the value. - */ - setAttribute: function(attr, val, unit) { - if ( this.patterns.noNegatives.test(attr) ) { - val = (val > 0) ? val : 0; - } - - YAHOO.util.Dom.setStyle(this.getEl(), attr, val + unit); - }, - - /** - * Returns current value of the attribute. - * @method getAttribute - * @param {String} attr The name of the attribute. - * @return {Number} val The current value of the attribute. - */ - getAttribute: function(attr) { - var el = this.getEl(); - var val = YAHOO.util.Dom.getStyle(el, attr); - - if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) { - return parseFloat(val); - } - - var a = this.patterns.offsetAttribute.exec(attr) || []; - var pos = !!( a[3] ); // top or left - var box = !!( a[2] ); // width or height - - // use offsets for width/height and abs pos top/left - if ( box || (YAHOO.util.Dom.getStyle(el, 'position') == 'absolute' && pos) ) { - val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)]; - } else { // default to zero for other 'auto' - val = 0; - } - - return val; - }, - - /** - * Returns the unit to use when none is supplied. - * @method getDefaultUnit - * @param {attr} attr The name of the attribute. - * @return {String} The default unit to be used. - */ - getDefaultUnit: function(attr) { - if ( this.patterns.defaultUnit.test(attr) ) { - return 'px'; - } - - return ''; - }, - - /** - * Sets the actual values to be used during the animation. Should only be needed for subclass use. - * @method setRuntimeAttribute - * @param {Object} attr The attribute object - * @private - */ - setRuntimeAttribute: function(attr) { - var start; - var end; - var attributes = this.attributes; - - this.runtimeAttributes[attr] = {}; - - var isset = function(prop) { - return (typeof prop !== 'undefined'); - }; - - if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) { - return false; // note return; nothing to animate to - } - - start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr); - - // To beats by, per SMIL 2.1 spec - if ( isset(attributes[attr]['to']) ) { - end = attributes[attr]['to']; - } else if ( isset(attributes[attr]['by']) ) { - if (start.constructor == Array) { - end = []; - for (var i = 0, len = start.length; i < len; ++i) { - end[i] = start[i] + attributes[attr]['by'][i]; - } - } else { - end = start + attributes[attr]['by']; - } - } - - this.runtimeAttributes[attr].start = start; - this.runtimeAttributes[attr].end = end; - - // set units if needed - this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr); - }, - - /** - * Constructor for Anim instance. - * @method init - * @param {String | HTMLElement} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - init: function(el, attributes, duration, method) { - /** - * Whether or not the animation is running. - * @property isAnimated - * @private - * @type Boolean - */ - var isAnimated = false; - - /** - * A Date object that is created when the animation begins. - * @property startTime - * @private - * @type Date - */ - var startTime = null; - - /** - * The number of frames this animation was able to execute. - * @property actualFrames - * @private - * @type Int - */ - var actualFrames = 0; - - /** - * The element to be animated. - * @property el - * @private - * @type HTMLElement - */ - el = YAHOO.util.Dom.get(el); - - /** - * The collection of attributes to be animated. - * Each attribute must have at least a "to" or "by" defined in order to animate. - * If "to" is supplied, the animation will end with the attribute at that value. - * If "by" is supplied, the animation will end at that value plus its starting value. - * If both are supplied, "to" is used, and "by" is ignored. - * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values). - * @property attributes - * @type Object - */ - this.attributes = attributes || {}; - - /** - * The length of the animation. Defaults to "1" (second). - * @property duration - * @type Number - */ - this.duration = duration || 1; - - /** - * The method that will provide values to the attribute(s) during the animation. - * Defaults to "YAHOO.util.Easing.easeNone". - * @property method - * @type Function - */ - this.method = method || YAHOO.util.Easing.easeNone; - - /** - * Whether or not the duration should be treated as seconds. - * Defaults to true. - * @property useSeconds - * @type Boolean - */ - this.useSeconds = true; // default to seconds - - /** - * The location of the current animation on the timeline. - * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time. - * @property currentFrame - * @type Int - */ - this.currentFrame = 0; - - /** - * The total number of frames to be executed. - * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time. - * @property totalFrames - * @type Int - */ - this.totalFrames = YAHOO.util.AnimMgr.fps; - - - /** - * Returns a reference to the animated element. - * @method getEl - * @return {HTMLElement} - */ - this.getEl = function() { return el; }; - - /** - * Checks whether the element is currently animated. - * @method isAnimated - * @return {Boolean} current value of isAnimated. - */ - this.isAnimated = function() { - return isAnimated; - }; - - /** - * Returns the animation start time. - * @method getStartTime - * @return {Date} current value of startTime. - */ - this.getStartTime = function() { - return startTime; - }; - - this.runtimeAttributes = {}; - - var logger = {}; - logger.log = function() {YAHOO.log.apply(window, arguments)}; - - logger.log('creating new instance of ' + this); - - /** - * Starts the animation by registering it with the animation manager. - * @method animate - */ - this.animate = function() { - if ( this.isAnimated() ) { - return false; - } - - this.currentFrame = 0; - - this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration; - - YAHOO.util.AnimMgr.registerElement(this); - }; - - /** - * Stops the animation. Normally called by AnimMgr when animation completes. - * @method stop - * @param {Boolean} finish (optional) If true, animation will jump to final frame. - */ - this.stop = function(finish) { - if (finish) { - this.currentFrame = this.totalFrames; - this._onTween.fire(); - } - YAHOO.util.AnimMgr.stop(this); - }; - - var onStart = function() { - this.onStart.fire(); - - this.runtimeAttributes = {}; - for (var attr in this.attributes) { - this.setRuntimeAttribute(attr); - } - - isAnimated = true; - actualFrames = 0; - startTime = new Date(); - }; - - /** - * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s). - * @private - */ - - var onTween = function() { - var data = { - duration: new Date() - this.getStartTime(), - currentFrame: this.currentFrame - }; - - data.toString = function() { - return ( - 'duration: ' + data.duration + - ', currentFrame: ' + data.currentFrame - ); - }; - - this.onTween.fire(data); - - var runtimeAttributes = this.runtimeAttributes; - - for (var attr in runtimeAttributes) { - this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit); - } - - actualFrames += 1; - }; - - var onComplete = function() { - var actual_duration = (new Date() - startTime) / 1000 ; - - var data = { - duration: actual_duration, - frames: actualFrames, - fps: actualFrames / actual_duration - }; - - data.toString = function() { - return ( - 'duration: ' + data.duration + - ', frames: ' + data.frames + - ', fps: ' + data.fps - ); - }; - - isAnimated = false; - actualFrames = 0; - this.onComplete.fire(data); - }; - - /** - * Custom event that fires after onStart, useful in subclassing - * @private - */ - this._onStart = new YAHOO.util.CustomEvent('_start', this, true); - - /** - * Custom event that fires when animation begins - * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction) - * @event onStart - */ - this.onStart = new YAHOO.util.CustomEvent('start', this); - - /** - * Custom event that fires between each frame - * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction) - * @event onTween - */ - this.onTween = new YAHOO.util.CustomEvent('tween', this); - - /** - * Custom event that fires after onTween - * @private - */ - this._onTween = new YAHOO.util.CustomEvent('_tween', this, true); - - /** - * Custom event that fires when animation ends - * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction) - * @event onComplete - */ - this.onComplete = new YAHOO.util.CustomEvent('complete', this); - /** - * Custom event that fires after onComplete - * @private - */ - this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true); - - this._onStart.subscribe(onStart); - this._onTween.subscribe(onTween); - this._onComplete.subscribe(onComplete); - } -}; - -/** - * Handles animation queueing and threading. - * Used by Anim and subclasses. - * @class AnimMgr - * @namespace YAHOO.util - */ -YAHOO.util.AnimMgr = new function() { - /** - * Reference to the animation Interval. - * @property thread - * @private - * @type Int - */ - var thread = null; - - /** - * The current queue of registered animation objects. - * @property queue - * @private - * @type Array - */ - var queue = []; - - /** - * The number of active animations. - * @property tweenCount - * @private - * @type Int - */ - var tweenCount = 0; - - /** - * Base frame rate (frames per second). - * Arbitrarily high for better x-browser calibration (slower browsers drop more frames). - * @property fps - * @type Int - * - */ - this.fps = 1000; - - /** - * Interval delay in milliseconds, defaults to fastest possible. - * @property delay - * @type Int - * - */ - this.delay = 1; - - /** - * Adds an animation instance to the animation queue. - * All animation instances must be registered in order to animate. - * @method registerElement - * @param {object} tween The Anim instance to be be registered - */ - this.registerElement = function(tween) { - queue[queue.length] = tween; - tweenCount += 1; - tween._onStart.fire(); - this.start(); - }; - - /** - * removes an animation instance from the animation queue. - * All animation instances must be registered in order to animate. - * @method unRegister - * @param {object} tween The Anim instance to be be registered - * @param {Int} index The index of the Anim instance - * @private - */ - this.unRegister = function(tween, index) { - tween._onComplete.fire(); - index = index || getIndex(tween); - if (index != -1) { - queue.splice(index, 1); - } - - tweenCount -= 1; - if (tweenCount <= 0) { - this.stop(); - } - }; - - /** - * Starts the animation thread. - * Only one thread can run at a time. - * @method start - */ - this.start = function() { - if (thread === null) { - thread = setInterval(this.run, this.delay); - } - }; - - /** - * Stops the animation thread or a specific animation instance. - * @method stop - * @param {object} tween A specific Anim instance to stop (optional) - * If no instance given, Manager stops thread and all animations. - */ - this.stop = function(tween) { - if (!tween) { - clearInterval(thread); - - for (var i = 0, len = queue.length; i < len; ++i) { - if ( queue[0].isAnimated() ) { - this.unRegister(queue[0], 0); - } - } - - queue = []; - thread = null; - tweenCount = 0; - } - else { - this.unRegister(tween); - } - }; - - /** - * Called per Interval to handle each animation frame. - * @method run - */ - this.run = function() { - for (var i = 0, len = queue.length; i < len; ++i) { - var tween = queue[i]; - if ( !tween || !tween.isAnimated() ) { continue; } - - if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null) - { - tween.currentFrame += 1; - - if (tween.useSeconds) { - correctFrame(tween); - } - tween._onTween.fire(); - } - else { YAHOO.util.AnimMgr.stop(tween, i); } - } - }; - - var getIndex = function(anim) { - for (var i = 0, len = queue.length; i < len; ++i) { - if (queue[i] == anim) { - return i; // note return; - } - } - return -1; - }; - - /** - * On the fly frame correction to keep animation on time. - * @method correctFrame - * @private - * @param {Object} tween The Anim instance being corrected. - */ - var correctFrame = function(tween) { - var frames = tween.totalFrames; - var frame = tween.currentFrame; - var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames); - var elapsed = (new Date() - tween.getStartTime()); - var tweak = 0; - - if (elapsed < tween.duration * 1000) { // check if falling behind - tweak = Math.round((elapsed / expected - 1) * tween.currentFrame); - } else { // went over duration, so jump to end - tweak = frames - (frame + 1); - } - if (tweak > 0 && isFinite(tweak)) { // adjust if needed - if (tween.currentFrame + tweak >= frames) {// dont go past last frame - tweak = frames - (frame + 1); - } - - tween.currentFrame += tweak; - } - }; -}; -/** - * Used to calculate Bezier splines for any number of control points. - * @class Bezier - * @namespace YAHOO.util - * - */ -YAHOO.util.Bezier = new function() { - /** - * Get the current position of the animated element based on t. - * Each point is an array of "x" and "y" values (0 = x, 1 = y) - * At least 2 points are required (start and end). - * First point is start. Last point is end. - * Additional control points are optional. - * @method getPosition - * @param {Array} points An array containing Bezier points - * @param {Number} t A number between 0 and 1 which is the basis for determining current position - * @return {Array} An array containing int x and y member data - */ - this.getPosition = function(points, t) { - var n = points.length; - var tmp = []; - - for (var i = 0; i < n; ++i){ - tmp[i] = [points[i][0], points[i][1]]; // save input - } - - for (var j = 1; j < n; ++j) { - for (i = 0; i < n - j; ++i) { - tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0]; - tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1]; - } - } - - return [ tmp[0][0], tmp[0][1] ]; - - }; -}; -(function() { -/** - * Anim subclass for color transitions. - * <p>Usage: <code>var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);</code> Color values can be specified with either 112233, #112233, - * [255,255,255], or rgb(255,255,255)</p> - * @class ColorAnim - * @namespace YAHOO.util - * @requires YAHOO.util.Anim - * @requires YAHOO.util.AnimMgr - * @requires YAHOO.util.Easing - * @requires YAHOO.util.Bezier - * @requires YAHOO.util.Dom - * @requires YAHOO.util.Event - * @constructor - * @extends YAHOO.util.Anim - * @param {HTMLElement | String} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - YAHOO.util.ColorAnim = function(el, attributes, duration, method) { - YAHOO.util.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method); - }; - - YAHOO.extend(YAHOO.util.ColorAnim, YAHOO.util.Anim); - - // shorthand - var Y = YAHOO.util; - var superclass = Y.ColorAnim.superclass; - var proto = Y.ColorAnim.prototype; - - proto.toString = function() { - var el = this.getEl(); - var id = el.id || el.tagName; - return ("ColorAnim " + id); - }; - - proto.patterns.color = /color$/i; - proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i; - proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i; - proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i; - proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/; // need rgba for safari - - /** - * Attempts to parse the given string and return a 3-tuple. - * @method parseColor - * @param {String} s The string to parse. - * @return {Array} The 3-tuple of rgb values. - */ - proto.parseColor = function(s) { - if (s.length == 3) { return s; } - - var c = this.patterns.hex.exec(s); - if (c && c.length == 4) { - return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ]; - } - - c = this.patterns.rgb.exec(s); - if (c && c.length == 4) { - return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ]; - } - - c = this.patterns.hex3.exec(s); - if (c && c.length == 4) { - return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ]; - } - - return null; - }; - - proto.getAttribute = function(attr) { - var el = this.getEl(); - if ( this.patterns.color.test(attr) ) { - var val = YAHOO.util.Dom.getStyle(el, attr); - - if (this.patterns.transparent.test(val)) { // bgcolor default - var parent = el.parentNode; // try and get from an ancestor - val = Y.Dom.getStyle(parent, attr); - - while (parent && this.patterns.transparent.test(val)) { - parent = parent.parentNode; - val = Y.Dom.getStyle(parent, attr); - if (parent.tagName.toUpperCase() == 'HTML') { - val = '#fff'; - } - } - } - } else { - val = superclass.getAttribute.call(this, attr); - } - - return val; - }; - - proto.doMethod = function(attr, start, end) { - var val; - - if ( this.patterns.color.test(attr) ) { - val = []; - for (var i = 0, len = start.length; i < len; ++i) { - val[i] = superclass.doMethod.call(this, attr, start[i], end[i]); - } - - val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')'; - } - else { - val = superclass.doMethod.call(this, attr, start, end); - } - - return val; - }; - - proto.setRuntimeAttribute = function(attr) { - superclass.setRuntimeAttribute.call(this, attr); - - if ( this.patterns.color.test(attr) ) { - var attributes = this.attributes; - var start = this.parseColor(this.runtimeAttributes[attr].start); - var end = this.parseColor(this.runtimeAttributes[attr].end); - // fix colors if going "by" - if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) { - end = this.parseColor(attributes[attr].by); - - for (var i = 0, len = start.length; i < len; ++i) { - end[i] = start[i] + end[i]; - } - } - - this.runtimeAttributes[attr].start = start; - this.runtimeAttributes[attr].end = end; - } - }; -})(); -/* -TERMS OF USE - EASING EQUATIONS -Open source under the BSD License. -Copyright 2001 Robert Penner All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** - * Singleton that determines how an animation proceeds from start to end. - * @class Easing - * @namespace YAHOO.util -*/ - -YAHOO.util.Easing = { - - /** - * Uniform speed between points. - * @method easeNone - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeNone: function (t, b, c, d) { - return c*t/d + b; - }, - - /** - * Begins slowly and accelerates towards end. (quadratic) - * @method easeIn - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeIn: function (t, b, c, d) { - return c*(t/=d)*t + b; - }, - - /** - * Begins quickly and decelerates towards end. (quadratic) - * @method easeOut - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeOut: function (t, b, c, d) { - return -c *(t/=d)*(t-2) + b; - }, - - /** - * Begins slowly and decelerates towards end. (quadratic) - * @method easeBoth - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeBoth: function (t, b, c, d) { - if ((t/=d/2) < 1) { - return c/2*t*t + b; - } - - return -c/2 * ((--t)*(t-2) - 1) + b; - }, - - /** - * Begins slowly and accelerates towards end. (quartic) - * @method easeInStrong - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeInStrong: function (t, b, c, d) { - return c*(t/=d)*t*t*t + b; - }, - - /** - * Begins quickly and decelerates towards end. (quartic) - * @method easeOutStrong - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeOutStrong: function (t, b, c, d) { - return -c * ((t=t/d-1)*t*t*t - 1) + b; - }, - - /** - * Begins slowly and decelerates towards end. (quartic) - * @method easeBothStrong - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeBothStrong: function (t, b, c, d) { - if ((t/=d/2) < 1) { - return c/2*t*t*t*t + b; - } - - return -c/2 * ((t-=2)*t*t*t - 2) + b; - }, - - /** - * Snap in elastic effect. - * @method elasticIn - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} a Amplitude (optional) - * @param {Number} p Period (optional) - * @return {Number} The computed value for the current animation frame - */ - - elasticIn: function (t, b, c, d, a, p) { - if (t == 0) { - return b; - } - if ( (t /= d) == 1 ) { - return b+c; - } - if (!p) { - p=d*.3; - } - - if (!a || a < Math.abs(c)) { - a = c; - var s = p/4; - } - else { - var s = p/(2*Math.PI) * Math.asin (c/a); - } - - return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; - }, - - /** - * Snap out elastic effect. - * @method elasticOut - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} a Amplitude (optional) - * @param {Number} p Period (optional) - * @return {Number} The computed value for the current animation frame - */ - elasticOut: function (t, b, c, d, a, p) { - if (t == 0) { - return b; - } - if ( (t /= d) == 1 ) { - return b+c; - } - if (!p) { - p=d*.3; - } - - if (!a || a < Math.abs(c)) { - a = c; - var s = p / 4; - } - else { - var s = p/(2*Math.PI) * Math.asin (c/a); - } - - return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; - }, - - /** - * Snap both elastic effect. - * @method elasticBoth - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} a Amplitude (optional) - * @param {Number} p Period (optional) - * @return {Number} The computed value for the current animation frame - */ - elasticBoth: function (t, b, c, d, a, p) { - if (t == 0) { - return b; - } - - if ( (t /= d/2) == 2 ) { - return b+c; - } - - if (!p) { - p = d*(.3*1.5); - } - - if ( !a || a < Math.abs(c) ) { - a = c; - var s = p/4; - } - else { - var s = p/(2*Math.PI) * Math.asin (c/a); - } - - if (t < 1) { - return -.5*(a*Math.pow(2,10*(t-=1)) * - Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; - } - return a*Math.pow(2,-10*(t-=1)) * - Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; - }, - - - /** - * Backtracks slightly, then reverses direction and moves to end. - * @method backIn - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} s Overshoot (optional) - * @return {Number} The computed value for the current animation frame - */ - backIn: function (t, b, c, d, s) { - if (typeof s == 'undefined') { - s = 1.70158; - } - return c*(t/=d)*t*((s+1)*t - s) + b; - }, - - /** - * Overshoots end, then reverses and comes back to end. - * @method backOut - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} s Overshoot (optional) - * @return {Number} The computed value for the current animation frame - */ - backOut: function (t, b, c, d, s) { - if (typeof s == 'undefined') { - s = 1.70158; - } - return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; - }, - - /** - * Backtracks slightly, then reverses direction, overshoots end, - * then reverses and comes back to end. - * @method backBoth - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} s Overshoot (optional) - * @return {Number} The computed value for the current animation frame - */ - backBoth: function (t, b, c, d, s) { - if (typeof s == 'undefined') { - s = 1.70158; - } - - if ((t /= d/2 ) < 1) { - return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; - } - return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; - }, - - /** - * Bounce off of start. - * @method bounceIn - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - bounceIn: function (t, b, c, d) { - return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b; - }, - - /** - * Bounces off end. - * @method bounceOut - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - bounceOut: function (t, b, c, d) { - if ((t/=d) < (1/2.75)) { - return c*(7.5625*t*t) + b; - } else if (t < (2/2.75)) { - return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; - } else if (t < (2.5/2.75)) { - return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; - } - return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; - }, - - /** - * Bounces off start and end. - * @method bounceBoth - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - bounceBoth: function (t, b, c, d) { - if (t < d/2) { - return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b; - } - return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b; - } -}; - -(function() { -/** - * Anim subclass for moving elements along a path defined by the "points" - * member of "attributes". All "points" are arrays with x, y coordinates. - * <p>Usage: <code>var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p> - * @class Motion - * @namespace YAHOO.util - * @requires YAHOO.util.Anim - * @requires YAHOO.util.AnimMgr - * @requires YAHOO.util.Easing - * @requires YAHOO.util.Bezier - * @requires YAHOO.util.Dom - * @requires YAHOO.util.Event - * @requires YAHOO.util.CustomEvent - * @constructor - * @extends YAHOO.util.Anim - * @param {String | HTMLElement} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - YAHOO.util.Motion = function(el, attributes, duration, method) { - if (el) { // dont break existing subclasses not using YAHOO.extend - YAHOO.util.Motion.superclass.constructor.call(this, el, attributes, duration, method); - } - }; - - YAHOO.extend(YAHOO.util.Motion, YAHOO.util.ColorAnim); - - // shorthand - var Y = YAHOO.util; - var superclass = Y.Motion.superclass; - var proto = Y.Motion.prototype; - - proto.toString = function() { - var el = this.getEl(); - var id = el.id || el.tagName; - return ("Motion " + id); - }; - - proto.patterns.points = /^points$/i; - - proto.setAttribute = function(attr, val, unit) { - if ( this.patterns.points.test(attr) ) { - unit = unit || 'px'; - superclass.setAttribute.call(this, 'left', val[0], unit); - superclass.setAttribute.call(this, 'top', val[1], unit); - } else { - superclass.setAttribute.call(this, attr, val, unit); - } - }; - - proto.getAttribute = function(attr) { - if ( this.patterns.points.test(attr) ) { - var val = [ - superclass.getAttribute.call(this, 'left'), - superclass.getAttribute.call(this, 'top') - ]; - } else { - val = superclass.getAttribute.call(this, attr); - } - - return val; - }; - - proto.doMethod = function(attr, start, end) { - var val = null; - - if ( this.patterns.points.test(attr) ) { - var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100; - val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t); - } else { - val = superclass.doMethod.call(this, attr, start, end); - } - return val; - }; - - proto.setRuntimeAttribute = function(attr) { - if ( this.patterns.points.test(attr) ) { - var el = this.getEl(); - var attributes = this.attributes; - var start; - var control = attributes['points']['control'] || []; - var end; - var i, len; - - if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points - control = [control]; - } else { // break reference to attributes.points.control - var tmp = []; - for (i = 0, len = control.length; i< len; ++i) { - tmp[i] = control[i]; - } - control = tmp; - } - - if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative - Y.Dom.setStyle(el, 'position', 'relative'); - } - - if ( isset(attributes['points']['from']) ) { - Y.Dom.setXY(el, attributes['points']['from']); // set position to from point - } - else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position - - start = this.getAttribute('points'); // get actual top & left - - // TO beats BY, per SMIL 2.1 spec - if ( isset(attributes['points']['to']) ) { - end = translateValues.call(this, attributes['points']['to'], start); - - var pageXY = Y.Dom.getXY(this.getEl()); - for (i = 0, len = control.length; i < len; ++i) { - control[i] = translateValues.call(this, control[i], start); - } - - - } else if ( isset(attributes['points']['by']) ) { - end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ]; - - for (i = 0, len = control.length; i < len; ++i) { - control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ]; - } - } - - this.runtimeAttributes[attr] = [start]; - - if (control.length > 0) { - this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control); - } - - this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end; - } - else { - superclass.setRuntimeAttribute.call(this, attr); - } - }; - - var translateValues = function(val, start) { - var pageXY = Y.Dom.getXY(this.getEl()); - val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ]; - - return val; - }; - - var isset = function(prop) { - return (typeof prop !== 'undefined'); - }; -})(); -(function() { -/** - * Anim subclass for scrolling elements to a position defined by the "scroll" - * member of "attributes". All "scroll" members are arrays with x, y scroll positions. - * <p>Usage: <code>var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p> - * @class Scroll - * @namespace YAHOO.util - * @requires YAHOO.util.Anim - * @requires YAHOO.util.AnimMgr - * @requires YAHOO.util.Easing - * @requires YAHOO.util.Bezier - * @requires YAHOO.util.Dom - * @requires YAHOO.util.Event - * @requires YAHOO.util.CustomEvent - * @extends YAHOO.util.Anim - * @constructor - * @param {String or HTMLElement} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - YAHOO.util.Scroll = function(el, attributes, duration, method) { - if (el) { // dont break existing subclasses not using YAHOO.extend - YAHOO.util.Scroll.superclass.constructor.call(this, el, attributes, duration, method); - } - }; - - YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim); - - // shorthand - var Y = YAHOO.util; - var superclass = Y.Scroll.superclass; - var proto = Y.Scroll.prototype; - - 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); - } - }; -})(); -YAHOO.register("animation", YAHOO.util.Anim, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/animation/animation-min.js b/interface/web/js/yui/animation/animation-min.js deleted file mode 100644 index 94ae5582a8..0000000000 --- a/interface/web/js/yui/animation/animation-min.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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.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;i<len;++i){end[i]=start[i]+attributes[attr]['by'][i];}}else{end=start+attributes[attr]['by'];}} -this.runtimeAttributes[attr].start=start;this.runtimeAttributes[attr].end=end;this.runtimeAttributes[attr].unit=(isset(attributes[attr].unit))?attributes[attr]['unit']:this.getDefaultUnit(attr);},init:function(el,attributes,duration,method){var isAnimated=false;var startTime=null;var actualFrames=0;el=YAHOO.util.Dom.get(el);this.attributes=attributes||{};this.duration=duration||1;this.method=method||YAHOO.util.Easing.easeNone;this.useSeconds=true;this.currentFrame=0;this.totalFrames=YAHOO.util.AnimMgr.fps;this.getEl=function(){return el;};this.isAnimated=function(){return isAnimated;};this.getStartTime=function(){return startTime;};this.runtimeAttributes={};this.animate=function(){if(this.isAnimated()){return false;} -this.currentFrame=0;this.totalFrames=(this.useSeconds)?Math.ceil(YAHOO.util.AnimMgr.fps*this.duration):this.duration;YAHOO.util.AnimMgr.registerElement(this);};this.stop=function(finish){if(finish){this.currentFrame=this.totalFrames;this._onTween.fire();} -YAHOO.util.AnimMgr.stop(this);};var onStart=function(){this.onStart.fire();this.runtimeAttributes={};for(var attr in this.attributes){this.setRuntimeAttribute(attr);} -isAnimated=true;actualFrames=0;startTime=new Date();};var onTween=function(){var data={duration:new Date()-this.getStartTime(),currentFrame:this.currentFrame};data.toString=function(){return('duration: '+data.duration+', currentFrame: '+data.currentFrame);};this.onTween.fire(data);var runtimeAttributes=this.runtimeAttributes;for(var attr in runtimeAttributes){this.setAttribute(attr,this.doMethod(attr,runtimeAttributes[attr].start,runtimeAttributes[attr].end),runtimeAttributes[attr].unit);} -actualFrames+=1;};var onComplete=function(){var actual_duration=(new Date()-startTime)/1000;var data={duration:actual_duration,frames:actualFrames,fps:actualFrames/actual_duration};data.toString=function(){return('duration: '+data.duration+', frames: '+data.frames+', fps: '+data.fps);};isAnimated=false;actualFrames=0;this.onComplete.fire(data);};this._onStart=new YAHOO.util.CustomEvent('_start',this,true);this.onStart=new YAHOO.util.CustomEvent('start',this);this.onTween=new YAHOO.util.CustomEvent('tween',this);this._onTween=new YAHOO.util.CustomEvent('_tween',this,true);this.onComplete=new YAHOO.util.CustomEvent('complete',this);this._onComplete=new YAHOO.util.CustomEvent('_complete',this,true);this._onStart.subscribe(onStart);this._onTween.subscribe(onTween);this._onComplete.subscribe(onComplete);}};YAHOO.util.AnimMgr=new function(){var thread=null;var queue=[];var tweenCount=0;this.fps=1000;this.delay=1;this.registerElement=function(tween){queue[queue.length]=tween;tweenCount+=1;tween._onStart.fire();this.start();};this.unRegister=function(tween,index){tween._onComplete.fire();index=index||getIndex(tween);if(index!=-1){queue.splice(index,1);} -tweenCount-=1;if(tweenCount<=0){this.stop();}};this.start=function(){if(thread===null){thread=setInterval(this.run,this.delay);}};this.stop=function(tween){if(!tween){clearInterval(thread);for(var i=0,len=queue.length;i<len;++i){if(queue[0].isAnimated()){this.unRegister(queue[0],0);}} -queue=[];thread=null;tweenCount=0;} -else{this.unRegister(tween);}};this.run=function(){for(var i=0,len=queue.length;i<len;++i){var tween=queue[i];if(!tween||!tween.isAnimated()){continue;} -if(tween.currentFrame<tween.totalFrames||tween.totalFrames===null) -{tween.currentFrame+=1;if(tween.useSeconds){correctFrame(tween);} -tween._onTween.fire();} -else{YAHOO.util.AnimMgr.stop(tween,i);}}};var getIndex=function(anim){for(var i=0,len=queue.length;i<len;++i){if(queue[i]==anim){return i;}} -return-1;};var correctFrame=function(tween){var frames=tween.totalFrames;var frame=tween.currentFrame;var expected=(tween.currentFrame*tween.duration*1000/tween.totalFrames);var elapsed=(new Date()-tween.getStartTime());var tweak=0;if(elapsed<tween.duration*1000){tweak=Math.round((elapsed/expected-1)*tween.currentFrame);}else{tweak=frames-(frame+1);} -if(tweak>0&&isFinite(tweak)){if(tween.currentFrame+tweak>=frames){tweak=frames-(frame+1);} -tween.currentFrame+=tweak;}};};YAHOO.util.Bezier=new function(){this.getPosition=function(points,t){var n=points.length;var tmp=[];for(var i=0;i<n;++i){tmp[i]=[points[i][0],points[i][1]];} -for(var j=1;j<n;++j){for(i=0;i<n-j;++i){tmp[i][0]=(1-t)*tmp[i][0]+t*tmp[parseInt(i+1,10)][0];tmp[i][1]=(1-t)*tmp[i][1]+t*tmp[parseInt(i+1,10)][1];}} -return[tmp[0][0],tmp[0][1]];};};(function(){YAHOO.util.ColorAnim=function(el,attributes,duration,method){YAHOO.util.ColorAnim.superclass.constructor.call(this,el,attributes,duration,method);};YAHOO.extend(YAHOO.util.ColorAnim,YAHOO.util.Anim);var Y=YAHOO.util;var superclass=Y.ColorAnim.superclass;var proto=Y.ColorAnim.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("ColorAnim "+id);};proto.patterns.color=/color$/i;proto.patterns.rgb=/^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;proto.patterns.hex=/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;proto.patterns.hex3=/^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;proto.patterns.transparent=/^transparent|rgba\(0, 0, 0, 0\)$/;proto.parseColor=function(s){if(s.length==3){return s;} -var c=this.patterns.hex.exec(s);if(c&&c.length==4){return[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)];} -c=this.patterns.rgb.exec(s);if(c&&c.length==4){return[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)];} -c=this.patterns.hex3.exec(s);if(c&&c.length==4){return[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)];} -return null;};proto.getAttribute=function(attr){var el=this.getEl();if(this.patterns.color.test(attr)){var val=YAHOO.util.Dom.getStyle(el,attr);if(this.patterns.transparent.test(val)){var parent=el.parentNode;val=Y.Dom.getStyle(parent,attr);while(parent&&this.patterns.transparent.test(val)){parent=parent.parentNode;val=Y.Dom.getStyle(parent,attr);if(parent.tagName.toUpperCase()=='HTML'){val='#fff';}}}}else{val=superclass.getAttribute.call(this,attr);} -return val;};proto.doMethod=function(attr,start,end){var val;if(this.patterns.color.test(attr)){val=[];for(var i=0,len=start.length;i<len;++i){val[i]=superclass.doMethod.call(this,attr,start[i],end[i]);} -val='rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';} -else{val=superclass.doMethod.call(this,attr,start,end);} -return val;};proto.setRuntimeAttribute=function(attr){superclass.setRuntimeAttribute.call(this,attr);if(this.patterns.color.test(attr)){var attributes=this.attributes;var start=this.parseColor(this.runtimeAttributes[attr].start);var end=this.parseColor(this.runtimeAttributes[attr].end);if(typeof attributes[attr]['to']==='undefined'&&typeof attributes[attr]['by']!=='undefined'){end=this.parseColor(attributes[attr].by);for(var i=0,len=start.length;i<len;++i){end[i]=start[i]+end[i];}} -this.runtimeAttributes[attr].start=start;this.runtimeAttributes[attr].end=end;}};})();YAHOO.util.Easing={easeNone:function(t,b,c,d){return c*t/d+b;},easeIn:function(t,b,c,d){return c*(t/=d)*t+b;},easeOut:function(t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeBoth:function(t,b,c,d){if((t/=d/2)<1){return c/2*t*t+b;} -return-c/2*((--t)*(t-2)-1)+b;},easeInStrong:function(t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutStrong:function(t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeBothStrong:function(t,b,c,d){if((t/=d/2)<1){return c/2*t*t*t*t+b;} -return-c/2*((t-=2)*t*t*t-2)+b;},elasticIn:function(t,b,c,d,a,p){if(t==0){return b;} -if((t/=d)==1){return b+c;} -if(!p){p=d*.3;} -if(!a||a<Math.abs(c)){a=c;var s=p/4;} -else{var s=p/(2*Math.PI)*Math.asin(c/a);} -return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},elasticOut:function(t,b,c,d,a,p){if(t==0){return b;} -if((t/=d)==1){return b+c;} -if(!p){p=d*.3;} -if(!a||a<Math.abs(c)){a=c;var s=p/4;} -else{var s=p/(2*Math.PI)*Math.asin(c/a);} -return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b;},elasticBoth:function(t,b,c,d,a,p){if(t==0){return b;} -if((t/=d/2)==2){return b+c;} -if(!p){p=d*(.3*1.5);} -if(!a||a<Math.abs(c)){a=c;var s=p/4;} -else{var s=p/(2*Math.PI)*Math.asin(c/a);} -if(t<1){return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;} -return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},backIn:function(t,b,c,d,s){if(typeof s=='undefined'){s=1.70158;} -return c*(t/=d)*t*((s+1)*t-s)+b;},backOut:function(t,b,c,d,s){if(typeof s=='undefined'){s=1.70158;} -return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},backBoth:function(t,b,c,d,s){if(typeof s=='undefined'){s=1.70158;} -if((t/=d/2)<1){return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;} -return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},bounceIn:function(t,b,c,d){return c-YAHOO.util.Easing.bounceOut(d-t,0,c,d)+b;},bounceOut:function(t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;} -return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;},bounceBoth:function(t,b,c,d){if(t<d/2){return YAHOO.util.Easing.bounceIn(t*2,0,c,d)*.5+b;} -return YAHOO.util.Easing.bounceOut(t*2-d,0,c,d)*.5+c*.5+b;}};(function(){YAHOO.util.Motion=function(el,attributes,duration,method){if(el){YAHOO.util.Motion.superclass.constructor.call(this,el,attributes,duration,method);}};YAHOO.extend(YAHOO.util.Motion,YAHOO.util.ColorAnim);var Y=YAHOO.util;var superclass=Y.Motion.superclass;var proto=Y.Motion.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("Motion "+id);};proto.patterns.points=/^points$/i;proto.setAttribute=function(attr,val,unit){if(this.patterns.points.test(attr)){unit=unit||'px';superclass.setAttribute.call(this,'left',val[0],unit);superclass.setAttribute.call(this,'top',val[1],unit);}else{superclass.setAttribute.call(this,attr,val,unit);}};proto.getAttribute=function(attr){if(this.patterns.points.test(attr)){var val=[superclass.getAttribute.call(this,'left'),superclass.getAttribute.call(this,'top')];}else{val=superclass.getAttribute.call(this,attr);} -return val;};proto.doMethod=function(attr,start,end){var val=null;if(this.patterns.points.test(attr)){var t=this.method(this.currentFrame,0,100,this.totalFrames)/100;val=Y.Bezier.getPosition(this.runtimeAttributes[attr],t);}else{val=superclass.doMethod.call(this,attr,start,end);} -return val;};proto.setRuntimeAttribute=function(attr){if(this.patterns.points.test(attr)){var el=this.getEl();var attributes=this.attributes;var start;var control=attributes['points']['control']||[];var end;var i,len;if(control.length>0&&!(control[0]instanceof Array)){control=[control];}else{var tmp=[];for(i=0,len=control.length;i<len;++i){tmp[i]=control[i];} -control=tmp;} -if(Y.Dom.getStyle(el,'position')=='static'){Y.Dom.setStyle(el,'position','relative');} -if(isset(attributes['points']['from'])){Y.Dom.setXY(el,attributes['points']['from']);} -else{Y.Dom.setXY(el,Y.Dom.getXY(el));} -start=this.getAttribute('points');if(isset(attributes['points']['to'])){end=translateValues.call(this,attributes['points']['to'],start);var pageXY=Y.Dom.getXY(this.getEl());for(i=0,len=control.length;i<len;++i){control[i]=translateValues.call(this,control[i],start);}}else if(isset(attributes['points']['by'])){end=[start[0]+attributes['points']['by'][0],start[1]+attributes['points']['by'][1]];for(i=0,len=control.length;i<len;++i){control[i]=[start[0]+control[i][0],start[1]+control[i][1]];}} -this.runtimeAttributes[attr]=[start];if(control.length>0){this.runtimeAttributes[attr]=this.runtimeAttributes[attr].concat(control);} -this.runtimeAttributes[attr][this.runtimeAttributes[attr].length]=end;} -else{superclass.setRuntimeAttribute.call(this,attr);}};var translateValues=function(val,start){var 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);}};})();YAHOO.register("animation",YAHOO.util.Anim,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/animation/animation.js b/interface/web/js/yui/animation/animation.js deleted file mode 100644 index 319b618d92..0000000000 --- a/interface/web/js/yui/animation/animation.js +++ /dev/null @@ -1,1358 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -*/ - -/** - * The animation module provides allows effects to be added to HTMLElements. - * @module animation - * @requires yahoo, event, dom - */ - -/** - * - * Base animation class that provides the interface for building animated effects. - * <p>Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);</p> - * @class Anim - * @namespace YAHOO.util - * @requires YAHOO.util.AnimMgr - * @requires YAHOO.util.Easing - * @requires YAHOO.util.Dom - * @requires YAHOO.util.Event - * @requires YAHOO.util.CustomEvent - * @constructor - * @param {String | HTMLElement} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - -YAHOO.util.Anim = function(el, attributes, duration, method) { - if (el) { - this.init(el, attributes, duration, method); - } -}; - -YAHOO.util.Anim.prototype = { - /** - * Provides a readable name for the Anim instance. - * @method toString - * @return {String} - */ - toString: function() { - var el = this.getEl(); - var id = el.id || el.tagName; - return ("Anim " + id); - }, - - patterns: { // cached for performance - noNegatives: /width|height|opacity|padding/i, // keep at zero or above - offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default - defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default - offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset - }, - - /** - * Returns the value computed by the animation's "method". - * @method doMethod - * @param {String} attr The name of the attribute. - * @param {Number} start The value this attribute should start from for this animation. - * @param {Number} end The value this attribute should end at for this animation. - * @return {Number} The Value to be applied to the attribute. - */ - doMethod: function(attr, start, end) { - return this.method(this.currentFrame, start, end - start, this.totalFrames); - }, - - /** - * Applies a value to an attribute. - * @method setAttribute - * @param {String} attr The name of the attribute. - * @param {Number} val The value to be applied to the attribute. - * @param {String} unit The unit ('px', '%', etc.) of the value. - */ - setAttribute: function(attr, val, unit) { - if ( this.patterns.noNegatives.test(attr) ) { - val = (val > 0) ? val : 0; - } - - YAHOO.util.Dom.setStyle(this.getEl(), attr, val + unit); - }, - - /** - * Returns current value of the attribute. - * @method getAttribute - * @param {String} attr The name of the attribute. - * @return {Number} val The current value of the attribute. - */ - getAttribute: function(attr) { - var el = this.getEl(); - var val = YAHOO.util.Dom.getStyle(el, attr); - - if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) { - return parseFloat(val); - } - - var a = this.patterns.offsetAttribute.exec(attr) || []; - var pos = !!( a[3] ); // top or left - var box = !!( a[2] ); // width or height - - // use offsets for width/height and abs pos top/left - if ( box || (YAHOO.util.Dom.getStyle(el, 'position') == 'absolute' && pos) ) { - val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)]; - } else { // default to zero for other 'auto' - val = 0; - } - - return val; - }, - - /** - * Returns the unit to use when none is supplied. - * @method getDefaultUnit - * @param {attr} attr The name of the attribute. - * @return {String} The default unit to be used. - */ - getDefaultUnit: function(attr) { - if ( this.patterns.defaultUnit.test(attr) ) { - return 'px'; - } - - return ''; - }, - - /** - * Sets the actual values to be used during the animation. Should only be needed for subclass use. - * @method setRuntimeAttribute - * @param {Object} attr The attribute object - * @private - */ - setRuntimeAttribute: function(attr) { - var start; - var end; - var attributes = this.attributes; - - this.runtimeAttributes[attr] = {}; - - var isset = function(prop) { - return (typeof prop !== 'undefined'); - }; - - if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) { - return false; // note return; nothing to animate to - } - - start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr); - - // To beats by, per SMIL 2.1 spec - if ( isset(attributes[attr]['to']) ) { - end = attributes[attr]['to']; - } else if ( isset(attributes[attr]['by']) ) { - if (start.constructor == Array) { - end = []; - for (var i = 0, len = start.length; i < len; ++i) { - end[i] = start[i] + attributes[attr]['by'][i]; - } - } else { - end = start + attributes[attr]['by']; - } - } - - this.runtimeAttributes[attr].start = start; - this.runtimeAttributes[attr].end = end; - - // set units if needed - this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr); - }, - - /** - * Constructor for Anim instance. - * @method init - * @param {String | HTMLElement} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - init: function(el, attributes, duration, method) { - /** - * Whether or not the animation is running. - * @property isAnimated - * @private - * @type Boolean - */ - var isAnimated = false; - - /** - * A Date object that is created when the animation begins. - * @property startTime - * @private - * @type Date - */ - var startTime = null; - - /** - * The number of frames this animation was able to execute. - * @property actualFrames - * @private - * @type Int - */ - var actualFrames = 0; - - /** - * The element to be animated. - * @property el - * @private - * @type HTMLElement - */ - el = YAHOO.util.Dom.get(el); - - /** - * The collection of attributes to be animated. - * Each attribute must have at least a "to" or "by" defined in order to animate. - * If "to" is supplied, the animation will end with the attribute at that value. - * If "by" is supplied, the animation will end at that value plus its starting value. - * If both are supplied, "to" is used, and "by" is ignored. - * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values). - * @property attributes - * @type Object - */ - this.attributes = attributes || {}; - - /** - * The length of the animation. Defaults to "1" (second). - * @property duration - * @type Number - */ - this.duration = duration || 1; - - /** - * The method that will provide values to the attribute(s) during the animation. - * Defaults to "YAHOO.util.Easing.easeNone". - * @property method - * @type Function - */ - this.method = method || YAHOO.util.Easing.easeNone; - - /** - * Whether or not the duration should be treated as seconds. - * Defaults to true. - * @property useSeconds - * @type Boolean - */ - this.useSeconds = true; // default to seconds - - /** - * The location of the current animation on the timeline. - * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time. - * @property currentFrame - * @type Int - */ - this.currentFrame = 0; - - /** - * The total number of frames to be executed. - * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time. - * @property totalFrames - * @type Int - */ - this.totalFrames = YAHOO.util.AnimMgr.fps; - - - /** - * Returns a reference to the animated element. - * @method getEl - * @return {HTMLElement} - */ - this.getEl = function() { return el; }; - - /** - * Checks whether the element is currently animated. - * @method isAnimated - * @return {Boolean} current value of isAnimated. - */ - this.isAnimated = function() { - return isAnimated; - }; - - /** - * Returns the animation start time. - * @method getStartTime - * @return {Date} current value of startTime. - */ - this.getStartTime = function() { - return startTime; - }; - - this.runtimeAttributes = {}; - - - - /** - * Starts the animation by registering it with the animation manager. - * @method animate - */ - this.animate = function() { - if ( this.isAnimated() ) { - return false; - } - - this.currentFrame = 0; - - this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration; - - YAHOO.util.AnimMgr.registerElement(this); - }; - - /** - * Stops the animation. Normally called by AnimMgr when animation completes. - * @method stop - * @param {Boolean} finish (optional) If true, animation will jump to final frame. - */ - this.stop = function(finish) { - if (finish) { - this.currentFrame = this.totalFrames; - this._onTween.fire(); - } - YAHOO.util.AnimMgr.stop(this); - }; - - var onStart = function() { - this.onStart.fire(); - - this.runtimeAttributes = {}; - for (var attr in this.attributes) { - this.setRuntimeAttribute(attr); - } - - isAnimated = true; - actualFrames = 0; - startTime = new Date(); - }; - - /** - * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s). - * @private - */ - - var onTween = function() { - var data = { - duration: new Date() - this.getStartTime(), - currentFrame: this.currentFrame - }; - - data.toString = function() { - return ( - 'duration: ' + data.duration + - ', currentFrame: ' + data.currentFrame - ); - }; - - this.onTween.fire(data); - - var runtimeAttributes = this.runtimeAttributes; - - for (var attr in runtimeAttributes) { - this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit); - } - - actualFrames += 1; - }; - - var onComplete = function() { - var actual_duration = (new Date() - startTime) / 1000 ; - - var data = { - duration: actual_duration, - frames: actualFrames, - fps: actualFrames / actual_duration - }; - - data.toString = function() { - return ( - 'duration: ' + data.duration + - ', frames: ' + data.frames + - ', fps: ' + data.fps - ); - }; - - isAnimated = false; - actualFrames = 0; - this.onComplete.fire(data); - }; - - /** - * Custom event that fires after onStart, useful in subclassing - * @private - */ - this._onStart = new YAHOO.util.CustomEvent('_start', this, true); - - /** - * Custom event that fires when animation begins - * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction) - * @event onStart - */ - this.onStart = new YAHOO.util.CustomEvent('start', this); - - /** - * Custom event that fires between each frame - * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction) - * @event onTween - */ - this.onTween = new YAHOO.util.CustomEvent('tween', this); - - /** - * Custom event that fires after onTween - * @private - */ - this._onTween = new YAHOO.util.CustomEvent('_tween', this, true); - - /** - * Custom event that fires when animation ends - * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction) - * @event onComplete - */ - this.onComplete = new YAHOO.util.CustomEvent('complete', this); - /** - * Custom event that fires after onComplete - * @private - */ - this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true); - - this._onStart.subscribe(onStart); - this._onTween.subscribe(onTween); - this._onComplete.subscribe(onComplete); - } -}; - -/** - * Handles animation queueing and threading. - * Used by Anim and subclasses. - * @class AnimMgr - * @namespace YAHOO.util - */ -YAHOO.util.AnimMgr = new function() { - /** - * Reference to the animation Interval. - * @property thread - * @private - * @type Int - */ - var thread = null; - - /** - * The current queue of registered animation objects. - * @property queue - * @private - * @type Array - */ - var queue = []; - - /** - * The number of active animations. - * @property tweenCount - * @private - * @type Int - */ - var tweenCount = 0; - - /** - * Base frame rate (frames per second). - * Arbitrarily high for better x-browser calibration (slower browsers drop more frames). - * @property fps - * @type Int - * - */ - this.fps = 1000; - - /** - * Interval delay in milliseconds, defaults to fastest possible. - * @property delay - * @type Int - * - */ - this.delay = 1; - - /** - * Adds an animation instance to the animation queue. - * All animation instances must be registered in order to animate. - * @method registerElement - * @param {object} tween The Anim instance to be be registered - */ - this.registerElement = function(tween) { - queue[queue.length] = tween; - tweenCount += 1; - tween._onStart.fire(); - this.start(); - }; - - /** - * removes an animation instance from the animation queue. - * All animation instances must be registered in order to animate. - * @method unRegister - * @param {object} tween The Anim instance to be be registered - * @param {Int} index The index of the Anim instance - * @private - */ - this.unRegister = function(tween, index) { - tween._onComplete.fire(); - index = index || getIndex(tween); - if (index != -1) { - queue.splice(index, 1); - } - - tweenCount -= 1; - if (tweenCount <= 0) { - this.stop(); - } - }; - - /** - * Starts the animation thread. - * Only one thread can run at a time. - * @method start - */ - this.start = function() { - if (thread === null) { - thread = setInterval(this.run, this.delay); - } - }; - - /** - * Stops the animation thread or a specific animation instance. - * @method stop - * @param {object} tween A specific Anim instance to stop (optional) - * If no instance given, Manager stops thread and all animations. - */ - this.stop = function(tween) { - if (!tween) { - clearInterval(thread); - - for (var i = 0, len = queue.length; i < len; ++i) { - if ( queue[0].isAnimated() ) { - this.unRegister(queue[0], 0); - } - } - - queue = []; - thread = null; - tweenCount = 0; - } - else { - this.unRegister(tween); - } - }; - - /** - * Called per Interval to handle each animation frame. - * @method run - */ - this.run = function() { - for (var i = 0, len = queue.length; i < len; ++i) { - var tween = queue[i]; - if ( !tween || !tween.isAnimated() ) { continue; } - - if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null) - { - tween.currentFrame += 1; - - if (tween.useSeconds) { - correctFrame(tween); - } - tween._onTween.fire(); - } - else { YAHOO.util.AnimMgr.stop(tween, i); } - } - }; - - var getIndex = function(anim) { - for (var i = 0, len = queue.length; i < len; ++i) { - if (queue[i] == anim) { - return i; // note return; - } - } - return -1; - }; - - /** - * On the fly frame correction to keep animation on time. - * @method correctFrame - * @private - * @param {Object} tween The Anim instance being corrected. - */ - var correctFrame = function(tween) { - var frames = tween.totalFrames; - var frame = tween.currentFrame; - var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames); - var elapsed = (new Date() - tween.getStartTime()); - var tweak = 0; - - if (elapsed < tween.duration * 1000) { // check if falling behind - tweak = Math.round((elapsed / expected - 1) * tween.currentFrame); - } else { // went over duration, so jump to end - tweak = frames - (frame + 1); - } - if (tweak > 0 && isFinite(tweak)) { // adjust if needed - if (tween.currentFrame + tweak >= frames) {// dont go past last frame - tweak = frames - (frame + 1); - } - - tween.currentFrame += tweak; - } - }; -}; -/** - * Used to calculate Bezier splines for any number of control points. - * @class Bezier - * @namespace YAHOO.util - * - */ -YAHOO.util.Bezier = new function() { - /** - * Get the current position of the animated element based on t. - * Each point is an array of "x" and "y" values (0 = x, 1 = y) - * At least 2 points are required (start and end). - * First point is start. Last point is end. - * Additional control points are optional. - * @method getPosition - * @param {Array} points An array containing Bezier points - * @param {Number} t A number between 0 and 1 which is the basis for determining current position - * @return {Array} An array containing int x and y member data - */ - this.getPosition = function(points, t) { - var n = points.length; - var tmp = []; - - for (var i = 0; i < n; ++i){ - tmp[i] = [points[i][0], points[i][1]]; // save input - } - - for (var j = 1; j < n; ++j) { - for (i = 0; i < n - j; ++i) { - tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0]; - tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1]; - } - } - - return [ tmp[0][0], tmp[0][1] ]; - - }; -}; -(function() { -/** - * Anim subclass for color transitions. - * <p>Usage: <code>var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);</code> Color values can be specified with either 112233, #112233, - * [255,255,255], or rgb(255,255,255)</p> - * @class ColorAnim - * @namespace YAHOO.util - * @requires YAHOO.util.Anim - * @requires YAHOO.util.AnimMgr - * @requires YAHOO.util.Easing - * @requires YAHOO.util.Bezier - * @requires YAHOO.util.Dom - * @requires YAHOO.util.Event - * @constructor - * @extends YAHOO.util.Anim - * @param {HTMLElement | String} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - YAHOO.util.ColorAnim = function(el, attributes, duration, method) { - YAHOO.util.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method); - }; - - YAHOO.extend(YAHOO.util.ColorAnim, YAHOO.util.Anim); - - // shorthand - var Y = YAHOO.util; - var superclass = Y.ColorAnim.superclass; - var proto = Y.ColorAnim.prototype; - - proto.toString = function() { - var el = this.getEl(); - var id = el.id || el.tagName; - return ("ColorAnim " + id); - }; - - proto.patterns.color = /color$/i; - proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i; - proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i; - proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i; - proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/; // need rgba for safari - - /** - * Attempts to parse the given string and return a 3-tuple. - * @method parseColor - * @param {String} s The string to parse. - * @return {Array} The 3-tuple of rgb values. - */ - proto.parseColor = function(s) { - if (s.length == 3) { return s; } - - var c = this.patterns.hex.exec(s); - if (c && c.length == 4) { - return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ]; - } - - c = this.patterns.rgb.exec(s); - if (c && c.length == 4) { - return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ]; - } - - c = this.patterns.hex3.exec(s); - if (c && c.length == 4) { - return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ]; - } - - return null; - }; - - proto.getAttribute = function(attr) { - var el = this.getEl(); - if ( this.patterns.color.test(attr) ) { - var val = YAHOO.util.Dom.getStyle(el, attr); - - if (this.patterns.transparent.test(val)) { // bgcolor default - var parent = el.parentNode; // try and get from an ancestor - val = Y.Dom.getStyle(parent, attr); - - while (parent && this.patterns.transparent.test(val)) { - parent = parent.parentNode; - val = Y.Dom.getStyle(parent, attr); - if (parent.tagName.toUpperCase() == 'HTML') { - val = '#fff'; - } - } - } - } else { - val = superclass.getAttribute.call(this, attr); - } - - return val; - }; - - proto.doMethod = function(attr, start, end) { - var val; - - if ( this.patterns.color.test(attr) ) { - val = []; - for (var i = 0, len = start.length; i < len; ++i) { - val[i] = superclass.doMethod.call(this, attr, start[i], end[i]); - } - - val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')'; - } - else { - val = superclass.doMethod.call(this, attr, start, end); - } - - return val; - }; - - proto.setRuntimeAttribute = function(attr) { - superclass.setRuntimeAttribute.call(this, attr); - - if ( this.patterns.color.test(attr) ) { - var attributes = this.attributes; - var start = this.parseColor(this.runtimeAttributes[attr].start); - var end = this.parseColor(this.runtimeAttributes[attr].end); - // fix colors if going "by" - if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) { - end = this.parseColor(attributes[attr].by); - - for (var i = 0, len = start.length; i < len; ++i) { - end[i] = start[i] + end[i]; - } - } - - this.runtimeAttributes[attr].start = start; - this.runtimeAttributes[attr].end = end; - } - }; -})(); -/* -TERMS OF USE - EASING EQUATIONS -Open source under the BSD License. -Copyright 2001 Robert Penner All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/** - * Singleton that determines how an animation proceeds from start to end. - * @class Easing - * @namespace YAHOO.util -*/ - -YAHOO.util.Easing = { - - /** - * Uniform speed between points. - * @method easeNone - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeNone: function (t, b, c, d) { - return c*t/d + b; - }, - - /** - * Begins slowly and accelerates towards end. (quadratic) - * @method easeIn - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeIn: function (t, b, c, d) { - return c*(t/=d)*t + b; - }, - - /** - * Begins quickly and decelerates towards end. (quadratic) - * @method easeOut - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeOut: function (t, b, c, d) { - return -c *(t/=d)*(t-2) + b; - }, - - /** - * Begins slowly and decelerates towards end. (quadratic) - * @method easeBoth - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeBoth: function (t, b, c, d) { - if ((t/=d/2) < 1) { - return c/2*t*t + b; - } - - return -c/2 * ((--t)*(t-2) - 1) + b; - }, - - /** - * Begins slowly and accelerates towards end. (quartic) - * @method easeInStrong - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeInStrong: function (t, b, c, d) { - return c*(t/=d)*t*t*t + b; - }, - - /** - * Begins quickly and decelerates towards end. (quartic) - * @method easeOutStrong - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeOutStrong: function (t, b, c, d) { - return -c * ((t=t/d-1)*t*t*t - 1) + b; - }, - - /** - * Begins slowly and decelerates towards end. (quartic) - * @method easeBothStrong - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - easeBothStrong: function (t, b, c, d) { - if ((t/=d/2) < 1) { - return c/2*t*t*t*t + b; - } - - return -c/2 * ((t-=2)*t*t*t - 2) + b; - }, - - /** - * Snap in elastic effect. - * @method elasticIn - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} a Amplitude (optional) - * @param {Number} p Period (optional) - * @return {Number} The computed value for the current animation frame - */ - - elasticIn: function (t, b, c, d, a, p) { - if (t == 0) { - return b; - } - if ( (t /= d) == 1 ) { - return b+c; - } - if (!p) { - p=d*.3; - } - - if (!a || a < Math.abs(c)) { - a = c; - var s = p/4; - } - else { - var s = p/(2*Math.PI) * Math.asin (c/a); - } - - return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; - }, - - /** - * Snap out elastic effect. - * @method elasticOut - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} a Amplitude (optional) - * @param {Number} p Period (optional) - * @return {Number} The computed value for the current animation frame - */ - elasticOut: function (t, b, c, d, a, p) { - if (t == 0) { - return b; - } - if ( (t /= d) == 1 ) { - return b+c; - } - if (!p) { - p=d*.3; - } - - if (!a || a < Math.abs(c)) { - a = c; - var s = p / 4; - } - else { - var s = p/(2*Math.PI) * Math.asin (c/a); - } - - return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; - }, - - /** - * Snap both elastic effect. - * @method elasticBoth - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} a Amplitude (optional) - * @param {Number} p Period (optional) - * @return {Number} The computed value for the current animation frame - */ - elasticBoth: function (t, b, c, d, a, p) { - if (t == 0) { - return b; - } - - if ( (t /= d/2) == 2 ) { - return b+c; - } - - if (!p) { - p = d*(.3*1.5); - } - - if ( !a || a < Math.abs(c) ) { - a = c; - var s = p/4; - } - else { - var s = p/(2*Math.PI) * Math.asin (c/a); - } - - if (t < 1) { - return -.5*(a*Math.pow(2,10*(t-=1)) * - Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; - } - return a*Math.pow(2,-10*(t-=1)) * - Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; - }, - - - /** - * Backtracks slightly, then reverses direction and moves to end. - * @method backIn - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} s Overshoot (optional) - * @return {Number} The computed value for the current animation frame - */ - backIn: function (t, b, c, d, s) { - if (typeof s == 'undefined') { - s = 1.70158; - } - return c*(t/=d)*t*((s+1)*t - s) + b; - }, - - /** - * Overshoots end, then reverses and comes back to end. - * @method backOut - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} s Overshoot (optional) - * @return {Number} The computed value for the current animation frame - */ - backOut: function (t, b, c, d, s) { - if (typeof s == 'undefined') { - s = 1.70158; - } - return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; - }, - - /** - * Backtracks slightly, then reverses direction, overshoots end, - * then reverses and comes back to end. - * @method backBoth - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @param {Number} s Overshoot (optional) - * @return {Number} The computed value for the current animation frame - */ - backBoth: function (t, b, c, d, s) { - if (typeof s == 'undefined') { - s = 1.70158; - } - - if ((t /= d/2 ) < 1) { - return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; - } - return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; - }, - - /** - * Bounce off of start. - * @method bounceIn - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - bounceIn: function (t, b, c, d) { - return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b; - }, - - /** - * Bounces off end. - * @method bounceOut - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - bounceOut: function (t, b, c, d) { - if ((t/=d) < (1/2.75)) { - return c*(7.5625*t*t) + b; - } else if (t < (2/2.75)) { - return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; - } else if (t < (2.5/2.75)) { - return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; - } - return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; - }, - - /** - * Bounces off start and end. - * @method bounceBoth - * @param {Number} t Time value used to compute current value - * @param {Number} b Starting value - * @param {Number} c Delta between start and end values - * @param {Number} d Total length of animation - * @return {Number} The computed value for the current animation frame - */ - bounceBoth: function (t, b, c, d) { - if (t < d/2) { - return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b; - } - return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b; - } -}; - -(function() { -/** - * Anim subclass for moving elements along a path defined by the "points" - * member of "attributes". All "points" are arrays with x, y coordinates. - * <p>Usage: <code>var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p> - * @class Motion - * @namespace YAHOO.util - * @requires YAHOO.util.Anim - * @requires YAHOO.util.AnimMgr - * @requires YAHOO.util.Easing - * @requires YAHOO.util.Bezier - * @requires YAHOO.util.Dom - * @requires YAHOO.util.Event - * @requires YAHOO.util.CustomEvent - * @constructor - * @extends YAHOO.util.Anim - * @param {String | HTMLElement} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - YAHOO.util.Motion = function(el, attributes, duration, method) { - if (el) { // dont break existing subclasses not using YAHOO.extend - YAHOO.util.Motion.superclass.constructor.call(this, el, attributes, duration, method); - } - }; - - YAHOO.extend(YAHOO.util.Motion, YAHOO.util.ColorAnim); - - // shorthand - var Y = YAHOO.util; - var superclass = Y.Motion.superclass; - var proto = Y.Motion.prototype; - - proto.toString = function() { - var el = this.getEl(); - var id = el.id || el.tagName; - return ("Motion " + id); - }; - - proto.patterns.points = /^points$/i; - - proto.setAttribute = function(attr, val, unit) { - if ( this.patterns.points.test(attr) ) { - unit = unit || 'px'; - superclass.setAttribute.call(this, 'left', val[0], unit); - superclass.setAttribute.call(this, 'top', val[1], unit); - } else { - superclass.setAttribute.call(this, attr, val, unit); - } - }; - - proto.getAttribute = function(attr) { - if ( this.patterns.points.test(attr) ) { - var val = [ - superclass.getAttribute.call(this, 'left'), - superclass.getAttribute.call(this, 'top') - ]; - } else { - val = superclass.getAttribute.call(this, attr); - } - - return val; - }; - - proto.doMethod = function(attr, start, end) { - var val = null; - - if ( this.patterns.points.test(attr) ) { - var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100; - val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t); - } else { - val = superclass.doMethod.call(this, attr, start, end); - } - return val; - }; - - proto.setRuntimeAttribute = function(attr) { - if ( this.patterns.points.test(attr) ) { - var el = this.getEl(); - var attributes = this.attributes; - var start; - var control = attributes['points']['control'] || []; - var end; - var i, len; - - if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points - control = [control]; - } else { // break reference to attributes.points.control - var tmp = []; - for (i = 0, len = control.length; i< len; ++i) { - tmp[i] = control[i]; - } - control = tmp; - } - - if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative - Y.Dom.setStyle(el, 'position', 'relative'); - } - - if ( isset(attributes['points']['from']) ) { - Y.Dom.setXY(el, attributes['points']['from']); // set position to from point - } - else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position - - start = this.getAttribute('points'); // get actual top & left - - // TO beats BY, per SMIL 2.1 spec - if ( isset(attributes['points']['to']) ) { - end = translateValues.call(this, attributes['points']['to'], start); - - var pageXY = Y.Dom.getXY(this.getEl()); - for (i = 0, len = control.length; i < len; ++i) { - control[i] = translateValues.call(this, control[i], start); - } - - - } else if ( isset(attributes['points']['by']) ) { - end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ]; - - for (i = 0, len = control.length; i < len; ++i) { - control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ]; - } - } - - this.runtimeAttributes[attr] = [start]; - - if (control.length > 0) { - this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control); - } - - this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end; - } - else { - superclass.setRuntimeAttribute.call(this, attr); - } - }; - - var translateValues = function(val, start) { - var pageXY = Y.Dom.getXY(this.getEl()); - val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ]; - - return val; - }; - - var isset = function(prop) { - return (typeof prop !== 'undefined'); - }; -})(); -(function() { -/** - * Anim subclass for scrolling elements to a position defined by the "scroll" - * member of "attributes". All "scroll" members are arrays with x, y scroll positions. - * <p>Usage: <code>var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p> - * @class Scroll - * @namespace YAHOO.util - * @requires YAHOO.util.Anim - * @requires YAHOO.util.AnimMgr - * @requires YAHOO.util.Easing - * @requires YAHOO.util.Bezier - * @requires YAHOO.util.Dom - * @requires YAHOO.util.Event - * @requires YAHOO.util.CustomEvent - * @extends YAHOO.util.Anim - * @constructor - * @param {String or HTMLElement} el Reference to the element that will be animated - * @param {Object} attributes The attribute(s) to be animated. - * Each attribute is an object with at minimum a "to" or "by" member defined. - * Additional optional members are "from" (defaults to current value), "units" (defaults to "px"). - * All attribute names use camelCase. - * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based - * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method) - */ - YAHOO.util.Scroll = function(el, attributes, duration, method) { - if (el) { // dont break existing subclasses not using YAHOO.extend - YAHOO.util.Scroll.superclass.constructor.call(this, el, attributes, duration, method); - } - }; - - YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim); - - // shorthand - var Y = YAHOO.util; - var superclass = Y.Scroll.superclass; - var proto = Y.Scroll.prototype; - - 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); - } - }; -})(); -YAHOO.register("animation", YAHOO.util.Anim, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/autocomplete/README b/interface/web/js/yui/autocomplete/README deleted file mode 100644 index 6ab63439b6..0000000000 --- a/interface/web/js/yui/autocomplete/README +++ /dev/null @@ -1,77 +0,0 @@ -AutoComplete Release Notes - -*** version 2.2.0 *** - -* No changes. - - - -*** version 0.12.2 *** - -* No changes. - - - -*** version 0.12.1 *** - -* No longer trigger typeAhead feature when user is backspacing on input text. - - - -*** version 0.12.0 *** - -* The following constants must be defined as static class properties and are no longer -available as instance properties: - -YAHOO.widget.DataSource.ERROR_DATANULL -YAHOO.widget.DataSource.ERROR_DATAPARSE -YAHOO.widget.DS_XHR.TYPE_JSON -YAHOO.widget.DS_XHR.TYPE_XML -YAHOO.widget.DS_XHR.TYPE_FLAT -YAHOO.widget.DS_XHR.ERROR_DATAXHR - -* The property minQueryLength now supports zero and negative number values for -DS_JSFunction and DS_XHR objects, to enable null or empty string queries and to disable -AutoComplete functionality altogether, respectively. - -* Enabling the alwaysShowContainer feature will no longer send containerExpandEvent or -containerCollapseEvent. - - - -**** version 0.11.3 *** - -* The iFrameSrc property has been deprecated. Implementers no longer need to -specify an https URL to avoid IE security warnings when working with sites over -SSL. - - - -*** version 0.11.0 *** - -* The method getListIds() has been deprecated for getListItems(), which returns -an array of DOM references. - -* All classnames have been prefixed with "yui-ac-". - -* Container elements should no longer have CSS property "display" set to "none". - -* The useIFrame property can now be set after instantiation. - -* On some browsers, the unmatchedItemSelectEvent may not be fired properly when -delimiter characters are defined. - -* On some browsers, defining delimiter characters while enabling forceSelection -may result in unexpected behavior. - - - -*** version 0.10.0 *** - -* Initial release - -* In order to enable the useIFrame property, it should be set in the -constructor. - -* On some browsers, defining delimiter characters while enabling forceSelection -may result in unexpected behavior. diff --git a/interface/web/js/yui/autocomplete/autocomplete-debug.js b/interface/web/js/yui/autocomplete/autocomplete-debug.js deleted file mode 100644 index 1e48da23dc..0000000000 --- a/interface/web/js/yui/autocomplete/autocomplete-debug.js +++ /dev/null @@ -1,3100 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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 - * @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: - * <ul> - * <li>Navigate with up/down arrow keys and/or mouse to pick a selection</li> - * <li>The drop down container can "roll down" or "fly out" via configurable - * animation</li> - * <li>UI look-and-feel customizable through CSS, including container - * attributes, borders, position, fonts, etc</li> - * </ul> - * - * @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 && (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 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. - * - * @property queryDelay - * @type Number - * @default 0.5 - */ -YAHOO.widget.AutoComplete.prototype.queryDelay = 0.5; - -/** - * 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 - * @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 {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(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<this.maxResultsDisplayed; i++) { - var oItem = document.createElement("li"); - oItem = oList.appendChild(oItem); - this._aListItems[i] = oItem; - this._initListItem(oItem, i); - } - this._maxResultsDisplayed = this.maxResultsDisplayed; -}; - -/** - * Initializes each <li> element in the container list. - * - * @method _initListItem - * @param oItem {HTMLElement} The <li> DOM element. - * @param nItemIndex {Number} The index of the element. - * @private - */ -YAHOO.widget.AutoComplete.prototype._initListItem = function(oItem, nItemIndex) { - var oSelf = this; - oItem.style.display = "none"; - oItem._nItemIndex = nItemIndex; - - oItem.mouseover = oItem.mouseout = oItem.onclick = null; - YAHOO.util.Event.addListener(oItem,"mouseover",oSelf._onItemMouseover,oSelf); - YAHOO.util.Event.addListener(oItem,"mouseout",oSelf._onItemMouseout,oSelf); - YAHOO.util.Event.addListener(oItem,"click",oSelf._onItemMouseclick,oSelf); -}; - -/** - * Enables interval detection for Korean IME support. - * - * @method _onIMEDetected - * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onIMEDetected = function(oSelf) { - oSelf._enableIntervalDetection(); -}; - -/** - * Enables query triggers based on text input detection by intervals (rather - * than by key events). - * - * @method _enableIntervalDetection - * @private - */ -YAHOO.widget.AutoComplete.prototype._enableIntervalDetection = function() { - var currValue = this._oTextbox.value; - var lastValue = this._sLastTextboxValue; - if(currValue != lastValue) { - this._sLastTextboxValue = currValue; - this._sendQuery(currValue); - } -}; - - -/** - * Cancels text input detection by intervals. - * - * @method _cancelIntervalDetection - * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._cancelIntervalDetection = function(oSelf) { - if(oSelf._queryInterval) { - clearInterval(oSelf._queryInterval); - } -}; - - -/** - * Whether or not key is functional or should be ignored. Note that the right - * arrow key is NOT an ignored key since it triggers queries for certain intl - * charsets. - * - * @method _isIgnoreKey - * @param nKeycode {Number} Code of key pressed. - * @return {Boolean} True if key should be ignored, false otherwise. - * @private - */ -YAHOO.widget.AutoComplete.prototype._isIgnoreKey = function(nKeyCode) { - if ((nKeyCode == 9) || (nKeyCode == 13) || // tab, enter - (nKeyCode == 16) || (nKeyCode == 17) || // shift, ctl - (nKeyCode >= 18 && nKeyCode <= 20) || // alt,pause/break,caps lock - (nKeyCode == 27) || // esc - (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end - (nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up - (nKeyCode == 40) || // down - (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert - return true; - } - return false; -}; - -/** - * 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 {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; - } - - 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 {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 - 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 {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)) { - 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 {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.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; - 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) { - 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 {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 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<!-"; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Queries the live data source defined by scriptURI 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_XHR.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { - var isXML = (this.responseType == YAHOO.widget.DS_XHR.TYPE_XML); - var sUri = this.scriptURI+"?"+this.scriptQueryParam+"="+sQuery; - if(this.scriptQueryAppend.length > 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); -}; - -YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/autocomplete/autocomplete-min.js b/interface/web/js/yui/autocomplete/autocomplete-min.js deleted file mode 100644 index 014a7ae3fc..0000000000 --- a/interface/web/js/yui/autocomplete/autocomplete-min.js +++ /dev/null @@ -1,183 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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<this.maxResultsDisplayed;i++){var oItem=document.createElement("li");oItem=oList.appendChild(oItem);this._aListItems[i]=oItem;this._initListItem(oItem,i);} -this._maxResultsDisplayed=this.maxResultsDisplayed;};YAHOO.widget.AutoComplete.prototype._initListItem=function(oItem,nItemIndex){var oSelf=this;oItem.style.display="none";oItem._nItemIndex=nItemIndex;oItem.mouseover=oItem.mouseout=oItem.onclick=null;YAHOO.util.Event.addListener(oItem,"mouseover",oSelf._onItemMouseover,oSelf);YAHOO.util.Event.addListener(oItem,"mouseout",oSelf._onItemMouseout,oSelf);YAHOO.util.Event.addListener(oItem,"click",oSelf._onItemMouseclick,oSelf);};YAHOO.widget.AutoComplete.prototype._onIMEDetected=function(oSelf){oSelf._enableIntervalDetection();};YAHOO.widget.AutoComplete.prototype._enableIntervalDetection=function(){var currValue=this._oTextbox.value;var lastValue=this._sLastTextboxValue;if(currValue!=lastValue){this._sLastTextboxValue=currValue;this._sendQuery(currValue);}};YAHOO.widget.AutoComplete.prototype._cancelIntervalDetection=function(oSelf){if(oSelf._queryInterval){clearInterval(oSelf._queryInterval);}};YAHOO.widget.AutoComplete.prototype._isIgnoreKey=function(nKeyCode){if((nKeyCode==9)||(nKeyCode==13)||(nKeyCode==16)||(nKeyCode==17)||(nKeyCode>=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=38)||(nKeyCode==40)||(nKeyCode>=44&&nKeyCode<=45)){return true;} -return false;};YAHOO.widget.AutoComplete.prototype._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.length<this.minQueryLength)||(!sQuery&&this.minQueryLength>0)){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<this._nDisplayedItems)){if(nKeyCode==40){if((oNewItem.offsetTop+oNewItem.offsetHeight)>(oContent.scrollTop+oContent.offsetHeight)){oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-oContent.offsetHeight;} -else if((oNewItem.offsetTop+oNewItem.offsetHeight)<oContent.scrollTop){oContent.scrollTop=oNewItem.offsetTop;}} -else{if(oNewItem.offsetTop<oContent.scrollTop){this._oContainer._oContent.scrollTop=oNewItem.offsetTop;} -else if(oNewItem.offsetTop>(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="\n<!-";YAHOO.widget.DS_XHR.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var isXML=(this.responseType==YAHOO.widget.DS_XHR.TYPE_XML);var sUri=this.scriptURI+"?"+this.scriptQueryParam+"="+sQuery;if(this.scriptQueryAppend.length>0){sUri+="&"+this.scriptQueryAppend;} -var oResponse=null;var oSelf=this;var responseSuccess=function(oResp){if(!oSelf._oConn||(oResp.tId!=oSelf._oConn.tId)){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,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);};YAHOO.register("autocomplete",YAHOO.widget.AutoComplete,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/autocomplete/autocomplete.js b/interface/web/js/yui/autocomplete/autocomplete.js deleted file mode 100644 index 2f10829f8d..0000000000 --- a/interface/web/js/yui/autocomplete/autocomplete.js +++ /dev/null @@ -1,3071 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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 - * @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: - * <ul> - * <li>Navigate with up/down arrow keys and/or mouse to pick a selection</li> - * <li>The drop down container can "roll down" or "fly out" via configurable - * animation</li> - * <li>UI look-and-feel customizable through CSS, including container - * attributes, borders, position, fonts, etc</li> - * </ul> - * - * @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 && (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 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. - * - * @property queryDelay - * @type Number - * @default 0.5 - */ -YAHOO.widget.AutoComplete.prototype.queryDelay = 0.5; - -/** - * 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 - * @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 {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(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<this.maxResultsDisplayed; i++) { - var oItem = document.createElement("li"); - oItem = oList.appendChild(oItem); - this._aListItems[i] = oItem; - this._initListItem(oItem, i); - } - this._maxResultsDisplayed = this.maxResultsDisplayed; -}; - -/** - * Initializes each <li> element in the container list. - * - * @method _initListItem - * @param oItem {HTMLElement} The <li> DOM element. - * @param nItemIndex {Number} The index of the element. - * @private - */ -YAHOO.widget.AutoComplete.prototype._initListItem = function(oItem, nItemIndex) { - var oSelf = this; - oItem.style.display = "none"; - oItem._nItemIndex = nItemIndex; - - oItem.mouseover = oItem.mouseout = oItem.onclick = null; - YAHOO.util.Event.addListener(oItem,"mouseover",oSelf._onItemMouseover,oSelf); - YAHOO.util.Event.addListener(oItem,"mouseout",oSelf._onItemMouseout,oSelf); - YAHOO.util.Event.addListener(oItem,"click",oSelf._onItemMouseclick,oSelf); -}; - -/** - * Enables interval detection for Korean IME support. - * - * @method _onIMEDetected - * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._onIMEDetected = function(oSelf) { - oSelf._enableIntervalDetection(); -}; - -/** - * Enables query triggers based on text input detection by intervals (rather - * than by key events). - * - * @method _enableIntervalDetection - * @private - */ -YAHOO.widget.AutoComplete.prototype._enableIntervalDetection = function() { - var currValue = this._oTextbox.value; - var lastValue = this._sLastTextboxValue; - if(currValue != lastValue) { - this._sLastTextboxValue = currValue; - this._sendQuery(currValue); - } -}; - - -/** - * Cancels text input detection by intervals. - * - * @method _cancelIntervalDetection - * @param oSelf {YAHOO.widget.AutoComplete} The AutoComplete instance. - * @private - */ -YAHOO.widget.AutoComplete.prototype._cancelIntervalDetection = function(oSelf) { - if(oSelf._queryInterval) { - clearInterval(oSelf._queryInterval); - } -}; - - -/** - * Whether or not key is functional or should be ignored. Note that the right - * arrow key is NOT an ignored key since it triggers queries for certain intl - * charsets. - * - * @method _isIgnoreKey - * @param nKeycode {Number} Code of key pressed. - * @return {Boolean} True if key should be ignored, false otherwise. - * @private - */ -YAHOO.widget.AutoComplete.prototype._isIgnoreKey = function(nKeyCode) { - if ((nKeyCode == 9) || (nKeyCode == 13) || // tab, enter - (nKeyCode == 16) || (nKeyCode == 17) || // shift, ctl - (nKeyCode >= 18 && nKeyCode <= 20) || // alt,pause/break,caps lock - (nKeyCode == 27) || // esc - (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end - (nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up - (nKeyCode == 40) || // down - (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert - return true; - } - return false; -}; - -/** - * 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 {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; - } - - 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 {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 - 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 {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)) { - 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 {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.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; - 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) { - 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 {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 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<!-"; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Queries the live data source defined by scriptURI 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_XHR.prototype.doQuery = function(oCallbackFn, sQuery, oParent) { - var isXML = (this.responseType == YAHOO.widget.DS_XHR.TYPE_XML); - var sUri = this.scriptURI+"?"+this.scriptQueryParam+"="+sQuery; - if(this.scriptQueryAppend.length > 0) { - sUri += "&" + this.scriptQueryAppend; - } - var oResponse = null; - - var oSelf = this; - /* - * Sets up ajax request callback - * - * @param {object} oReq HTTPXMLRequest object - * @private - */ - var responseSuccess = function(oResp) { - // Response ID does not match last made request ID. - if(!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) { - oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, 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); -}; - -YAHOO.register("autocomplete", YAHOO.widget.AutoComplete, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/button/README b/interface/web/js/yui/button/README deleted file mode 100644 index 036e33d9c9..0000000000 --- a/interface/web/js/yui/button/README +++ /dev/null @@ -1,3 +0,0 @@ -*** Version 2.2.0 *** - -* Button Control introduced \ No newline at end of file diff --git a/interface/web/js/yui/button/assets/background.png b/interface/web/js/yui/button/assets/background.png deleted file mode 100644 index 87c85b5e539b5c514df107bbb4e298948a016e3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^j6iI}!3HGf{@&OHq*&4&eH|GXuHCreA7KRKOP07s zlmzFem6RtIr7}3C<R_&nc;+Uirv{}arc@T5Otk?j^7eFb45_%arRSg^gCPgg+%NYp zo3d3T)u^x@Vc)#T*d?t_`_(;{v⪼Oj;R#FQjQp>4z5<vOdu!mJTA0o0$@hB>p~n gmGe&Zeg<ZSM{^R?Y|Bpl2O7)Z>FVdQ&MBb@01E{`BLDyZ diff --git a/interface/web/js/yui/button/assets/button.css b/interface/web/js/yui/button/assets/button.css deleted file mode 100644 index 7e19047208..0000000000 --- a/interface/web/js/yui/button/assets/button.css +++ /dev/null @@ -1,217 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -.yuibutton { - - display:-moz-inline-stack; /* Gecko */ - display:inline-block; /* IE, Opera and Safari */ - - border-width:1px 0; - border-style:solid; - border-color:#999; - - background:#ecece3 url(background.png) left center; - - /* Give the transparent background image to IE 6 */ - _background-image:none; - _filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../build/button/assets/background.png', sizingMethod = 'scale'); - - margin:auto .25em; - -} - -.yuibutton .first-child { - - display:block; /* Gecko, Opera and Safari */ - *display:inline-block; /* IE */ - - border-width:0 1px; - border-style:solid; - border-color:#999; - - margin:0 -1px; - *position:relative; - *left:-1px; - -} - -.yuibutton button, -.yuibutton a { - - display:block; /* Opera and Safari */ - display:-moz-inline-block; /* Gecko */ - *display:inline-block; /* IE */ - padding:.25em .5em; - border:1px solid #ccc; - -} - -.yuibutton button { - - overflow:visible; /* Remove superfluous padding for IE */ - font-size:100%; /* Makes form controls resizable in IE */ - background-color:transparent; - cursor:pointer; - cursor:hand; - -} - -.yuibutton a { - - text-decoration:none; - color:#000; - -} - -.yuibutton.splitbutton button, -.yuibutton.menubutton button { - - padding-right:20px; - background-position:right center; - background-repeat:no-repeat; - -} - -.yuibutton.menubutton button { - - background-image:url(menuarrow.gif); - -} - -.yuibutton.splitbutton button { - - background-image:url(splitarrow.gif); - -} - - -/* Focus state */ - -.yuibutton.focus { - - border-color:#5e5c95; - -} - -.yuibutton.focus .first-child { - - border-color:#5e5c95; - -} - -.yuibutton.focus button, -.yuibutton.focus a { - - border-color:#cec1fc; - -} - - -/* Hover state */ - -.yuibutton.hover { - - border-color:#406fac; - background-color:#98d5fc; - -} - -.yuibutton.hover .first-child { - - border-color:#406fac; - -} - -.yuibutton.hover button, -.yuibutton.hover a { - - border-color:#7099ce; - -} - - -/* Active state */ - -.yuibutton.active { - - border-color:#7a8180; - background-color:#333; - -} - -.yuibutton.active .first-child { - - border-color:#7a8180; - -} - -.yuibutton.active button, -.yuibutton.active a { - - border-color:#98a09f; - -} - -.yuibutton.splitbutton.activeoption button { - - background-color:transparent; - background-image:url(splitarrow_active.gif); - -} - - - -/* Checked state */ - -.yuibutton.radio.checked, -.yuibutton.checkbox.checked { - - border-color:#7a8180; - background-color:#333; - -} - -.yuibutton.radio.checked .first-child, -.yuibutton.checkbox.checked .first-child { - - border-color:#7a8180; - -} - -.yuibutton.radio.checked button, -.yuibutton.checkbox.checked button { - - border-color:#98a09f; - -} - - - -/* Disabled state */ - -.yuibutton.disabled { - - border-color:#cbcdc5; - background:#ecece3; - - _filter:none; - -} - -.yuibutton.disabled .first-child { - - border-color:#cbcdc5; - -} - -.yuibutton.disabled button, -.yuibutton.disabled a { - - border-color:transparent; - color:#b9b9b9; - cursor:default; - -} \ No newline at end of file diff --git a/interface/web/js/yui/button/assets/menuarrow.gif b/interface/web/js/yui/button/assets/menuarrow.gif deleted file mode 100644 index ffa2ba9d25d7ec10438cc1c8ac043c99d4cd7d55..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 67 zcmZ?wbhEHb6ky<Fn8?5o85wc&=FR&0dIkmt#h)yU3=GT+IzTo9NS=X7WKRFe-3t7! U33`5JtBxFx<!gHs#K2$;05drei~s-t diff --git a/interface/web/js/yui/button/assets/splitarrow.gif b/interface/web/js/yui/button/assets/splitarrow.gif deleted file mode 100644 index 6d1ce65940cde97983279c08a144b48d9e8e4b89..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmZ?wbhEHb6ksr7Sj50^^XARS$cXy-`t#?{fB5j>|Ns9CV4(Pug^_`Ql|cu@1F2<T z4zmck^X}D2vE^&T)~%`h&hxBOX68&WtCiQ;Hu3-2`z~Vo_nFIo-`c)lg0_N&6f48R v<_aIJ>2A-3wdUSxVwHR<{`lNF$F-vEqUn2Y8&$0d-hKG>=h<z(3=Gx)X}djS diff --git a/interface/web/js/yui/button/assets/splitarrow_active.gif b/interface/web/js/yui/button/assets/splitarrow_active.gif deleted file mode 100644 index 25c0884e06acfc235acccf87d3ae141edfe8dbdf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 145 zcmZ?wbhEHb6ksr7Sj50kUtb>?8FBOG%?}?woIihl=FFK4V4(Pu1x)LJNRV0v<}i=o zJMUhd6kEPVY~7m5?>x^sWoFJ4vs!tbZ4>{Wz3(EXf1kPh_pR*<CTKHgNHH=kY_9Op sn(p>oSZnUBCRWL(;*Za*b6hLhE}Fjgwo%oZ;N6E`f1cgu%fMg_0M=nV82|tP diff --git a/interface/web/js/yui/button/button-beta-debug.js b/interface/web/js/yui/button/button-beta-debug.js deleted file mode 100644 index c2c0e094b9..0000000000 --- a/interface/web/js/yui/button/button-beta-debug.js +++ /dev/null @@ -1,4061 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** -* @module button -* @description <p>The Button Control enables the creation of rich, graphical -* buttons that function like traditional HTML form buttons. <em>Unlike</em> -* 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 -* <a href="module_menu.html">Menu Control</a>, 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.</p> -* <p>The Button Control supports the following types:</p> -* <dl> -* <dt>button</dt> -* <dd>Basic push button that can execute a user-specified command when -* pressed.</dd> -* <dt>link</dt> -* <dd>Navigates to a specified url when pressed.</dd> -* <dt>submit</dt> -* <dd>Submits the parent form when pressed.</dd> -* <dt>reset</dt> -* <dd>Resets the parent form when pressed.</dd> -* <dt>checkbox</dt> -* <dd>Maintains a "checked" state that can be toggled on and off.</dd> -* <dt>radio</dt> -* <dd>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.</dd> -* <dt>menubutton</dt> -* <dd>When pressed will show/hide a menu.</dd> -* <dt>splitbutton</dt> -* <dd>Can execute a user-specified command or display a menu when pressed.</dd> -* </dl> -* @title Button -* @namespace YAHOO.widget -* @requires yahoo, dom, element, event -* @optional container, menu -* @beta -*/ - - -(function() { - -// Shorthard for utilities - -var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event, - Lang = YAHOO.lang, - - - // Private member variables - - m_oButtons = {}, - m_oFocusedButton = null; - - - -// Constructor - - -/** -* The Button class creates a rich, graphical button. -* @param {String} p_oElement String specifying the id attribute of the -* <code><input></code>, <code><a></code> or -* <code><span></code> element to be used to create the button. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>|<a href=" -* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html# -* ID-33759296">HTMLElement</a>} p_oElement Object reference for the -* <code><input></code>, <code><a></code> or -* <code><span></code> 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 -*/ -YAHOO.widget.Button = function(p_oElement, p_oAttributes) { - - var fnSuperClass = YAHOO.widget.Button.superclass.constructor; - - 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 { - - var oConfig = { - - element: null, - attributes: (p_oAttributes || {}) - - }; - - - if(Lang.isString(p_oElement)) { - - var me = this; - - Event.onAvailable(p_oElement, function() { - - var sTagName = this.tagName.toUpperCase(); - - if(sTagName == me.TAG_NAME) { - - oConfig.attributes.id = this.id; - - } - else if(sTagName == "INPUT" && !oConfig.attributes.id) { - - oConfig.attributes.id = Dom.generateId(); - - YAHOO.log( - "No value specified for the button's \"id\" " + - "attribute. Setting button id to \"" + - oConfig.attributes.id + "\".", - "warn" - ); - - } - - me.logger = new YAHOO.widget.LogWriter( - "Button " + oConfig.attributes.id - ); - - me.logger.log( - "Building the button using an existing HTML " + - "element as a source element." - ); - - - oConfig.attributes.srcelement = this; - - initConfig.call(me, oConfig); - - - if(!oConfig.element) { - - me.logger.log( - "Source element could not be used as is. " + - "Creating a new HTML element for the button." - ); - - oConfig.element = - me._createButtonElement(oConfig.attributes.type); - - } - - fnSuperClass.call(me, oConfig.element, oConfig.attributes); - - }); - - } - else { - - var sTagName = p_oElement.tagName.toUpperCase(); - - if(sTagName == this.TAG_NAME) { - - 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" - ); - - } - - - } - else if(sTagName == "INPUT" && !oConfig.attributes.id) { - - 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); - - } - - } - -}; - - - -// Private methods - - -/** -* @method getFirstElement -* @description Returns an HTML element's first HTML element node. -* @private -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-58190037">HTMLElement</a>} p_oElement Object -* reference specifying the element to be evaluated. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-58190037">HTMLElement</a>} -*/ -function getFirstElement(p_oElement) { - - var oFirstChild = p_oElement.firstChild; - - if(oFirstChild) { - - if(oFirstChild.nodeType == 1) { - - return oFirstChild; - - } - else { - - var oNextSibling = oFirstChild.nextSibling; - - if(oNextSibling && oNextSibling.nodeType == 1) { - - return oNextSibling; - - } - - } - - } - -} - - -/** -* @method createInputElement -* @description Creates an <code><input></code> element of the -* specified type. -* @private -* @param {String} p_sType String specifying the type of -* <code><input></code> element to create. -* @param {String} p_sName String specifying the name of -* <code><input></code> element to create. -* @param {String} p_sValue String specifying the value of -* <code><input></code> element to create. -* @param {String} p_bChecked Boolean specifying if the -* <code><input></code> element is to be checked. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>} -*/ -function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) { - - var oInput; - - if(navigator.userAgent.indexOf("MSIE") != -1) { - - /* - For IE it is necessary to create the element with the - "type," "name," "value," and "checked" properties set all at once. - */ - - var sInput = "<input type=\"" + p_sType + "\" name=\"" + p_sName + "\""; - - if(p_bChecked) { - - sInput += " checked"; - - } - - sInput += ">"; - - oInput = document.createElement(sInput); - - } - else { - - oInput = document.createElement("input"); - oInput.name = p_sName; - oInput.type = p_sType; - - if(p_bChecked) { - - oInput.checked = true; - - } - - } - - oInput.value = p_sValue; - - return oInput; - -} - - -/** -* @method setAttributesFromSrcElement -* @description Gets the values for all the attributes of the source element -* (either <code><input></code> or <code><a></code>) that map to -* Button configuration attributes and sets them into a collection that is -* passed to the Button constructor. -* @private -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>|<a href="http://www.w3.org/ -* TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID- -* 48250443">HTMLAnchorElement</a>} p_oElement Object reference to the HTML -* element (either <code><input></code> or <code><span></code>) -* 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 me = this; - - /** - * @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 <code><button></code> for the value attribute rather - than the value of the "value" attribute. - */ - - var 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( !("disabled" in p_oAttributes) ) { - - p_oAttributes.disabled = p_oElement.disabled; - - } - - setAttributeFromDOMAttribute("name"); - setAttributeFromDOMAttribute("value"); - setAttributeFromDOMAttribute("title"); - - } - - - var sSrcElementTagName = p_oElement.tagName.toUpperCase(); - - - if( !("label" in p_oAttributes) ) { - - // Set the "label" property - - var sText = sSrcElementTagName == "INPUT" ? - p_oElement.value : p_oElement.innerHTML; - - - if(sText && sText.length > 0) { - - p_oAttributes.label = sText; - - } - - } - - - setAttributeFromDOMAttribute("tabindex"); - setAttributeFromDOMAttribute("accesskey"); - - - switch(sSrcElementTagName) { - - 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(); - - var oRootNode = p_oElement.parentNode.parentNode; - - if(Dom.hasClass(oRootNode, "checked")) { - - p_oAttributes.checked = true; - - } - - if(Dom.hasClass(oRootNode, "disabled")) { - - p_oAttributes.disabled = true; - - } - - p_oElement.removeAttribute("name"); - p_oElement.removeAttribute("value"); - - p_oElement.setAttribute("type", "button"); - - break; - - } - -} - - -/** -* @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, - sSrcElementTagName = oSrcElement.tagName.toUpperCase(); - - - if(sSrcElementTagName == this.TAG_NAME) { - - p_oConfig.element = oSrcElement; - - var oFirstChild = getFirstElement(p_oConfig.element); - - Dom.addClass(oFirstChild, "first-child"); - - if(oFirstChild) { - - var oButton = getFirstElement(oFirstChild); - - - if(oButton) { - - var sButtonTagName = oButton.tagName.toUpperCase(); - - - if(sButtonTagName == "A" || sButtonTagName == "BUTTON") { - - setAttributesFromSrcElement.call( - this, - oButton, - oAttributes - ); - - } - - } - - } - - } - else if(sSrcElementTagName == "INPUT") { - - setAttributesFromSrcElement.call(this, oSrcElement, oAttributes); - - } - -} - - -YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, { - - -// Protected properties - - -/** -* @property _button -* @description Object reference to the button's internal -* <code><a></code> or <code><button></code> element. -* @default null -* @protected -* @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-48250443">HTMLAnchorElement</a>|<a href=" -* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID- -* 34812697">HTMLButtonElement</a> -*/ -_button: null, - - -/** -* @property _menu -* @description Object reference to the button's menu. -* @default null -* @protected -* @type <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a> -*/ -_menu: 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 _oninitAttributeValue -* @description Object reference to the button's current value for the "oninit" -* configuration attribute. -* @default null -* @protected -* @type Object -*/ -_oninitAttributeValue: 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" and "mousedown" -* and "mouseup" event handlers are assigned -* @default false -* @protected -* @type Boolean -*/ -_hasMouseEventHandlers: false, - - - -// Constants - - -/** -* @property TAG_NAME -* @description The name of the tag to be used for the button's root element. -* @default "SPAN" -* @final -* @type String -*/ -TAG_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 "yuibutton" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuibutton", - - -/** -* @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 "menubutton." -* @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 -* "menubutton" 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 "splitebutton." -* @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 -* "splitbutton" 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 == "splitbutton") { - - 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) { - - if(this.get("type") != "link") { - - var sTitle = p_sTitle; - - if(!sTitle) { - - - var sType = this.get("type"); - - switch(sType) { - - case "radio": - - sTitle = this.RADIO_DEFAULT_TITLE; - - break; - - case "checkbox": - - sTitle = this.CHECKBOX_DEFAULT_TITLE; - - break; - - case "menubutton": - - sTitle = this.MENUBUTTON_DEFAULT_TITLE; - - break; - - case "splitbutton": - - 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.hasFocus()) { - - this.blur(); - - } - - this._button.setAttribute("disabled", "disabled"); - - this.addClass("disabled"); - - } - else { - - this._button.removeAttribute("disabled"); - - this.removeClass("disabled"); - - } - - } - -}, - - -/** -* @method _setAccessKey -* @description Sets the value of the button's "accesskey" attribute. -* @protected -* @param {String} p_sAccessKey String indicating the value for the button's -* "accesskey" attribute. -*/ -_setAccessKey: function(p_sAccessKey) { - - this._button.accessKey = p_sAccessKey; - -}, - - -/** -* @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.addClass("checked"); - - sTitle = (sType == "radio") ? - this.RADIO_CHECKED_TITLE : - this.CHECKBOX_CHECKED_TITLE; - - } - else { - - this.removeClass("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 Menu = YAHOO.widget.Menu, - oMenu, - me = this; - - if(!Menu) { - - this.logger.log("YAHOO.widget.Menu dependency not met.", "error"); - - return false; - - } - - - function initMenu() { - - if(oMenu) { - - oMenu.showEvent.subscribe(this._onMenuShow, this, true); - oMenu.hideEvent.subscribe(this._onMenuHide, this, true); - oMenu.keyDownEvent.subscribe(this._onMenuKeyDown, this, true); - oMenu.renderEvent.subscribe(this._onMenuRender, this, true); - oMenu.clickEvent.subscribe(this._onMenuClick, this, true); - oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded, this, true); - - var oSrcElement = oMenu.srcElement; - - if(oSrcElement && oSrcElement.tagName.toUpperCase() == "SELECT") { - - oSrcElement.style.display = "none"; - oSrcElement.parentNode.removeChild(oSrcElement); - - } - - this._menu = oMenu; - - } - else { - - this._menu.destroy(); - this._menu = null; - - } - - } - - - if(p_oMenu instanceof Menu) { - - oMenu = p_oMenu; - - var aItems = oMenu.getItems(), - nItems = aItems.length, - oItem; - - if(nItems > 0) { - - var i = nItems - 1; - - do { - - oItem = aItems[i]; - - if(oItem) { - - oItem.cfg.subscribeToConfigEvent( - "selected", - this._onMenuItemSelected, - oItem, - this - ); - - } - - } - while(i--); - - } - - initMenu.call(this); - - } - else if(Lang.isArray(p_oMenu)) { - - this.on("appendTo", function() { - - oMenu = new Menu( - Dom.generateId(), - { lazyload: true, itemdata: p_oMenu } - ); - - initMenu.call(me); - - }); - - } - else if(Lang.isString(p_oMenu)) { - - Event.onContentReady(p_oMenu, function() { - - oMenu = new Menu(this, { lazyload: true }); - - initMenu.call(me); - - }); - - } - else if(p_oMenu && p_oMenu.nodeName) { - - oMenu = new Menu(p_oMenu, { lazyload: true }); - - 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 _setOnInit -* @description Sets the value of the button's "init" attribute. -* @protected -* @param {Object} p_oObject Object indicating the value for the button's -* "oninit" attribute. -*/ -_setOnInit: function(p_oObject) { - - /* - Remove any existing listeners if a "init" event handler has already - been specified. - */ - - if( - this._oninitAttributeValue && - (this._oninitAttributeValue != p_oObject) - ) { - - this.removeListener("init", this._oninitAttributeValue.fn); - - this._oninitAttributeValue = null; - - } - - - if( - !this._oninitAttributeValue && - Lang.isObject(p_oObject) && - Lang.isFunction(p_oObject.fn) - ) { - - this.on("init", p_oObject.fn, p_oObject.obj, p_oObject.scope); - - this._oninitAttributeValue = p_oObject; - - } - -}, - - - -// Protected methods - - -/** -* @method _createButtonElement -* @description Creates the button's element. -* @protected -* @param {String} p_sType String indicating the type of element to create. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-58190037">HTMLElement</a>} -*/ -_createButtonElement: function(p_sType) { - - var sTagName = this.TAG_NAME, - oElement = document.createElement(sTagName); - - oElement.innerHTML = - - "<" + sTagName + " class=\"first-child\">" + - (p_sType == "link" ? "<a></a>" : "<button type=\"button\"></button>") + - "</" + sTagName + ">"; - - return oElement; - -}, - - -/** -* @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; - - if(nKeyCodes > 0) { - - var 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. -* @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 - ); - -}, - - -_originalMaxHeight: -1, - - -/** -* @method _showMenu -* @description Shows the button's menu. -* @protected -*/ -_showMenu: function() { - - var oMenu = this._menu; - - if(oMenu) { - - YAHOO.widget.MenuManager.hideVisible(); - - oMenu.cfg.applyConfig({ - context:[this.get("id"), "tl", "bl"], - clicktohide: false, - constraintoviewport: false, - visible: true - }); - - oMenu.cfg.fireQueue(); - - var nViewportHeight = Dom.getViewportHeight(), - 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"); - - var nY = oMenu.cfg.getProperty("y"), - - nScrollTop = ( - document.documentElement.scrollTop || - document.body.scrollTop - ); - - - 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"); - - } - - } - - oMenu.cfg.setProperty("constraintoviewport", true); - - } - -}, - - -/** -* @method _hideMenu -* @description Hides the button's menu. -* @protected -*/ -_hideMenu: function() { - - var oMenu = this._menu; - - if(oMenu && oMenu.cfg.getProperty("visible")) { - - oMenu.hide(); - - } - -}, - - -/** -* @method _submitForm -* @description Submits the form to which the button belongs. -* @protected -*/ -_submitForm: function() { - - var oForm = this.getForm(); - - if(oForm) { - - YAHOO.widget.Button.addHiddenFieldsToForm(oForm); - - this.createHiddenField(); - - oForm.submit(); - - } - -}, - - - -// 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.get("disabled")) { - - if(!this._hasMouseEventHandlers) { - - this.on("mouseout", this._onMouseOut); - this.on("mousedown", this._onMouseDown); - this.on("mouseup", this._onMouseUp); - - this._hasMouseEventHandlers = true; - - } - - this.addClass("hover"); - - if(this._activationButtonPressed) { - - this.addClass("active"); - - } - - - if(this._bOptionPressed) { - - this.addClass("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) { - - if(!this.get("disabled")) { - - this.removeClass("hover"); - - if(this.get("type") != "menubutton") { - - this.removeClass("active"); - - } - - if(this._activationButtonPressed || this._bOptionPressed) { - - Event.on(document, "mouseup", this._onDocumentMouseUp, this, true); - - } - - } - -}, - - -/** -* @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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onDocumentMouseUp: function(p_oEvent, p_oButton) { - - this._activationButtonPressed = false; - this._bOptionPressed = false; - - var sType = this.get("type"); - - if(sType == "menubutton" || sType == "splitbutton") { - - this.removeClass((sType == "menubutton" ? "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) { - - if(!this.get("disabled")) { - - if((p_oEvent.which || p_oEvent.button) == 1) { - - if(!this.hasFocus()) { - - this.focus(); - - } - - - var sType = this.get("type"); - - - if(sType == "splitbutton") { - - var 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.addClass("active"); - - this._activationButtonPressed = true; - - } - - } - else if(sType == "menubutton") { - - if(this.hasClass("active")) { - - this._hideMenu(); - - this._activationButtonPressed = false; - - } - else { - - this._showMenu(); - - this._activationButtonPressed = true; - - } - - } - else { - - this.addClass("active"); - - this._activationButtonPressed = true; - - } - - - - if(sType == "splitbutton" || sType == "menubutton") { - - var me = this; - - - function onMouseUp() { - - me._hideMenu(); - me.removeListener("mouseup", onMouseUp); - - } - - - 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) { - - if(!this.get("disabled")) { - - - if(this._hideMenuTimerId) { - - window.clearTimeout(this._hideMenuTimerId); - - } - - var sType = this.get("type"); - - if(sType == "checkbox" || sType == "radio") { - - this.set("checked", !(this.get("checked"))); - - } - - - this._activationButtonPressed = false; - - - if(this.get("type") != "menubutton") { - - this.removeClass("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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button that -* fired the event. -*/ -_onFocus: function(p_oEvent, p_oButton) { - - if(!this.get("disabled")) { - - this.addClass("focus"); - - if(this._activationKeyPressed) { - - this.addClass("active"); - - } - - m_oFocusedButton = this; - - - if(!this._hasKeyEventHandlers) { - - var oElement = this._button; - - Event.on(oElement, "blur", this._onBlur, this, true); - Event.on(oElement, "keydown", this._onKeyDown, this, true); - Event.on(oElement, "keyup", this._onKeyUp, this, true); - - 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onBlur: function(p_oEvent, p_oButton) { - - if(!this.get("disabled")) { - - this.removeClass("focus"); - - if(this.get("type") != "menubutton") { - - this.removeClass("active"); - - } - - if(this._activationKeyPressed) { - - Event.on(document, "keyup", this._onDocumentKeyUp, this, true); - - } - - - 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onDocumentKeyUp: function(p_oEvent, p_oButton) { - - 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onKeyDown: function(p_oEvent, p_oButton) { - - if(!this.get("disabled")) { - - if( - this.get("type") == "splitbutton" && - this._isSplitButtonOptionKey(p_oEvent) - ) { - - this.fireEvent("option", p_oEvent); - - } - else if(this._isActivationKey(Event.getCharCode(p_oEvent))) { - - if(this.get("type") == "menubutton") { - - this._showMenu(); - - } - else { - - this._activationKeyPressed = true; - - this.addClass("active"); - - } - - } - - - var oMenu = this._menu; - - 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onKeyUp: function(p_oEvent, p_oButton) { - - if(!this.get("disabled")) { - - if(this._isActivationKey(Event.getCharCode(p_oEvent))) { - - var sType = this.get("type"); - - if(sType == "checkbox" || sType == "radio") { - - this.set("checked", !(this.get("checked"))); - - } - - this._activationKeyPressed = false; - - if(this.get("type") != "menubutton") { - - this.removeClass("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; - - 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": - - var oForm = this.getForm(); - - if(oForm) { - - oForm.reset(); - - } - - break; - - case "menubutton": - - sTitle = this._menu.cfg.getProperty("visible") ? - this.MENUBUTTON_MENU_VISIBLE_TITLE : - this.MENUBUTTON_DEFAULT_TITLE; - - this.set("title", sTitle); - - break; - - case "splitbutton": - - var 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(); - - var 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() { - - var oForm = me.getForm(); - - if(oForm) { - - Event.on(oForm, "reset", me._onFormReset, me, true); - Event.on(oForm, "submit", me._onFormSubmit, me, true); - - } - - }, 0); - -}, - - -/** -* @method _onFormSubmit -* @description "submit" 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onFormSubmit: function(p_oEvent, p_oButton) { - - var sType = this.get("type"), - oMenuItem = this.get("selectedMenuItem"), - oForm = this.getForm(); - - - if(sType == "radio" || sType == "checkbox") { - - YAHOO.log("Creating hidden field for button: " + this); - - this.createHiddenField(); - - } - else if(oMenuItem) { - - var oSrcElement = this._menu.srcElement; - - if(oSrcElement && oSrcElement.tagName.toUpperCase() == "SELECT") { - - oForm.appendChild(oSrcElement); - oSrcElement.selectedIndex = oMenuItem.index; - - } - else { - - var oValue = (oMenuItem.value === null || oMenuItem.value === "") ? - oMenuItem.cfg.getProperty("text") : - oMenuItem.value; - - - if(oValue) { - - var oField = createInputElement( - "hidden", - (this.get("name") + "_options"), - oValue - ); - - oForm.appendChild(oField); - - } - - } - - } - -}, - - -/** -* @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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onFormReset: function(p_oEvent, p_oButton) { - - var sType = this.get("type"); - - if(sType == "checkbox" || sType == "radio") { - - this.resetValue("checked"); - - } - - if(this._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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onDocumentMouseDown: function(p_oEvent, p_oButton) { - - 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("activeoption")) { - - this._hideMenu(); - - this._bOptionPressed = false; - - } - else { - - this._showMenu(); - - this._bOptionPressed = true; - - } - -}, - - -/** -* @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. -* @param {Array} p_aArgs Array of arguments sent when the event was fired. -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onMenuShow: function(p_sType, p_aArgs, p_oButton) { - - Event.on(document, "mousedown", this._onDocumentMouseDown, this, true); - - var sTitle, - sClass; - - if(this.get("type") == "splitbutton") { - - sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE; - sClass = "activeoption"; - - } - else { - - sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE; - sClass = "active"; - - } - - this.addClass(sClass); - 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. -* @param {Array} p_aArgs Array of arguments sent when the event was fired. -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onMenuHide: function(p_sType, p_aArgs, p_oButton) { - - if(this._originalMaxHeight != -1) { - - this._menu.cfg.setProperty("maxheight", this._originalMaxHeight); - - } - - - var sTitle, - sClass; - - if(this.get("type") == "splitbutton") { - - sTitle = this.SPLITBUTTON_DEFAULT_TITLE; - sClass = "activeoption"; - - } - else { - - sTitle = this.MENUBUTTON_DEFAULT_TITLE; - sClass = "active"; - } - - - this.removeClass(sClass); - this.set("title", sTitle); - -}, - - -/** -* @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. -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onMenuKeyDown: function(p_sType, p_aArgs, p_oButton) { - - var oEvent = p_aArgs[0]; - - if(Event.getCharCode(oEvent) == 27) { - - this.focus(); - - if(this.get("type") == "splitbutton") { - - 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 that -* was fired. -* @param {Array} p_aArgs Array of arguments sent when the event was fired. -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onMenuRender: function(p_sType, p_aArgs, p_oButton) { - - this.get("element").parentNode.appendChild(this._menu.element); - -}, - - -/** -* @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 {<a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a>} -* p_oItem Object representing the menu item that subscribed to the event. -*/ -_onMenuItemSelected: function(p_sType, p_aArgs, p_oItem) { - - this.set("selectedMenuItem", p_oItem); - -}, - - -/** -* @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 {<a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a>} -* 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, - 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. -* @param {YAHOO.widget.Button} p_oButton Object representing the menu's button. -*/ -_onMenuClick: function(p_sType, p_aArgs, p_oButton) { - - var oItem = p_aArgs[0]; - - if(oItem) { - - var oSrcElement = this.get("srcelement"); - - if(oSrcElement && oSrcElement.type == "submit") { - - this._submitForm(); - - } - - this._hideMenu(); - - } - -}, - - - -// Public methods - - -/** -* @method createHiddenField -* @description Creates the button's hidden form field and appends it to its -* parent form. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>} -*/ -createHiddenField: function () { - - if(!this.get("disabled")) { - - var sType = this.get("type"), - - bCheckable = (sType == "checkbox" || sType == "radio"), - - oField = createInputElement( - (bCheckable ? this.get("type") : "hidden"), - this.get("name"), - this.get("value"), - this.get("checked") - ), - - oForm = this.getForm(); - - - if(oField && bCheckable) { - - oField.style.display = "none"; - - } - - - if(oForm) { - - oForm.appendChild(oField); - - } - - - return oField; - - } - -}, - - -/** -* @method init -* @description The Button class's initialization method. -* @param {String} p_oElement String specifying the id attribute of the -* <code><input></code>, <code><a></code> or -* <code><span></code> element to be used to create the button. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>|<a href=" -* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html# -* ID-33759296">HTMLElement</a>} p_oElement Object reference for the -* <code><input></code>, <code><a></code> or -* <code><span></code> 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 sTagName = p_oAttributes.type == "link" ? "A" : "BUTTON", - oSrcElement = p_oAttributes.srcelement; - - - this._button = p_oElement.getElementsByTagName(sTagName)[0]; - - - 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(this.get("type")); - - Event.on(this._button, "focus", this._onFocus, this, true); - this.on("mouseover", this._onMouseOver); - this.on("click", this._onClick); - this.on("appendTo", this._onAppendTo); - - var oContainer = this.get("container"), - oElement = this.get("element"); - - - if(oContainer) { - - if(Lang.isString(oContainer)) { - - var me = this; - - Event.onContentReady(oContainer, function() { - - me.appendTo(this); - - }); - - } - else { - - this.appendTo(oContainer); - - } - - } - else if( - !Dom.inDocument(oElement) && - oSrcElement && - oSrcElement.tagName.toUpperCase() == "INPUT" - ) { - - var 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( - Dom.inDocument(oElement) && - oSrcElement.tagName.toUpperCase() == "SPAN" - ) { - - var oForm = this.getForm(); - - if(oForm) { - - Event.on(oForm, "reset", this._onFormReset, this, true); - Event.on(oForm, "submit", this._onFormSubmit, this, true); - - } - - } - - this.fireEvent("init"); - - 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: - * "button," "link," "submit," "reset," "checkbox," "radio," "menubutton," - * and "splitbutton." - * @default "button" - * @type String - */ - this.setAttributeConfig("type", { - - value: (oAttributes.type || "button"), - 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.) - * @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 <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|String - * @default null - */ - this.setAttributeConfig("container", { - - value: oAttributes.container - - }); - - - /** - * @config srcelement - * @description Object reference to the HTML element (either - * <code><input></code> or <code><span></code>) used to - * create the button. - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|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: - * <ul> - * <li>Object specifying a <a href="YAHOO.widget.Menu.html"> - * YAHOO.widget.Menu</a> instance.</li> - * <li>String specifying the id attribute of the <code><div></code> - * element used to create the menu.</li> - * <li>String specifying the id attribute of the - * <code><select></code> element used to create the menu.</li> - * <li>Object specifying the <code><div></code> element used to - * create the menu.</li> - * <li>Object specifying the <code><select></code> element used to - * create the menu.</li> - * <li>Array of object literals, each representing a set of - * <a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a> - * configuration attributes.</li> - * <li>Array of strings representing the text labels for each menu item in - * the menu.</li> - * </ul> - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|String|Array - * @default null - */ - this.setAttributeConfig("menu", { - - value: null, - method: this._setMenu - - }); - - - /** - * @config selectedMenuItem - * @description Reference to the item in the button's menu that is - * currently selected. - * @type <a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a> - * @default null - */ - this.setAttributeConfig("selectedMenuItem", { - - value: null - - }); - - - /** - * @config onclick - * @description Object literal representing the code to be executed when - * the button is clicked. Format:<br> <code> {<br> - * <strong>fn:</strong> Function, // The handler to call when the - * event fires.<br> <strong>obj:</strong> Object, // An object to - * pass back to the handler.<br> <strong>scope:</strong> Object // - * The object to use for the scope of the handler.<br> } </code> - * @type Object - * @default null - */ - this.setAttributeConfig("onclick", { - - value: oAttributes.onclick, - method: this._setOnClick - - }); - - - /** - * @config oninit - * @description Object literal representing the code to be executed when - * the button is initialized. Format:<br> <code> {<br> - * <strong>fn:</strong> Function, // The handler to call when the - * event fires.<br> <strong>obj:</strong> Object, // An object to - * pass back to the handler.<br> <strong>scope:</strong> Object // - * The object to use for the scope of the handler.<br> } </code> - * @type Object - * @default null - */ - this.setAttributeConfig("oninit", { - - value: oAttributes.oninit, - method: this._setOnInit - - }); - -}, - - -/** -* @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("active"); - -}, - - -/** -* @method getMenu -* @description Returns a reference to the button's menu. -* @return {<a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a>} -*/ -getMenu: function() { - - return this._menu; - -}, - - -/** -* @method getForm -* @description Returns a reference to the button's menu. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-40002357">HTMLFormElement</a>} -*/ -getForm: function() { - - return this._button.form; - -}, - - -/** -* @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); - - } - - - oParentNode.removeChild(oElement); - - this.logger.log("Removing from document."); - - delete m_oButtons[this.get("id")]; - - this.logger.log("Destroyed."); - -}, - - -/** -* @method toString -* @description Returns a string representing the button. -* @return {String} -*/ -toString: function() { - - return ("Button " + this.get("id")); - -} - -}); - - -/** -* @method addHiddenFieldsToForm -* @description Searches the specified form and adds hidden fields for instances -* of YAHOO.widget.Button that are of type "radio," "checkbox," "menubutton," -* and "splitbutton." -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-40002357">HTMLFormElement</a>} p_oForm Object reference -* for the form to search. -*/ -YAHOO.widget.Button.addHiddenFieldsToForm = function(p_oForm) { - - var aButtons = Dom.getElementsByClassName("yuibutton", "*", p_oForm), - nButtons = aButtons.length; - - - if(nButtons > 0) { - - YAHOO.log("Form contains " + nButtons + " YUI buttons."); - - var oButton = null, - sType = null, - oMenuItem = null, - oMenu = null; - - for(var i=0; i<nButtons; i++) { - - oButton = m_oButtons[aButtons[i].id]; - - if(oButton) { - - sType = oButton.get("type"); - oMenuItem = oButton.get("selectedMenuItem"); - - - if(sType == "radio" || sType == "checkbox") { - - YAHOO.log("Creating hidden field for button: " + oButton); - - oButton.createHiddenField(); - - } - else if(oMenuItem) { - - oMenu = oButton.getMenu(); - - var oSrcElement = oMenu.srcElement; - - if( - oSrcElement && - oSrcElement.tagName.toUpperCase() == "SELECT" - ) { - - oButton.getForm().appendChild(oSrcElement); - oSrcElement.selectedIndex = oMenuItem.index; - - } - else { - - var oValue = ( - oMenuItem.value === null || - oMenuItem.value === "" - ) ? oMenuItem.cfg.getProperty("text") : - oMenuItem.value; - - if(oValue) { - - var oField = createInputElement( - "hidden", - (oButton.get("name") + "_options"), - oValue - ); - - oButton.getForm().appendChild(oField); - - } - - } - - } - - } - - } - - } - -}; - - - -// 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 <a href=" -* YAHOO.util.Element.html#addListener">Element.addListener</a> 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 <a href=" -* YAHOO.util.Element.html#addListener">Element.addListener</a> 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 <a href=" -* YAHOO.util.Element.html#addListener">Element.addListener</a> for more -* information on listening for this event. -* @type YAHOO.util.CustomEvent -*/ - - -/** -* @event init -* @description Fires when the Button is initialized. Subscribe to this event -* by specifying a value for the "oninit" configuration attribute. Format:<br> -* <code> {<br> <strong>fn:</strong> Function, // The handler to call -* when the event fires.<br> <strong>obj:</strong> Object, // An object -* to pass back to the handler.<br> <strong>scope:</strong> Object // -* The object to use for the scope of the handler.<br> } </code> -* @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 -* <code><div></code> element of the button group. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object -* specifying the <code><div></code> 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; - - if( - arguments.length == 1 && - !Lang.isString(p_oElement) && - !p_oElement.nodeName - ) { - - if(!p_oElement.id) { - - var 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)) { - - var me = this; - - Event.onContentReady(p_oElement, function() { - - if(this.nodeName.toUpperCase() == me.TAG_NAME) { - - me.logger = - new YAHOO.widget.LogWriter("ButtonGroup " + p_oElement); - - fnSuperClass.call(me, this, p_oAttributes); - - } - - }); - - } - else { - - var sNodeName = p_oElement.nodeName; - - if(sNodeName && sNodeName == this.TAG_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, - - -/** -* @property _oninitAttributeValue -* @description Object reference to the button group's current value for the -* "oninit" configuration attribute. -* @default null -* @protected -* @type Object -*/ -_oninitAttributeValue: null, - - - -// Constants - - -/** -* @property TAG_NAME -* @description The name of the tag to be used for the button group's element. -* @default "DIV" -* @final -* @type String -*/ -TAG_NAME: "DIV", - - -/** -* @property CSS_CLASS_NAME -* @description String representing the CSS class(es) to be applied to the -* button group's element. -* @default "yuibuttongroup" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuibuttongroup", - - - -// Protected methods - - -/** -* @method _createGroupElement -* @description Creates the button group's element. -* @protected -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} -*/ -_createGroupElement: function() { - - var oElement = document.createElement(this.TAG_NAME); - - oElement.className = this.CSS_CLASS_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(); - - if(nButtons > 0) { - - var i = nButtons - 1; - - do { - - this._buttons[i].set("disabled", p_bDisabled); - - } - while(i--); - - } - -}, - - -/** -* @method _setOnInit -* @description Sets the value of the button group's "init" attribute. -* @protected -* @param {Object} p_oObject Object indicating the value for the button's -* "oninit" attribute. -*/ -_setOnInit: function(p_oObject) { - - /* - Remove any existing listeners if a "init" event handler has already - been specified. - */ - - if( - this._oninitAttributeValue && - (this._oninitAttributeValue != p_oObject) - ) { - - this.removeListener("init", this._oninitAttributeValue.fn); - - this._oninitAttributeValue = null; - - } - - - if( - !this._oninitAttributeValue && - Lang.isObject(p_oObject) && - Lang.isFunction(p_oObject.fn) - ) { - - this.on("init", p_oObject.fn, p_oObject.obj, p_oObject.scope); - - this._oninitAttributeValue = p_oObject; - - } - -}, - - -// 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; - - for(var 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 {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} 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 -* <code><div></code> element of the button group. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object -* specifying the <code><div></code> 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.logger.log( - "Searching for child nodes with the class name " + - "\"yuibutton\" to add to the button group." - ); - - var aButtons = this.getElementsByClassName("yuibutton"); - - - if(aButtons.length > 0) { - - this.logger.log( - "Found " + aButtons.length + " child nodes with the class " + - "name \"yuibutton.\" 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)) { - - var me = this; - - Event.onContentReady(oContainer, function() { - - me.appendTo(this); - - }); - - } - else { - - this.appendTo(oContainer); - - } - - } - - - this.fireEvent("init"); - - 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 <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|String - * @default null - */ - this.setAttributeConfig("container", { - - value: oAttributes.container - - }); - - - /** - * @config checkedButton - * @description Reference for the button in the button group that - * is checked. - * @type {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} - * @default null - */ - this.setAttributeConfig("checkedButton", { - - value: null - - }); - - - /** - * @config oninit - * @description Object literal representing the code to be executed when - * the button group is initialized. Format:<br> <code> {<br> - * <strong>fn:</strong> Function, // The handler to call when the - * event fires.<br> <strong>obj:</strong> Object, // An object to - * pass back to the handler.<br> <strong>scope:</strong> Object // - * The object to use for the scope of the handler.<br> } </code> - * @type Object - * @default null - */ - this.setAttributeConfig("oninit", { - - value: oAttributes.oninit, - method: this._setOnInit - - }); - -}, - - -/** -* @method addButton -* @description Adds the button to the button group. -* @param {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} p_oButton -* Object reference for the <a href="YAHOO.widget.Button.html"> -* YAHOO.widget.Button</a> instance to be added to the button group. -* @param {String} p_oButton String specifying the id attribute of the -* <code><input></code> or <code><span></code> element to be -* used to create the button to be added to the button group. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>|<a href=" -* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html# -* ID-33759296">HTMLElement</a>} p_oButton Object reference for the -* <code><input></code> or <code><span></code> 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 -* <a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a> configuration -* attributes used to configure the button to be added to the button group. -* @return {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} -*/ -addButton: function(p_oButton) { - - var oButton; - - - 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) { - - var 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); - - } - - - 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 <a href="YAHOO.widget.Button.html"> -* YAHOO.widget.Button</a> instances to be added -* to the button group. -* @param {Array} p_aButtons Array of strings specifying the id attribute of -* the <code><input></code> or <code><span></code> 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 -* <code><input></code> or <code><span></code> 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 -* <a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a> configuration -* attributes used to configure each button to be added to the button group. -* @return {Array} -*/ -addButtons: function(p_aButtons) { - - if(Lang.isArray(p_aButtons)) { - - var nButtons = p_aButtons.length, - oButton, - aButtons = []; - - if(nButtons > 0) { - - for(var 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); - - 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(); - - - var nButtons = this._buttons.length; - - if(nButtons > 0) { - - var 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 {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} -*/ -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; - - if(Lang.isNumber(p_nIndex)) { - - oButton = this._buttons[p_nIndex]; - - if(oButton) { - - oButton.focus(); - - } - - } - else { - - var nButtons = this.getCount(); - - for(var 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; - - if(nButtons > 0) { - - var 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")); - -} - -}); - - - -// Events - - -/** -* @event init -* @description Fires when the button group is initialized. Subscribe to this -* event by specifying a value for the "oninit" configuration attribute. -* Format:<br> <code> {<br> <strong>fn:</strong> Function, // The -* handler to call when the event fires.<br> <strong>obj:</strong> Object, -* // An object to pass back to the handler.<br> <strong>scope:</strong> -* Object // The object to use for the scope of the handler.<br> -* } </code> -* @type YAHOO.util.CustomEvent -*/ - -})(); -YAHOO.register("button", YAHOO.widget.Button, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/button/button-beta-min.js b/interface/web/js/yui/button/button-beta-min.js deleted file mode 100644 index a9827b9f64..0000000000 --- a/interface/web/js/yui/button/button-beta-min.js +++ /dev/null @@ -1,126 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,m_oButtons={},m_oFocusedButton=null;YAHOO.widget.Button=function(p_oElement,p_oAttributes){var fnSuperClass=YAHOO.widget.Button.superclass.constructor;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{var oConfig={element:null,attributes:(p_oAttributes||{})};if(Lang.isString(p_oElement)){var me=this;Event.onAvailable(p_oElement,function(){var sTagName=this.tagName.toUpperCase();if(sTagName==me.TAG_NAME){oConfig.attributes.id=this.id;} -else if(sTagName=="INPUT"&&!oConfig.attributes.id){oConfig.attributes.id=Dom.generateId();} -oConfig.attributes.srcelement=this;initConfig.call(me,oConfig);if(!oConfig.element){oConfig.element=me._createButtonElement(oConfig.attributes.type);} -fnSuperClass.call(me,oConfig.element,oConfig.attributes);});} -else{var sTagName=p_oElement.tagName.toUpperCase();if(sTagName==this.TAG_NAME){if(p_oElement.id){oConfig.attributes.id=p_oElement.id;} -else{oConfig.attributes.id=Dom.generateId();}} -else if(sTagName=="INPUT"&&!oConfig.attributes.id){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);}}};function getFirstElement(p_oElement){var oFirstChild=p_oElement.firstChild;if(oFirstChild){if(oFirstChild.nodeType==1){return oFirstChild;} -else{var oNextSibling=oFirstChild.nextSibling;if(oNextSibling&&oNextSibling.nodeType==1){return oNextSibling;}}}} -function createInputElement(p_sType,p_sName,p_sValue,p_bChecked){var oInput;if(navigator.userAgent.indexOf("MSIE")!=-1){var sInput="<input type=\""+p_sType+"\" name=\""+p_sName+"\"";if(p_bChecked){sInput+=" checked";} -sInput+=">";oInput=document.createElement(sInput);} -else{oInput=document.createElement("input");oInput.name=p_sName;oInput.type=p_sType;if(p_bChecked){oInput.checked=true;}} -oInput.value=p_sValue;return oInput;} -function setAttributesFromSrcElement(p_oElement,p_oAttributes){var me=this;function setAttributeFromDOMAttribute(p_sAttribute){if(!(p_sAttribute in p_oAttributes)){var oAttribute=p_oElement.getAttributeNode(p_sAttribute);if(oAttribute&&("value"in oAttribute)){p_oAttributes[p_sAttribute]=oAttribute.value;}}} -function setFormElementProperties(){setAttributeFromDOMAttribute("type");if(!("disabled"in p_oAttributes)){p_oAttributes.disabled=p_oElement.disabled;} -setAttributeFromDOMAttribute("name");setAttributeFromDOMAttribute("value");setAttributeFromDOMAttribute("title");} -var sSrcElementTagName=p_oElement.tagName.toUpperCase();if(!("label"in p_oAttributes)){var sText=sSrcElementTagName=="INPUT"?p_oElement.value:p_oElement.innerHTML;if(sText&&sText.length>0){p_oAttributes.label=sText;}} -setAttributeFromDOMAttribute("tabindex");setAttributeFromDOMAttribute("accesskey");switch(sSrcElementTagName){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();var oRootNode=p_oElement.parentNode.parentNode;if(Dom.hasClass(oRootNode,"checked")){p_oAttributes.checked=true;} -if(Dom.hasClass(oRootNode,"disabled")){p_oAttributes.disabled=true;} -p_oElement.removeAttribute("name");p_oElement.removeAttribute("value");p_oElement.setAttribute("type","button");break;}} -function initConfig(p_oConfig){var oAttributes=p_oConfig.attributes,oSrcElement=oAttributes.srcelement,sSrcElementTagName=oSrcElement.tagName.toUpperCase();if(sSrcElementTagName==this.TAG_NAME){p_oConfig.element=oSrcElement;var oFirstChild=getFirstElement(p_oConfig.element);Dom.addClass(oFirstChild,"first-child");if(oFirstChild){var oButton=getFirstElement(oFirstChild);if(oButton){var sButtonTagName=oButton.tagName.toUpperCase();if(sButtonTagName=="A"||sButtonTagName=="BUTTON"){setAttributesFromSrcElement.call(this,oButton,oAttributes);}}}} -else if(sSrcElementTagName=="INPUT"){setAttributesFromSrcElement.call(this,oSrcElement,oAttributes);}} -YAHOO.extend(YAHOO.widget.Button,YAHOO.util.Element,{_button:null,_menu:null,_onclickAttributeValue:null,_oninitAttributeValue:null,_activationKeyPressed:false,_activationButtonPressed:false,_hasKeyEventHandlers:false,_hasMouseEventHandlers:false,TAG_NAME:"SPAN",CHECK_ACTIVATION_KEYS:[32],ACTIVATION_KEYS:[13,32],OPTION_AREA_WIDTH:20,CSS_CLASS_NAME:"yuibutton",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=="splitbutton"){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){if(this.get("type")!="link"){var sTitle=p_sTitle;if(!sTitle){var sType=this.get("type");switch(sType){case"radio":sTitle=this.RADIO_DEFAULT_TITLE;break;case"checkbox":sTitle=this.CHECKBOX_DEFAULT_TITLE;break;case"menubutton":sTitle=this.MENUBUTTON_DEFAULT_TITLE;break;case"splitbutton":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.hasFocus()){this.blur();} -this._button.setAttribute("disabled","disabled");this.addClass("disabled");} -else{this._button.removeAttribute("disabled");this.removeClass("disabled");}}},_setAccessKey:function(p_sAccessKey){this._button.accessKey=p_sAccessKey;},_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.addClass("checked");sTitle=(sType=="radio")?this.RADIO_CHECKED_TITLE:this.CHECKBOX_CHECKED_TITLE;} -else{this.removeClass("checked");sTitle=(sType=="radio")?this.RADIO_DEFAULT_TITLE:this.CHECKBOX_DEFAULT_TITLE;} -this.set("title",sTitle);}},_setMenu:function(p_oMenu){var Menu=YAHOO.widget.Menu,oMenu,me=this;if(!Menu){return false;} -function initMenu(){if(oMenu){oMenu.showEvent.subscribe(this._onMenuShow,this,true);oMenu.hideEvent.subscribe(this._onMenuHide,this,true);oMenu.keyDownEvent.subscribe(this._onMenuKeyDown,this,true);oMenu.renderEvent.subscribe(this._onMenuRender,this,true);oMenu.clickEvent.subscribe(this._onMenuClick,this,true);oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded,this,true);var oSrcElement=oMenu.srcElement;if(oSrcElement&&oSrcElement.tagName.toUpperCase()=="SELECT"){oSrcElement.style.display="none";oSrcElement.parentNode.removeChild(oSrcElement);} -this._menu=oMenu;} -else{this._menu.destroy();this._menu=null;}} -if(p_oMenu instanceof Menu){oMenu=p_oMenu;var aItems=oMenu.getItems(),nItems=aItems.length,oItem;if(nItems>0){var i=nItems-1;do{oItem=aItems[i];if(oItem){oItem.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,oItem,this);}} -while(i--);} -initMenu.call(this);} -else if(Lang.isArray(p_oMenu)){this.on("appendTo",function(){oMenu=new Menu(Dom.generateId(),{lazyload:true,itemdata:p_oMenu});initMenu.call(me);});} -else if(Lang.isString(p_oMenu)){Event.onContentReady(p_oMenu,function(){oMenu=new Menu(this,{lazyload:true});initMenu.call(me);});} -else if(p_oMenu&&p_oMenu.nodeName){oMenu=new Menu(p_oMenu,{lazyload:true});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;}},_setOnInit:function(p_oObject){if(this._oninitAttributeValue&&(this._oninitAttributeValue!=p_oObject)){this.removeListener("init",this._oninitAttributeValue.fn);this._oninitAttributeValue=null;} -if(!this._oninitAttributeValue&&Lang.isObject(p_oObject)&&Lang.isFunction(p_oObject.fn)){this.on("init",p_oObject.fn,p_oObject.obj,p_oObject.scope);this._oninitAttributeValue=p_oObject;}},_createButtonElement:function(p_sType){var sTagName=this.TAG_NAME,oElement=document.createElement(sTagName);oElement.innerHTML="<"+sTagName+" class=\"first-child\">"+ -(p_sType=="link"?"<a></a>":"<button type=\"button\"></button>")+"</"+sTagName+">";return oElement;},_isActivationKey:function(p_nKeyCode){var sType=this.get("type"),aKeyCodes=(sType=="checkbox"||sType=="radio")?this.CHECK_ACTIVATION_KEYS:this.ACTIVATION_KEYS,nKeyCodes=aKeyCodes.length;if(nKeyCodes>0){var 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);},_originalMaxHeight:-1,_showMenu:function(){var oMenu=this._menu;if(oMenu){YAHOO.widget.MenuManager.hideVisible();oMenu.cfg.applyConfig({context:[this.get("id"),"tl","bl"],clicktohide:false,constraintoviewport:false,visible:true});oMenu.cfg.fireQueue();var nViewportHeight=Dom.getViewportHeight(),nMenuHeight=oMenu.element.offsetHeight;if((oMenu.cfg.getProperty("y")+nMenuHeight)>nViewportHeight){oMenu.align("bl","tl");var nY=oMenu.cfg.getProperty("y"),nScrollTop=(document.documentElement.scrollTop||document.body.scrollTop);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");}} -oMenu.cfg.setProperty("constraintoviewport",true);}},_hideMenu:function(){var oMenu=this._menu;if(oMenu&&oMenu.cfg.getProperty("visible")){oMenu.hide();}},_submitForm:function(){var oForm=this.getForm();if(oForm){YAHOO.widget.Button.addHiddenFieldsToForm(oForm);this.createHiddenField();oForm.submit();}},_onMouseOver:function(p_oEvent){if(!this.get("disabled")){if(!this._hasMouseEventHandlers){this.on("mouseout",this._onMouseOut);this.on("mousedown",this._onMouseDown);this.on("mouseup",this._onMouseUp);this._hasMouseEventHandlers=true;} -this.addClass("hover");if(this._activationButtonPressed){this.addClass("active");} -if(this._bOptionPressed){this.addClass("activeoption");}}},_onMouseOut:function(p_oEvent){if(!this.get("disabled")){this.removeClass("hover");if(this.get("type")!="menubutton"){this.removeClass("active");} -if(this._activationButtonPressed||this._bOptionPressed){Event.on(document,"mouseup",this._onDocumentMouseUp,this,true);}}},_onDocumentMouseUp:function(p_oEvent,p_oButton){this._activationButtonPressed=false;this._bOptionPressed=false;var sType=this.get("type");if(sType=="menubutton"||sType=="splitbutton"){this.removeClass((sType=="menubutton"?"active":"activeoption"));this._hideMenu();} -Event.removeListener(document,"mouseup",this._onDocumentMouseUp);},_onMouseDown:function(p_oEvent){if(!this.get("disabled")){if((p_oEvent.which||p_oEvent.button)==1){if(!this.hasFocus()){this.focus();} -var sType=this.get("type");if(sType=="splitbutton"){var 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.addClass("active");this._activationButtonPressed=true;}} -else if(sType=="menubutton"){if(this.hasClass("active")){this._hideMenu();this._activationButtonPressed=false;} -else{this._showMenu();this._activationButtonPressed=true;}} -else{this.addClass("active");this._activationButtonPressed=true;} -if(sType=="splitbutton"||sType=="menubutton"){var me=this;function onMouseUp(){me._hideMenu();me.removeListener("mouseup",onMouseUp);} -this._hideMenuTimerId=window.setTimeout(function(){me.on("mouseup",onMouseUp);},250);}}}},_onMouseUp:function(p_oEvent){if(!this.get("disabled")){if(this._hideMenuTimerId){window.clearTimeout(this._hideMenuTimerId);} -var sType=this.get("type");if(sType=="checkbox"||sType=="radio"){this.set("checked",!(this.get("checked")));} -this._activationButtonPressed=false;if(this.get("type")!="menubutton"){this.removeClass("active");}}},_onFocus:function(p_oEvent,p_oButton){if(!this.get("disabled")){this.addClass("focus");if(this._activationKeyPressed){this.addClass("active");} -m_oFocusedButton=this;if(!this._hasKeyEventHandlers){var oElement=this._button;Event.on(oElement,"blur",this._onBlur,this,true);Event.on(oElement,"keydown",this._onKeyDown,this,true);Event.on(oElement,"keyup",this._onKeyUp,this,true);this._hasKeyEventHandlers=true;} -this.fireEvent("focus",p_oEvent);}},_onBlur:function(p_oEvent,p_oButton){if(!this.get("disabled")){this.removeClass("focus");if(this.get("type")!="menubutton"){this.removeClass("active");} -if(this._activationKeyPressed){Event.on(document,"keyup",this._onDocumentKeyUp,this,true);} -m_oFocusedButton=null;this.fireEvent("blur",p_oEvent);}},_onDocumentKeyUp:function(p_oEvent,p_oButton){if(this._isActivationKey(Event.getCharCode(p_oEvent))){this._activationKeyPressed=false;Event.removeListener(document,"keyup",this._onDocumentKeyUp);}},_onKeyDown:function(p_oEvent,p_oButton){if(!this.get("disabled")){if(this.get("type")=="splitbutton"&&this._isSplitButtonOptionKey(p_oEvent)){this.fireEvent("option",p_oEvent);} -else if(this._isActivationKey(Event.getCharCode(p_oEvent))){if(this.get("type")=="menubutton"){this._showMenu();} -else{this._activationKeyPressed=true;this.addClass("active");}} -var oMenu=this._menu;if(oMenu&&oMenu.cfg.getProperty("visible")&&Event.getCharCode(p_oEvent)==27){oMenu.hide();this.focus();}}},_onKeyUp:function(p_oEvent,p_oButton){if(!this.get("disabled")){if(this._isActivationKey(Event.getCharCode(p_oEvent))){var sType=this.get("type");if(sType=="checkbox"||sType=="radio"){this.set("checked",!(this.get("checked")));} -this._activationKeyPressed=false;if(this.get("type")!="menubutton"){this.removeClass("active");}}}},_onClick:function(p_oEvent){var sType=this.get("type"),sTitle;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":var oForm=this.getForm();if(oForm){oForm.reset();} -break;case"menubutton":sTitle=this._menu.cfg.getProperty("visible")?this.MENUBUTTON_MENU_VISIBLE_TITLE:this.MENUBUTTON_DEFAULT_TITLE;this.set("title",sTitle);break;case"splitbutton":var 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();var 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;}},_onAppendTo:function(p_oEvent){var me=this;window.setTimeout(function(){var oForm=me.getForm();if(oForm){Event.on(oForm,"reset",me._onFormReset,me,true);Event.on(oForm,"submit",me._onFormSubmit,me,true);}},0);},_onFormSubmit:function(p_oEvent,p_oButton){var sType=this.get("type"),oMenuItem=this.get("selectedMenuItem"),oForm=this.getForm();if(sType=="radio"||sType=="checkbox"){this.createHiddenField();} -else if(oMenuItem){var oSrcElement=this._menu.srcElement;if(oSrcElement&&oSrcElement.tagName.toUpperCase()=="SELECT"){oForm.appendChild(oSrcElement);oSrcElement.selectedIndex=oMenuItem.index;} -else{var oValue=(oMenuItem.value===null||oMenuItem.value==="")?oMenuItem.cfg.getProperty("text"):oMenuItem.value;if(oValue){var oField=createInputElement("hidden",(this.get("name")+"_options"),oValue);oForm.appendChild(oField);}}}},_onFormReset:function(p_oEvent,p_oButton){var sType=this.get("type");if(sType=="checkbox"||sType=="radio"){this.resetValue("checked");} -if(this._menu){this.resetValue("selectedMenuItem");}},_onDocumentMouseDown:function(p_oEvent,p_oButton){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);}},_onOption:function(p_oEvent){if(this.hasClass("activeoption")){this._hideMenu();this._bOptionPressed=false;} -else{this._showMenu();this._bOptionPressed=true;}},_onMenuShow:function(p_sType,p_aArgs,p_oButton){Event.on(document,"mousedown",this._onDocumentMouseDown,this,true);var sTitle,sClass;if(this.get("type")=="splitbutton"){sTitle=this.SPLITBUTTON_OPTION_VISIBLE_TITLE;sClass="activeoption";} -else{sTitle=this.MENUBUTTON_MENU_VISIBLE_TITLE;sClass="active";} -this.addClass(sClass);this.set("title",sTitle);},_onMenuHide:function(p_sType,p_aArgs,p_oButton){if(this._originalMaxHeight!=-1){this._menu.cfg.setProperty("maxheight",this._originalMaxHeight);} -var sTitle,sClass;if(this.get("type")=="splitbutton"){sTitle=this.SPLITBUTTON_DEFAULT_TITLE;sClass="activeoption";} -else{sTitle=this.MENUBUTTON_DEFAULT_TITLE;sClass="active";} -this.removeClass(sClass);this.set("title",sTitle);},_onMenuKeyDown:function(p_sType,p_aArgs,p_oButton){var oEvent=p_aArgs[0];if(Event.getCharCode(oEvent)==27){this.focus();if(this.get("type")=="splitbutton"){this._bOptionPressed=false;}}},_onMenuRender:function(p_sType,p_aArgs,p_oButton){this.get("element").parentNode.appendChild(this._menu.element);},_onMenuItemSelected:function(p_sType,p_aArgs,p_oItem){this.set("selectedMenuItem",p_oItem);},_onMenuItemAdded:function(p_sType,p_aArgs,p_oItem){var oItem=p_aArgs[0];oItem.cfg.subscribeToConfigEvent("selected",this._onMenuItemSelected,oItem,this);},_onMenuClick:function(p_sType,p_aArgs,p_oButton){var oItem=p_aArgs[0];if(oItem){var oSrcElement=this.get("srcelement");if(oSrcElement&&oSrcElement.type=="submit"){this._submitForm();} -this._hideMenu();}},createHiddenField:function(){if(!this.get("disabled")){var sType=this.get("type"),bCheckable=(sType=="checkbox"||sType=="radio"),oField=createInputElement((bCheckable?this.get("type"):"hidden"),this.get("name"),this.get("value"),this.get("checked")),oForm=this.getForm();if(oField&&bCheckable){oField.style.display="none";} -if(oForm){oForm.appendChild(oField);} -return oField;}},init:function(p_oElement,p_oAttributes){var sTagName=p_oAttributes.type=="link"?"A":"BUTTON",oSrcElement=p_oAttributes.srcelement;this._button=p_oElement.getElementsByTagName(sTagName)[0];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(this.get("type"));Event.on(this._button,"focus",this._onFocus,this,true);this.on("mouseover",this._onMouseOver);this.on("click",this._onClick);this.on("appendTo",this._onAppendTo);var oContainer=this.get("container"),oElement=this.get("element");if(oContainer){if(Lang.isString(oContainer)){var me=this;Event.onContentReady(oContainer,function(){me.appendTo(this);});} -else{this.appendTo(oContainer);}} -else if(!Dom.inDocument(oElement)&&oSrcElement&&oSrcElement.tagName.toUpperCase()=="INPUT"){var 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(Dom.inDocument(oElement)&&oSrcElement.tagName.toUpperCase()=="SPAN"){var oForm=this.getForm();if(oForm){Event.on(oForm,"reset",this._onFormReset,this,true);Event.on(oForm,"submit",this._onFormSubmit,this,true);}} -this.fireEvent("init");},initAttributes:function(p_oAttributes){var oAttributes=p_oAttributes||{};YAHOO.widget.Button.superclass.initAttributes.call(this,oAttributes);this.setAttributeConfig("type",{value:(oAttributes.type||"button"),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});this.setAttributeConfig("srcelement",{value:oAttributes.srcelement,writeOnce:true});this.setAttributeConfig("menu",{value:null,method:this._setMenu});this.setAttributeConfig("selectedMenuItem",{value:null});this.setAttributeConfig("onclick",{value:oAttributes.onclick,method:this._setOnClick});this.setAttributeConfig("oninit",{value:oAttributes.oninit,method:this._setOnInit});},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("active");},getMenu:function(){return this._menu;},getForm:function(){return this._button.form;},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);} -oParentNode.removeChild(oElement);delete m_oButtons[this.get("id")];},toString:function(){return("Button "+this.get("id"));}});YAHOO.widget.Button.addHiddenFieldsToForm=function(p_oForm){var aButtons=Dom.getElementsByClassName("yuibutton","*",p_oForm),nButtons=aButtons.length;if(nButtons>0){var oButton=null,sType=null,oMenuItem=null,oMenu=null;for(var i=0;i<nButtons;i++){oButton=m_oButtons[aButtons[i].id];if(oButton){sType=oButton.get("type");oMenuItem=oButton.get("selectedMenuItem");if(sType=="radio"||sType=="checkbox"){oButton.createHiddenField();} -else if(oMenuItem){oMenu=oButton.getMenu();var oSrcElement=oMenu.srcElement;if(oSrcElement&&oSrcElement.tagName.toUpperCase()=="SELECT"){oButton.getForm().appendChild(oSrcElement);oSrcElement.selectedIndex=oMenuItem.index;} -else{var oValue=(oMenuItem.value===null||oMenuItem.value==="")?oMenuItem.cfg.getProperty("text"):oMenuItem.value;if(oValue){var oField=createInputElement("hidden",(oButton.get("name")+"_options"),oValue);oButton.getForm().appendChild(oField);}}}}}}};})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang,Button=YAHOO.widget.Button;m_oButtons={};YAHOO.widget.ButtonGroup=function(p_oElement,p_oAttributes){var fnSuperClass=YAHOO.widget.ButtonGroup.superclass.constructor;if(arguments.length==1&&!Lang.isString(p_oElement)&&!p_oElement.nodeName){if(!p_oElement.id){var sId=Dom.generateId();p_oElement.id=sId;} -fnSuperClass.call(this,(this._createGroupElement()),p_oElement);} -else if(Lang.isString(p_oElement)){var me=this;Event.onContentReady(p_oElement,function(){if(this.nodeName.toUpperCase()==me.TAG_NAME){fnSuperClass.call(me,this,p_oAttributes);}});} -else{var sNodeName=p_oElement.nodeName;if(sNodeName&&sNodeName==this.TAG_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,{_buttons:null,_oninitAttributeValue:null,TAG_NAME:"DIV",CSS_CLASS_NAME:"yuibuttongroup",_createGroupElement:function(){var oElement=document.createElement(this.TAG_NAME);oElement.className=this.CSS_CLASS_NAME;return oElement;},_setDisabled:function(p_bDisabled){var nButtons=this.getCount();if(nButtons>0){var i=nButtons-1;do{this._buttons[i].set("disabled",p_bDisabled);} -while(i--);}},_setOnInit:function(p_oObject){if(this._oninitAttributeValue&&(this._oninitAttributeValue!=p_oObject)){this.removeListener("init",this._oninitAttributeValue.fn);this._oninitAttributeValue=null;} -if(!this._oninitAttributeValue&&Lang.isObject(p_oObject)&&Lang.isFunction(p_oObject.fn)){this.on("init",p_oObject.fn,p_oObject.obj,p_oObject.scope);this._oninitAttributeValue=p_oObject;}},_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;for(var i=0;i<nButtons;i++){aButtons[i].appendTo(this.get("element"));}},_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);}},init:function(p_oElement,p_oAttributes){this._buttons=[];YAHOO.widget.ButtonGroup.superclass.init.call(this,p_oElement,p_oAttributes);var aButtons=this.getElementsByClassName("yuibutton");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)){var me=this;Event.onContentReady(oContainer,function(){me.appendTo(this);});} -else{this.appendTo(oContainer);}} -this.fireEvent("init");},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});this.setAttributeConfig("checkedButton",{value:null});this.setAttributeConfig("oninit",{value:oAttributes.oninit,method:this._setOnInit});},addButton:function(p_oButton){var oButton;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){var 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);} -oButton.on("checkedChange",this._onButtonCheckedChange,oButton,this);return oButton;}},addButtons:function(p_aButtons){if(Lang.isArray(p_aButtons)){var nButtons=p_aButtons.length,oButton,aButtons=[];if(nButtons>0){for(var i=0;i<nButtons;i++){oButton=this.addButton(p_aButtons[i]);if(oButton){aButtons[aButtons.length]=oButton;}} -if(aButtons.length>0){return aButtons;}}}},removeButton:function(p_nIndex){var oButton=this.getButton(p_nIndex);if(oButton){this._buttons.splice(p_nIndex,1);delete m_oButtons[oButton.get("id")];oButton.removeListener("checkedChange",this._onButtonCheckedChange);oButton.destroy();var nButtons=this._buttons.length;if(nButtons>0){var 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;if(Lang.isNumber(p_nIndex)){oButton=this._buttons[p_nIndex];if(oButton){oButton.focus();}} -else{var nButtons=this.getCount();for(var i=0;i<nButtons;i++){oButton=this._buttons[i];if(!oButton.get("disabled")){oButton.focus();break;}}}},check:function(p_nIndex){var oButton=this.getButton(p_nIndex);if(oButton){oButton.set("checked",true);}},destroy:function(){var nButtons=this._buttons.length,oElement=this.get("element"),oParentNode=oElement.parentNode;if(nButtons>0){var 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.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/button/button-beta.js b/interface/web/js/yui/button/button-beta.js deleted file mode 100644 index f3082d99b7..0000000000 --- a/interface/web/js/yui/button/button-beta.js +++ /dev/null @@ -1,3949 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** -* @module button -* @description <p>The Button Control enables the creation of rich, graphical -* buttons that function like traditional HTML form buttons. <em>Unlike</em> -* 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 -* <a href="module_menu.html">Menu Control</a>, 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.</p> -* <p>The Button Control supports the following types:</p> -* <dl> -* <dt>button</dt> -* <dd>Basic push button that can execute a user-specified command when -* pressed.</dd> -* <dt>link</dt> -* <dd>Navigates to a specified url when pressed.</dd> -* <dt>submit</dt> -* <dd>Submits the parent form when pressed.</dd> -* <dt>reset</dt> -* <dd>Resets the parent form when pressed.</dd> -* <dt>checkbox</dt> -* <dd>Maintains a "checked" state that can be toggled on and off.</dd> -* <dt>radio</dt> -* <dd>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.</dd> -* <dt>menubutton</dt> -* <dd>When pressed will show/hide a menu.</dd> -* <dt>splitbutton</dt> -* <dd>Can execute a user-specified command or display a menu when pressed.</dd> -* </dl> -* @title Button -* @namespace YAHOO.widget -* @requires yahoo, dom, element, event -* @optional container, menu -* @beta -*/ - - -(function() { - -// Shorthard for utilities - -var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event, - Lang = YAHOO.lang, - - - // Private member variables - - m_oButtons = {}, - m_oFocusedButton = null; - - - -// Constructor - - -/** -* The Button class creates a rich, graphical button. -* @param {String} p_oElement String specifying the id attribute of the -* <code><input></code>, <code><a></code> or -* <code><span></code> element to be used to create the button. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>|<a href=" -* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html# -* ID-33759296">HTMLElement</a>} p_oElement Object reference for the -* <code><input></code>, <code><a></code> or -* <code><span></code> 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 -*/ -YAHOO.widget.Button = function(p_oElement, p_oAttributes) { - - var fnSuperClass = YAHOO.widget.Button.superclass.constructor; - - 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 { - - var oConfig = { - - element: null, - attributes: (p_oAttributes || {}) - - }; - - - if(Lang.isString(p_oElement)) { - - var me = this; - - Event.onAvailable(p_oElement, function() { - - var sTagName = this.tagName.toUpperCase(); - - if(sTagName == me.TAG_NAME) { - - oConfig.attributes.id = this.id; - - } - else if(sTagName == "INPUT" && !oConfig.attributes.id) { - - oConfig.attributes.id = Dom.generateId(); - - - } - - - - - oConfig.attributes.srcelement = this; - - initConfig.call(me, oConfig); - - - if(!oConfig.element) { - - - oConfig.element = - me._createButtonElement(oConfig.attributes.type); - - } - - fnSuperClass.call(me, oConfig.element, oConfig.attributes); - - }); - - } - else { - - var sTagName = p_oElement.tagName.toUpperCase(); - - if(sTagName == this.TAG_NAME) { - - if(p_oElement.id) { - - oConfig.attributes.id = p_oElement.id; - - } - else { - - oConfig.attributes.id = Dom.generateId(); - - - } - - - } - else if(sTagName == "INPUT" && !oConfig.attributes.id) { - - 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); - - } - - } - -}; - - - -// Private methods - - -/** -* @method getFirstElement -* @description Returns an HTML element's first HTML element node. -* @private -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-58190037">HTMLElement</a>} p_oElement Object -* reference specifying the element to be evaluated. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-58190037">HTMLElement</a>} -*/ -function getFirstElement(p_oElement) { - - var oFirstChild = p_oElement.firstChild; - - if(oFirstChild) { - - if(oFirstChild.nodeType == 1) { - - return oFirstChild; - - } - else { - - var oNextSibling = oFirstChild.nextSibling; - - if(oNextSibling && oNextSibling.nodeType == 1) { - - return oNextSibling; - - } - - } - - } - -} - - -/** -* @method createInputElement -* @description Creates an <code><input></code> element of the -* specified type. -* @private -* @param {String} p_sType String specifying the type of -* <code><input></code> element to create. -* @param {String} p_sName String specifying the name of -* <code><input></code> element to create. -* @param {String} p_sValue String specifying the value of -* <code><input></code> element to create. -* @param {String} p_bChecked Boolean specifying if the -* <code><input></code> element is to be checked. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>} -*/ -function createInputElement(p_sType, p_sName, p_sValue, p_bChecked) { - - var oInput; - - if(navigator.userAgent.indexOf("MSIE") != -1) { - - /* - For IE it is necessary to create the element with the - "type," "name," "value," and "checked" properties set all at once. - */ - - var sInput = "<input type=\"" + p_sType + "\" name=\"" + p_sName + "\""; - - if(p_bChecked) { - - sInput += " checked"; - - } - - sInput += ">"; - - oInput = document.createElement(sInput); - - } - else { - - oInput = document.createElement("input"); - oInput.name = p_sName; - oInput.type = p_sType; - - if(p_bChecked) { - - oInput.checked = true; - - } - - } - - oInput.value = p_sValue; - - return oInput; - -} - - -/** -* @method setAttributesFromSrcElement -* @description Gets the values for all the attributes of the source element -* (either <code><input></code> or <code><a></code>) that map to -* Button configuration attributes and sets them into a collection that is -* passed to the Button constructor. -* @private -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>|<a href="http://www.w3.org/ -* TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID- -* 48250443">HTMLAnchorElement</a>} p_oElement Object reference to the HTML -* element (either <code><input></code> or <code><span></code>) -* 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 me = this; - - /** - * @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 <code><button></code> for the value attribute rather - than the value of the "value" attribute. - */ - - var 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( !("disabled" in p_oAttributes) ) { - - p_oAttributes.disabled = p_oElement.disabled; - - } - - setAttributeFromDOMAttribute("name"); - setAttributeFromDOMAttribute("value"); - setAttributeFromDOMAttribute("title"); - - } - - - var sSrcElementTagName = p_oElement.tagName.toUpperCase(); - - - if( !("label" in p_oAttributes) ) { - - // Set the "label" property - - var sText = sSrcElementTagName == "INPUT" ? - p_oElement.value : p_oElement.innerHTML; - - - if(sText && sText.length > 0) { - - p_oAttributes.label = sText; - - } - - } - - - setAttributeFromDOMAttribute("tabindex"); - setAttributeFromDOMAttribute("accesskey"); - - - switch(sSrcElementTagName) { - - 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(); - - var oRootNode = p_oElement.parentNode.parentNode; - - if(Dom.hasClass(oRootNode, "checked")) { - - p_oAttributes.checked = true; - - } - - if(Dom.hasClass(oRootNode, "disabled")) { - - p_oAttributes.disabled = true; - - } - - p_oElement.removeAttribute("name"); - p_oElement.removeAttribute("value"); - - p_oElement.setAttribute("type", "button"); - - break; - - } - -} - - -/** -* @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, - sSrcElementTagName = oSrcElement.tagName.toUpperCase(); - - - if(sSrcElementTagName == this.TAG_NAME) { - - p_oConfig.element = oSrcElement; - - var oFirstChild = getFirstElement(p_oConfig.element); - - Dom.addClass(oFirstChild, "first-child"); - - if(oFirstChild) { - - var oButton = getFirstElement(oFirstChild); - - - if(oButton) { - - var sButtonTagName = oButton.tagName.toUpperCase(); - - - if(sButtonTagName == "A" || sButtonTagName == "BUTTON") { - - setAttributesFromSrcElement.call( - this, - oButton, - oAttributes - ); - - } - - } - - } - - } - else if(sSrcElementTagName == "INPUT") { - - setAttributesFromSrcElement.call(this, oSrcElement, oAttributes); - - } - -} - - -YAHOO.extend(YAHOO.widget.Button, YAHOO.util.Element, { - - -// Protected properties - - -/** -* @property _button -* @description Object reference to the button's internal -* <code><a></code> or <code><button></code> element. -* @default null -* @protected -* @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-48250443">HTMLAnchorElement</a>|<a href=" -* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID- -* 34812697">HTMLButtonElement</a> -*/ -_button: null, - - -/** -* @property _menu -* @description Object reference to the button's menu. -* @default null -* @protected -* @type <a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a> -*/ -_menu: 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 _oninitAttributeValue -* @description Object reference to the button's current value for the "oninit" -* configuration attribute. -* @default null -* @protected -* @type Object -*/ -_oninitAttributeValue: 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" and "mousedown" -* and "mouseup" event handlers are assigned -* @default false -* @protected -* @type Boolean -*/ -_hasMouseEventHandlers: false, - - - -// Constants - - -/** -* @property TAG_NAME -* @description The name of the tag to be used for the button's root element. -* @default "SPAN" -* @final -* @type String -*/ -TAG_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 "yuibutton" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuibutton", - - -/** -* @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 "menubutton." -* @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 -* "menubutton" 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 "splitebutton." -* @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 -* "splitbutton" 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 == "splitbutton") { - - 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) { - - if(this.get("type") != "link") { - - var sTitle = p_sTitle; - - if(!sTitle) { - - - var sType = this.get("type"); - - switch(sType) { - - case "radio": - - sTitle = this.RADIO_DEFAULT_TITLE; - - break; - - case "checkbox": - - sTitle = this.CHECKBOX_DEFAULT_TITLE; - - break; - - case "menubutton": - - sTitle = this.MENUBUTTON_DEFAULT_TITLE; - - break; - - case "splitbutton": - - 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.hasFocus()) { - - this.blur(); - - } - - this._button.setAttribute("disabled", "disabled"); - - this.addClass("disabled"); - - } - else { - - this._button.removeAttribute("disabled"); - - this.removeClass("disabled"); - - } - - } - -}, - - -/** -* @method _setAccessKey -* @description Sets the value of the button's "accesskey" attribute. -* @protected -* @param {String} p_sAccessKey String indicating the value for the button's -* "accesskey" attribute. -*/ -_setAccessKey: function(p_sAccessKey) { - - this._button.accessKey = p_sAccessKey; - -}, - - -/** -* @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.addClass("checked"); - - sTitle = (sType == "radio") ? - this.RADIO_CHECKED_TITLE : - this.CHECKBOX_CHECKED_TITLE; - - } - else { - - this.removeClass("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 Menu = YAHOO.widget.Menu, - oMenu, - me = this; - - if(!Menu) { - - - return false; - - } - - - function initMenu() { - - if(oMenu) { - - oMenu.showEvent.subscribe(this._onMenuShow, this, true); - oMenu.hideEvent.subscribe(this._onMenuHide, this, true); - oMenu.keyDownEvent.subscribe(this._onMenuKeyDown, this, true); - oMenu.renderEvent.subscribe(this._onMenuRender, this, true); - oMenu.clickEvent.subscribe(this._onMenuClick, this, true); - oMenu.itemAddedEvent.subscribe(this._onMenuItemAdded, this, true); - - var oSrcElement = oMenu.srcElement; - - if(oSrcElement && oSrcElement.tagName.toUpperCase() == "SELECT") { - - oSrcElement.style.display = "none"; - oSrcElement.parentNode.removeChild(oSrcElement); - - } - - this._menu = oMenu; - - } - else { - - this._menu.destroy(); - this._menu = null; - - } - - } - - - if(p_oMenu instanceof Menu) { - - oMenu = p_oMenu; - - var aItems = oMenu.getItems(), - nItems = aItems.length, - oItem; - - if(nItems > 0) { - - var i = nItems - 1; - - do { - - oItem = aItems[i]; - - if(oItem) { - - oItem.cfg.subscribeToConfigEvent( - "selected", - this._onMenuItemSelected, - oItem, - this - ); - - } - - } - while(i--); - - } - - initMenu.call(this); - - } - else if(Lang.isArray(p_oMenu)) { - - this.on("appendTo", function() { - - oMenu = new Menu( - Dom.generateId(), - { lazyload: true, itemdata: p_oMenu } - ); - - initMenu.call(me); - - }); - - } - else if(Lang.isString(p_oMenu)) { - - Event.onContentReady(p_oMenu, function() { - - oMenu = new Menu(this, { lazyload: true }); - - initMenu.call(me); - - }); - - } - else if(p_oMenu && p_oMenu.nodeName) { - - oMenu = new Menu(p_oMenu, { lazyload: true }); - - 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 _setOnInit -* @description Sets the value of the button's "init" attribute. -* @protected -* @param {Object} p_oObject Object indicating the value for the button's -* "oninit" attribute. -*/ -_setOnInit: function(p_oObject) { - - /* - Remove any existing listeners if a "init" event handler has already - been specified. - */ - - if( - this._oninitAttributeValue && - (this._oninitAttributeValue != p_oObject) - ) { - - this.removeListener("init", this._oninitAttributeValue.fn); - - this._oninitAttributeValue = null; - - } - - - if( - !this._oninitAttributeValue && - Lang.isObject(p_oObject) && - Lang.isFunction(p_oObject.fn) - ) { - - this.on("init", p_oObject.fn, p_oObject.obj, p_oObject.scope); - - this._oninitAttributeValue = p_oObject; - - } - -}, - - - -// Protected methods - - -/** -* @method _createButtonElement -* @description Creates the button's element. -* @protected -* @param {String} p_sType String indicating the type of element to create. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-58190037">HTMLElement</a>} -*/ -_createButtonElement: function(p_sType) { - - var sTagName = this.TAG_NAME, - oElement = document.createElement(sTagName); - - oElement.innerHTML = - - "<" + sTagName + " class=\"first-child\">" + - (p_sType == "link" ? "<a></a>" : "<button type=\"button\"></button>") + - "</" + sTagName + ">"; - - return oElement; - -}, - - -/** -* @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; - - if(nKeyCodes > 0) { - - var 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. -* @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 - ); - -}, - - -_originalMaxHeight: -1, - - -/** -* @method _showMenu -* @description Shows the button's menu. -* @protected -*/ -_showMenu: function() { - - var oMenu = this._menu; - - if(oMenu) { - - YAHOO.widget.MenuManager.hideVisible(); - - oMenu.cfg.applyConfig({ - context:[this.get("id"), "tl", "bl"], - clicktohide: false, - constraintoviewport: false, - visible: true - }); - - oMenu.cfg.fireQueue(); - - var nViewportHeight = Dom.getViewportHeight(), - nMenuHeight = oMenu.element.offsetHeight; - - - if((oMenu.cfg.getProperty("y") + nMenuHeight) > nViewportHeight) { - - - oMenu.align("bl", "tl"); - - var nY = oMenu.cfg.getProperty("y"), - - nScrollTop = ( - document.documentElement.scrollTop || - document.body.scrollTop - ); - - - 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"); - - } - - } - - oMenu.cfg.setProperty("constraintoviewport", true); - - } - -}, - - -/** -* @method _hideMenu -* @description Hides the button's menu. -* @protected -*/ -_hideMenu: function() { - - var oMenu = this._menu; - - if(oMenu && oMenu.cfg.getProperty("visible")) { - - oMenu.hide(); - - } - -}, - - -/** -* @method _submitForm -* @description Submits the form to which the button belongs. -* @protected -*/ -_submitForm: function() { - - var oForm = this.getForm(); - - if(oForm) { - - YAHOO.widget.Button.addHiddenFieldsToForm(oForm); - - this.createHiddenField(); - - oForm.submit(); - - } - -}, - - - -// 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.get("disabled")) { - - if(!this._hasMouseEventHandlers) { - - this.on("mouseout", this._onMouseOut); - this.on("mousedown", this._onMouseDown); - this.on("mouseup", this._onMouseUp); - - this._hasMouseEventHandlers = true; - - } - - this.addClass("hover"); - - if(this._activationButtonPressed) { - - this.addClass("active"); - - } - - - if(this._bOptionPressed) { - - this.addClass("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) { - - if(!this.get("disabled")) { - - this.removeClass("hover"); - - if(this.get("type") != "menubutton") { - - this.removeClass("active"); - - } - - if(this._activationButtonPressed || this._bOptionPressed) { - - Event.on(document, "mouseup", this._onDocumentMouseUp, this, true); - - } - - } - -}, - - -/** -* @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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onDocumentMouseUp: function(p_oEvent, p_oButton) { - - this._activationButtonPressed = false; - this._bOptionPressed = false; - - var sType = this.get("type"); - - if(sType == "menubutton" || sType == "splitbutton") { - - this.removeClass((sType == "menubutton" ? "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) { - - if(!this.get("disabled")) { - - if((p_oEvent.which || p_oEvent.button) == 1) { - - if(!this.hasFocus()) { - - this.focus(); - - } - - - var sType = this.get("type"); - - - if(sType == "splitbutton") { - - var 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.addClass("active"); - - this._activationButtonPressed = true; - - } - - } - else if(sType == "menubutton") { - - if(this.hasClass("active")) { - - this._hideMenu(); - - this._activationButtonPressed = false; - - } - else { - - this._showMenu(); - - this._activationButtonPressed = true; - - } - - } - else { - - this.addClass("active"); - - this._activationButtonPressed = true; - - } - - - - if(sType == "splitbutton" || sType == "menubutton") { - - var me = this; - - - function onMouseUp() { - - me._hideMenu(); - me.removeListener("mouseup", onMouseUp); - - } - - - 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) { - - if(!this.get("disabled")) { - - - if(this._hideMenuTimerId) { - - window.clearTimeout(this._hideMenuTimerId); - - } - - var sType = this.get("type"); - - if(sType == "checkbox" || sType == "radio") { - - this.set("checked", !(this.get("checked"))); - - } - - - this._activationButtonPressed = false; - - - if(this.get("type") != "menubutton") { - - this.removeClass("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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button that -* fired the event. -*/ -_onFocus: function(p_oEvent, p_oButton) { - - if(!this.get("disabled")) { - - this.addClass("focus"); - - if(this._activationKeyPressed) { - - this.addClass("active"); - - } - - m_oFocusedButton = this; - - - if(!this._hasKeyEventHandlers) { - - var oElement = this._button; - - Event.on(oElement, "blur", this._onBlur, this, true); - Event.on(oElement, "keydown", this._onKeyDown, this, true); - Event.on(oElement, "keyup", this._onKeyUp, this, true); - - 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onBlur: function(p_oEvent, p_oButton) { - - if(!this.get("disabled")) { - - this.removeClass("focus"); - - if(this.get("type") != "menubutton") { - - this.removeClass("active"); - - } - - if(this._activationKeyPressed) { - - Event.on(document, "keyup", this._onDocumentKeyUp, this, true); - - } - - - 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onDocumentKeyUp: function(p_oEvent, p_oButton) { - - 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onKeyDown: function(p_oEvent, p_oButton) { - - if(!this.get("disabled")) { - - if( - this.get("type") == "splitbutton" && - this._isSplitButtonOptionKey(p_oEvent) - ) { - - this.fireEvent("option", p_oEvent); - - } - else if(this._isActivationKey(Event.getCharCode(p_oEvent))) { - - if(this.get("type") == "menubutton") { - - this._showMenu(); - - } - else { - - this._activationKeyPressed = true; - - this.addClass("active"); - - } - - } - - - var oMenu = this._menu; - - 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onKeyUp: function(p_oEvent, p_oButton) { - - if(!this.get("disabled")) { - - if(this._isActivationKey(Event.getCharCode(p_oEvent))) { - - var sType = this.get("type"); - - if(sType == "checkbox" || sType == "radio") { - - this.set("checked", !(this.get("checked"))); - - } - - this._activationKeyPressed = false; - - if(this.get("type") != "menubutton") { - - this.removeClass("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; - - 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": - - var oForm = this.getForm(); - - if(oForm) { - - oForm.reset(); - - } - - break; - - case "menubutton": - - sTitle = this._menu.cfg.getProperty("visible") ? - this.MENUBUTTON_MENU_VISIBLE_TITLE : - this.MENUBUTTON_DEFAULT_TITLE; - - this.set("title", sTitle); - - break; - - case "splitbutton": - - var 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(); - - var 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() { - - var oForm = me.getForm(); - - if(oForm) { - - Event.on(oForm, "reset", me._onFormReset, me, true); - Event.on(oForm, "submit", me._onFormSubmit, me, true); - - } - - }, 0); - -}, - - -/** -* @method _onFormSubmit -* @description "submit" 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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onFormSubmit: function(p_oEvent, p_oButton) { - - var sType = this.get("type"), - oMenuItem = this.get("selectedMenuItem"), - oForm = this.getForm(); - - - if(sType == "radio" || sType == "checkbox") { - - - this.createHiddenField(); - - } - else if(oMenuItem) { - - var oSrcElement = this._menu.srcElement; - - if(oSrcElement && oSrcElement.tagName.toUpperCase() == "SELECT") { - - oForm.appendChild(oSrcElement); - oSrcElement.selectedIndex = oMenuItem.index; - - } - else { - - var oValue = (oMenuItem.value === null || oMenuItem.value === "") ? - oMenuItem.cfg.getProperty("text") : - oMenuItem.value; - - - if(oValue) { - - var oField = createInputElement( - "hidden", - (this.get("name") + "_options"), - oValue - ); - - oForm.appendChild(oField); - - } - - } - - } - -}, - - -/** -* @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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onFormReset: function(p_oEvent, p_oButton) { - - var sType = this.get("type"); - - if(sType == "checkbox" || sType == "radio") { - - this.resetValue("checked"); - - } - - if(this._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). -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onDocumentMouseDown: function(p_oEvent, p_oButton) { - - 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("activeoption")) { - - this._hideMenu(); - - this._bOptionPressed = false; - - } - else { - - this._showMenu(); - - this._bOptionPressed = true; - - } - -}, - - -/** -* @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. -* @param {Array} p_aArgs Array of arguments sent when the event was fired. -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onMenuShow: function(p_sType, p_aArgs, p_oButton) { - - Event.on(document, "mousedown", this._onDocumentMouseDown, this, true); - - var sTitle, - sClass; - - if(this.get("type") == "splitbutton") { - - sTitle = this.SPLITBUTTON_OPTION_VISIBLE_TITLE; - sClass = "activeoption"; - - } - else { - - sTitle = this.MENUBUTTON_MENU_VISIBLE_TITLE; - sClass = "active"; - - } - - this.addClass(sClass); - 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. -* @param {Array} p_aArgs Array of arguments sent when the event was fired. -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onMenuHide: function(p_sType, p_aArgs, p_oButton) { - - if(this._originalMaxHeight != -1) { - - this._menu.cfg.setProperty("maxheight", this._originalMaxHeight); - - } - - - var sTitle, - sClass; - - if(this.get("type") == "splitbutton") { - - sTitle = this.SPLITBUTTON_DEFAULT_TITLE; - sClass = "activeoption"; - - } - else { - - sTitle = this.MENUBUTTON_DEFAULT_TITLE; - sClass = "active"; - } - - - this.removeClass(sClass); - this.set("title", sTitle); - -}, - - -/** -* @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. -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onMenuKeyDown: function(p_sType, p_aArgs, p_oButton) { - - var oEvent = p_aArgs[0]; - - if(Event.getCharCode(oEvent) == 27) { - - this.focus(); - - if(this.get("type") == "splitbutton") { - - 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 that -* was fired. -* @param {Array} p_aArgs Array of arguments sent when the event was fired. -* @param {YAHOO.widget.Button} p_oButton Object representing the button. -*/ -_onMenuRender: function(p_sType, p_aArgs, p_oButton) { - - this.get("element").parentNode.appendChild(this._menu.element); - -}, - - -/** -* @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 {<a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a>} -* p_oItem Object representing the menu item that subscribed to the event. -*/ -_onMenuItemSelected: function(p_sType, p_aArgs, p_oItem) { - - this.set("selectedMenuItem", p_oItem); - -}, - - -/** -* @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 {<a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a>} -* 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, - 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. -* @param {YAHOO.widget.Button} p_oButton Object representing the menu's button. -*/ -_onMenuClick: function(p_sType, p_aArgs, p_oButton) { - - var oItem = p_aArgs[0]; - - if(oItem) { - - var oSrcElement = this.get("srcelement"); - - if(oSrcElement && oSrcElement.type == "submit") { - - this._submitForm(); - - } - - this._hideMenu(); - - } - -}, - - - -// Public methods - - -/** -* @method createHiddenField -* @description Creates the button's hidden form field and appends it to its -* parent form. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>} -*/ -createHiddenField: function () { - - if(!this.get("disabled")) { - - var sType = this.get("type"), - - bCheckable = (sType == "checkbox" || sType == "radio"), - - oField = createInputElement( - (bCheckable ? this.get("type") : "hidden"), - this.get("name"), - this.get("value"), - this.get("checked") - ), - - oForm = this.getForm(); - - - if(oField && bCheckable) { - - oField.style.display = "none"; - - } - - - if(oForm) { - - oForm.appendChild(oField); - - } - - - return oField; - - } - -}, - - -/** -* @method init -* @description The Button class's initialization method. -* @param {String} p_oElement String specifying the id attribute of the -* <code><input></code>, <code><a></code> or -* <code><span></code> element to be used to create the button. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>|<a href=" -* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html# -* ID-33759296">HTMLElement</a>} p_oElement Object reference for the -* <code><input></code>, <code><a></code> or -* <code><span></code> 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 sTagName = p_oAttributes.type == "link" ? "A" : "BUTTON", - oSrcElement = p_oAttributes.srcelement; - - - this._button = p_oElement.getElementsByTagName(sTagName)[0]; - - - 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(this.get("type")); - - Event.on(this._button, "focus", this._onFocus, this, true); - this.on("mouseover", this._onMouseOver); - this.on("click", this._onClick); - this.on("appendTo", this._onAppendTo); - - var oContainer = this.get("container"), - oElement = this.get("element"); - - - if(oContainer) { - - if(Lang.isString(oContainer)) { - - var me = this; - - Event.onContentReady(oContainer, function() { - - me.appendTo(this); - - }); - - } - else { - - this.appendTo(oContainer); - - } - - } - else if( - !Dom.inDocument(oElement) && - oSrcElement && - oSrcElement.tagName.toUpperCase() == "INPUT" - ) { - - var 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( - Dom.inDocument(oElement) && - oSrcElement.tagName.toUpperCase() == "SPAN" - ) { - - var oForm = this.getForm(); - - if(oForm) { - - Event.on(oForm, "reset", this._onFormReset, this, true); - Event.on(oForm, "submit", this._onFormSubmit, this, true); - - } - - } - - this.fireEvent("init"); - - -}, - - -/** -* @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: - * "button," "link," "submit," "reset," "checkbox," "radio," "menubutton," - * and "splitbutton." - * @default "button" - * @type String - */ - this.setAttributeConfig("type", { - - value: (oAttributes.type || "button"), - 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.) - * @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 <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|String - * @default null - */ - this.setAttributeConfig("container", { - - value: oAttributes.container - - }); - - - /** - * @config srcelement - * @description Object reference to the HTML element (either - * <code><input></code> or <code><span></code>) used to - * create the button. - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|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: - * <ul> - * <li>Object specifying a <a href="YAHOO.widget.Menu.html"> - * YAHOO.widget.Menu</a> instance.</li> - * <li>String specifying the id attribute of the <code><div></code> - * element used to create the menu.</li> - * <li>String specifying the id attribute of the - * <code><select></code> element used to create the menu.</li> - * <li>Object specifying the <code><div></code> element used to - * create the menu.</li> - * <li>Object specifying the <code><select></code> element used to - * create the menu.</li> - * <li>Array of object literals, each representing a set of - * <a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a> - * configuration attributes.</li> - * <li>Array of strings representing the text labels for each menu item in - * the menu.</li> - * </ul> - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|String|Array - * @default null - */ - this.setAttributeConfig("menu", { - - value: null, - method: this._setMenu - - }); - - - /** - * @config selectedMenuItem - * @description Reference to the item in the button's menu that is - * currently selected. - * @type <a href="YAHOO.widget.MenuItem.html">YAHOO.widget.MenuItem</a> - * @default null - */ - this.setAttributeConfig("selectedMenuItem", { - - value: null - - }); - - - /** - * @config onclick - * @description Object literal representing the code to be executed when - * the button is clicked. Format:<br> <code> {<br> - * <strong>fn:</strong> Function, // The handler to call when the - * event fires.<br> <strong>obj:</strong> Object, // An object to - * pass back to the handler.<br> <strong>scope:</strong> Object // - * The object to use for the scope of the handler.<br> } </code> - * @type Object - * @default null - */ - this.setAttributeConfig("onclick", { - - value: oAttributes.onclick, - method: this._setOnClick - - }); - - - /** - * @config oninit - * @description Object literal representing the code to be executed when - * the button is initialized. Format:<br> <code> {<br> - * <strong>fn:</strong> Function, // The handler to call when the - * event fires.<br> <strong>obj:</strong> Object, // An object to - * pass back to the handler.<br> <strong>scope:</strong> Object // - * The object to use for the scope of the handler.<br> } </code> - * @type Object - * @default null - */ - this.setAttributeConfig("oninit", { - - value: oAttributes.oninit, - method: this._setOnInit - - }); - -}, - - -/** -* @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("active"); - -}, - - -/** -* @method getMenu -* @description Returns a reference to the button's menu. -* @return {<a href="YAHOO.widget.Menu.html">YAHOO.widget.Menu</a>} -*/ -getMenu: function() { - - return this._menu; - -}, - - -/** -* @method getForm -* @description Returns a reference to the button's menu. -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-40002357">HTMLFormElement</a>} -*/ -getForm: function() { - - return this._button.form; - -}, - - -/** -* @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); - - } - - - oParentNode.removeChild(oElement); - - - delete m_oButtons[this.get("id")]; - - -}, - - -/** -* @method toString -* @description Returns a string representing the button. -* @return {String} -*/ -toString: function() { - - return ("Button " + this.get("id")); - -} - -}); - - -/** -* @method addHiddenFieldsToForm -* @description Searches the specified form and adds hidden fields for instances -* of YAHOO.widget.Button that are of type "radio," "checkbox," "menubutton," -* and "splitbutton." -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-40002357">HTMLFormElement</a>} p_oForm Object reference -* for the form to search. -*/ -YAHOO.widget.Button.addHiddenFieldsToForm = function(p_oForm) { - - var aButtons = Dom.getElementsByClassName("yuibutton", "*", p_oForm), - nButtons = aButtons.length; - - - if(nButtons > 0) { - - - var oButton = null, - sType = null, - oMenuItem = null, - oMenu = null; - - for(var i=0; i<nButtons; i++) { - - oButton = m_oButtons[aButtons[i].id]; - - if(oButton) { - - sType = oButton.get("type"); - oMenuItem = oButton.get("selectedMenuItem"); - - - if(sType == "radio" || sType == "checkbox") { - - - oButton.createHiddenField(); - - } - else if(oMenuItem) { - - oMenu = oButton.getMenu(); - - var oSrcElement = oMenu.srcElement; - - if( - oSrcElement && - oSrcElement.tagName.toUpperCase() == "SELECT" - ) { - - oButton.getForm().appendChild(oSrcElement); - oSrcElement.selectedIndex = oMenuItem.index; - - } - else { - - var oValue = ( - oMenuItem.value === null || - oMenuItem.value === "" - ) ? oMenuItem.cfg.getProperty("text") : - oMenuItem.value; - - if(oValue) { - - var oField = createInputElement( - "hidden", - (oButton.get("name") + "_options"), - oValue - ); - - oButton.getForm().appendChild(oField); - - } - - } - - } - - } - - } - - } - -}; - - - -// 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 <a href=" -* YAHOO.util.Element.html#addListener">Element.addListener</a> 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 <a href=" -* YAHOO.util.Element.html#addListener">Element.addListener</a> 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 <a href=" -* YAHOO.util.Element.html#addListener">Element.addListener</a> for more -* information on listening for this event. -* @type YAHOO.util.CustomEvent -*/ - - -/** -* @event init -* @description Fires when the Button is initialized. Subscribe to this event -* by specifying a value for the "oninit" configuration attribute. Format:<br> -* <code> {<br> <strong>fn:</strong> Function, // The handler to call -* when the event fires.<br> <strong>obj:</strong> Object, // An object -* to pass back to the handler.<br> <strong>scope:</strong> Object // -* The object to use for the scope of the handler.<br> } </code> -* @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 -* <code><div></code> element of the button group. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object -* specifying the <code><div></code> 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; - - if( - arguments.length == 1 && - !Lang.isString(p_oElement) && - !p_oElement.nodeName - ) { - - if(!p_oElement.id) { - - var sId = Dom.generateId(); - - p_oElement.id = sId; - - - } - - - - fnSuperClass.call(this, (this._createGroupElement()), p_oElement); - - } - else if(Lang.isString(p_oElement)) { - - var me = this; - - Event.onContentReady(p_oElement, function() { - - if(this.nodeName.toUpperCase() == me.TAG_NAME) { - - - fnSuperClass.call(me, this, p_oAttributes); - - } - - }); - - } - else { - - var sNodeName = p_oElement.nodeName; - - if(sNodeName && sNodeName == this.TAG_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, - - -/** -* @property _oninitAttributeValue -* @description Object reference to the button group's current value for the -* "oninit" configuration attribute. -* @default null -* @protected -* @type Object -*/ -_oninitAttributeValue: null, - - - -// Constants - - -/** -* @property TAG_NAME -* @description The name of the tag to be used for the button group's element. -* @default "DIV" -* @final -* @type String -*/ -TAG_NAME: "DIV", - - -/** -* @property CSS_CLASS_NAME -* @description String representing the CSS class(es) to be applied to the -* button group's element. -* @default "yuibuttongroup" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuibuttongroup", - - - -// Protected methods - - -/** -* @method _createGroupElement -* @description Creates the button group's element. -* @protected -* @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} -*/ -_createGroupElement: function() { - - var oElement = document.createElement(this.TAG_NAME); - - oElement.className = this.CSS_CLASS_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(); - - if(nButtons > 0) { - - var i = nButtons - 1; - - do { - - this._buttons[i].set("disabled", p_bDisabled); - - } - while(i--); - - } - -}, - - -/** -* @method _setOnInit -* @description Sets the value of the button group's "init" attribute. -* @protected -* @param {Object} p_oObject Object indicating the value for the button's -* "oninit" attribute. -*/ -_setOnInit: function(p_oObject) { - - /* - Remove any existing listeners if a "init" event handler has already - been specified. - */ - - if( - this._oninitAttributeValue && - (this._oninitAttributeValue != p_oObject) - ) { - - this.removeListener("init", this._oninitAttributeValue.fn); - - this._oninitAttributeValue = null; - - } - - - if( - !this._oninitAttributeValue && - Lang.isObject(p_oObject) && - Lang.isFunction(p_oObject.fn) - ) { - - this.on("init", p_oObject.fn, p_oObject.obj, p_oObject.scope); - - this._oninitAttributeValue = p_oObject; - - } - -}, - - -// 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; - - for(var 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 {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} 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 -* <code><div></code> element of the button group. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object -* specifying the <code><div></code> 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 - ); - - - - var aButtons = this.getElementsByClassName("yuibutton"); - - - 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)) { - - var me = this; - - Event.onContentReady(oContainer, function() { - - me.appendTo(this); - - }); - - } - else { - - this.appendTo(oContainer); - - } - - } - - - this.fireEvent("init"); - - -}, - - -/** -* @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 <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|String - * @default null - */ - this.setAttributeConfig("container", { - - value: oAttributes.container - - }); - - - /** - * @config checkedButton - * @description Reference for the button in the button group that - * is checked. - * @type {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} - * @default null - */ - this.setAttributeConfig("checkedButton", { - - value: null - - }); - - - /** - * @config oninit - * @description Object literal representing the code to be executed when - * the button group is initialized. Format:<br> <code> {<br> - * <strong>fn:</strong> Function, // The handler to call when the - * event fires.<br> <strong>obj:</strong> Object, // An object to - * pass back to the handler.<br> <strong>scope:</strong> Object // - * The object to use for the scope of the handler.<br> } </code> - * @type Object - * @default null - */ - this.setAttributeConfig("oninit", { - - value: oAttributes.oninit, - method: this._setOnInit - - }); - -}, - - -/** -* @method addButton -* @description Adds the button to the button group. -* @param {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} p_oButton -* Object reference for the <a href="YAHOO.widget.Button.html"> -* YAHOO.widget.Button</a> instance to be added to the button group. -* @param {String} p_oButton String specifying the id attribute of the -* <code><input></code> or <code><span></code> element to be -* used to create the button to be added to the button group. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-6043025">HTMLInputElement</a>|<a href=" -* http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html# -* ID-33759296">HTMLElement</a>} p_oButton Object reference for the -* <code><input></code> or <code><span></code> 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 -* <a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a> configuration -* attributes used to configure the button to be added to the button group. -* @return {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} -*/ -addButton: function(p_oButton) { - - var oButton; - - - 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) { - - var 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); - - } - - - 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 <a href="YAHOO.widget.Button.html"> -* YAHOO.widget.Button</a> instances to be added -* to the button group. -* @param {Array} p_aButtons Array of strings specifying the id attribute of -* the <code><input></code> or <code><span></code> 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 -* <code><input></code> or <code><span></code> 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 -* <a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a> configuration -* attributes used to configure each button to be added to the button group. -* @return {Array} -*/ -addButtons: function(p_aButtons) { - - if(Lang.isArray(p_aButtons)) { - - var nButtons = p_aButtons.length, - oButton, - aButtons = []; - - if(nButtons > 0) { - - for(var 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); - - if(oButton) { - - - this._buttons.splice(p_nIndex, 1); - delete m_oButtons[oButton.get("id")]; - - oButton.removeListener("checkedChange", this._onButtonCheckedChange); - oButton.destroy(); - - - var nButtons = this._buttons.length; - - if(nButtons > 0) { - - var 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 {<a href="YAHOO.widget.Button.html">YAHOO.widget.Button</a>} -*/ -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; - - if(Lang.isNumber(p_nIndex)) { - - oButton = this._buttons[p_nIndex]; - - if(oButton) { - - oButton.focus(); - - } - - } - else { - - var nButtons = this.getCount(); - - for(var 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; - - if(nButtons > 0) { - - var 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")); - -} - -}); - - - -// Events - - -/** -* @event init -* @description Fires when the button group is initialized. Subscribe to this -* event by specifying a value for the "oninit" configuration attribute. -* Format:<br> <code> {<br> <strong>fn:</strong> Function, // The -* handler to call when the event fires.<br> <strong>obj:</strong> Object, -* // An object to pass back to the handler.<br> <strong>scope:</strong> -* Object // The object to use for the scope of the handler.<br> -* } </code> -* @type YAHOO.util.CustomEvent -*/ - -})(); -YAHOO.register("button", YAHOO.widget.Button, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/calendar/README b/interface/web/js/yui/calendar/README deleted file mode 100644 index f0ddd1214b..0000000000 --- a/interface/web/js/yui/calendar/README +++ /dev/null @@ -1,88 +0,0 @@ -Calendar Release Notes - -*** 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 - -*** version 0.12.1 *** - - - Calendar and CalendarGroup now automatically parse the argument passed to setMonth and setYear into an integer, eliminating potential concatenation bugs. - -*** version 0.12 *** - - - New documentation format implemented - - Calendar2up and Calendar_Core are now deprecated. Now, Calendar alone represents the single Calendar instance, and CalendarGroup represents an n-up instance, defaulting to 2up - - Added semantic style classes to Calendar elements to allow for custom styling solely using CSS. - - Remapped all configuration properties to use the Config object (familiar to those who use the Container collection of controls). Property names are the same as their previous counterparts, but wrapped into Calendar.cfg, allowing for runtime reconfiguration of most properties - - Added "title" property for setting the Calendar title - - Added "close" property for enabling and disabling the close icon - - Added "iframe" property for enabling an iframe shim in Internet Explorer 6 and below to fix the select bleed-through bug - - pageDate moved to property: "pagedate" - - selectedDates moved to property: "selected" - - minDate moved to property : "mindate", which accepts a JavaScript Date object like its predecessor, but also supports string dates - - maxDate moved to property : "maxdate", which accepts a JavaScript Date object like its predecessor, but also supports string dates - - Moved style declarations to initStyles function - - Optimized event handling in doSelectCell/doCellMouseOver/doCellMouseOut by only attaching the listener to the outer Calendar container, and only reacting to events on cells with the "selectable" CSS class. - - Added domEventMap field for applying DOM event listeners to cells containing specific class and tag combinations. - - Moved all cell DOM event attachment to applyListeners function - - Added getDateByCellId / getDateFieldsByCellId helper functions - - Corrected DateMath.getWeekNumber to comply with ISO week number handling - - Separated renderCellDefault style portions into styleCellDefault function for easy extension - - Deprecated onBeforeSelect. Created beforeSelectEvent which automatically subscribes to its deprecated predecessor. - - Deprecated onSelect. Created selectEvent, which automatically subscribes to its deprecated predecessor. - - Deprecated onBeforeDeselect. Created beforeSelectEvent which automatically subscribes to its deprecated predecessor. - - Deprecated onDeselect. Created beforeDeselectEvent, which automatically subscribes to its deprecated predecessor. - - Deprecated onChangePage. Created changePageEvent, which automatically subscribes to its deprecated predecessor. - - Deprecated onRender. Created renderEvent, which automatically subscribes to its deprecated predecessor. - - Deprecated onReset. Created resetEvent, which automatically subscribes to its deprecated predecessor. - - Deprecated onClear. Created clearEvent, which automatically subscribes to its deprecated predecessor. - - Corrected setMonth documentation to refer to 0-11 indexed months. - - Added show and hide methods to Calendar for setting the Calendar's display property. - - Optimized internal render classes to use innerHTML and string buffers - - Removed wireCustomEvents function - - Removed wireDefaultEvents function - - Removed doNextMonth / doPreviousMonth - - Removed all buildShell (header, body, footer) functions, since the Calendar shell is now built dynamically on each render - - Wired all CalendarGroup events and configuration properties to be properly delegated to Calendar - - Augmented CalendarGroup with all built-in renderers, label functions, hide, show, and initStyles, creating API transparency between Calendar and CalendarGroup. - - Made all tagName, createElement, and entity references XHTML compliant - - Fixed Daylight Saving Time bug for Brazilian time zone - -*** version 0.11.3 *** - - - Calendar_Core: Added arguments for selected/deselected dates to onSelect/onDeselect - - CalendarGroup: Fixed bug where selected dates passed to constructor were not represented in selectedDates - - Calendar2up: Now displays correctly in Opera 9 - -*** version 0.11.0 *** - - - DateMath: DateMath.add now properly adds weeks - - DateMath: between() function added - - DateMath: getWeekNumber() fixed to take starting day of week into account - - All references to Calendar's built in CSS class handlers are removed, replaced with calls to Dom utility (addClass, removeClass) - - Several CSS class constants now have clearer names - - All CSS classes are now properly namespaced to avoid CSS conflicts - - Fixed table:hover bug in CSS - - Calendar no longer requires the container ID and variable name to match in order for month navigation to function properly - - Calendar month navigation arrows are now represented as background images - -*** version 0.10.0 *** - - - Major performance improvements from attaching DOM events to associated table cells only once, when the Calendar shell is built - - DOM events for mouseover/mouseout are now fired for all browsers (not just Internet Explorer) - - Reset functionality bug fixed for 2-up Calendar view - -*** version 0.9.0 *** - -* Initial release diff --git a/interface/web/js/yui/calendar/assets/calendar.css b/interface/web/js/yui/calendar/assets/calendar.css deleted file mode 100644 index c9d43ebcdd..0000000000 --- a/interface/web/js/yui/calendar/assets/calendar.css +++ /dev/null @@ -1,197 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -.yui-calcontainer { - position:relative; - padding:5px; - background-color:#F7F9FB; - border:1px solid #7B9EBD; - float:left; - overflow:hidden; -} - -.yui-calcontainer iframe { - position:absolute; - border:none; - margin:0;padding:0; - left:-1px; - top:-1px; - z-index:0; - width:50em; - height:50em; -} - -.yui-calcontainer.multi { - padding:0; -} - -.yui-calcontainer.multi .groupcal { - padding:5px; - background-color:transparent; - z-index:1; - float:left; - position:relative; - border:none; -} - -.yui-calcontainer .title { - font:100% sans-serif; - color:#000; - font-weight:bold; - margin-bottom:5px; - height:25px; - position:absolute; - top:3px;left:5px; - z-index:1; -} - -.yui-calcontainer .close-icon { - position:absolute; - right:3px; - top:3px; - border:none; - z-index:1; -} - -.yui-calcontainer .calclose { - background: url("calx.gif") no-repeat; - width:17px; - height:13px; - cursor:pointer; -} - -/* Calendar element styles */ - -.yui-calendar { - font:100% sans-serif; - text-align:center; - border-spacing:0; - border-collapse:separate; - position:relative; -} - -.yui-calcontainer.withtitle { - padding-top:1.5em; -} - -.yui-calendar .calnavleft { - position:absolute; - cursor:pointer; - top:2px; - bottom:0; - width:9px; - height:12px; - left:2px; - z-index:1; - background: url("callt.gif") no-repeat; -} - -.yui-calendar .calnavright { - position:absolute; - cursor:pointer; - top:2px; - bottom:0; - width:9px; - height:12px; - right:2px; - z-index:1; - background: url("calrt.gif") no-repeat; -} - -.yui-calendar td.calcell { - padding:.1em .2em; - border:1px solid #E0E0E0; - text-align:center; -} - -.yui-calendar td.calcell a { - color:#003DB8; - text-decoration:none; -} - -.yui-calendar td.calcell.today { - border:1px solid #000; -} - -.yui-calendar td.calcell.oom { - cursor:default; - color:#999; - background-color:#EEE; - border:1px solid #E0E0E0; -} - -.yui-calendar td.calcell.selected { - color:#003DB8; - background-color:#FFF19F; - border:1px solid #FF9900; -} - -.yui-calendar td.calcell.calcellhover { - cursor:pointer; - color:#FFF; - background-color:#FF9900; - border:1px solid #FF9900; -} - -.yui-calendar td.calcell.calcellhover a { - color:#FFF; -} - -.yui-calendar td.calcell.restricted { - text-decoration:line-through; -} - -.yui-calendar td.calcell.previous { - color:#CCC; -} - -.yui-calendar td.calcell.highlight1 { background-color:#CCFF99; } -.yui-calendar td.calcell.highlight2 { background-color:#99CCFF; } -.yui-calendar td.calcell.highlight3 { background-color:#FFCCCC; } -.yui-calendar td.calcell.highlight4 { background-color:#CCFF99; } - -.yui-calendar .calhead { - border:1px solid #E0E0E0; - vertical-align:middle; - background-color:#FFF; -} - -.yui-calendar .calheader { - position:relative; - width:100%; - text-align:center; -} - -.yui-calendar .calheader img { - border:none; -} - -.yui-calendar .calweekdaycell { - color:#666; - font-weight:normal; - text-align:center; - width:1.5em; -} - -.yui-calendar .calfoot { - background-color:#EEE; -} - -.yui-calendar .calrowhead, .yui-calendar .calrowfoot { - color:#666; - font-size:9px; - font-style:italic; - font-weight:normal; - width:15px; -} - -.yui-calendar .calrowhead { - border-right-width:2px; -} - -/* Specific changes for calendar running under fonts/reset */ -.yui-calendar .calbody a:hover {background:inherit;} -p#clear {clear:left; padding-top:10px;} diff --git a/interface/web/js/yui/calendar/assets/callt.gif b/interface/web/js/yui/calendar/assets/callt.gif deleted file mode 100644 index a6cc8da5b221d372ea075b3a4a10211d3a23cb51..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 93 zcmZ?wbhEHb<YeGsSj5Wk|NnpEw3#!{{AVyuO9N8>|1*Gr;!hSv1_o9J9S{$smVsF* qV%6o-OdT896eo&R8_GI9Z+s-tb-65V<*lvjzBf272=!xPum%9G>mWw} diff --git a/interface/web/js/yui/calendar/assets/calrt.gif b/interface/web/js/yui/calendar/assets/calrt.gif deleted file mode 100644 index ee137b2ff769d99132234b67f1e528daf65cb397..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 94 zcmZ?wbhEHb<YeGsSj5Wk|NnpEw3#!{{AVyuO9N8>|1*Gr;!hSv1_o9J9S{$smVsG0 rV)Ip7rjCbGR9fsBH@3+N1|(QayL)o!6Ro<}FL)f+p7oi^z+epk(%c}| diff --git a/interface/web/js/yui/calendar/assets/calx.gif b/interface/web/js/yui/calendar/assets/calx.gif deleted file mode 100644 index 27e7bc36e4524623db3c43f4d86717a703f37406..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 88 zcmZ?wbhEHb6lCCKn8?J?-rj!k;>G{}|1&T!DE?$&WME)o&;ha;K=KSsnmzrMhu-GT qE4kQMmbu}<w=*F(*xPP@_Ed77c4*eJvsw*$wrA7%H0^>I7_0#*o**Fr diff --git a/interface/web/js/yui/calendar/calendar-debug.js b/interface/web/js/yui/calendar/calendar-debug.js deleted file mode 100644 index 9b1a305616..0000000000 --- a/interface/web/js/yui/calendar/calendar-debug.js +++ /dev/null @@ -1,4331 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** -* 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); - } - if (!owner) { 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<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - - if (queueItem) { - var queueItemKey = queueItem[0]; - var queueItemValue = queueItem[1]; - - if (queueItemKey.toLowerCase() == key) { - // found a dupe... push to end of queue, null current item, and break - eventQueue[i] = null; - eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]); - foundDuplicate = true; - break; - } - } - } - - if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue - eventQueue.push([key, value]); - } - } - - if (property.supercedes) { - for (var s=0;s<property.supercedes.length;s++) { - var supercedesCheck = property.supercedes[s]; - - for (var q=0;q<eventQueue.length;q++) { - var queueItemCheck = eventQueue[q]; - - if (queueItemCheck) { - var queueItemCheckKey = queueItemCheck[0]; - var queueItemCheckValue = queueItemCheck[1]; - - if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) { - eventQueue.push([queueItemCheckKey, queueItemCheckValue]); - eventQueue[q] = null; - break; - } - } - } - } - } - YAHOO.log("Config event queue: " + this.outputEventQueue(), "info"); - - return true; - } else { - return false; - } - }; - - /** - * Fires the event for a property using the property's current value. - * @method refireEvent - * @param {String} key The name of the property - */ - this.refireEvent = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') { - if (this.queueInProgress) { - this.queueProperty(key); - } else { - fireEvent(key, property.value); - } - } - }; - - /** - * Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their associated events to execute. - * @method applyConfig - * @param {Object} userConfig The configuration Object literal - * @param {Boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. - */ - this.applyConfig = function(userConfig, init) { - if (init) { - initialConfig = userConfig; - } - for (var prop in userConfig) { - this.queueProperty(prop, userConfig[prop]); - } - }; - - /** - * Refires the events for all configuration properties using their current values. - * @method refresh - */ - this.refresh = function() { - for (var prop in config) { - this.refireEvent(prop); - } - }; - - /** - * Fires the normalized list of queued property change events - * @method fireQueue - */ - this.fireQueue = function() { - this.queueInProgress = true; - for (var i=0;i<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - if (queueItem) { - var key = queueItem[0]; - var value = queueItem[1]; - - var property = config[key]; - property.value = value; - - fireEvent(key,value); - } - } - - this.queueInProgress = false; - eventQueue = []; - }; - - /** - * Subscribes an external handler to the change event for any given property. - * @method subscribeToConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @param {Boolean} override Optional. If true, will override "this" within the handler to map to the scope Object passed into the method. - * @return {Boolean} True, if the subscription was successful, otherwise false. - */ - this.subscribeToConfigEvent = function(key, handler, obj, override) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) { - property.event.subscribe(handler, obj, override); - } - return true; - } else { - return false; - } - }; - - /** - * Unsubscribes an external handler from the change event for any given property. - * @method unsubscribeFromConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @return {Boolean} True, if the unsubscription was successful, otherwise false. - */ - this.unsubscribeFromConfigEvent = function(key, handler, obj) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.event.unsubscribe(handler, obj); - } else { - return false; - } - }; - - /** - * Returns a string representation of the Config object - * @method toString - * @return {String} The Config object in string format. - */ - this.toString = function() { - var output = "Config"; - if (this.owner) { - output += " [" + this.owner.toString() + "]"; - } - return output; - }; - - /** - * Returns a string representation of the Config object's current CustomEvent queue - * @method outputEventQueue - * @return {String} The string list of CustomEvents currently queued for execution - */ - this.outputEventQueue = function() { - var output = ""; - for (var q=0;q<eventQueue.length;q++) { - var queueItem = eventQueue[q]; - if (queueItem) { - output += queueItem[0] + "=" + queueItem[1] + ", "; - } - } - return output; - }; -}; - -/** -* Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent -* @method YAHOO.util.Config.alreadySubscribed -* @static -* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions -* @param {Function} fn The function to look for in the subscribers list -* @param {Object} obj The execution scope Object for the subscription -* @return {Boolean} true, if the function/Object pair is already subscribed to the CustomEvent passed in -*/ -YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) { - for (var e=0;e<evt.subscribers.length;e++) { - var subsc = evt.subscribers[e]; - if (subsc && subsc.obj == obj && subsc.fn == fn) { - return true; - } - } - return false; -}; - -/** -* YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility -* used for adding, subtracting, and comparing dates. -* @namespace YAHOO.widget -* @class DateMath -*/ -YAHOO.widget.DateMath = { - /** - * Constant field representing Day - * @property DAY - * @static - * @final - * @type String - */ - DAY : "D", - - /** - * Constant field representing Week - * @property WEEK - * @static - * @final - * @type String - */ - WEEK : "W", - - /** - * Constant field representing Year - * @property YEAR - * @static - * @final - * @type String - */ - YEAR : "Y", - - /** - * Constant field representing Month - * @property MONTH - * @static - * @final - * @type String - */ - MONTH : "M", - - /** - * Constant field representing one day, in milliseconds - * @property ONE_DAY_MS - * @static - * @final - * @type Number - */ - ONE_DAY_MS : 1000*60*60*24, - - /** - * Adds the specified amount of time to the this instance. - * @method add - * @param {Date} date The JavaScript Date object to perform addition on - * @param {String} field The field constant to be used for performing addition. - * @param {Number} amount The number of units (measured in the field constant) to add to the date. - * @return {Date} The resulting Date object - */ - add : function(date, field, amount) { - var d = new Date(date.getTime()); - switch (field) { - case this.MONTH: - var newMonth = date.getMonth() + amount; - var years = 0; - - - if (newMonth < 0) { - while (newMonth < 0) { - newMonth += 12; - years -= 1; - } - } else if (newMonth > 11) { - while (newMonth > 11) { - newMonth -= 12; - years += 1; - } - } - - d.setMonth(newMonth); - d.setFullYear(date.getFullYear() + years); - break; - case this.DAY: - d.setDate(date.getDate() + amount); - break; - case this.YEAR: - d.setFullYear(date.getFullYear() + amount); - break; - case this.WEEK: - d.setDate(date.getDate() + (amount * 7)); - break; - } - return d; - }, - - /** - * Subtracts the specified amount of time from the this instance. - * @method subtract - * @param {Date} date The JavaScript Date object to perform subtraction on - * @param {Number} field The this field constant to be used for performing subtraction. - * @param {Number} amount The number of units (measured in the field constant) to subtract from the date. - * @return {Date} The resulting Date object - */ - subtract : function(date, field, amount) { - return this.add(date, field, (amount*-1)); - }, - - /** - * Determines whether a given date is before another date on the calendar. - * @method before - * @param {Date} date The Date object to compare with the compare argument - * @param {Date} compareTo The Date object to use for the comparison - * @return {Boolean} true if the date occurs before the compared date; false if not. - */ - before : function(date, compareTo) { - var ms = compareTo.getTime(); - if (date.getTime() < ms) { - return true; - } else { - return false; - } - }, - - /** - * Determines whether a given date is after another date on the calendar. - * @method after - * @param {Date} date The Date object to compare with the compare argument - * @param {Date} compareTo The Date object to use for the comparison - * @return {Boolean} true if the date occurs after the compared date; false if not. - */ - after : function(date, compareTo) { - var ms = compareTo.getTime(); - if (date.getTime() > ms) { - return true; - } else { - return false; - } - }, - - /** - * Determines whether a given date is between two other dates on the calendar. - * @method between - * @param {Date} date The date to check for - * @param {Date} dateBegin The start of the range - * @param {Date} dateEnd The end of the range - * @return {Boolean} true if the date occurs between the compared dates; false if not. - */ - between : function(date, dateBegin, dateEnd) { - if (this.after(date, dateBegin) && this.before(date, dateEnd)) { - return true; - } else { - return false; - } - }, - - /** - * Retrieves a JavaScript Date object representing January 1 of any given year. - * @method getJan1 - * @param {Number} calendarYear The calendar year for which to retrieve January 1 - * @return {Date} January 1 of the calendar year specified. - */ - getJan1 : function(calendarYear) { - return new Date(calendarYear,0,1); - }, - - /** - * Calculates the number of days the specified date is from January 1 of the specified calendar year. - * Passing January 1 to this function would return an offset value of zero. - * @method getDayOffset - * @param {Date} date The JavaScript date for which to find the offset - * @param {Number} calendarYear The calendar year to use for determining the offset - * @return {Number} The number of days since January 1 of the given year - */ - getDayOffset : function(date, calendarYear) { - var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1. - - // Find the number of days the passed in date is away from the calendar year start - var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS); - return dayOffset; - }, - - /** - * Calculates the week number for the given date. This function assumes that week 1 is the - * week in which January 1 appears, regardless of whether the week consists of a full 7 days. - * The calendar year can be specified to help find what a the week number would be for a given - * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or - * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction - * easily. - * @method getWeekNumber - * @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) { - 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; - }, - - /** - * Determines if a given week overlaps two different years. - * @method isYearOverlapWeek - * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week. - * @return {Boolean} true if the date overlaps two different years. - */ - isYearOverlapWeek : function(weekBeginDate) { - var overlaps = false; - var nextWeek = this.add(weekBeginDate, this.DAY, 6); - if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) { - overlaps = true; - } - return overlaps; - }, - - /** - * Determines if a given week overlaps two different months. - * @method isMonthOverlapWeek - * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week. - * @return {Boolean} true if the date overlaps two different months. - */ - isMonthOverlapWeek : function(weekBeginDate) { - var overlaps = false; - var nextWeek = this.add(weekBeginDate, this.DAY, 6); - if (nextWeek.getMonth() != weekBeginDate.getMonth()) { - overlaps = true; - } - return overlaps; - }, - - /** - * Gets the first day of a month containing a given date. - * @method findMonthStart - * @param {Date} date The JavaScript Date used to calculate the month start - * @return {Date} The JavaScript Date representing the first day of the month - */ - findMonthStart : function(date) { - var start = new Date(date.getFullYear(), date.getMonth(), 1); - return start; - }, - - /** - * Gets the last day of a month containing a given date. - * @method findMonthEnd - * @param {Date} date The JavaScript Date used to calculate the month end - * @return {Date} The JavaScript Date representing the last day of the month - */ - findMonthEnd : function(date) { - var start = this.findMonthStart(date); - var nextMonth = this.add(start, this.MONTH, 1); - var end = this.subtract(nextMonth, this.DAY, 1); - return end; - }, - - /** - * Clears the time fields from a given date, effectively setting the time to 12 noon. - * @method clearTime - * @param {Date} date The JavaScript Date for which the time fields will be cleared - * @return {Date} The JavaScript Date cleared of all time fields - */ - clearTime : function(date) { - date.setHours(12,0,0,0); - return date; - } -}; - -/** -* 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. -* @module calendar -* @title Calendar -* @namespace YAHOO.widget -* @requires yahoo,dom,event -*/ - -/** -* Calendar is the base class for the Calendar widget. In its most basic -* implementation, it has the ability to render a calendar widget on the page -* that can be manipulated to select a single date, move back and forth between -* months and years. -* <p>To construct the placeholder for the calendar widget, the code is as -* follows: -* <xmp> -* <div id="cal1Container"></div> -* </xmp> -* Note that the table can be replaced with any kind of element. -* </p> -* @namespace YAHOO.widget -* @class Calendar -* @constructor -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -YAHOO.widget.Calendar = function(id, containerId, config) { - this.init(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 = null; - -/** -* Type constant used for renderers to represent an individual date (M/D/Y) -* @property YAHOO.widget.Calendar.DATE -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.DATE = "D"; - -/** -* Type constant used for renderers to represent an individual date across any year (M/D) -* @property YAHOO.widget.Calendar.MONTH_DAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MONTH_DAY = "MD"; - -/** -* Type constant used for renderers to represent a weekday -* @property YAHOO.widget.Calendar.WEEKDAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.WEEKDAY = "WD"; - -/** -* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y) -* @property YAHOO.widget.Calendar.RANGE -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.RANGE = "R"; - -/** -* Type constant used for renderers to represent a month across any year -* @property YAHOO.widget.Calendar.MONTH -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MONTH = "M"; - -/** -* Constant that represents the total number of date cells that are displayed in a given month -* @property YAHOO.widget.Calendar.DISPLAY_DAYS -* @static -* @final -* @type Number -*/ -YAHOO.widget.Calendar.DISPLAY_DAYS = 42; - -/** -* Constant used for halting the execution of the remainder of the render stack -* @property YAHOO.widget.Calendar.STOP_RENDER -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.STOP_RENDER = "S"; - -YAHOO.widget.Calendar.prototype = { - - /** - * The configuration object used to set up the calendars various locale and style options. - * @property Config - * @private - * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty. - * @type Object - */ - Config : null, - - /** - * The parent CalendarGroup, only to be set explicitly by the parent group - * @property parent - * @type CalendarGroup - */ - parent : null, - - /** - * The index of this item in the parent group - * @property index - * @type Number - */ - index : -1, - - /** - * The collection of calendar table cells - * @property cells - * @type HTMLTableCellElement[] - */ - cells : null, - - /** - * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D]. - * @property cellDates - * @type Array[](Number[]) - */ - cellDates : null, - - /** - * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page. - * @property id - * @type String - */ - id : null, - - /** - * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered. - * @property oDomContainer - * @type HTMLElement - */ - oDomContainer : null, - - /** - * A Date object representing today's date. - * @property today - * @type Date - */ - today : null, - - /** - * The list of render functions, along with required parameters, used to render cells. - * @property renderStack - * @type Array[] - */ - renderStack : null, - - /** - * A copy of the initial render functions created before rendering. - * @property _renderStack - * @private - * @type Array - */ - _renderStack : null, - - /** - * The private list of initially selected dates. - * @property _selectedDates - * @private - * @type Array - */ - _selectedDates : null, - - /** - * A map of DOM event handlers to attach to cells associated with specific CSS class names - * @property domEventMap - * @type Object - */ - domEventMap : null -}; - - - -/** -* Initializes the Calendar widget. -* @method init -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @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.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"); } - - /** - * The Config object used to hold the configuration variables for the Calendar - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - /** - * The local object which contains the Calendar's options - * @property Options - * @type Object - */ - this.Options = {}; - - /** - * The local object which contains the Calendar's locale settings - * @property Locale - * @type Object - */ - 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(); -}; - -/** -* Renders the built-in IFRAME shim for the IE6 and below -* @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.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; - } - } - } -}; - -/** -* Default handler for the "title" property -* @method configTitle -*/ -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"); - } - } -}; - -/** -* Default handler for the "close" property -* @method configClose -*/ -YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) { - var close = args[0]; - var title = this.cfg.getProperty("title"); - - 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.className = "link-close"; - YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true); - - 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 = '<span class="' + YAHOO.widget.CalendarGroup.CSS_2UPCLOSE + ' ' + this.Style.CSS_CLOSE + '"></span>'; - } - - 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"); - } - } -}; - -/** -* Initializes Calendar's built-in CustomEvents -* @method initEvents -*/ -YAHOO.widget.Calendar.prototype.initEvents = function() { - - /** - * Fired before a selection is made - * @event beforeSelectEvent - */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect"); - - /** - * 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"); - - /** - * Fired before a selection is made - * @event beforeDeselectEvent - */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect"); - - /** - * 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"); - - /** - * Fired when the Calendar page is changed - * @event changePageEvent - */ - this.changePageEvent = new YAHOO.util.CustomEvent("changePage"); - - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); - - /** - * Fired when the Calendar is reset - * @event resetEvent - */ - this.resetEvent = new YAHOO.util.CustomEvent("reset"); - - /** - * Fired when the Calendar is cleared - * @event clearEvent - */ - 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); -}; - - -/** -* The default event function that is attached to a date link within a calendar cell -* when the calendar is rendered. -* @method doSelectCell -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -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; - } - } - - 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; - - 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) { - link.blur(); - } - cal.selectCell(index); - } - } -}; - -/** -* The event that is executed when the user hovers over a cell -* @method doCellMouseOver -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -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); - } -}; - -/** -* The event that is executed when the user moves the mouse out of a cell -* @method doCellMouseOut -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -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() { - - /** - * 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 } ); - - /** - * The date or range of dates representing the current Calendar selection - * @config selected - * @type String - * @default [] - */ - this.cfg.addProperty("selected", { value:[], handler:this.configSelected } ); - - /** - * The title to display above the Calendar's month header - * @config title - * @type String - * @default "" - */ - this.cfg.addProperty("title", { value:"", handler:this.configTitle } ); - - /** - * Whether or not a close button should be displayed for this Calendar - * @config close - * @type Boolean - * @default false - */ - this.cfg.addProperty("close", { value:false, 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. - * @config iframe - * @type Boolean - * @default true - */ - this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } ); - - /** - * The minimum selectable date in the current Calendar (mm/dd/yyyy) - * @config mindate - * @type String - * @default null - */ - this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } ); - - /** - * The maximum selectable date in the current Calendar (mm/dd/yyyy) - * @config maxdate - * @type String - * @default null - */ - this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } ); - - - // Options properties - - /** - * True if the Calendar should allow multiple selections. False by default. - * @config MULTI_SELECT - * @type Boolean - * @default false - */ - this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * The weekday the week begins on. Default is 0 (Sunday). - * @config START_WEEKDAY - * @type number - * @default 0 - */ - this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } ); - - /** - * True if the Calendar should show weekday labels. True by default. - * @config SHOW_WEEKDAYS - * @type Boolean - * @default true - */ - this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row headers. False by default. - * @config SHOW_WEEK_HEADER - * @type Boolean - * @default false - */ - this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row footers. False by default. - * @config SHOW_WEEK_FOOTER - * @type Boolean - * @default false - */ - this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, 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. - * @config HIDE_BLANK_WEEKS - * @type Boolean - * @default false - */ - this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * The image that should be used for the left navigation arrow. - * @config NAV_ARROW_LEFT - * @type String - * @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:null, handler:this.configOptions } ); - - /** - * The image that should be used for the right navigation arrow. - * @config NAV_ARROW_RIGHT - * @type String - * @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:null, handler:this.configOptions } ); - - // Locale properties - - /** - * The short month labels for the current locale. - * @config MONTHS_SHORT - * @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 } ); - - /** - * The long month labels for the current locale. - * @config MONTHS_LONG - * @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 } ); - - /** - * The 1-character weekday labels for the current locale. - * @config WEEKDAYS_1CHAR - * @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 } ); - - /** - * The short weekday labels for the current locale. - * @config WEEKDAYS_SHORT - * @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 } ); - - /** - * The medium weekday labels for the current locale. - * @config WEEKDAYS_MEDIUM - * @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 } ); - - /** - * The long weekday labels for the current locale. - * @config WEEKDAYS_LONG - * @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 } ); - - /** - * Refreshes the locale values used to build the Calendar. - * @method refreshLocale - * @private - */ - 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); - - /** - * The setting that determines which length of month labels should be used. Possible values are "short" and "long". - * @config LOCALE_MONTHS - * @type String - * @default "long" - */ - this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } ); - - /** - * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". - * @config LOCALE_WEEKDAYS - * @type String - * @default "short" - */ - this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } ); - - /** - * The value used to delimit individual dates in a date string passed to various Calendar functions. - * @config DATE_DELIMITER - * @type String - * @default "," - */ - this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } ); - - /** - * The value used to delimit date fields in a date string passed to various Calendar functions. - * @config DATE_FIELD_DELIMITER - * @type String - * @default "/" - */ - this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } ); - - /** - * The value used to delimit date ranges in a date string passed to various Calendar functions. - * @config DATE_RANGE_DELIMITER - * @type String - * @default "-" - */ - this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } ); - - /** - * The position of the month in a month/year date string - * @config MY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/year date string - * @config MY_YEAR_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day date string - * @config MD_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/year date string - * @config MD_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day/year date string - * @config MDY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/day/year date string - * @config MDY_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/day/year date string - * @config MDY_YEAR_POSITION - * @type Number - * @default 3 - */ - this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } ); -}; - -/** -* The default handler for the "pagedate" property -* @method configPageDate -*/ -YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { - this.cfg.setProperty("pagedate", this._parsePageDate(args[0]), true); -}; - -/** -* The default handler for the "mindate" property -* @method configMinDate -*/ -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])); - } -}; - -/** -* The default handler for the "maxdate" property -* @method configMaxDate -*/ -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])); - } -}; - -/** -* The default handler for the "selected" property -* @method configSelected -*/ -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"); - } -}; - -/** -* The default handler for all configuration options properties -* @method configOptions -*/ -YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { - type = type.toUpperCase(); - var val = args[0]; - this.Options[type] = val; -}; - -/** -* The default handler for all configuration locale properties -* @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"); - -}; - -/** -* The default handler for all configuration locale field length properties -* @method configLocaleValues -*/ -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;w<START_WEEKDAY;++w) { - this.Locale.LOCALE_WEEKDAYS.push(this.Locale.LOCALE_WEEKDAYS.shift()); - } - } - break; - } -}; - -/** -* Defines the style constants for the Calendar -* @method initStyles -*/ -YAHOO.widget.Calendar.prototype.initStyles = function() { - - /** - * Collection of Style constants for the Calendar - * @property Style - */ - this.Style = { - /** - * @property Style.CSS_ROW_HEADER - */ - CSS_ROW_HEADER: "calrowhead", - /** - * @property Style.CSS_ROW_FOOTER - */ - CSS_ROW_FOOTER: "calrowfoot", - /** - * @property Style.CSS_CELL - */ - CSS_CELL : "calcell", - /** - * @property Style.CSS_CELL_SELECTED - */ - CSS_CELL_SELECTED : "selected", - /** - * @property Style.CSS_CELL_SELECTABLE - */ - CSS_CELL_SELECTABLE : "selectable", - /** - * @property Style.CSS_CELL_RESTRICTED - */ - CSS_CELL_RESTRICTED : "restricted", - /** - * @property Style.CSS_CELL_TODAY - */ - CSS_CELL_TODAY : "today", - /** - * @property Style.CSS_CELL_OOM - */ - CSS_CELL_OOM : "oom", - /** - * @property Style.CSS_CELL_OOB - */ - CSS_CELL_OOB : "previous", - /** - * @property Style.CSS_HEADER - */ - CSS_HEADER : "calheader", - /** - * @property Style.CSS_HEADER_TEXT - */ - CSS_HEADER_TEXT : "calhead", - /** - * @property Style.CSS_BODY - */ - CSS_BODY : "calbody", - /** - * @property Style.CSS_WEEKDAY_CELL - */ - CSS_WEEKDAY_CELL : "calweekdaycell", - /** - * @property Style.CSS_WEEKDAY_ROW - */ - CSS_WEEKDAY_ROW : "calweekdayrow", - /** - * @property Style.CSS_FOOTER - */ - CSS_FOOTER : "calfoot", - /** - * @property Style.CSS_CALENDAR - */ - CSS_CALENDAR : "yui-calendar", - /** - * @property Style.CSS_SINGLE - */ - CSS_SINGLE : "single", - /** - * @property Style.CSS_CONTAINER - */ - CSS_CONTAINER : "yui-calcontainer", - /** - * @property Style.CSS_NAV_LEFT - */ - CSS_NAV_LEFT : "calnavleft", - /** - * @property Style.CSS_NAV_RIGHT - */ - CSS_NAV_RIGHT : "calnavright", - /** - * @property Style.CSS_CLOSE - */ - CSS_CLOSE : "calclose", - /** - * @property Style.CSS_CELL_TOP - */ - CSS_CELL_TOP : "calcelltop", - /** - * @property Style.CSS_CELL_LEFT - */ - CSS_CELL_LEFT : "calcellleft", - /** - * @property Style.CSS_CELL_RIGHT - */ - CSS_CELL_RIGHT : "calcellright", - /** - * @property Style.CSS_CELL_BOTTOM - */ - CSS_CELL_BOTTOM : "calcellbottom", - /** - * @property Style.CSS_CELL_HOVER - */ - CSS_CELL_HOVER : "calcellhover", - /** - * @property Style.CSS_CELL_HIGHLIGHT1 - */ - CSS_CELL_HIGHLIGHT1 : "highlight1", - /** - * @property Style.CSS_CELL_HIGHLIGHT2 - */ - CSS_CELL_HIGHLIGHT2 : "highlight2", - /** - * @property Style.CSS_CELL_HIGHLIGHT3 - */ - CSS_CELL_HIGHLIGHT3 : "highlight3", - /** - * @property Style.CSS_CELL_HIGHLIGHT4 - */ - CSS_CELL_HIGHLIGHT4 : "highlight4" - }; -}; - -/** -* Builds the date label that will be displayed in the calendar header or -* footer, depending on configuration. -* @method buildMonthLabel -* @return {String} The formatted calendar month label -*/ -YAHOO.widget.Calendar.prototype.buildMonthLabel = function() { - var text = this.Locale.LOCALE_MONTHS[this.cfg.getProperty("pagedate").getMonth()] + " " + this.cfg.getProperty("pagedate").getFullYear(); - return text; -}; - -/** -* Builds the date digit that will be displayed in calendar cells -* @method buildDayLabel -* @param {Date} workingDate The current working date -* @return {String} The formatted day label -*/ -YAHOO.widget.Calendar.prototype.buildDayLabel = function(workingDate) { - var day = workingDate.getDate(); - return day; -}; - -/** -* Renders the calendar header. -* @method renderHeader -* @param {Array} html The current working HTML array -* @return {Array} The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderHeader = function(html) { - this.logger.log("Rendering header", "info"); - var colSpan = 7; - - var DEPR_NAV_LEFT = "us/tr/callt.gif"; - var DEPR_NAV_RIGHT = "us/tr/calrt.gif"; - - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { - colSpan += 1; - } - - if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { - colSpan += 1; - } - - html[html.length] = "<thead>"; - html[html.length] = "<tr>"; - html[html.length] = '<th colspan="' + colSpan + '" class="' + this.Style.CSS_HEADER_TEXT + '">'; - html[html.length] = '<div class="' + this.Style.CSS_HEADER + '">'; - - 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) { - var leftArrow = this.cfg.getProperty("NAV_ARROW_LEFT"); - // 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; - } - var leftStyle = (leftArrow === null) ? "" : ' style="background-image:url(' + leftArrow + ')"'; - html[html.length] = '<a class="' + this.Style.CSS_NAV_LEFT + '"' + leftStyle + ' > </a>'; - } - - html[html.length] = this.buildMonthLabel(); - - if (renderRight) { - var rightArrow = this.cfg.getProperty("NAV_ARROW_RIGHT"); - 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] = '<a class="' + this.Style.CSS_NAV_RIGHT + '"' + rightStyle + ' > </a>'; - } - - html[html.length] = '</div>'; - html[html.length] = '</th>'; - html[html.length] = '</tr>'; - - if (this.cfg.getProperty("SHOW_WEEKDAYS")) { - html = this.buildWeekdays(html); - } - - html[html.length] = '</thead>'; - - return html; -}; - -/** -* Renders the Calendar's weekday headers. -* @method buildWeekdays -* @param {Array} html The current working HTML array -* @return {Array} The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) { - - html[html.length] = '<tr class="' + this.Style.CSS_WEEKDAY_ROW + '">'; - - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { - html[html.length] = '<th> </th>'; - } - - for(var i=0;i<this.Locale.LOCALE_WEEKDAYS.length;++i) { - html[html.length] = '<th class="calweekdaycell">' + this.Locale.LOCALE_WEEKDAYS[i] + '</th>'; - } - - if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { - html[html.length] = '<th> </th>'; - } - - html[html.length] = '</tr>'; - - return html; -}; - -/** -* Renders the calendar body. -* @method renderBody -* @param {Date} workingDate The current working Date being used for the render process -* @param {Array} html The current working HTML array -* @return {Array} The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderBody = function(workingDate, html) { - this.logger.log("Rendering body", "info"); - - var startDay = this.cfg.getProperty("START_WEEKDAY"); - - 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; - 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"); - - 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] = '<tbody class="m' + (useDate.getMonth()+1) + ' ' + this.Style.CSS_BODY + '">'; - - 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] = '<tr class="' + weekClass + '">'; - - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); } - - for (var d=0;d<7;d++){ // Render actual days - - var cellRenderers = []; - - this.clearElement(cell); - - YAHOO.util.Dom.addClass(cell, "calcell"); - - cell.id = this.id + "_cell" + 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()) { - 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)) { - 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<this.renderStack.length;++s) { - - var rArray = this.renderStack[s]; - var type = rArray[0]; - - var month; - var day; - var year; - - switch (type) { - case YAHOO.widget.Calendar.DATE: - month = rArray[1][1]; - day = rArray[1][2]; - year = rArray[1][0]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case YAHOO.widget.Calendar.MONTH_DAY: - month = rArray[1][0]; - day = rArray[1][1]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case YAHOO.widget.Calendar.RANGE: - var date1 = rArray[1][0]; - var date2 = rArray[1][1]; - - var d1month = date1[1]; - var d1day = date1[2]; - var d1year = date1[0]; - - var d1 = new Date(d1year, d1month-1, d1day); - - var d2month = date2[1]; - var d2day = date2[2]; - var d2year = date2[0]; - - var d2 = new Date(d2year, d2month-1, d2day); - - if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) { - renderer = rArray[2]; - - if (workingDate.getTime()==d2.getTime()) { - this.renderStack.splice(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 ( - (mindate && (workingDate.getTime() < mindate.getTime())) || - (maxdate && (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<cellRenderers.length;++x) { - var ren = cellRenderers[x]; - this.logger.log("renderer[" + x + "] for (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender"); - if (ren.call((this.parent || this),workingDate,cell) == YAHOO.widget.Calendar.STOP_RENDER) { - break; - } - } - - workingDate.setTime(workingDate.getTime() + YAHOO.widget.DateMath.ONE_DAY_MS); - - if (i >= 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<blankWeeks;++p) { - postDays -= 7; - } - } - - if (i >= ((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); } - - html[html.length] = '</tr>'; - } - } - - html[html.length] = '</tbody>'; - - return html; -}; - -/** -* Renders the calendar footer. In the default implementation, there is -* no footer. -* @method renderFooter -* @param {Array} html The current working HTML array -* @return {Array} The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderFooter = function(html) { return html; }; - -/** -* Renders the calendar after it has been configured. The render() method has a specific call chain that will execute -* when the method is called: renderHeader, renderBody, renderFooter. -* Refer to the documentation for those methods for information on -* individual render tasks. -* @method render -*/ -YAHOO.widget.Calendar.prototype.render = function() { - this.beforeRenderEvent.fire(); - - // Find starting day of the current month - 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] = '<table cellSpacing="0" class="' + this.Style.CSS_CALENDAR + ' y' + workingDate.getFullYear() + '" id="' + this.id + '">'; - html = this.renderHeader(html); - html = this.renderBody(workingDate, html); - html = this.renderFooter(html); - html[html.length] = '</table>'; - - 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(); -}; - -/** -* Applies the Calendar's DOM listeners to applicable elements. -* @method applyListeners -*/ -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 (YAHOO.lang.hasOwnProperty(this.domEventMap, cls)) { - var items = this.domEventMap[cls]; - - if (! (items instanceof Array)) { - items = [items]; - } - - for (var i=0;i<items.length;i++) { - var item = items[i]; - elements = YAHOO.util.Dom.getElementsByClassName(cls, item.tag, this.oDomContainer); - - for (var c=0;c<elements.length;c++) { - el = elements[c]; - YAHOO.util.Event.addListener(el, item.event, item.handler, item.scope, item.correct ); - } - } - } - } - } - - 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); -}; - -/** -* Retrieves the Date object for the specified Calendar cell -* @method getDateByCellId -* @param {String} id The id of the cell -* @return {Date} The Date object for the specified Calendar cell -*/ -YAHOO.widget.Calendar.prototype.getDateByCellId = function(id) { - var date = this.getDateFieldsByCellId(id); - return new Date(date[0],date[1]-1,date[2]); -}; - -/** -* Retrieves the Date object for the specified Calendar cell -* @method getDateFieldsByCellId -* @param {String} id The id of the cell -* @return {Array} The array of Date fields for the specified Calendar cell -*/ -YAHOO.widget.Calendar.prototype.getDateFieldsByCellId = function(id) { - id = id.toLowerCase().split("_cell")[1]; - id = parseInt(id, 10); - return this.cellDates[id]; -}; - -// BEGIN BUILT-IN TABLE CELL RENDERERS - -/** -* Renders a cell that falls before the minimum date or after the maximum date. -* widget class. -* @method renderOutOfBoundsDate -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -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; -}; - -/** -* Renders the row header for a week. -* @method renderRowHeader -* @param {Number} weekNum The week number of the current row -* @param {Array} cell The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderRowHeader = function(weekNum, html) { - html[html.length] = '<th class="calrowhead">' + weekNum + '</th>'; - return html; -}; - -/** -* Renders the row footer for a week. -* @method renderRowFooter -* @param {Number} weekNum The week number of the current row -* @param {Array} cell The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) { - html[html.length] = '<th class="calrowfoot">' + weekNum + '</th>'; - return html; -}; - -/** -* Renders a single standard calendar cell in the calendar widget table. -* All logic for determining how a standard default cell will be rendered is -* encapsulated in this method, and must be accounted for when extending the -* widget class. -* @method renderCellDefault -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) { - cell.innerHTML = '<a href="javascript:void(null);" >' + this.buildDayLabel(workingDate) + "</a>"; -}; - -/** -* Styles a selectable cell. -* @method styleCellDefault -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.styleCellDefault = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE); -}; - - -/** -* Renders a single standard calendar cell using the CSS hightlight1 style -* @method renderCellStyleHighlight1 -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1 = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1); -}; - -/** -* Renders a single standard calendar cell using the CSS hightlight2 style -* @method renderCellStyleHighlight2 -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2 = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2); -}; - -/** -* Renders a single standard calendar cell using the CSS hightlight3 style -* @method renderCellStyleHighlight3 -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3 = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3); -}; - -/** -* Renders a single standard calendar cell using the CSS hightlight4 style -* @method renderCellStyleHighlight4 -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4 = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4); -}; - -/** -* Applies the default style used for rendering today's date to the current calendar cell -* @method renderCellStyleToday -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleToday = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY); -}; - -/** -* Applies the default style used for rendering selected dates to the current calendar cell -* @method renderCellStyleSelected -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleSelected = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED); -}; - -/** -* Applies the default style used for rendering dates that are not a part of the current -* month (preceding or trailing the cells for the current month) -* @method renderCellNotThisMonth -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -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; -}; - -/** -* Renders the current calendar cell as a non-selectable "black-out" date using the default -* restricted style. -* @method renderBodyCellRestricted -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -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; -}; - -// END BUILT-IN TABLE CELL RENDERERS - -// BEGIN MONTH NAVIGATION METHODS - -/** -* Adds the designated number of months to the current calendar month, and sets the current -* calendar page date to the new month. -* @method addMonths -* @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)); - this.resetRenderers(); - this.changePageEvent.fire(); -}; - -/** -* Subtracts the designated number of months from the current calendar month, and sets the current -* calendar page date to the new month. -* @method subtractMonths -* @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)); - this.resetRenderers(); - this.changePageEvent.fire(); -}; - -/** -* Adds the designated number of years to the current calendar, and sets the current -* calendar page date to the new month. -* @method addYears -* @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)); - this.resetRenderers(); - this.changePageEvent.fire(); -}; - -/** -* Subtcats the designated number of years from the current calendar, and sets the current -* calendar page date to the new month. -* @method subtractYears -* @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)); - this.resetRenderers(); - this.changePageEvent.fire(); -}; - -/** -* Navigates to the next month page in the calendar widget. -* @method nextMonth -*/ -YAHOO.widget.Calendar.prototype.nextMonth = function() { - this.addMonths(1); -}; - -/** -* Navigates to the previous month page in the calendar widget. -* @method previousMonth -*/ -YAHOO.widget.Calendar.prototype.previousMonth = function() { - this.subtractMonths(1); -}; - -/** -* Navigates to the next year in the currently selected month in the calendar widget. -* @method nextYear -*/ -YAHOO.widget.Calendar.prototype.nextYear = function() { - this.addYears(1); -}; - -/** -* Navigates to the previous year in the currently selected month in the calendar widget. -* @method previousYear -*/ -YAHOO.widget.Calendar.prototype.previousYear = function() { - this.subtractYears(1); -}; - -// END MONTH NAVIGATION METHODS - -// BEGIN SELECTION METHODS - -/** -* Resets the calendar widget to the originally selected month and year, and -* sets the calendar to the initial selection(s). -* @method reset -*/ -YAHOO.widget.Calendar.prototype.reset = function() { - this.cfg.resetProperty("selected"); - this.cfg.resetProperty("pagedate"); - this.resetEvent.fire(); -}; - -/** -* Clears the selected dates in the current calendar widget and sets the calendar -* to the current month and year. -* @method clear -*/ -YAHOO.widget.Calendar.prototype.clear = function() { - this.cfg.setProperty("selected", []); - this.cfg.setProperty("pagedate", new Date(this.today.getTime())); - this.clearEvent.fire(); -}; - -/** -* 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. -* @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). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -*/ -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<aToBeSelected.length;++a) { - var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select - if (this._indexOfSelectedFieldArray(toSelect) == -1) { // not already selected? - selected[selected.length]=toSelect; - } - } - - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); - } - - this.selectEvent.fire(aToBeSelected); - - return this.getSelectedDates(); -}; - -/** -* Selects a date on the current calendar by referencing the index of the cell that should be selected. -* This method is used to easily select a single cell (usually with a mouse click) without having to do -* a full render. The selected style is applied to the cell directly. -* @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 selectDate = cellDate.concat(); - - selected[selected.length] = selectDate; - - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); - } - - this.renderCellStyleSelected(dCellDate,cell); - - this.selectEvent.fire([selectDate]); - - this.doCellMouseOut.call(cell, null, this); - - return this.getSelectedDates(); -}; - -/** -* Deselects a date or a collection of dates on the current calendar. This method, by default, -* does not call the render method explicitly. Once deselection has completed, render must be -* called for the changes to be reflected visually. -* @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). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {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 aToBeSelected = this._toFieldArray(date); - - for (var a=0;a<aToBeSelected.length;++a) { - var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select - var index = this._indexOfSelectedFieldArray(toSelect); - - if (index != -1) { - selected.splice(index,1); - } - } - - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); - } - - this.deselectEvent.fire(aToBeSelected); - - return this.getSelectedDates(); -}; - -/** -* Deselects a date on the current calendar by referencing the index of the cell that should be deselected. -* This method is used to easily deselect a single cell (usually with a mouse click) without having to do -* a full render. The selected style is removed from the cell directly. -* @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(); - - var selected = this.cfg.getProperty("selected"); - - var cell = this.cells[i]; - var cellDate = this.cellDates[i]; - var cellDateIndex = this._indexOfSelectedFieldArray(cellDate); - - var dCellDate = this._toDate(cellDate); - - var selectDate = cellDate.concat(); - - if (cellDateIndex > -1) { - if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() && - this.cfg.getProperty("pagedate").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(); -}; - -/** -* Deselects all dates on the current calendar. -* @method deselectAll -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -* Assuming that this function executes properly, the return value should be an empty array. -* However, the empty array is returned for the sake of being able to check the selection status -* of the calendar. -*/ -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 (count > 0) { - this.deselectEvent.fire(sel); - } - - return this.getSelectedDates(); -}; - -// END SELECTION METHODS - -// BEGIN TYPE CONVERSION METHODS - -/** -* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure -* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]]. -* @method _toFieldArray -* @private -* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are -* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {Array[](Number[])} Array of date field arrays -*/ -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;i<date.length;++i) { - var d = date[i]; - returnDate[returnDate.length] = [d.getFullYear(),d.getMonth()+1,d.getDate()]; - } - } - - return returnDate; -}; - -/** -* Converts a date field array [yyyy,mm,dd] to a JavaScript Date object. -* @method _toDate -* @private -* @param {Number[]} dateFieldArray The date field array to convert to a JavaScript Date. -* @return {Date} JavaScript Date object representing the date field array -*/ -YAHOO.widget.Calendar.prototype._toDate = function(dateFieldArray) { - if (dateFieldArray instanceof Date) { - return dateFieldArray; - } else { - return new Date(dateFieldArray[0],dateFieldArray[1]-1,dateFieldArray[2]); - } -}; - -// END TYPE CONVERSION METHODS - -// BEGIN UTILITY METHODS - -/** -* Converts a date field array [yyyy,mm,dd] to a JavaScript Date object. -* @method _fieldArraysAreEqual -* @private -* @param {Number[]} array1 The first date field array to compare -* @param {Number[]} array2 The first date field array to compare -* @return {Boolean} The boolean that represents the equality of the two arrays -*/ -YAHOO.widget.Calendar.prototype._fieldArraysAreEqual = function(array1, array2) { - var match = false; - - if (array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2]) { - match=true; - } - - return match; -}; - -/** -* Gets the index of a date field array [yyyy,mm,dd] in the current list of selected dates. -* @method _indexOfSelectedFieldArray -* @private -* @param {Number[]} find The date field array to search for -* @return {Number} The index of the date field array within the collection of selected dates. -* -1 will be returned if the date is not found. -*/ -YAHOO.widget.Calendar.prototype._indexOfSelectedFieldArray = function(find) { - var selected = -1; - var seldates = this.cfg.getProperty("selected"); - - for (var s=0;s<seldates.length;++s) { - var sArray = seldates[s]; - if (find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2]) { - selected = s; - break; - } - } - - return selected; -}; - -/** -* Determines whether a given date is OOM (out of month). -* @method isDateOOM -* @param {Date} date The JavaScript Date object for which to check the OOM status -* @return {Boolean} true if the date is OOM -*/ -YAHOO.widget.Calendar.prototype.isDateOOM = function(date) { - var isOOM = false; - if (date.getMonth() != this.cfg.getProperty("pagedate").getMonth()) { - isOOM = true; - } - return isOOM; -}; - -/** - * 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; - - if (date) { - if (date instanceof Date) { - parsedDate = YAHOO.widget.DateMath.findMonthStart(date); - } else { - var month, year, aMonthYear; - aMonthYear = date.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); - - parsedDate = new Date(year, month, 1); - } - } else { - parsedDate = new Date(this.today.getFullYear(), this.today.getMonth(), 1); - } - return parsedDate; -}; - -// END UTILITY METHODS - -// BEGIN EVENT HANDLERS - -/** -* Event executed before a date is selected in the calendar widget. -* @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.parent) { - this.parent.callChildFunction("clearAllBodyCellStyles", this.Style.CSS_CELL_SELECTED); - this.parent.deselectAll(); - } else { - this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED); - this.deselectAll(); - } - } -}; - -/** -* Event executed when a date is selected in the calendar widget. -* @param {Array} selected An array of date field arrays representing which date or dates were selected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ] -* @deprecated Event handlers for this event should be susbcribed to selectEvent. -*/ -YAHOO.widget.Calendar.prototype.onSelect = function(selected) { }; - -/** -* Event executed before a date is deselected in the calendar widget. -* @deprecated Event handlers for this event should be susbcribed to beforeDeselectEvent. -*/ -YAHOO.widget.Calendar.prototype.onBeforeDeselect = function() { }; - -/** -* Event executed when a date is deselected in the calendar widget. -* @param {Array} selected An array of date field arrays representing which date or dates were deselected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ] -* @deprecated Event handlers for this event should be susbcribed to deselectEvent. -*/ -YAHOO.widget.Calendar.prototype.onDeselect = function(deselected) { }; - -/** -* Event executed when the user navigates to a different calendar page. -* @deprecated Event handlers for this event should be susbcribed to changePageEvent. -*/ -YAHOO.widget.Calendar.prototype.onChangePage = function() { - this.render(); -}; - -/** -* Event executed when the calendar widget is rendered. -* @deprecated Event handlers for this event should be susbcribed to renderEvent. -*/ -YAHOO.widget.Calendar.prototype.onRender = function() { }; - -/** -* Event executed when the calendar widget is reset to its original state. -* @deprecated Event handlers for this event should be susbcribed to resetEvemt. -*/ -YAHOO.widget.Calendar.prototype.onReset = function() { this.render(); }; - -/** -* Event executed when the calendar widget is completely cleared to the current month with no selections. -* @deprecated Event handlers for this event should be susbcribed to clearEvent. -*/ -YAHOO.widget.Calendar.prototype.onClear = function() { this.render(); }; - -/** -* Validates the calendar widget. This method has no default implementation -* and must be extended by subclassing the widget. -* @return Should return true if the widget validates, and false if -* it doesn't. -* @type Boolean -*/ -YAHOO.widget.Calendar.prototype.validate = function() { return true; }; - -// END EVENT HANDLERS - -// BEGIN DATE PARSE METHODS - -/** -* Converts a date string to a date field array -* @private -* @param {String} sDate Date string. Valid formats are mm/dd and mm/dd/yyyy. -* @return A date field array representing the string passed to the method -* @type Array[](Number[]) -*/ -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;i<rArray.length;i++) { - rArray[i] = parseInt(rArray[i], 10); - } - - return rArray; -}; - -/** -* Converts a multi or single-date string to an array of date field arrays -* @private -* @param {String} sDates Date string with one or more comma-delimited dates. Valid formats are mm/dd, mm/dd/yyyy, mm/dd/yyyy-mm/dd/yyyy -* @return An array of date field arrays -* @type Array[](Number[]) -*/ -YAHOO.widget.Calendar.prototype._parseDates = function(sDates) { - var aReturn = []; - - var aDates = sDates.split(this.Locale.DATE_DELIMITER); - - for (var d=0;d<aDates.length;++d) { - var sDate = aDates[d]; - - if (sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER) != -1) { - // This is a range - var aRange = sDate.split(this.Locale.DATE_RANGE_DELIMITER); - - var dateStart = this._parseDate(aRange[0]); - var dateEnd = this._parseDate(aRange[1]); - - var fullRange = this._parseRange(dateStart, dateEnd); - aReturn = aReturn.concat(fullRange); - } else { - // This is not a range - var aDate = this._parseDate(sDate); - aReturn.push(aDate); - } - } - return aReturn; -}; - -/** -* Converts a date range to the full list of included dates -* @private -* @param {Number[]} startDate Date field array representing the first date in the range -* @param {Number[]} endDate Date field array representing the last date in the range -* @return An array of date field arrays -* @type Array[](Number[]) -*/ -YAHOO.widget.Calendar.prototype._parseRange = function(startDate, endDate) { - var dStart = new Date(startDate[0],startDate[1]-1,startDate[2]); - var dCurrent = YAHOO.widget.DateMath.add(new Date(startDate[0],startDate[1]-1,startDate[2]),YAHOO.widget.DateMath.DAY,1); - var dEnd = new Date(endDate[0], endDate[1]-1, endDate[2]); - - var results = []; - results.push(startDate); - while (dCurrent.getTime() <= dEnd.getTime()) { - results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]); - dCurrent = YAHOO.widget.DateMath.add(dCurrent,YAHOO.widget.DateMath.DAY,1); - } - return results; -}; - -// END DATE PARSE METHODS - -// BEGIN RENDERER METHODS - -/** -* Resets the render stack of the current calendar to its original pre-render value. -*/ -YAHOO.widget.Calendar.prototype.resetRenderers = function() { - this.renderStack = this._renderStack.concat(); -}; - -/** -* Clears the inner HTML, CSS class and style information from the specified cell. -* @method clearElement -* @param {HTMLTableCellElement} The cell to clear -*/ -YAHOO.widget.Calendar.prototype.clearElement = function(cell) { - cell.innerHTML = " "; - cell.className=""; -}; - -/** -* Adds a renderer to the render stack. The function reference passed to this method will be executed -* when a date cell matches the conditions specified in the date string for this renderer. -* @method addRenderer -* @param {String} sDates A date string to associate with the specified renderer. Valid formats -* include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005) -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.Calendar.prototype.addRenderer = function(sDates, fnRender) { - var aDates = this._parseDates(sDates); - for (var i=0;i<aDates.length;++i) { - var aDate = aDates[i]; - - if (aDate.length == 2) { // this is either a range or a month/day combo - if (aDate[0] instanceof Array) { // this is a range - this._addRenderer(YAHOO.widget.Calendar.RANGE,aDate,fnRender); - } else { // this is a month/day combo - this._addRenderer(YAHOO.widget.Calendar.MONTH_DAY,aDate,fnRender); - } - } else if (aDate.length == 3) { - this._addRenderer(YAHOO.widget.Calendar.DATE,aDate,fnRender); - } - } -}; - -/** -* The private method used for adding cell renderers to the local render stack. -* This method is called by other methods that set the renderer type prior to the method call. -* @method _addRenderer -* @private -* @param {String} type The type string that indicates the type of date renderer being added. -* Values are YAHOO.widget.Calendar.DATE, YAHOO.widget.Calendar.MONTH_DAY, YAHOO.widget.Calendar.WEEKDAY, -* YAHOO.widget.Calendar.RANGE, YAHOO.widget.Calendar.MONTH -* @param {Array} aDates An array of dates used to construct the renderer. The format varies based -* on the renderer type -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.Calendar.prototype._addRenderer = function(type, aDates, fnRender) { - var add = [type,aDates,fnRender]; - this.renderStack.unshift(add); - this._renderStack = this.renderStack.concat(); -}; - -/** -* Adds a month to the render stack. The function reference passed to this method will be executed -* when a date cell matches the month passed to this method. -* @method addMonthRenderer -* @param {Number} month The month (1-12) to associate with this renderer -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.Calendar.prototype.addMonthRenderer = function(month, fnRender) { - this._addRenderer(YAHOO.widget.Calendar.MONTH,[month],fnRender); -}; - -/** -* Adds a weekday to the render stack. The function reference passed to this method will be executed -* when a date cell matches the weekday passed to this method. -* @method addWeekdayRenderer -* @param {Number} weekday The weekday (0-6) to associate with this renderer -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.Calendar.prototype.addWeekdayRenderer = function(weekday, fnRender) { - this._addRenderer(YAHOO.widget.Calendar.WEEKDAY,[weekday],fnRender); -}; - -// END RENDERER METHODS - -// BEGIN CSS METHODS - -/** -* Removes all styles from all body cells in the current calendar table. -* @method clearAllBodyCellStyles -* @param {style} The CSS class name to remove from all calendar body cells -*/ -YAHOO.widget.Calendar.prototype.clearAllBodyCellStyles = function(style) { - for (var c=0;c<this.cells.length;++c) { - YAHOO.util.Dom.removeClass(this.cells[c],style); - } -}; - -// END CSS METHODS - -// BEGIN GETTER/SETTER METHODS -/** -* Sets the calendar's month explicitly -* @method setMonth -* @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"); - current.setMonth(parseInt(month, 10)); - this.cfg.setProperty("pagedate", current); -}; - -/** -* Sets the calendar's year explicitly. -* @method setYear -* @param {Number} year The numeric 4-digit year -*/ -YAHOO.widget.Calendar.prototype.setYear = function(year) { - var current = this.cfg.getProperty("pagedate"); - current.setFullYear(parseInt(year, 10)); - this.cfg.setProperty("pagedate", current); -}; - -/** -* Gets the list of currently selected dates from the calendar. -* @method getSelectedDates -* @return {Date[]} An array of currently selected JavaScript Date objects. -*/ -YAHOO.widget.Calendar.prototype.getSelectedDates = function() { - var returnDates = []; - var selected = this.cfg.getProperty("selected"); - - for (var d=0;d<selected.length;++d) { - var dateArray = selected[d]; - - var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]); - returnDates.push(date); - } - - returnDates.sort( function(a,b) { return a-b; } ); - return returnDates; -}; - -/// END GETTER/SETTER METHODS /// - -/** -* Hides the Calendar's outer container from view. -* @method hide -*/ -YAHOO.widget.Calendar.prototype.hide = function() { - this.oDomContainer.style.display = "none"; -}; - -/** -* Shows the Calendar's outer container. -* @method show -*/ -YAHOO.widget.Calendar.prototype.show = function() { - this.oDomContainer.style.display = "block"; -}; - -/** -* Returns a string representing the current browser. -* @property browser -* @type String -*/ -YAHOO.widget.Calendar.prototype.browser = function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) - return 'opera'; - } else if (ua.indexOf('msie 7')!=-1) { // IE7 - return 'ie7'; - } else if (ua.indexOf('msie') !=-1) { // IE - return 'ie'; - } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") - return 'safari'; - } else if (ua.indexOf('gecko') != -1) { // Gecko - return 'gecko'; - } else { - return false; - } - }(); -/** -* Returns a string representation of the object. -* @method toString -* @return {String} A string representation of the Calendar object. -*/ -YAHOO.widget.Calendar.prototype.toString = function() { - return "Calendar " + this.id; -}; - -/** -* @namespace YAHOO.widget -* @class Calendar_Core -* @extends YAHOO.widget.Calendar -* @deprecated The old Calendar_Core class is no longer necessary. -*/ -YAHOO.widget.Calendar_Core = YAHOO.widget.Calendar; - -YAHOO.widget.Cal_Core = YAHOO.widget.Calendar; - -/** -* YAHOO.widget.CalendarGroup is a special container class for YAHOO.widget.Calendar. This class facilitates -* the ability to have multi-page calendar views that share a single dataset and are -* dependent on each other. -* -* The calendar group instance will refer to each of its elements using a 0-based index. -* For example, to construct the placeholder for a calendar group widget with id "cal1" and -* containerId of "cal1Container", the markup would be as follows: -* <xmp> -* <div id="cal1Container_0"></div> -* <div id="cal1Container_1"></div> -* </xmp> -* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers. -* @namespace YAHOO.widget -* @class CalendarGroup -* @constructor -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -YAHOO.widget.CalendarGroup = function(id, containerId, config) { - if (arguments.length > 0) { - this.init(id, containerId, config); - } -}; - -/** -* Initializes the calendar group. All subclasses must call this method in order for the -* group to be initialized properly. -* @method init -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -YAHOO.widget.CalendarGroup.prototype.init = function(id, containerId, config) { - this.logger = new YAHOO.widget.LogWriter("CalendarGroup " + id); - this.initEvents(); - this.initStyles(); - - /** - * The collection of Calendar pages contained within the CalendarGroup - * @property pages - * @type YAHOO.widget.Calendar[] - */ - this.pages = []; - - /** - * The unique id associated with the CalendarGroup - * @property id - * @type String - */ - this.id = id; - - /** - * The unique id associated with the CalendarGroup container - * @property containerId - * @type String - */ - this.containerId = containerId; - - /** - * The outer containing element for the CalendarGroup - * @property oDomContainer - * @type HTMLElement - */ - 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); - - /** - * The Config object used to hold the configuration variables for the CalendarGroup - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - /** - * The local object which contains the CalendarGroup's options - * @property Options - * @type Object - */ - this.Options = {}; - - /** - * The local object which contains the CalendarGroup's locale settings - * @property Locale - * @type Object - */ - this.Locale = {}; - - this.setupConfig(); - - if (config) { - this.cfg.applyConfig(config, true); - } - - this.cfg.fireQueue(); - - // OPERA HACK FOR MISWRAPPED FLOATS - if (this.browser == "opera"){ - var fixWidth = function() { - var startW = this.oDomContainer.offsetWidth; - var w = 0; - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - w += cal.oDomContainer.offsetWidth; - } - if (w > 0) { - this.oDomContainer.style.width = w + "px"; - } - }; - this.renderEvent.subscribe(fixWidth,this,true); - } - this.logger.log("Initialized " + this.pages.length + "-page CalendarGroup", "info"); -}; - - -YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { - /** - * 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 } ); - - /** - * 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 } ); - - /** - * The date or range of dates representing the current Calendar selection - * @config selected - * @type String - * @default [] - */ - this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } ); - - /** - * The title to display above the CalendarGroup's month header - * @config title - * @type String - * @default "" - */ - this.cfg.addProperty("title", { value:"", handler:this.configTitle } ); - - /** - * Whether or not a close button should be displayed for this CalendarGroup - * @config close - * @type Boolean - * @default false - */ - this.cfg.addProperty("close", { value:false, 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. - * @config iframe - * @type Boolean - * @default true - */ - this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * The minimum selectable date in the current Calendar (mm/dd/yyyy) - * @config mindate - * @type String - * @default null - */ - this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } ); - - /** - * The maximum selectable date in the current Calendar (mm/dd/yyyy) - * @config maxdate - * @type String - * @default null - */ - this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig } ); - - // Options properties - - /** - * True if the Calendar should allow multiple selections. False by default. - * @config MULTI_SELECT - * @type Boolean - * @default false - */ - this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * The weekday the week begins on. Default is 0 (Sunday). - * @config START_WEEKDAY - * @type number - * @default 0 - */ - this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * True if the Calendar should show weekday labels. True by default. - * @config SHOW_WEEKDAYS - * @type Boolean - * @default true - */ - this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row headers. False by default. - * @config SHOW_WEEK_HEADER - * @type Boolean - * @default false - */ - this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row footers. False by default. - * @config SHOW_WEEK_FOOTER - * @type Boolean - * @default false - */ - this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, 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. - * @config HIDE_BLANK_WEEKS - * @type Boolean - * @default false - */ - this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * The image that should be used for the left navigation arrow. - * @config NAV_ARROW_LEFT - * @type String - * @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:null, handler:this.delegateConfig } ); - - /** - * The image that should be used for the right navigation arrow. - * @config NAV_ARROW_RIGHT - * @type String - * @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:null, handler:this.delegateConfig } ); - - // Locale properties - - /** - * The short month labels for the current locale. - * @config MONTHS_SHORT - * @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 } ); - - /** - * The long month labels for the current locale. - * @config MONTHS_LONG - * @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 } ); - - /** - * The 1-character weekday labels for the current locale. - * @config WEEKDAYS_1CHAR - * @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 } ); - - /** - * The short weekday labels for the current locale. - * @config WEEKDAYS_SHORT - * @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 } ); - - /** - * The medium weekday labels for the current locale. - * @config WEEKDAYS_MEDIUM - * @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 } ); - - /** - * The long weekday labels for the current locale. - * @config WEEKDAYS_LONG - * @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 } ); - - /** - * The setting that determines which length of month labels should be used. Possible values are "short" and "long". - * @config LOCALE_MONTHS - * @type String - * @default "long" - */ - this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.delegateConfig } ); - - /** - * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". - * @config LOCALE_WEEKDAYS - * @type String - * @default "short" - */ - this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.delegateConfig } ); - - /** - * The value used to delimit individual dates in a date string passed to various Calendar functions. - * @config DATE_DELIMITER - * @type String - * @default "," - */ - this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.delegateConfig } ); - - /** - * The value used to delimit date fields in a date string passed to various Calendar functions. - * @config DATE_FIELD_DELIMITER - * @type String - * @default "/" - */ - this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } ); - - /** - * The value used to delimit date ranges in a date string passed to various Calendar functions. - * @config DATE_RANGE_DELIMITER - * @type String - * @default "-" - */ - this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } ); - - /** - * The position of the month in a month/year date string - * @config MY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/year date string - * @config MY_YEAR_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day date string - * @config MD_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/year date string - * @config MD_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day/year date string - * @config MDY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/day/year date string - * @config MDY_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/day/year date string - * @config MDY_YEAR_POSITION - * @type Number - * @default 3 - */ - this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - -}; - -/** -* Initializes CalendarGroup's built-in CustomEvents -* @method initEvents -*/ -YAHOO.widget.CalendarGroup.prototype.initEvents = function() { - var me = this; - - /** - * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents - * @method sub - * @private - * @param {Function} fn The function to subscribe to this CustomEvent - * @param {Object} obj The CustomEvent's scope object - * @param {Boolean} bOverride Whether or not to apply scope correction - */ - var sub = function(fn, obj, bOverride) { - for (var p=0;p<me.pages.length;++p) { - var cal = me.pages[p]; - cal[this.type + "Event"].subscribe(fn, obj, bOverride); - } - }; - - /** - * Proxy unsubscriber to unsubscribe from the CalendarGroup's child Calendars' CustomEvents - * @method unsub - * @private - * @param {Function} fn The function to subscribe to this CustomEvent - * @param {Object} obj The CustomEvent's scope object - */ - var unsub = function(fn, obj) { - for (var p=0;p<me.pages.length;++p) { - var cal = me.pages[p]; - cal[this.type + "Event"].unsubscribe(fn, obj); - } - }; - - /** - * Fired before a selection is made - * @event beforeSelectEvent - */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect"); - this.beforeSelectEvent.subscribe = sub; this.beforeSelectEvent.unsubscribe = unsub; - - /** - * 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.subscribe = sub; this.selectEvent.unsubscribe = unsub; - - /** - * Fired before a selection is made - * @event beforeDeselectEvent - */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect"); - this.beforeDeselectEvent.subscribe = sub; this.beforeDeselectEvent.unsubscribe = unsub; - - /** - * 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.subscribe = sub; this.deselectEvent.unsubscribe = unsub; - - /** - * Fired when the Calendar page is changed - * @event changePageEvent - */ - this.changePageEvent = new YAHOO.util.CustomEvent("changePage"); - this.changePageEvent.subscribe = sub; this.changePageEvent.unsubscribe = unsub; - - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - this.beforeRenderEvent.subscribe = sub; this.beforeRenderEvent.unsubscribe = unsub; - - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); - this.renderEvent.subscribe = sub; this.renderEvent.unsubscribe = unsub; - - /** - * Fired when the Calendar is reset - * @event resetEvent - */ - this.resetEvent = new YAHOO.util.CustomEvent("reset"); - this.resetEvent.subscribe = sub; this.resetEvent.unsubscribe = unsub; - - /** - * Fired when the Calendar is cleared - * @event clearEvent - */ - this.clearEvent = new YAHOO.util.CustomEvent("clear"); - this.clearEvent.subscribe = sub; this.clearEvent.unsubscribe = unsub; - -}; - -/** -* The default Config handler for the "pages" property -* @method configPages -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.CalendarGroup.prototype.configPages = function(type, args, obj) { - var pageCount = args[0]; - - for (var p=0;p<pageCount;++p) { - var calId = this.id + "_" + p; - var calContainerId = this.containerId + "_" + p; - - var childConfig = this.cfg.getConfig(); - childConfig.close = false; - childConfig.title = false; - - var cal = this.constructChild(calId, calContainerId, childConfig); - var caldate = cal.cfg.getProperty("pagedate"); - this._setMonthOnDate(caldate, caldate.getMonth() + p); - cal.cfg.setProperty("pagedate", caldate); - - YAHOO.util.Dom.removeClass(cal.oDomContainer, this.Style.CSS_SINGLE); - YAHOO.util.Dom.addClass(cal.oDomContainer, "groupcal"); - - if (p===0) { - YAHOO.util.Dom.addClass(cal.oDomContainer, "first"); - } - - if (p==(pageCount-1)) { - YAHOO.util.Dom.addClass(cal.oDomContainer, "last"); - } - - cal.parent = this; - cal.index = p; - - this.pages[this.pages.length] = cal; - } -}; - -/** -* The default Config handler for the "pagedate" property -* @method configPageDate -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.CalendarGroup.prototype.configPageDate = function(type, args, obj) { - var val = args[0]; - var firstPageDate; - - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - if (p === 0) { - firstPageDate = cal._parsePageDate(val); - cal.cfg.setProperty("pagedate", firstPageDate); - } else { - var pageDate = new Date(firstPageDate); - this._setMonthOnDate(pageDate, pageDate.getMonth() + p); - cal.cfg.setProperty("pagedate", pageDate); - } - } -}; - -/** -* Delegates a configuration property to the CustomEvents associated with the CalendarGroup's children -* @method delegateConfig -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.CalendarGroup.prototype.delegateConfig = function(type, args, obj) { - var val = args[0]; - var cal; - - for (var p=0;p<this.pages.length;p++) { - cal = this.pages[p]; - cal.cfg.setProperty(type, val); - } -}; - - -/** -* Adds a function to all child Calendars within this CalendarGroup. -* @method setChildFunction -* @param {String} fnName The name of the function -* @param {Function} fn The function to apply to each Calendar page object -*/ -YAHOO.widget.CalendarGroup.prototype.setChildFunction = function(fnName, fn) { - var pageCount = this.cfg.getProperty("pages"); - - for (var p=0;p<pageCount;++p) { - this.pages[p][fnName] = fn; - } -}; - -/** -* Calls a function within all child Calendars within this CalendarGroup. -* @method callChildFunction -* @param {String} fnName The name of the function -* @param {Array} args The arguments to pass to the function -*/ -YAHOO.widget.CalendarGroup.prototype.callChildFunction = function(fnName, args) { - var pageCount = this.cfg.getProperty("pages"); - - for (var p=0;p<pageCount;++p) { - var page = this.pages[p]; - if (page[fnName]) { - var fn = page[fnName]; - fn.call(page, args); - } - } -}; - -/** -* Constructs a child calendar. This method can be overridden if a subclassed version of the default -* calendar is to be used. -* @method constructChild -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -* @return {YAHOO.widget.Calendar} The YAHOO.widget.Calendar instance that is constructed -*/ -YAHOO.widget.CalendarGroup.prototype.constructChild = function(id,containerId,config) { - var container = document.getElementById(containerId); - if (! container) { - container = document.createElement("div"); - container.id = containerId; - this.oDomContainer.appendChild(container); - } - return new YAHOO.widget.Calendar(id,containerId,config); -}; - - -/** -* Sets the calendar group's month explicitly. This month will be set into the first -* page of the multi-page calendar, and all other months will be iterated appropriately. -* @method setMonth -* @param {Number} month The numeric month, from 0 (January) to 11 (December) -*/ -YAHOO.widget.CalendarGroup.prototype.setMonth = function(month) { - month = parseInt(month, 10); - var currYear; - - for (var p=0; p<this.pages.length; ++p) { - var cal = this.pages[p]; - var pageDate = cal.cfg.getProperty("pagedate"); - if (p === 0) { - currYear = pageDate.getFullYear(); - } else { - pageDate.setYear(currYear); - } - this._setMonthOnDate(pageDate, month+p); - cal.cfg.setProperty("pagedate", pageDate); - } -}; - -/** -* Sets the calendar group's year explicitly. This year will be set into the first -* page of the multi-page calendar, and all other months will be iterated appropriately. -* @method setYear -* @param {Number} year The numeric 4-digit year -*/ -YAHOO.widget.CalendarGroup.prototype.setYear = function(year) { - year = parseInt(year, 10); - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - var pageDate = cal.cfg.getProperty("pageDate"); - - if ((pageDate.getMonth()+1) == 1 && p>0) { - year+=1; - } - cal.setYear(year); - } -}; -/** -* Calls the render function of all child calendars within the group. -* @method render -*/ -YAHOO.widget.CalendarGroup.prototype.render = function() { - this.renderHeader(); - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.render(); - } - this.renderFooter(); -}; - -/** -* 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. -* @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). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -*/ -YAHOO.widget.CalendarGroup.prototype.select = function(date) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.select(date); - } - return this.getSelectedDates(); -}; - -/** -* Selects a date on the current calendar by referencing the index of the cell that should be selected. -* This method is used to easily select a single cell (usually with a mouse click) without having to do -* a full render. The selected style is applied to the cell directly. -* @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.CalendarGroup.prototype.selectCell = function(cellIndex) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.selectCell(cellIndex); - } - return this.getSelectedDates(); -}; - -/** -* Deselects a date or a collection of dates on the current calendar. This method, by default, -* does not call the render method explicitly. Once deselection has completed, render must be -* called for the changes to be reflected visually. -* @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). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -*/ -YAHOO.widget.CalendarGroup.prototype.deselect = function(date) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.deselect(date); - } - return this.getSelectedDates(); -}; - -/** -* Deselects all dates on the current calendar. -* @method deselectAll -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -* Assuming that this function executes properly, the return value should be an empty array. -* However, the empty array is returned for the sake of being able to check the selection status -* of the calendar. -*/ -YAHOO.widget.CalendarGroup.prototype.deselectAll = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.deselectAll(); - } - return this.getSelectedDates(); -}; - -/** -* Deselects a date on the current calendar by referencing the index of the cell that should be deselected. -* This method is used to easily deselect a single cell (usually with a mouse click) without having to do -* a full render. The selected style is removed from the cell directly. -* @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.CalendarGroup.prototype.deselectCell = function(cellIndex) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.deselectCell(cellIndex); - } - return this.getSelectedDates(); -}; - -/** -* Resets the calendar widget to the originally selected month and year, and -* sets the calendar to the initial selection(s). -* @method reset -*/ -YAHOO.widget.CalendarGroup.prototype.reset = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.reset(); - } -}; - -/** -* Clears the selected dates in the current calendar widget and sets the calendar -* to the current month and year. -* @method clear -*/ -YAHOO.widget.CalendarGroup.prototype.clear = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.clear(); - } -}; - -/** -* Navigates to the next month page in the calendar widget. -* @method nextMonth -*/ -YAHOO.widget.CalendarGroup.prototype.nextMonth = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.nextMonth(); - } -}; - -/** -* Navigates to the previous month page in the calendar widget. -* @method previousMonth -*/ -YAHOO.widget.CalendarGroup.prototype.previousMonth = function() { - for (var p=this.pages.length-1;p>=0;--p) { - var cal = this.pages[p]; - cal.previousMonth(); - } -}; - -/** -* Navigates to the next year in the currently selected month in the calendar widget. -* @method nextYear -*/ -YAHOO.widget.CalendarGroup.prototype.nextYear = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.nextYear(); - } -}; - -/** -* Navigates to the previous year in the currently selected month in the calendar widget. -* @method previousYear -*/ -YAHOO.widget.CalendarGroup.prototype.previousYear = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.previousYear(); - } -}; - - -/** -* Gets the list of currently selected dates from the calendar. -* @return An array of currently selected JavaScript Date objects. -* @type Date[] -*/ -YAHOO.widget.CalendarGroup.prototype.getSelectedDates = function() { - var returnDates = []; - var selected = this.cfg.getProperty("selected"); - - for (var d=0;d<selected.length;++d) { - var dateArray = selected[d]; - - var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]); - returnDates.push(date); - } - - returnDates.sort( function(a,b) { return a-b; } ); - return returnDates; -}; - -/** -* Adds a renderer to the render stack. The function reference passed to this method will be executed -* when a date cell matches the conditions specified in the date string for this renderer. -* @method addRenderer -* @param {String} sDates A date string to associate with the specified renderer. Valid formats -* include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005) -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.CalendarGroup.prototype.addRenderer = function(sDates, fnRender) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.addRenderer(sDates, fnRender); - } -}; - -/** -* Adds a month to the render stack. The function reference passed to this method will be executed -* when a date cell matches the month passed to this method. -* @method addMonthRenderer -* @param {Number} month The month (1-12) to associate with this renderer -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.CalendarGroup.prototype.addMonthRenderer = function(month, fnRender) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.addMonthRenderer(month, fnRender); - } -}; - -/** -* Adds a weekday to the render stack. The function reference passed to this method will be executed -* when a date cell matches the weekday passed to this method. -* @method addWeekdayRenderer -* @param {Number} weekday The weekday (0-6) to associate with this renderer -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.CalendarGroup.prototype.addWeekdayRenderer = function(weekday, fnRender) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.addWeekdayRenderer(weekday, fnRender); - } -}; - -/** -* Renders the header for the CalendarGroup. -* @method renderHeader -*/ -YAHOO.widget.CalendarGroup.prototype.renderHeader = function() {}; - -/** -* Renders a footer for the 2-up calendar container. By default, this method is -* unimplemented. -* @method renderFooter -*/ -YAHOO.widget.CalendarGroup.prototype.renderFooter = function() {}; - -/** -* Adds the designated number of months to the current calendar month, and sets the current -* calendar page date to the new month. -* @method addMonths -* @param {Number} count The number of months to add to the current calendar -*/ -YAHOO.widget.CalendarGroup.prototype.addMonths = function(count) { - this.callChildFunction("addMonths", count); -}; - - -/** -* Subtracts the designated number of months from the current calendar month, and sets the current -* calendar page date to the new month. -* @method subtractMonths -* @param {Number} count The number of months to subtract from the current calendar -*/ -YAHOO.widget.CalendarGroup.prototype.subtractMonths = function(count) { - this.callChildFunction("subtractMonths", count); -}; - -/** -* Adds the designated number of years to the current calendar, and sets the current -* calendar page date to the new month. -* @method addYears -* @param {Number} count The number of years to add to the current calendar -*/ -YAHOO.widget.CalendarGroup.prototype.addYears = function(count) { - this.callChildFunction("addYears", count); -}; - -/** -* Subtcats the designated number of years from the current calendar, and sets the current -* calendar page date to the new month. -* @method subtractYears -* @param {Number} count The number of years to subtract from the current calendar -*/ -YAHOO.widget.CalendarGroup.prototype.subtractYears = function(count) { - this.callChildFunction("subtractYears", count); -}; - -/** -* Sets the month on a Date object, taking into account year rollover if the month is less than 0 or greater than 11. -* The Date object passed in is modified. It should be cloned before passing it into this method if the original value needs to be maintained -* @method _setMonthOnDate -* @private -* @param {Date} date The Date object on which to set the month index -* @param {Number} iMonth The month index to set -*/ -YAHOO.widget.CalendarGroup.prototype._setMonthOnDate = function(date, iMonth) { - // BUG in Safari 1.3, 2.0 (WebKit build < 420), Date.setMonth does not work consistently if iMonth is not 0-11 - if (this.browser == "safari" && (iMonth < 0 || iMonth > 11)) { - var DM = YAHOO.widget.DateMath; - var newDate = DM.add(date, DM.MONTH, iMonth-date.getMonth()); - date.setTime(newDate.getTime()); - } else { - date.setMonth(iMonth); - } -}; - - -/** -* CSS class representing the container for the calendar -* @property YAHOO.widget.CalendarGroup.CSS_CONTAINER -* @static -* @final -* @type String -*/ -YAHOO.widget.CalendarGroup.CSS_CONTAINER = "yui-calcontainer"; - -/** -* CSS class representing the container for the calendar -* @property YAHOO.widget.CalendarGroup.CSS_MULTI_UP -* @static -* @final -* @type String -*/ -YAHOO.widget.CalendarGroup.CSS_MULTI_UP = "multi"; - -/** -* CSS class representing the title for the 2-up calendar -* @property YAHOO.widget.CalendarGroup.CSS_2UPTITLE -* @static -* @final -* @type String -*/ -YAHOO.widget.CalendarGroup.CSS_2UPTITLE = "title"; - -/** -* CSS class representing the close icon for the 2-up calendar -* @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 <a href="YAHOO.widget.Calendar.html#Style.CSS_CLOSE">Style.CSS_CLOSE</a> 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", - "buildMonthLabel", - "renderOutOfBoundsDate", - "renderRowHeader", - "renderRowFooter", - "renderCellDefault", - "styleCellDefault", - "renderCellStyleHighlight1", - "renderCellStyleHighlight2", - "renderCellStyleHighlight3", - "renderCellStyleHighlight4", - "renderCellStyleToday", - "renderCellStyleSelected", - "renderCellNotThisMonth", - "renderBodyCellRestricted", - "initStyles", - "configTitle", - "configClose", - "hide", - "show", - "browser"); - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} A string representation of the CalendarGroup object. -*/ -YAHOO.widget.CalendarGroup.prototype.toString = function() { - return "CalendarGroup " + this.id; -}; - -YAHOO.widget.CalGrp = YAHOO.widget.CalendarGroup; - -/** -* @class YAHOO.widget.Calendar2up -* @extends YAHOO.widget.CalendarGroup -* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default. -*/ -YAHOO.widget.Calendar2up = function(id, containerId, config) { - this.init(id, containerId, config); -}; - -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; - -YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/calendar/calendar-min.js b/interface/web/js/yui/calendar/calendar-min.js deleted file mode 100644 index 687026526d..0000000000 --- a/interface/web/js/yui/calendar/calendar-min.js +++ /dev/null @@ -1,116 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var queueItemKey=queueItem[0];var queueItemValue=queueItem[1];if(queueItemKey.toLowerCase()==key){eventQueue[i]=null;eventQueue.push([key,(typeof value!='undefined'?value:queueItemValue)]);foundDuplicate=true;break;}}} -if(!foundDuplicate&&typeof value!='undefined'){eventQueue.push([key,value]);}} -if(property.supercedes){for(var s=0;s<property.supercedes.length;s++){var supercedesCheck=property.supercedes[s];for(var q=0;q<eventQueue.length;q++){var queueItemCheck=eventQueue[q];if(queueItemCheck){var queueItemCheckKey=queueItemCheck[0];var queueItemCheckValue=queueItemCheck[1];if(queueItemCheckKey.toLowerCase()==supercedesCheck.toLowerCase()){eventQueue.push([queueItemCheckKey,queueItemCheckValue]);eventQueue[q]=null;break;}}}}} -return true;}else{return false;}};this.refireEvent=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event&&typeof property.value!='undefined'){if(this.queueInProgress){this.queueProperty(key);}else{fireEvent(key,property.value);}}};this.applyConfig=function(userConfig,init){if(init){initialConfig=userConfig;} -for(var prop in userConfig){this.queueProperty(prop,userConfig[prop]);}};this.refresh=function(){for(var prop in config){this.refireEvent(prop);}};this.fireQueue=function(){this.queueInProgress=true;for(var i=0;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var key=queueItem[0];var value=queueItem[1];var property=config[key];property.value=value;fireEvent(key,value);}} -this.queueInProgress=false;eventQueue=[];};this.subscribeToConfigEvent=function(key,handler,obj,override){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(!YAHOO.util.Config.alreadySubscribed(property.event,handler,obj)){property.event.subscribe(handler,obj,override);} -return true;}else{return false;}};this.unsubscribeFromConfigEvent=function(key,handler,obj){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){return property.event.unsubscribe(handler,obj);}else{return false;}};this.toString=function(){var output="Config";if(this.owner){output+=" ["+this.owner.toString()+"]";} -return output;};this.outputEventQueue=function(){var output="";for(var q=0;q<eventQueue.length;q++){var queueItem=eventQueue[q];if(queueItem){output+=queueItem[0]+"="+queueItem[1]+", ";}} -return output;};};YAHOO.util.Config.alreadySubscribed=function(evt,fn,obj){for(var e=0;e<evt.subscribers.length;e++){var subsc=evt.subscribers[e];if(subsc&&subsc.obj==obj&&subsc.fn==fn){return true;}} -return false;};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;}},after: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=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.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(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 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.className="link-close";YAHOO.util.Event.addListener(linkClose,"click",this.hide,this,true);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='<span class="'+YAHOO.widget.CalendarGroup.CSS_2UPCLOSE+' '+this.Style.CSS_CLOSE+'"></span>';} -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;}} -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:null,handler:this.configOptions});this.cfg.addProperty("NAV_ARROW_RIGHT",{value:null,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){this.cfg.setProperty("pagedate",this._parsePageDate(args[0]),true);};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;w<START_WEEKDAY;++w){this.Locale.LOCALE_WEEKDAYS.push(this.Locale.LOCALE_WEEKDAYS.shift());}} -break;}};YAHOO.widget.Calendar.prototype.initStyles=function(){this.Style={CSS_ROW_HEADER:"calrowhead",CSS_ROW_FOOTER:"calrowfoot",CSS_CELL:"calcell",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.buildMonthLabel=function(){var text=this.Locale.LOCALE_MONTHS[this.cfg.getProperty("pagedate").getMonth()]+" "+this.cfg.getProperty("pagedate").getFullYear();return text;};YAHOO.widget.Calendar.prototype.buildDayLabel=function(workingDate){var day=workingDate.getDate();return day;};YAHOO.widget.Calendar.prototype.renderHeader=function(html){var colSpan=7;var DEPR_NAV_LEFT="us/tr/callt.gif";var DEPR_NAV_RIGHT="us/tr/calrt.gif";if(this.cfg.getProperty("SHOW_WEEK_HEADER")){colSpan+=1;} -if(this.cfg.getProperty("SHOW_WEEK_FOOTER")){colSpan+=1;} -html[html.length]="<thead>";html[html.length]="<tr>";html[html.length]='<th colspan="'+colSpan+'" class="'+this.Style.CSS_HEADER_TEXT+'">';html[html.length]='<div class="'+this.Style.CSS_HEADER+'">';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){var leftArrow=this.cfg.getProperty("NAV_ARROW_LEFT");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]='<a class="'+this.Style.CSS_NAV_LEFT+'"'+leftStyle+' > </a>';} -html[html.length]=this.buildMonthLabel();if(renderRight){var rightArrow=this.cfg.getProperty("NAV_ARROW_RIGHT");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]='<a class="'+this.Style.CSS_NAV_RIGHT+'"'+rightStyle+' > </a>';} -html[html.length]='</div>';html[html.length]='</th>';html[html.length]='</tr>';if(this.cfg.getProperty("SHOW_WEEKDAYS")){html=this.buildWeekdays(html);} -html[html.length]='</thead>';return html;};YAHOO.widget.Calendar.prototype.buildWeekdays=function(html){html[html.length]='<tr class="'+this.Style.CSS_WEEKDAY_ROW+'">';if(this.cfg.getProperty("SHOW_WEEK_HEADER")){html[html.length]='<th> </th>';} -for(var i=0;i<this.Locale.LOCALE_WEEKDAYS.length;++i){html[html.length]='<th class="calweekdaycell">'+this.Locale.LOCALE_WEEKDAYS[i]+'</th>';} -if(this.cfg.getProperty("SHOW_WEEK_FOOTER")){html[html.length]='<th> </th>';} -html[html.length]='</tr>';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.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]='<tbody class="m'+(useDate.getMonth()+1)+' '+this.Style.CSS_BODY+'">';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]='<tr class="'+weekClass+'">';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<this.renderStack.length;++s){var rArray=this.renderStack[s];var type=rArray[0];var month;var day;var year;switch(type){case YAHOO.widget.Calendar.DATE:month=rArray[1][1];day=rArray[1][2];year=rArray[1][0];if(workingDate.getMonth()+1==month&&workingDate.getDate()==day&&workingDate.getFullYear()==year){renderer=rArray[2];this.renderStack.splice(s,1);} -break;case YAHOO.widget.Calendar.MONTH_DAY:month=rArray[1][0];day=rArray[1][1];if(workingDate.getMonth()+1==month&&workingDate.getDate()==day){renderer=rArray[2];this.renderStack.splice(s,1);} -break;case YAHOO.widget.Calendar.RANGE:var date1=rArray[1][0];var date2=rArray[1][1];var d1month=date1[1];var d1day=date1[2];var d1year=date1[0];var d1=new Date(d1year,d1month-1,d1day);var d2month=date2[1];var d2day=date2[2];var d2year=date2[0];var d2=new Date(d2year,d2month-1,d2day);if(workingDate.getTime()>=d1.getTime()&&workingDate.getTime()<=d2.getTime()){renderer=rArray[2];if(workingDate.getTime()==d2.getTime()){this.renderStack.splice(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((mindate&&(workingDate.getTime()<mindate.getTime()))||(maxdate&&(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<cellRenderers.length;++x){var ren=cellRenderers[x];if(ren.call((this.parent||this),workingDate,cell)==YAHOO.widget.Calendar.STOP_RENDER){break;}} -workingDate.setTime(workingDate.getTime()+YAHOO.widget.DateMath.ONE_DAY_MS);if(i>=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<blankWeeks;++p){postDays-=7;}} -if(i>=((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);} -html[html.length]='</tr>';}} -html[html.length]='</tbody>';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]='<table cellSpacing="0" class="'+this.Style.CSS_CALENDAR+' y'+workingDate.getFullYear()+'" id="'+this.id+'">';html=this.renderHeader(html);html=this.renderBody(workingDate,html);html=this.renderFooter(html);html[html.length]='</table>';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(YAHOO.lang.hasOwnProperty(this.domEventMap,cls)){var items=this.domEventMap[cls];if(!(items instanceof Array)){items=[items];} -for(var i=0;i<items.length;i++){var item=items[i];elements=YAHOO.util.Dom.getElementsByClassName(cls,item.tag,this.oDomContainer);for(var c=0;c<elements.length;c++){el=elements[c];YAHOO.util.Event.addListener(el,item.event,item.handler,item.scope,item.correct);}}}}} -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]='<th class="calrowhead">'+weekNum+'</th>';return html;};YAHOO.widget.Calendar.prototype.renderRowFooter=function(weekNum,html){html[html.length]='<th class="calrowfoot">'+weekNum+'</th>';return html;};YAHOO.widget.Calendar.prototype.renderCellDefault=function(workingDate,cell){cell.innerHTML='<a href="javascript:void(null);" >'+this.buildDayLabel(workingDate)+"</a>";};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<aToBeSelected.length;++a){var toSelect=aToBeSelected[a];if(this._indexOfSelectedFieldArray(toSelect)==-1){selected[selected.length]=toSelect;}} -if(this.parent){this.parent.cfg.setProperty("selected",selected);}else{this.cfg.setProperty("selected",selected);} -this.selectEvent.fire(aToBeSelected);return this.getSelectedDates();};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 selectDate=cellDate.concat();selected[selected.length]=selectDate;if(this.parent){this.parent.cfg.setProperty("selected",selected);}else{this.cfg.setProperty("selected",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){this.beforeDeselectEvent.fire();var selected=this.cfg.getProperty("selected");var aToBeSelected=this._toFieldArray(date);for(var a=0;a<aToBeSelected.length;++a){var toSelect=aToBeSelected[a];var index=this._indexOfSelectedFieldArray(toSelect);if(index!=-1){selected.splice(index,1);}} -if(this.parent){this.parent.cfg.setProperty("selected",selected);}else{this.cfg.setProperty("selected",selected);} -this.deselectEvent.fire(aToBeSelected);return this.getSelectedDates();};YAHOO.widget.Calendar.prototype.deselectCell=function(i){this.beforeDeselectEvent.fire();var selected=this.cfg.getProperty("selected");var cell=this.cells[i];var cellDate=this.cellDates[i];var cellDateIndex=this._indexOfSelectedFieldArray(cellDate);var dCellDate=this._toDate(cellDate);var selectDate=cellDate.concat();if(cellDateIndex>-1){if(this.cfg.getProperty("pagedate").getMonth()==dCellDate.getMonth()&&this.cfg.getProperty("pagedate").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(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;i<date.length;++i){var d=date[i];returnDate[returnDate.length]=[d.getFullYear(),d.getMonth()+1,d.getDate()];}} -return returnDate;};YAHOO.widget.Calendar.prototype._toDate=function(dateFieldArray){if(dateFieldArray instanceof Date){return dateFieldArray;}else{return new Date(dateFieldArray[0],dateFieldArray[1]-1,dateFieldArray[2]);}};YAHOO.widget.Calendar.prototype._fieldArraysAreEqual=function(array1,array2){var match=false;if(array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2]){match=true;} -return match;};YAHOO.widget.Calendar.prototype._indexOfSelectedFieldArray=function(find){var selected=-1;var seldates=this.cfg.getProperty("selected");for(var s=0;s<seldates.length;++s){var sArray=seldates[s];if(find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2]){selected=s;break;}} -return selected;};YAHOO.widget.Calendar.prototype.isDateOOM=function(date){var isOOM=false;if(date.getMonth()!=this.cfg.getProperty("pagedate").getMonth()){isOOM=true;} -return isOOM;};YAHOO.widget.Calendar.prototype._parsePageDate=function(date){var parsedDate;if(date){if(date instanceof Date){parsedDate=YAHOO.widget.DateMath.findMonthStart(date);}else{var month,year,aMonthYear;aMonthYear=date.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);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("MULTI_SELECT")===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;i<rArray.length;i++){rArray[i]=parseInt(rArray[i],10);} -return rArray;};YAHOO.widget.Calendar.prototype._parseDates=function(sDates){var aReturn=[];var aDates=sDates.split(this.Locale.DATE_DELIMITER);for(var d=0;d<aDates.length;++d){var sDate=aDates[d];if(sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER)!=-1){var aRange=sDate.split(this.Locale.DATE_RANGE_DELIMITER);var dateStart=this._parseDate(aRange[0]);var dateEnd=this._parseDate(aRange[1]);var fullRange=this._parseRange(dateStart,dateEnd);aReturn=aReturn.concat(fullRange);}else{var aDate=this._parseDate(sDate);aReturn.push(aDate);}} -return aReturn;};YAHOO.widget.Calendar.prototype._parseRange=function(startDate,endDate){var dStart=new Date(startDate[0],startDate[1]-1,startDate[2]);var dCurrent=YAHOO.widget.DateMath.add(new Date(startDate[0],startDate[1]-1,startDate[2]),YAHOO.widget.DateMath.DAY,1);var dEnd=new Date(endDate[0],endDate[1]-1,endDate[2]);var results=[];results.push(startDate);while(dCurrent.getTime()<=dEnd.getTime()){results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]);dCurrent=YAHOO.widget.DateMath.add(dCurrent,YAHOO.widget.DateMath.DAY,1);} -return results;};YAHOO.widget.Calendar.prototype.resetRenderers=function(){this.renderStack=this._renderStack.concat();};YAHOO.widget.Calendar.prototype.clearElement=function(cell){cell.innerHTML=" ";cell.className="";};YAHOO.widget.Calendar.prototype.addRenderer=function(sDates,fnRender){var aDates=this._parseDates(sDates);for(var i=0;i<aDates.length;++i){var aDate=aDates[i];if(aDate.length==2){if(aDate[0]instanceof Array){this._addRenderer(YAHOO.widget.Calendar.RANGE,aDate,fnRender);}else{this._addRenderer(YAHOO.widget.Calendar.MONTH_DAY,aDate,fnRender);}}else if(aDate.length==3){this._addRenderer(YAHOO.widget.Calendar.DATE,aDate,fnRender);}}};YAHOO.widget.Calendar.prototype._addRenderer=function(type,aDates,fnRender){var add=[type,aDates,fnRender];this.renderStack.unshift(add);this._renderStack=this.renderStack.concat();};YAHOO.widget.Calendar.prototype.addMonthRenderer=function(month,fnRender){this._addRenderer(YAHOO.widget.Calendar.MONTH,[month],fnRender);};YAHOO.widget.Calendar.prototype.addWeekdayRenderer=function(weekday,fnRender){this._addRenderer(YAHOO.widget.Calendar.WEEKDAY,[weekday],fnRender);};YAHOO.widget.Calendar.prototype.clearAllBodyCellStyles=function(style){for(var c=0;c<this.cells.length;++c){YAHOO.util.Dom.removeClass(this.cells[c],style);}};YAHOO.widget.Calendar.prototype.setMonth=function(month){var current=this.cfg.getProperty("pagedate");current.setMonth(parseInt(month,10));this.cfg.setProperty("pagedate",current);};YAHOO.widget.Calendar.prototype.setYear=function(year){var current=this.cfg.getProperty("pagedate");current.setFullYear(parseInt(year,10));this.cfg.setProperty("pagedate",current);};YAHOO.widget.Calendar.prototype.getSelectedDates=function(){var returnDates=[];var selected=this.cfg.getProperty("selected");for(var d=0;d<selected.length;++d){var dateArray=selected[d];var date=new Date(dateArray[0],dateArray[1]-1,dateArray[2]);returnDates.push(date);} -returnDates.sort(function(a,b){return a-b;});return returnDates;};YAHOO.widget.Calendar.prototype.hide=function(){this.oDomContainer.style.display="none";};YAHOO.widget.Calendar.prototype.show=function(){this.oDomContainer.style.display="block";};YAHOO.widget.Calendar.prototype.browser=function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('opera')!=-1){return'opera';}else if(ua.indexOf('msie 7')!=-1){return'ie7';}else if(ua.indexOf('msie')!=-1){return'ie';}else if(ua.indexOf('safari')!=-1){return'safari';}else if(ua.indexOf('gecko')!=-1){return'gecko';}else{return false;}}();YAHOO.widget.Calendar.prototype.toString=function(){return"Calendar "+this.id;};YAHOO.widget.Calendar_Core=YAHOO.widget.Calendar;YAHOO.widget.Cal_Core=YAHOO.widget.Calendar;YAHOO.widget.CalendarGroup=function(id,containerId,config){if(arguments.length>0){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;p<this.pages.length;++p){var cal=this.pages[p];w+=cal.oDomContainer.offsetWidth;} -if(w>0){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:null,handler:this.delegateConfig});this.cfg.addProperty("NAV_ARROW_RIGHT",{value:null,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;p<me.pages.length;++p){var cal=me.pages[p];cal[this.type+"Event"].subscribe(fn,obj,bOverride);}};var unsub=function(fn,obj){for(var p=0;p<me.pages.length;++p){var cal=me.pages[p];cal[this.type+"Event"].unsubscribe(fn,obj);}};this.beforeSelectEvent=new YAHOO.util.CustomEvent("beforeSelect");this.beforeSelectEvent.subscribe=sub;this.beforeSelectEvent.unsubscribe=unsub;this.selectEvent=new YAHOO.util.CustomEvent("select");this.selectEvent.subscribe=sub;this.selectEvent.unsubscribe=unsub;this.beforeDeselectEvent=new YAHOO.util.CustomEvent("beforeDeselect");this.beforeDeselectEvent.subscribe=sub;this.beforeDeselectEvent.unsubscribe=unsub;this.deselectEvent=new YAHOO.util.CustomEvent("deselect");this.deselectEvent.subscribe=sub;this.deselectEvent.unsubscribe=unsub;this.changePageEvent=new YAHOO.util.CustomEvent("changePage");this.changePageEvent.subscribe=sub;this.changePageEvent.unsubscribe=unsub;this.beforeRenderEvent=new YAHOO.util.CustomEvent("beforeRender");this.beforeRenderEvent.subscribe=sub;this.beforeRenderEvent.unsubscribe=unsub;this.renderEvent=new YAHOO.util.CustomEvent("render");this.renderEvent.subscribe=sub;this.renderEvent.unsubscribe=unsub;this.resetEvent=new YAHOO.util.CustomEvent("reset");this.resetEvent.subscribe=sub;this.resetEvent.unsubscribe=unsub;this.clearEvent=new YAHOO.util.CustomEvent("clear");this.clearEvent.subscribe=sub;this.clearEvent.unsubscribe=unsub;};YAHOO.widget.CalendarGroup.prototype.configPages=function(type,args,obj){var pageCount=args[0];for(var p=0;p<pageCount;++p){var calId=this.id+"_"+p;var calContainerId=this.containerId+"_"+p;var childConfig=this.cfg.getConfig();childConfig.close=false;childConfig.title=false;var cal=this.constructChild(calId,calContainerId,childConfig);var caldate=cal.cfg.getProperty("pagedate");this._setMonthOnDate(caldate,caldate.getMonth()+p);cal.cfg.setProperty("pagedate",caldate);YAHOO.util.Dom.removeClass(cal.oDomContainer,this.Style.CSS_SINGLE);YAHOO.util.Dom.addClass(cal.oDomContainer,"groupcal");if(p===0){YAHOO.util.Dom.addClass(cal.oDomContainer,"first");} -if(p==(pageCount-1)){YAHOO.util.Dom.addClass(cal.oDomContainer,"last");} -cal.parent=this;cal.index=p;this.pages[this.pages.length]=cal;}};YAHOO.widget.CalendarGroup.prototype.configPageDate=function(type,args,obj){var val=args[0];var firstPageDate;for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];if(p===0){firstPageDate=cal._parsePageDate(val);cal.cfg.setProperty("pagedate",firstPageDate);}else{var pageDate=new Date(firstPageDate);this._setMonthOnDate(pageDate,pageDate.getMonth()+p);cal.cfg.setProperty("pagedate",pageDate);}}};YAHOO.widget.CalendarGroup.prototype.delegateConfig=function(type,args,obj){var val=args[0];var cal;for(var p=0;p<this.pages.length;p++){cal=this.pages[p];cal.cfg.setProperty(type,val);}};YAHOO.widget.CalendarGroup.prototype.setChildFunction=function(fnName,fn){var pageCount=this.cfg.getProperty("pages");for(var p=0;p<pageCount;++p){this.pages[p][fnName]=fn;}};YAHOO.widget.CalendarGroup.prototype.callChildFunction=function(fnName,args){var pageCount=this.cfg.getProperty("pages");for(var p=0;p<pageCount;++p){var page=this.pages[p];if(page[fnName]){var fn=page[fnName];fn.call(page,args);}}};YAHOO.widget.CalendarGroup.prototype.constructChild=function(id,containerId,config){var container=document.getElementById(containerId);if(!container){container=document.createElement("div");container.id=containerId;this.oDomContainer.appendChild(container);} -return new YAHOO.widget.Calendar(id,containerId,config);};YAHOO.widget.CalendarGroup.prototype.setMonth=function(month){month=parseInt(month,10);var currYear;for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];var pageDate=cal.cfg.getProperty("pagedate");if(p===0){currYear=pageDate.getFullYear();}else{pageDate.setYear(currYear);} -this._setMonthOnDate(pageDate,month+p);cal.cfg.setProperty("pagedate",pageDate);}};YAHOO.widget.CalendarGroup.prototype.setYear=function(year){year=parseInt(year,10);for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];var pageDate=cal.cfg.getProperty("pageDate");if((pageDate.getMonth()+1)==1&&p>0){year+=1;} -cal.setYear(year);}};YAHOO.widget.CalendarGroup.prototype.render=function(){this.renderHeader();for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.render();} -this.renderFooter();};YAHOO.widget.CalendarGroup.prototype.select=function(date){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.select(date);} -return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.selectCell=function(cellIndex){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.selectCell(cellIndex);} -return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.deselect=function(date){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.deselect(date);} -return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.deselectAll=function(){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.deselectAll();} -return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.deselectCell=function(cellIndex){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.deselectCell(cellIndex);} -return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.reset=function(){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.reset();}};YAHOO.widget.CalendarGroup.prototype.clear=function(){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.clear();}};YAHOO.widget.CalendarGroup.prototype.nextMonth=function(){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.nextMonth();}};YAHOO.widget.CalendarGroup.prototype.previousMonth=function(){for(var p=this.pages.length-1;p>=0;--p){var cal=this.pages[p];cal.previousMonth();}};YAHOO.widget.CalendarGroup.prototype.nextYear=function(){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.nextYear();}};YAHOO.widget.CalendarGroup.prototype.previousYear=function(){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.previousYear();}};YAHOO.widget.CalendarGroup.prototype.getSelectedDates=function(){var returnDates=[];var selected=this.cfg.getProperty("selected");for(var d=0;d<selected.length;++d){var dateArray=selected[d];var date=new Date(dateArray[0],dateArray[1]-1,dateArray[2]);returnDates.push(date);} -returnDates.sort(function(a,b){return a-b;});return returnDates;};YAHOO.widget.CalendarGroup.prototype.addRenderer=function(sDates,fnRender){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.addRenderer(sDates,fnRender);}};YAHOO.widget.CalendarGroup.prototype.addMonthRenderer=function(month,fnRender){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.addMonthRenderer(month,fnRender);}};YAHOO.widget.CalendarGroup.prototype.addWeekdayRenderer=function(weekday,fnRender){for(var p=0;p<this.pages.length;++p){var cal=this.pages[p];cal.addWeekdayRenderer(weekday,fnRender);}};YAHOO.widget.CalendarGroup.prototype.renderHeader=function(){};YAHOO.widget.CalendarGroup.prototype.renderFooter=function(){};YAHOO.widget.CalendarGroup.prototype.addMonths=function(count){this.callChildFunction("addMonths",count);};YAHOO.widget.CalendarGroup.prototype.subtractMonths=function(count){this.callChildFunction("subtractMonths",count);};YAHOO.widget.CalendarGroup.prototype.addYears=function(count){this.callChildFunction("addYears",count);};YAHOO.widget.CalendarGroup.prototype.subtractYears=function(count){this.callChildFunction("subtractYears",count);};YAHOO.widget.CalendarGroup.prototype._setMonthOnDate=function(date,iMonth){if(this.browser=="safari"&&(iMonth<0||iMonth>11)){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.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.augment(YAHOO.widget.CalendarGroup,YAHOO.widget.Calendar,"buildDayLabel","buildMonthLabel","renderOutOfBoundsDate","renderRowHeader","renderRowFooter","renderCellDefault","styleCellDefault","renderCellStyleHighlight1","renderCellStyleHighlight2","renderCellStyleHighlight3","renderCellStyleHighlight4","renderCellStyleToday","renderCellStyleSelected","renderCellNotThisMonth","renderBodyCellRestricted","initStyles","configTitle","configClose","hide","show","browser");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.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/calendar/calendar.js b/interface/web/js/yui/calendar/calendar.js deleted file mode 100644 index a75c9f3304..0000000000 --- a/interface/web/js/yui/calendar/calendar.js +++ /dev/null @@ -1,4309 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** -* 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<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - - if (queueItem) { - var queueItemKey = queueItem[0]; - var queueItemValue = queueItem[1]; - - if (queueItemKey.toLowerCase() == key) { - // found a dupe... push to end of queue, null current item, and break - eventQueue[i] = null; - eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]); - foundDuplicate = true; - break; - } - } - } - - if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue - eventQueue.push([key, value]); - } - } - - if (property.supercedes) { - for (var s=0;s<property.supercedes.length;s++) { - var supercedesCheck = property.supercedes[s]; - - for (var q=0;q<eventQueue.length;q++) { - var queueItemCheck = eventQueue[q]; - - if (queueItemCheck) { - var queueItemCheckKey = queueItemCheck[0]; - var queueItemCheckValue = queueItemCheck[1]; - - if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) { - eventQueue.push([queueItemCheckKey, queueItemCheckValue]); - eventQueue[q] = null; - break; - } - } - } - } - } - - return true; - } else { - return false; - } - }; - - /** - * Fires the event for a property using the property's current value. - * @method refireEvent - * @param {String} key The name of the property - */ - this.refireEvent = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') { - if (this.queueInProgress) { - this.queueProperty(key); - } else { - fireEvent(key, property.value); - } - } - }; - - /** - * Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their associated events to execute. - * @method applyConfig - * @param {Object} userConfig The configuration Object literal - * @param {Boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. - */ - this.applyConfig = function(userConfig, init) { - if (init) { - initialConfig = userConfig; - } - for (var prop in userConfig) { - this.queueProperty(prop, userConfig[prop]); - } - }; - - /** - * Refires the events for all configuration properties using their current values. - * @method refresh - */ - this.refresh = function() { - for (var prop in config) { - this.refireEvent(prop); - } - }; - - /** - * Fires the normalized list of queued property change events - * @method fireQueue - */ - this.fireQueue = function() { - this.queueInProgress = true; - for (var i=0;i<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - if (queueItem) { - var key = queueItem[0]; - var value = queueItem[1]; - - var property = config[key]; - property.value = value; - - fireEvent(key,value); - } - } - - this.queueInProgress = false; - eventQueue = []; - }; - - /** - * Subscribes an external handler to the change event for any given property. - * @method subscribeToConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @param {Boolean} override Optional. If true, will override "this" within the handler to map to the scope Object passed into the method. - * @return {Boolean} True, if the subscription was successful, otherwise false. - */ - this.subscribeToConfigEvent = function(key, handler, obj, override) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) { - property.event.subscribe(handler, obj, override); - } - return true; - } else { - return false; - } - }; - - /** - * Unsubscribes an external handler from the change event for any given property. - * @method unsubscribeFromConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @return {Boolean} True, if the unsubscription was successful, otherwise false. - */ - this.unsubscribeFromConfigEvent = function(key, handler, obj) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.event.unsubscribe(handler, obj); - } else { - return false; - } - }; - - /** - * Returns a string representation of the Config object - * @method toString - * @return {String} The Config object in string format. - */ - this.toString = function() { - var output = "Config"; - if (this.owner) { - output += " [" + this.owner.toString() + "]"; - } - return output; - }; - - /** - * Returns a string representation of the Config object's current CustomEvent queue - * @method outputEventQueue - * @return {String} The string list of CustomEvents currently queued for execution - */ - this.outputEventQueue = function() { - var output = ""; - for (var q=0;q<eventQueue.length;q++) { - var queueItem = eventQueue[q]; - if (queueItem) { - output += queueItem[0] + "=" + queueItem[1] + ", "; - } - } - return output; - }; -}; - -/** -* Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent -* @method YAHOO.util.Config.alreadySubscribed -* @static -* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions -* @param {Function} fn The function to look for in the subscribers list -* @param {Object} obj The execution scope Object for the subscription -* @return {Boolean} true, if the function/Object pair is already subscribed to the CustomEvent passed in -*/ -YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) { - for (var e=0;e<evt.subscribers.length;e++) { - var subsc = evt.subscribers[e]; - if (subsc && subsc.obj == obj && subsc.fn == fn) { - return true; - } - } - return false; -}; - -/** -* YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility -* used for adding, subtracting, and comparing dates. -* @namespace YAHOO.widget -* @class DateMath -*/ -YAHOO.widget.DateMath = { - /** - * Constant field representing Day - * @property DAY - * @static - * @final - * @type String - */ - DAY : "D", - - /** - * Constant field representing Week - * @property WEEK - * @static - * @final - * @type String - */ - WEEK : "W", - - /** - * Constant field representing Year - * @property YEAR - * @static - * @final - * @type String - */ - YEAR : "Y", - - /** - * Constant field representing Month - * @property MONTH - * @static - * @final - * @type String - */ - MONTH : "M", - - /** - * Constant field representing one day, in milliseconds - * @property ONE_DAY_MS - * @static - * @final - * @type Number - */ - ONE_DAY_MS : 1000*60*60*24, - - /** - * Adds the specified amount of time to the this instance. - * @method add - * @param {Date} date The JavaScript Date object to perform addition on - * @param {String} field The field constant to be used for performing addition. - * @param {Number} amount The number of units (measured in the field constant) to add to the date. - * @return {Date} The resulting Date object - */ - add : function(date, field, amount) { - var d = new Date(date.getTime()); - switch (field) { - case this.MONTH: - var newMonth = date.getMonth() + amount; - var years = 0; - - - if (newMonth < 0) { - while (newMonth < 0) { - newMonth += 12; - years -= 1; - } - } else if (newMonth > 11) { - while (newMonth > 11) { - newMonth -= 12; - years += 1; - } - } - - d.setMonth(newMonth); - d.setFullYear(date.getFullYear() + years); - break; - case this.DAY: - d.setDate(date.getDate() + amount); - break; - case this.YEAR: - d.setFullYear(date.getFullYear() + amount); - break; - case this.WEEK: - d.setDate(date.getDate() + (amount * 7)); - break; - } - return d; - }, - - /** - * Subtracts the specified amount of time from the this instance. - * @method subtract - * @param {Date} date The JavaScript Date object to perform subtraction on - * @param {Number} field The this field constant to be used for performing subtraction. - * @param {Number} amount The number of units (measured in the field constant) to subtract from the date. - * @return {Date} The resulting Date object - */ - subtract : function(date, field, amount) { - return this.add(date, field, (amount*-1)); - }, - - /** - * Determines whether a given date is before another date on the calendar. - * @method before - * @param {Date} date The Date object to compare with the compare argument - * @param {Date} compareTo The Date object to use for the comparison - * @return {Boolean} true if the date occurs before the compared date; false if not. - */ - before : function(date, compareTo) { - var ms = compareTo.getTime(); - if (date.getTime() < ms) { - return true; - } else { - return false; - } - }, - - /** - * Determines whether a given date is after another date on the calendar. - * @method after - * @param {Date} date The Date object to compare with the compare argument - * @param {Date} compareTo The Date object to use for the comparison - * @return {Boolean} true if the date occurs after the compared date; false if not. - */ - after : function(date, compareTo) { - var ms = compareTo.getTime(); - if (date.getTime() > ms) { - return true; - } else { - return false; - } - }, - - /** - * Determines whether a given date is between two other dates on the calendar. - * @method between - * @param {Date} date The date to check for - * @param {Date} dateBegin The start of the range - * @param {Date} dateEnd The end of the range - * @return {Boolean} true if the date occurs between the compared dates; false if not. - */ - between : function(date, dateBegin, dateEnd) { - if (this.after(date, dateBegin) && this.before(date, dateEnd)) { - return true; - } else { - return false; - } - }, - - /** - * Retrieves a JavaScript Date object representing January 1 of any given year. - * @method getJan1 - * @param {Number} calendarYear The calendar year for which to retrieve January 1 - * @return {Date} January 1 of the calendar year specified. - */ - getJan1 : function(calendarYear) { - return new Date(calendarYear,0,1); - }, - - /** - * Calculates the number of days the specified date is from January 1 of the specified calendar year. - * Passing January 1 to this function would return an offset value of zero. - * @method getDayOffset - * @param {Date} date The JavaScript date for which to find the offset - * @param {Number} calendarYear The calendar year to use for determining the offset - * @return {Number} The number of days since January 1 of the given year - */ - getDayOffset : function(date, calendarYear) { - var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1. - - // Find the number of days the passed in date is away from the calendar year start - var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS); - return dayOffset; - }, - - /** - * Calculates the week number for the given date. This function assumes that week 1 is the - * week in which January 1 appears, regardless of whether the week consists of a full 7 days. - * The calendar year can be specified to help find what a the week number would be for a given - * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or - * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction - * easily. - * @method getWeekNumber - * @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) { - 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; - }, - - /** - * Determines if a given week overlaps two different years. - * @method isYearOverlapWeek - * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week. - * @return {Boolean} true if the date overlaps two different years. - */ - isYearOverlapWeek : function(weekBeginDate) { - var overlaps = false; - var nextWeek = this.add(weekBeginDate, this.DAY, 6); - if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) { - overlaps = true; - } - return overlaps; - }, - - /** - * Determines if a given week overlaps two different months. - * @method isMonthOverlapWeek - * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week. - * @return {Boolean} true if the date overlaps two different months. - */ - isMonthOverlapWeek : function(weekBeginDate) { - var overlaps = false; - var nextWeek = this.add(weekBeginDate, this.DAY, 6); - if (nextWeek.getMonth() != weekBeginDate.getMonth()) { - overlaps = true; - } - return overlaps; - }, - - /** - * Gets the first day of a month containing a given date. - * @method findMonthStart - * @param {Date} date The JavaScript Date used to calculate the month start - * @return {Date} The JavaScript Date representing the first day of the month - */ - findMonthStart : function(date) { - var start = new Date(date.getFullYear(), date.getMonth(), 1); - return start; - }, - - /** - * Gets the last day of a month containing a given date. - * @method findMonthEnd - * @param {Date} date The JavaScript Date used to calculate the month end - * @return {Date} The JavaScript Date representing the last day of the month - */ - findMonthEnd : function(date) { - var start = this.findMonthStart(date); - var nextMonth = this.add(start, this.MONTH, 1); - var end = this.subtract(nextMonth, this.DAY, 1); - return end; - }, - - /** - * Clears the time fields from a given date, effectively setting the time to 12 noon. - * @method clearTime - * @param {Date} date The JavaScript Date for which the time fields will be cleared - * @return {Date} The JavaScript Date cleared of all time fields - */ - clearTime : function(date) { - date.setHours(12,0,0,0); - return date; - } -}; - -/** -* 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. -* @module calendar -* @title Calendar -* @namespace YAHOO.widget -* @requires yahoo,dom,event -*/ - -/** -* Calendar is the base class for the Calendar widget. In its most basic -* implementation, it has the ability to render a calendar widget on the page -* that can be manipulated to select a single date, move back and forth between -* months and years. -* <p>To construct the placeholder for the calendar widget, the code is as -* follows: -* <xmp> -* <div id="cal1Container"></div> -* </xmp> -* Note that the table can be replaced with any kind of element. -* </p> -* @namespace YAHOO.widget -* @class Calendar -* @constructor -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -YAHOO.widget.Calendar = function(id, containerId, config) { - this.init(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 = null; - -/** -* Type constant used for renderers to represent an individual date (M/D/Y) -* @property YAHOO.widget.Calendar.DATE -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.DATE = "D"; - -/** -* Type constant used for renderers to represent an individual date across any year (M/D) -* @property YAHOO.widget.Calendar.MONTH_DAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MONTH_DAY = "MD"; - -/** -* Type constant used for renderers to represent a weekday -* @property YAHOO.widget.Calendar.WEEKDAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.WEEKDAY = "WD"; - -/** -* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y) -* @property YAHOO.widget.Calendar.RANGE -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.RANGE = "R"; - -/** -* Type constant used for renderers to represent a month across any year -* @property YAHOO.widget.Calendar.MONTH -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.MONTH = "M"; - -/** -* Constant that represents the total number of date cells that are displayed in a given month -* @property YAHOO.widget.Calendar.DISPLAY_DAYS -* @static -* @final -* @type Number -*/ -YAHOO.widget.Calendar.DISPLAY_DAYS = 42; - -/** -* Constant used for halting the execution of the remainder of the render stack -* @property YAHOO.widget.Calendar.STOP_RENDER -* @static -* @final -* @type String -*/ -YAHOO.widget.Calendar.STOP_RENDER = "S"; - -YAHOO.widget.Calendar.prototype = { - - /** - * The configuration object used to set up the calendars various locale and style options. - * @property Config - * @private - * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty. - * @type Object - */ - Config : null, - - /** - * The parent CalendarGroup, only to be set explicitly by the parent group - * @property parent - * @type CalendarGroup - */ - parent : null, - - /** - * The index of this item in the parent group - * @property index - * @type Number - */ - index : -1, - - /** - * The collection of calendar table cells - * @property cells - * @type HTMLTableCellElement[] - */ - cells : null, - - /** - * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D]. - * @property cellDates - * @type Array[](Number[]) - */ - cellDates : null, - - /** - * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page. - * @property id - * @type String - */ - id : null, - - /** - * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered. - * @property oDomContainer - * @type HTMLElement - */ - oDomContainer : null, - - /** - * A Date object representing today's date. - * @property today - * @type Date - */ - today : null, - - /** - * The list of render functions, along with required parameters, used to render cells. - * @property renderStack - * @type Array[] - */ - renderStack : null, - - /** - * A copy of the initial render functions created before rendering. - * @property _renderStack - * @private - * @type Array - */ - _renderStack : null, - - /** - * The private list of initially selected dates. - * @property _selectedDates - * @private - * @type Array - */ - _selectedDates : null, - - /** - * A map of DOM event handlers to attach to cells associated with specific CSS class names - * @property domEventMap - * @type Object - */ - domEventMap : null -}; - - - -/** -* Initializes the Calendar widget. -* @method init -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -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); - - /** - * The Config object used to hold the configuration variables for the Calendar - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - /** - * The local object which contains the Calendar's options - * @property Options - * @type Object - */ - this.Options = {}; - - /** - * The local object which contains the Calendar's locale settings - * @property Locale - * @type Object - */ - 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(); -}; - -/** -* Renders the built-in IFRAME shim for the IE6 and below -* @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.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; - } - } - } -}; - -/** -* Default handler for the "title" property -* @method configTitle -*/ -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"); - } - } -}; - -/** -* Default handler for the "close" property -* @method configClose -*/ -YAHOO.widget.Calendar.prototype.configClose = function(type, args, obj) { - var close = args[0]; - var title = this.cfg.getProperty("title"); - - 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.className = "link-close"; - YAHOO.util.Event.addListener(linkClose, "click", this.hide, this, true); - - 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 = '<span class="' + YAHOO.widget.CalendarGroup.CSS_2UPCLOSE + ' ' + this.Style.CSS_CLOSE + '"></span>'; - } - - 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"); - } - } -}; - -/** -* Initializes Calendar's built-in CustomEvents -* @method initEvents -*/ -YAHOO.widget.Calendar.prototype.initEvents = function() { - - /** - * Fired before a selection is made - * @event beforeSelectEvent - */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect"); - - /** - * 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"); - - /** - * Fired before a selection is made - * @event beforeDeselectEvent - */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect"); - - /** - * 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"); - - /** - * Fired when the Calendar page is changed - * @event changePageEvent - */ - this.changePageEvent = new YAHOO.util.CustomEvent("changePage"); - - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); - - /** - * Fired when the Calendar is reset - * @event resetEvent - */ - this.resetEvent = new YAHOO.util.CustomEvent("reset"); - - /** - * Fired when the Calendar is cleared - * @event clearEvent - */ - 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); -}; - - -/** -* The default event function that is attached to a date link within a calendar cell -* when the calendar is rendered. -* @method doSelectCell -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -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; - } - } - - 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); - } - } -}; - -/** -* The event that is executed when the user hovers over a cell -* @method doCellMouseOver -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -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); - } -}; - -/** -* The event that is executed when the user moves the mouse out of a cell -* @method doCellMouseOut -* @param {DOMEvent} e The event -* @param {Calendar} cal A reference to the calendar passed by the Event utility -*/ -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() { - - /** - * 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 } ); - - /** - * The date or range of dates representing the current Calendar selection - * @config selected - * @type String - * @default [] - */ - this.cfg.addProperty("selected", { value:[], handler:this.configSelected } ); - - /** - * The title to display above the Calendar's month header - * @config title - * @type String - * @default "" - */ - this.cfg.addProperty("title", { value:"", handler:this.configTitle } ); - - /** - * Whether or not a close button should be displayed for this Calendar - * @config close - * @type Boolean - * @default false - */ - this.cfg.addProperty("close", { value:false, 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. - * @config iframe - * @type Boolean - * @default true - */ - this.cfg.addProperty("iframe", { value:true, handler:this.configIframe, validator:this.cfg.checkBoolean } ); - - /** - * The minimum selectable date in the current Calendar (mm/dd/yyyy) - * @config mindate - * @type String - * @default null - */ - this.cfg.addProperty("mindate", { value:null, handler:this.configMinDate } ); - - /** - * The maximum selectable date in the current Calendar (mm/dd/yyyy) - * @config maxdate - * @type String - * @default null - */ - this.cfg.addProperty("maxdate", { value:null, handler:this.configMaxDate } ); - - - // Options properties - - /** - * True if the Calendar should allow multiple selections. False by default. - * @config MULTI_SELECT - * @type Boolean - * @default false - */ - this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * The weekday the week begins on. Default is 0 (Sunday). - * @config START_WEEKDAY - * @type number - * @default 0 - */ - this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.configOptions, validator:this.cfg.checkNumber } ); - - /** - * True if the Calendar should show weekday labels. True by default. - * @config SHOW_WEEKDAYS - * @type Boolean - * @default true - */ - this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row headers. False by default. - * @config SHOW_WEEK_HEADER - * @type Boolean - * @default false - */ - this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row footers. False by default. - * @config SHOW_WEEK_FOOTER - * @type Boolean - * @default false - */ - this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, 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. - * @config HIDE_BLANK_WEEKS - * @type Boolean - * @default false - */ - this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.configOptions, validator:this.cfg.checkBoolean } ); - - /** - * The image that should be used for the left navigation arrow. - * @config NAV_ARROW_LEFT - * @type String - * @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:null, handler:this.configOptions } ); - - /** - * The image that should be used for the right navigation arrow. - * @config NAV_ARROW_RIGHT - * @type String - * @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:null, handler:this.configOptions } ); - - // Locale properties - - /** - * The short month labels for the current locale. - * @config MONTHS_SHORT - * @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 } ); - - /** - * The long month labels for the current locale. - * @config MONTHS_LONG - * @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 } ); - - /** - * The 1-character weekday labels for the current locale. - * @config WEEKDAYS_1CHAR - * @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 } ); - - /** - * The short weekday labels for the current locale. - * @config WEEKDAYS_SHORT - * @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 } ); - - /** - * The medium weekday labels for the current locale. - * @config WEEKDAYS_MEDIUM - * @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 } ); - - /** - * The long weekday labels for the current locale. - * @config WEEKDAYS_LONG - * @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 } ); - - /** - * Refreshes the locale values used to build the Calendar. - * @method refreshLocale - * @private - */ - 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); - - /** - * The setting that determines which length of month labels should be used. Possible values are "short" and "long". - * @config LOCALE_MONTHS - * @type String - * @default "long" - */ - this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.configLocaleValues } ); - - /** - * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". - * @config LOCALE_WEEKDAYS - * @type String - * @default "short" - */ - this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.configLocaleValues } ); - - /** - * The value used to delimit individual dates in a date string passed to various Calendar functions. - * @config DATE_DELIMITER - * @type String - * @default "," - */ - this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.configLocale } ); - - /** - * The value used to delimit date fields in a date string passed to various Calendar functions. - * @config DATE_FIELD_DELIMITER - * @type String - * @default "/" - */ - this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.configLocale } ); - - /** - * The value used to delimit date ranges in a date string passed to various Calendar functions. - * @config DATE_RANGE_DELIMITER - * @type String - * @default "-" - */ - this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.configLocale } ); - - /** - * The position of the month in a month/year date string - * @config MY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/year date string - * @config MY_YEAR_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day date string - * @config MD_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/year date string - * @config MD_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day/year date string - * @config MDY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/day/year date string - * @config MDY_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.configLocale, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/day/year date string - * @config MDY_YEAR_POSITION - * @type Number - * @default 3 - */ - this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.configLocale, validator:this.cfg.checkNumber } ); -}; - -/** -* The default handler for the "pagedate" property -* @method configPageDate -*/ -YAHOO.widget.Calendar.prototype.configPageDate = function(type, args, obj) { - this.cfg.setProperty("pagedate", this._parsePageDate(args[0]), true); -}; - -/** -* The default handler for the "mindate" property -* @method configMinDate -*/ -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])); - } -}; - -/** -* The default handler for the "maxdate" property -* @method configMaxDate -*/ -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])); - } -}; - -/** -* The default handler for the "selected" property -* @method configSelected -*/ -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"); - } -}; - -/** -* The default handler for all configuration options properties -* @method configOptions -*/ -YAHOO.widget.Calendar.prototype.configOptions = function(type, args, obj) { - type = type.toUpperCase(); - var val = args[0]; - this.Options[type] = val; -}; - -/** -* The default handler for all configuration locale properties -* @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"); - -}; - -/** -* The default handler for all configuration locale field length properties -* @method configLocaleValues -*/ -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;w<START_WEEKDAY;++w) { - this.Locale.LOCALE_WEEKDAYS.push(this.Locale.LOCALE_WEEKDAYS.shift()); - } - } - break; - } -}; - -/** -* Defines the style constants for the Calendar -* @method initStyles -*/ -YAHOO.widget.Calendar.prototype.initStyles = function() { - - /** - * Collection of Style constants for the Calendar - * @property Style - */ - this.Style = { - /** - * @property Style.CSS_ROW_HEADER - */ - CSS_ROW_HEADER: "calrowhead", - /** - * @property Style.CSS_ROW_FOOTER - */ - CSS_ROW_FOOTER: "calrowfoot", - /** - * @property Style.CSS_CELL - */ - CSS_CELL : "calcell", - /** - * @property Style.CSS_CELL_SELECTED - */ - CSS_CELL_SELECTED : "selected", - /** - * @property Style.CSS_CELL_SELECTABLE - */ - CSS_CELL_SELECTABLE : "selectable", - /** - * @property Style.CSS_CELL_RESTRICTED - */ - CSS_CELL_RESTRICTED : "restricted", - /** - * @property Style.CSS_CELL_TODAY - */ - CSS_CELL_TODAY : "today", - /** - * @property Style.CSS_CELL_OOM - */ - CSS_CELL_OOM : "oom", - /** - * @property Style.CSS_CELL_OOB - */ - CSS_CELL_OOB : "previous", - /** - * @property Style.CSS_HEADER - */ - CSS_HEADER : "calheader", - /** - * @property Style.CSS_HEADER_TEXT - */ - CSS_HEADER_TEXT : "calhead", - /** - * @property Style.CSS_BODY - */ - CSS_BODY : "calbody", - /** - * @property Style.CSS_WEEKDAY_CELL - */ - CSS_WEEKDAY_CELL : "calweekdaycell", - /** - * @property Style.CSS_WEEKDAY_ROW - */ - CSS_WEEKDAY_ROW : "calweekdayrow", - /** - * @property Style.CSS_FOOTER - */ - CSS_FOOTER : "calfoot", - /** - * @property Style.CSS_CALENDAR - */ - CSS_CALENDAR : "yui-calendar", - /** - * @property Style.CSS_SINGLE - */ - CSS_SINGLE : "single", - /** - * @property Style.CSS_CONTAINER - */ - CSS_CONTAINER : "yui-calcontainer", - /** - * @property Style.CSS_NAV_LEFT - */ - CSS_NAV_LEFT : "calnavleft", - /** - * @property Style.CSS_NAV_RIGHT - */ - CSS_NAV_RIGHT : "calnavright", - /** - * @property Style.CSS_CLOSE - */ - CSS_CLOSE : "calclose", - /** - * @property Style.CSS_CELL_TOP - */ - CSS_CELL_TOP : "calcelltop", - /** - * @property Style.CSS_CELL_LEFT - */ - CSS_CELL_LEFT : "calcellleft", - /** - * @property Style.CSS_CELL_RIGHT - */ - CSS_CELL_RIGHT : "calcellright", - /** - * @property Style.CSS_CELL_BOTTOM - */ - CSS_CELL_BOTTOM : "calcellbottom", - /** - * @property Style.CSS_CELL_HOVER - */ - CSS_CELL_HOVER : "calcellhover", - /** - * @property Style.CSS_CELL_HIGHLIGHT1 - */ - CSS_CELL_HIGHLIGHT1 : "highlight1", - /** - * @property Style.CSS_CELL_HIGHLIGHT2 - */ - CSS_CELL_HIGHLIGHT2 : "highlight2", - /** - * @property Style.CSS_CELL_HIGHLIGHT3 - */ - CSS_CELL_HIGHLIGHT3 : "highlight3", - /** - * @property Style.CSS_CELL_HIGHLIGHT4 - */ - CSS_CELL_HIGHLIGHT4 : "highlight4" - }; -}; - -/** -* Builds the date label that will be displayed in the calendar header or -* footer, depending on configuration. -* @method buildMonthLabel -* @return {String} The formatted calendar month label -*/ -YAHOO.widget.Calendar.prototype.buildMonthLabel = function() { - var text = this.Locale.LOCALE_MONTHS[this.cfg.getProperty("pagedate").getMonth()] + " " + this.cfg.getProperty("pagedate").getFullYear(); - return text; -}; - -/** -* Builds the date digit that will be displayed in calendar cells -* @method buildDayLabel -* @param {Date} workingDate The current working date -* @return {String} The formatted day label -*/ -YAHOO.widget.Calendar.prototype.buildDayLabel = function(workingDate) { - var day = workingDate.getDate(); - return day; -}; - -/** -* Renders the calendar header. -* @method renderHeader -* @param {Array} html The current working HTML array -* @return {Array} The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderHeader = function(html) { - var colSpan = 7; - - var DEPR_NAV_LEFT = "us/tr/callt.gif"; - var DEPR_NAV_RIGHT = "us/tr/calrt.gif"; - - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { - colSpan += 1; - } - - if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { - colSpan += 1; - } - - html[html.length] = "<thead>"; - html[html.length] = "<tr>"; - html[html.length] = '<th colspan="' + colSpan + '" class="' + this.Style.CSS_HEADER_TEXT + '">'; - html[html.length] = '<div class="' + this.Style.CSS_HEADER + '">'; - - 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) { - var leftArrow = this.cfg.getProperty("NAV_ARROW_LEFT"); - // 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; - } - var leftStyle = (leftArrow === null) ? "" : ' style="background-image:url(' + leftArrow + ')"'; - html[html.length] = '<a class="' + this.Style.CSS_NAV_LEFT + '"' + leftStyle + ' > </a>'; - } - - html[html.length] = this.buildMonthLabel(); - - if (renderRight) { - var rightArrow = this.cfg.getProperty("NAV_ARROW_RIGHT"); - 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] = '<a class="' + this.Style.CSS_NAV_RIGHT + '"' + rightStyle + ' > </a>'; - } - - html[html.length] = '</div>'; - html[html.length] = '</th>'; - html[html.length] = '</tr>'; - - if (this.cfg.getProperty("SHOW_WEEKDAYS")) { - html = this.buildWeekdays(html); - } - - html[html.length] = '</thead>'; - - return html; -}; - -/** -* Renders the Calendar's weekday headers. -* @method buildWeekdays -* @param {Array} html The current working HTML array -* @return {Array} The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.buildWeekdays = function(html) { - - html[html.length] = '<tr class="' + this.Style.CSS_WEEKDAY_ROW + '">'; - - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { - html[html.length] = '<th> </th>'; - } - - for(var i=0;i<this.Locale.LOCALE_WEEKDAYS.length;++i) { - html[html.length] = '<th class="calweekdaycell">' + this.Locale.LOCALE_WEEKDAYS[i] + '</th>'; - } - - if (this.cfg.getProperty("SHOW_WEEK_FOOTER")) { - html[html.length] = '<th> </th>'; - } - - html[html.length] = '</tr>'; - - return html; -}; - -/** -* Renders the calendar body. -* @method renderBody -* @param {Date} workingDate The current working Date being used for the render process -* @param {Array} html The current working HTML array -* @return {Array} The current working HTML array -*/ -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.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] = '<tbody class="m' + (useDate.getMonth()+1) + ' ' + this.Style.CSS_BODY + '">'; - - 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] = '<tr class="' + weekClass + '">'; - - if (this.cfg.getProperty("SHOW_WEEK_HEADER")) { html = this.renderRowHeader(weekNum, html); } - - for (var d=0;d<7;d++){ // Render actual days - - 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()]; // Add this date to cellDates - - 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<this.renderStack.length;++s) { - - var rArray = this.renderStack[s]; - var type = rArray[0]; - - var month; - var day; - var year; - - switch (type) { - case YAHOO.widget.Calendar.DATE: - month = rArray[1][1]; - day = rArray[1][2]; - year = rArray[1][0]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case YAHOO.widget.Calendar.MONTH_DAY: - month = rArray[1][0]; - day = rArray[1][1]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case YAHOO.widget.Calendar.RANGE: - var date1 = rArray[1][0]; - var date2 = rArray[1][1]; - - var d1month = date1[1]; - var d1day = date1[2]; - var d1year = date1[0]; - - var d1 = new Date(d1year, d1month-1, d1day); - - var d2month = date2[1]; - var d2day = date2[2]; - var d2year = date2[0]; - - var d2 = new Date(d2year, d2month-1, d2day); - - if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) { - renderer = rArray[2]; - - if (workingDate.getTime()==d2.getTime()) { - this.renderStack.splice(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 ( - (mindate && (workingDate.getTime() < mindate.getTime())) || - (maxdate && (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<cellRenderers.length;++x) { - var ren = cellRenderers[x]; - if (ren.call((this.parent || this),workingDate,cell) == YAHOO.widget.Calendar.STOP_RENDER) { - break; - } - } - - workingDate.setTime(workingDate.getTime() + YAHOO.widget.DateMath.ONE_DAY_MS); - - if (i >= 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<blankWeeks;++p) { - postDays -= 7; - } - } - - if (i >= ((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); } - - html[html.length] = '</tr>'; - } - } - - html[html.length] = '</tbody>'; - - return html; -}; - -/** -* Renders the calendar footer. In the default implementation, there is -* no footer. -* @method renderFooter -* @param {Array} html The current working HTML array -* @return {Array} The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderFooter = function(html) { return html; }; - -/** -* Renders the calendar after it has been configured. The render() method has a specific call chain that will execute -* when the method is called: renderHeader, renderBody, renderFooter. -* Refer to the documentation for those methods for information on -* individual render tasks. -* @method render -*/ -YAHOO.widget.Calendar.prototype.render = function() { - this.beforeRenderEvent.fire(); - - // Find starting day of the current month - 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] = '<table cellSpacing="0" class="' + this.Style.CSS_CALENDAR + ' y' + workingDate.getFullYear() + '" id="' + this.id + '">'; - html = this.renderHeader(html); - html = this.renderBody(workingDate, html); - html = this.renderFooter(html); - html[html.length] = '</table>'; - - 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(); -}; - -/** -* Applies the Calendar's DOM listeners to applicable elements. -* @method applyListeners -*/ -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 (YAHOO.lang.hasOwnProperty(this.domEventMap, cls)) { - var items = this.domEventMap[cls]; - - if (! (items instanceof Array)) { - items = [items]; - } - - for (var i=0;i<items.length;i++) { - var item = items[i]; - elements = YAHOO.util.Dom.getElementsByClassName(cls, item.tag, this.oDomContainer); - - for (var c=0;c<elements.length;c++) { - el = elements[c]; - YAHOO.util.Event.addListener(el, item.event, item.handler, item.scope, item.correct ); - } - } - } - } - } - - 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); -}; - -/** -* Retrieves the Date object for the specified Calendar cell -* @method getDateByCellId -* @param {String} id The id of the cell -* @return {Date} The Date object for the specified Calendar cell -*/ -YAHOO.widget.Calendar.prototype.getDateByCellId = function(id) { - var date = this.getDateFieldsByCellId(id); - return new Date(date[0],date[1]-1,date[2]); -}; - -/** -* Retrieves the Date object for the specified Calendar cell -* @method getDateFieldsByCellId -* @param {String} id The id of the cell -* @return {Array} The array of Date fields for the specified Calendar cell -*/ -YAHOO.widget.Calendar.prototype.getDateFieldsByCellId = function(id) { - id = id.toLowerCase().split("_cell")[1]; - id = parseInt(id, 10); - return this.cellDates[id]; -}; - -// BEGIN BUILT-IN TABLE CELL RENDERERS - -/** -* Renders a cell that falls before the minimum date or after the maximum date. -* widget class. -* @method renderOutOfBoundsDate -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -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; -}; - -/** -* Renders the row header for a week. -* @method renderRowHeader -* @param {Number} weekNum The week number of the current row -* @param {Array} cell The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderRowHeader = function(weekNum, html) { - html[html.length] = '<th class="calrowhead">' + weekNum + '</th>'; - return html; -}; - -/** -* Renders the row footer for a week. -* @method renderRowFooter -* @param {Number} weekNum The week number of the current row -* @param {Array} cell The current working HTML array -*/ -YAHOO.widget.Calendar.prototype.renderRowFooter = function(weekNum, html) { - html[html.length] = '<th class="calrowfoot">' + weekNum + '</th>'; - return html; -}; - -/** -* Renders a single standard calendar cell in the calendar widget table. -* All logic for determining how a standard default cell will be rendered is -* encapsulated in this method, and must be accounted for when extending the -* widget class. -* @method renderCellDefault -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellDefault = function(workingDate, cell) { - cell.innerHTML = '<a href="javascript:void(null);" >' + this.buildDayLabel(workingDate) + "</a>"; -}; - -/** -* Styles a selectable cell. -* @method styleCellDefault -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.styleCellDefault = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE); -}; - - -/** -* Renders a single standard calendar cell using the CSS hightlight1 style -* @method renderCellStyleHighlight1 -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleHighlight1 = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1); -}; - -/** -* Renders a single standard calendar cell using the CSS hightlight2 style -* @method renderCellStyleHighlight2 -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleHighlight2 = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2); -}; - -/** -* Renders a single standard calendar cell using the CSS hightlight3 style -* @method renderCellStyleHighlight3 -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleHighlight3 = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3); -}; - -/** -* Renders a single standard calendar cell using the CSS hightlight4 style -* @method renderCellStyleHighlight4 -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleHighlight4 = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4); -}; - -/** -* Applies the default style used for rendering today's date to the current calendar cell -* @method renderCellStyleToday -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleToday = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY); -}; - -/** -* Applies the default style used for rendering selected dates to the current calendar cell -* @method renderCellStyleSelected -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -YAHOO.widget.Calendar.prototype.renderCellStyleSelected = function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED); -}; - -/** -* Applies the default style used for rendering dates that are not a part of the current -* month (preceding or trailing the cells for the current month) -* @method renderCellNotThisMonth -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -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; -}; - -/** -* Renders the current calendar cell as a non-selectable "black-out" date using the default -* restricted style. -* @method renderBodyCellRestricted -* @param {Date} workingDate The current working Date object being used to generate the calendar -* @param {HTMLTableCellElement} cell The current working cell in the calendar -* @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering -* should not be terminated -*/ -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; -}; - -// END BUILT-IN TABLE CELL RENDERERS - -// BEGIN MONTH NAVIGATION METHODS - -/** -* Adds the designated number of months to the current calendar month, and sets the current -* calendar page date to the new month. -* @method addMonths -* @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)); - this.resetRenderers(); - this.changePageEvent.fire(); -}; - -/** -* Subtracts the designated number of months from the current calendar month, and sets the current -* calendar page date to the new month. -* @method subtractMonths -* @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)); - this.resetRenderers(); - this.changePageEvent.fire(); -}; - -/** -* Adds the designated number of years to the current calendar, and sets the current -* calendar page date to the new month. -* @method addYears -* @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)); - this.resetRenderers(); - this.changePageEvent.fire(); -}; - -/** -* Subtcats the designated number of years from the current calendar, and sets the current -* calendar page date to the new month. -* @method subtractYears -* @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)); - this.resetRenderers(); - this.changePageEvent.fire(); -}; - -/** -* Navigates to the next month page in the calendar widget. -* @method nextMonth -*/ -YAHOO.widget.Calendar.prototype.nextMonth = function() { - this.addMonths(1); -}; - -/** -* Navigates to the previous month page in the calendar widget. -* @method previousMonth -*/ -YAHOO.widget.Calendar.prototype.previousMonth = function() { - this.subtractMonths(1); -}; - -/** -* Navigates to the next year in the currently selected month in the calendar widget. -* @method nextYear -*/ -YAHOO.widget.Calendar.prototype.nextYear = function() { - this.addYears(1); -}; - -/** -* Navigates to the previous year in the currently selected month in the calendar widget. -* @method previousYear -*/ -YAHOO.widget.Calendar.prototype.previousYear = function() { - this.subtractYears(1); -}; - -// END MONTH NAVIGATION METHODS - -// BEGIN SELECTION METHODS - -/** -* Resets the calendar widget to the originally selected month and year, and -* sets the calendar to the initial selection(s). -* @method reset -*/ -YAHOO.widget.Calendar.prototype.reset = function() { - this.cfg.resetProperty("selected"); - this.cfg.resetProperty("pagedate"); - this.resetEvent.fire(); -}; - -/** -* Clears the selected dates in the current calendar widget and sets the calendar -* to the current month and year. -* @method clear -*/ -YAHOO.widget.Calendar.prototype.clear = function() { - this.cfg.setProperty("selected", []); - this.cfg.setProperty("pagedate", new Date(this.today.getTime())); - this.clearEvent.fire(); -}; - -/** -* 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. -* @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). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {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<aToBeSelected.length;++a) { - var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select - if (this._indexOfSelectedFieldArray(toSelect) == -1) { // not already selected? - selected[selected.length]=toSelect; - } - } - - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); - } - - this.selectEvent.fire(aToBeSelected); - - return this.getSelectedDates(); -}; - -/** -* Selects a date on the current calendar by referencing the index of the cell that should be selected. -* This method is used to easily select a single cell (usually with a mouse click) without having to do -* a full render. The selected style is applied to the cell directly. -* @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 selectDate = cellDate.concat(); - - selected[selected.length] = selectDate; - - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); - } - - this.renderCellStyleSelected(dCellDate,cell); - - this.selectEvent.fire([selectDate]); - - this.doCellMouseOut.call(cell, null, this); - - return this.getSelectedDates(); -}; - -/** -* Deselects a date or a collection of dates on the current calendar. This method, by default, -* does not call the render method explicitly. Once deselection has completed, render must be -* called for the changes to be reflected visually. -* @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). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {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 aToBeSelected = this._toFieldArray(date); - - for (var a=0;a<aToBeSelected.length;++a) { - var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select - var index = this._indexOfSelectedFieldArray(toSelect); - - if (index != -1) { - selected.splice(index,1); - } - } - - if (this.parent) { - this.parent.cfg.setProperty("selected", selected); - } else { - this.cfg.setProperty("selected", selected); - } - - this.deselectEvent.fire(aToBeSelected); - - return this.getSelectedDates(); -}; - -/** -* Deselects a date on the current calendar by referencing the index of the cell that should be deselected. -* This method is used to easily deselect a single cell (usually with a mouse click) without having to do -* a full render. The selected style is removed from the cell directly. -* @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(); - - var selected = this.cfg.getProperty("selected"); - - var cell = this.cells[i]; - var cellDate = this.cellDates[i]; - var cellDateIndex = this._indexOfSelectedFieldArray(cellDate); - - var dCellDate = this._toDate(cellDate); - - var selectDate = cellDate.concat(); - - if (cellDateIndex > -1) { - if (this.cfg.getProperty("pagedate").getMonth() == dCellDate.getMonth() && - this.cfg.getProperty("pagedate").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(); -}; - -/** -* Deselects all dates on the current calendar. -* @method deselectAll -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -* Assuming that this function executes properly, the return value should be an empty array. -* However, the empty array is returned for the sake of being able to check the selection status -* of the calendar. -*/ -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 (count > 0) { - this.deselectEvent.fire(sel); - } - - return this.getSelectedDates(); -}; - -// END SELECTION METHODS - -// BEGIN TYPE CONVERSION METHODS - -/** -* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure -* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]]. -* @method _toFieldArray -* @private -* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are -* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {Array[](Number[])} Array of date field arrays -*/ -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;i<date.length;++i) { - var d = date[i]; - returnDate[returnDate.length] = [d.getFullYear(),d.getMonth()+1,d.getDate()]; - } - } - - return returnDate; -}; - -/** -* Converts a date field array [yyyy,mm,dd] to a JavaScript Date object. -* @method _toDate -* @private -* @param {Number[]} dateFieldArray The date field array to convert to a JavaScript Date. -* @return {Date} JavaScript Date object representing the date field array -*/ -YAHOO.widget.Calendar.prototype._toDate = function(dateFieldArray) { - if (dateFieldArray instanceof Date) { - return dateFieldArray; - } else { - return new Date(dateFieldArray[0],dateFieldArray[1]-1,dateFieldArray[2]); - } -}; - -// END TYPE CONVERSION METHODS - -// BEGIN UTILITY METHODS - -/** -* Converts a date field array [yyyy,mm,dd] to a JavaScript Date object. -* @method _fieldArraysAreEqual -* @private -* @param {Number[]} array1 The first date field array to compare -* @param {Number[]} array2 The first date field array to compare -* @return {Boolean} The boolean that represents the equality of the two arrays -*/ -YAHOO.widget.Calendar.prototype._fieldArraysAreEqual = function(array1, array2) { - var match = false; - - if (array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2]) { - match=true; - } - - return match; -}; - -/** -* Gets the index of a date field array [yyyy,mm,dd] in the current list of selected dates. -* @method _indexOfSelectedFieldArray -* @private -* @param {Number[]} find The date field array to search for -* @return {Number} The index of the date field array within the collection of selected dates. -* -1 will be returned if the date is not found. -*/ -YAHOO.widget.Calendar.prototype._indexOfSelectedFieldArray = function(find) { - var selected = -1; - var seldates = this.cfg.getProperty("selected"); - - for (var s=0;s<seldates.length;++s) { - var sArray = seldates[s]; - if (find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2]) { - selected = s; - break; - } - } - - return selected; -}; - -/** -* Determines whether a given date is OOM (out of month). -* @method isDateOOM -* @param {Date} date The JavaScript Date object for which to check the OOM status -* @return {Boolean} true if the date is OOM -*/ -YAHOO.widget.Calendar.prototype.isDateOOM = function(date) { - var isOOM = false; - if (date.getMonth() != this.cfg.getProperty("pagedate").getMonth()) { - isOOM = true; - } - return isOOM; -}; - -/** - * 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; - - if (date) { - if (date instanceof Date) { - parsedDate = YAHOO.widget.DateMath.findMonthStart(date); - } else { - var month, year, aMonthYear; - aMonthYear = date.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); - - parsedDate = new Date(year, month, 1); - } - } else { - parsedDate = new Date(this.today.getFullYear(), this.today.getMonth(), 1); - } - return parsedDate; -}; - -// END UTILITY METHODS - -// BEGIN EVENT HANDLERS - -/** -* Event executed before a date is selected in the calendar widget. -* @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.parent) { - this.parent.callChildFunction("clearAllBodyCellStyles", this.Style.CSS_CELL_SELECTED); - this.parent.deselectAll(); - } else { - this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED); - this.deselectAll(); - } - } -}; - -/** -* Event executed when a date is selected in the calendar widget. -* @param {Array} selected An array of date field arrays representing which date or dates were selected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ] -* @deprecated Event handlers for this event should be susbcribed to selectEvent. -*/ -YAHOO.widget.Calendar.prototype.onSelect = function(selected) { }; - -/** -* Event executed before a date is deselected in the calendar widget. -* @deprecated Event handlers for this event should be susbcribed to beforeDeselectEvent. -*/ -YAHOO.widget.Calendar.prototype.onBeforeDeselect = function() { }; - -/** -* Event executed when a date is deselected in the calendar widget. -* @param {Array} selected An array of date field arrays representing which date or dates were deselected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ] -* @deprecated Event handlers for this event should be susbcribed to deselectEvent. -*/ -YAHOO.widget.Calendar.prototype.onDeselect = function(deselected) { }; - -/** -* Event executed when the user navigates to a different calendar page. -* @deprecated Event handlers for this event should be susbcribed to changePageEvent. -*/ -YAHOO.widget.Calendar.prototype.onChangePage = function() { - this.render(); -}; - -/** -* Event executed when the calendar widget is rendered. -* @deprecated Event handlers for this event should be susbcribed to renderEvent. -*/ -YAHOO.widget.Calendar.prototype.onRender = function() { }; - -/** -* Event executed when the calendar widget is reset to its original state. -* @deprecated Event handlers for this event should be susbcribed to resetEvemt. -*/ -YAHOO.widget.Calendar.prototype.onReset = function() { this.render(); }; - -/** -* Event executed when the calendar widget is completely cleared to the current month with no selections. -* @deprecated Event handlers for this event should be susbcribed to clearEvent. -*/ -YAHOO.widget.Calendar.prototype.onClear = function() { this.render(); }; - -/** -* Validates the calendar widget. This method has no default implementation -* and must be extended by subclassing the widget. -* @return Should return true if the widget validates, and false if -* it doesn't. -* @type Boolean -*/ -YAHOO.widget.Calendar.prototype.validate = function() { return true; }; - -// END EVENT HANDLERS - -// BEGIN DATE PARSE METHODS - -/** -* Converts a date string to a date field array -* @private -* @param {String} sDate Date string. Valid formats are mm/dd and mm/dd/yyyy. -* @return A date field array representing the string passed to the method -* @type Array[](Number[]) -*/ -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;i<rArray.length;i++) { - rArray[i] = parseInt(rArray[i], 10); - } - - return rArray; -}; - -/** -* Converts a multi or single-date string to an array of date field arrays -* @private -* @param {String} sDates Date string with one or more comma-delimited dates. Valid formats are mm/dd, mm/dd/yyyy, mm/dd/yyyy-mm/dd/yyyy -* @return An array of date field arrays -* @type Array[](Number[]) -*/ -YAHOO.widget.Calendar.prototype._parseDates = function(sDates) { - var aReturn = []; - - var aDates = sDates.split(this.Locale.DATE_DELIMITER); - - for (var d=0;d<aDates.length;++d) { - var sDate = aDates[d]; - - if (sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER) != -1) { - // This is a range - var aRange = sDate.split(this.Locale.DATE_RANGE_DELIMITER); - - var dateStart = this._parseDate(aRange[0]); - var dateEnd = this._parseDate(aRange[1]); - - var fullRange = this._parseRange(dateStart, dateEnd); - aReturn = aReturn.concat(fullRange); - } else { - // This is not a range - var aDate = this._parseDate(sDate); - aReturn.push(aDate); - } - } - return aReturn; -}; - -/** -* Converts a date range to the full list of included dates -* @private -* @param {Number[]} startDate Date field array representing the first date in the range -* @param {Number[]} endDate Date field array representing the last date in the range -* @return An array of date field arrays -* @type Array[](Number[]) -*/ -YAHOO.widget.Calendar.prototype._parseRange = function(startDate, endDate) { - var dStart = new Date(startDate[0],startDate[1]-1,startDate[2]); - var dCurrent = YAHOO.widget.DateMath.add(new Date(startDate[0],startDate[1]-1,startDate[2]),YAHOO.widget.DateMath.DAY,1); - var dEnd = new Date(endDate[0], endDate[1]-1, endDate[2]); - - var results = []; - results.push(startDate); - while (dCurrent.getTime() <= dEnd.getTime()) { - results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]); - dCurrent = YAHOO.widget.DateMath.add(dCurrent,YAHOO.widget.DateMath.DAY,1); - } - return results; -}; - -// END DATE PARSE METHODS - -// BEGIN RENDERER METHODS - -/** -* Resets the render stack of the current calendar to its original pre-render value. -*/ -YAHOO.widget.Calendar.prototype.resetRenderers = function() { - this.renderStack = this._renderStack.concat(); -}; - -/** -* Clears the inner HTML, CSS class and style information from the specified cell. -* @method clearElement -* @param {HTMLTableCellElement} The cell to clear -*/ -YAHOO.widget.Calendar.prototype.clearElement = function(cell) { - cell.innerHTML = " "; - cell.className=""; -}; - -/** -* Adds a renderer to the render stack. The function reference passed to this method will be executed -* when a date cell matches the conditions specified in the date string for this renderer. -* @method addRenderer -* @param {String} sDates A date string to associate with the specified renderer. Valid formats -* include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005) -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.Calendar.prototype.addRenderer = function(sDates, fnRender) { - var aDates = this._parseDates(sDates); - for (var i=0;i<aDates.length;++i) { - var aDate = aDates[i]; - - if (aDate.length == 2) { // this is either a range or a month/day combo - if (aDate[0] instanceof Array) { // this is a range - this._addRenderer(YAHOO.widget.Calendar.RANGE,aDate,fnRender); - } else { // this is a month/day combo - this._addRenderer(YAHOO.widget.Calendar.MONTH_DAY,aDate,fnRender); - } - } else if (aDate.length == 3) { - this._addRenderer(YAHOO.widget.Calendar.DATE,aDate,fnRender); - } - } -}; - -/** -* The private method used for adding cell renderers to the local render stack. -* This method is called by other methods that set the renderer type prior to the method call. -* @method _addRenderer -* @private -* @param {String} type The type string that indicates the type of date renderer being added. -* Values are YAHOO.widget.Calendar.DATE, YAHOO.widget.Calendar.MONTH_DAY, YAHOO.widget.Calendar.WEEKDAY, -* YAHOO.widget.Calendar.RANGE, YAHOO.widget.Calendar.MONTH -* @param {Array} aDates An array of dates used to construct the renderer. The format varies based -* on the renderer type -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.Calendar.prototype._addRenderer = function(type, aDates, fnRender) { - var add = [type,aDates,fnRender]; - this.renderStack.unshift(add); - this._renderStack = this.renderStack.concat(); -}; - -/** -* Adds a month to the render stack. The function reference passed to this method will be executed -* when a date cell matches the month passed to this method. -* @method addMonthRenderer -* @param {Number} month The month (1-12) to associate with this renderer -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.Calendar.prototype.addMonthRenderer = function(month, fnRender) { - this._addRenderer(YAHOO.widget.Calendar.MONTH,[month],fnRender); -}; - -/** -* Adds a weekday to the render stack. The function reference passed to this method will be executed -* when a date cell matches the weekday passed to this method. -* @method addWeekdayRenderer -* @param {Number} weekday The weekday (0-6) to associate with this renderer -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.Calendar.prototype.addWeekdayRenderer = function(weekday, fnRender) { - this._addRenderer(YAHOO.widget.Calendar.WEEKDAY,[weekday],fnRender); -}; - -// END RENDERER METHODS - -// BEGIN CSS METHODS - -/** -* Removes all styles from all body cells in the current calendar table. -* @method clearAllBodyCellStyles -* @param {style} The CSS class name to remove from all calendar body cells -*/ -YAHOO.widget.Calendar.prototype.clearAllBodyCellStyles = function(style) { - for (var c=0;c<this.cells.length;++c) { - YAHOO.util.Dom.removeClass(this.cells[c],style); - } -}; - -// END CSS METHODS - -// BEGIN GETTER/SETTER METHODS -/** -* Sets the calendar's month explicitly -* @method setMonth -* @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"); - current.setMonth(parseInt(month, 10)); - this.cfg.setProperty("pagedate", current); -}; - -/** -* Sets the calendar's year explicitly. -* @method setYear -* @param {Number} year The numeric 4-digit year -*/ -YAHOO.widget.Calendar.prototype.setYear = function(year) { - var current = this.cfg.getProperty("pagedate"); - current.setFullYear(parseInt(year, 10)); - this.cfg.setProperty("pagedate", current); -}; - -/** -* Gets the list of currently selected dates from the calendar. -* @method getSelectedDates -* @return {Date[]} An array of currently selected JavaScript Date objects. -*/ -YAHOO.widget.Calendar.prototype.getSelectedDates = function() { - var returnDates = []; - var selected = this.cfg.getProperty("selected"); - - for (var d=0;d<selected.length;++d) { - var dateArray = selected[d]; - - var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]); - returnDates.push(date); - } - - returnDates.sort( function(a,b) { return a-b; } ); - return returnDates; -}; - -/// END GETTER/SETTER METHODS /// - -/** -* Hides the Calendar's outer container from view. -* @method hide -*/ -YAHOO.widget.Calendar.prototype.hide = function() { - this.oDomContainer.style.display = "none"; -}; - -/** -* Shows the Calendar's outer container. -* @method show -*/ -YAHOO.widget.Calendar.prototype.show = function() { - this.oDomContainer.style.display = "block"; -}; - -/** -* Returns a string representing the current browser. -* @property browser -* @type String -*/ -YAHOO.widget.Calendar.prototype.browser = function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) - return 'opera'; - } else if (ua.indexOf('msie 7')!=-1) { // IE7 - return 'ie7'; - } else if (ua.indexOf('msie') !=-1) { // IE - return 'ie'; - } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") - return 'safari'; - } else if (ua.indexOf('gecko') != -1) { // Gecko - return 'gecko'; - } else { - return false; - } - }(); -/** -* Returns a string representation of the object. -* @method toString -* @return {String} A string representation of the Calendar object. -*/ -YAHOO.widget.Calendar.prototype.toString = function() { - return "Calendar " + this.id; -}; - -/** -* @namespace YAHOO.widget -* @class Calendar_Core -* @extends YAHOO.widget.Calendar -* @deprecated The old Calendar_Core class is no longer necessary. -*/ -YAHOO.widget.Calendar_Core = YAHOO.widget.Calendar; - -YAHOO.widget.Cal_Core = YAHOO.widget.Calendar; - -/** -* YAHOO.widget.CalendarGroup is a special container class for YAHOO.widget.Calendar. This class facilitates -* the ability to have multi-page calendar views that share a single dataset and are -* dependent on each other. -* -* The calendar group instance will refer to each of its elements using a 0-based index. -* For example, to construct the placeholder for a calendar group widget with id "cal1" and -* containerId of "cal1Container", the markup would be as follows: -* <xmp> -* <div id="cal1Container_0"></div> -* <div id="cal1Container_1"></div> -* </xmp> -* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers. -* @namespace YAHOO.widget -* @class CalendarGroup -* @constructor -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -YAHOO.widget.CalendarGroup = function(id, containerId, config) { - if (arguments.length > 0) { - this.init(id, containerId, config); - } -}; - -/** -* Initializes the calendar group. All subclasses must call this method in order for the -* group to be initialized properly. -* @method init -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -*/ -YAHOO.widget.CalendarGroup.prototype.init = function(id, containerId, config) { - this.initEvents(); - this.initStyles(); - - /** - * The collection of Calendar pages contained within the CalendarGroup - * @property pages - * @type YAHOO.widget.Calendar[] - */ - this.pages = []; - - /** - * The unique id associated with the CalendarGroup - * @property id - * @type String - */ - this.id = id; - - /** - * The unique id associated with the CalendarGroup container - * @property containerId - * @type String - */ - this.containerId = containerId; - - /** - * The outer containing element for the CalendarGroup - * @property oDomContainer - * @type HTMLElement - */ - 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); - - /** - * The Config object used to hold the configuration variables for the CalendarGroup - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - /** - * The local object which contains the CalendarGroup's options - * @property Options - * @type Object - */ - this.Options = {}; - - /** - * The local object which contains the CalendarGroup's locale settings - * @property Locale - * @type Object - */ - this.Locale = {}; - - this.setupConfig(); - - if (config) { - this.cfg.applyConfig(config, true); - } - - this.cfg.fireQueue(); - - // OPERA HACK FOR MISWRAPPED FLOATS - if (this.browser == "opera"){ - var fixWidth = function() { - var startW = this.oDomContainer.offsetWidth; - var w = 0; - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - w += cal.oDomContainer.offsetWidth; - } - if (w > 0) { - this.oDomContainer.style.width = w + "px"; - } - }; - this.renderEvent.subscribe(fixWidth,this,true); - } -}; - - -YAHOO.widget.CalendarGroup.prototype.setupConfig = function() { - /** - * 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 } ); - - /** - * 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 } ); - - /** - * The date or range of dates representing the current Calendar selection - * @config selected - * @type String - * @default [] - */ - this.cfg.addProperty("selected", { value:[], handler:this.delegateConfig } ); - - /** - * The title to display above the CalendarGroup's month header - * @config title - * @type String - * @default "" - */ - this.cfg.addProperty("title", { value:"", handler:this.configTitle } ); - - /** - * Whether or not a close button should be displayed for this CalendarGroup - * @config close - * @type Boolean - * @default false - */ - this.cfg.addProperty("close", { value:false, 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. - * @config iframe - * @type Boolean - * @default true - */ - this.cfg.addProperty("iframe", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * The minimum selectable date in the current Calendar (mm/dd/yyyy) - * @config mindate - * @type String - * @default null - */ - this.cfg.addProperty("mindate", { value:null, handler:this.delegateConfig } ); - - /** - * The maximum selectable date in the current Calendar (mm/dd/yyyy) - * @config maxdate - * @type String - * @default null - */ - this.cfg.addProperty("maxdate", { value:null, handler:this.delegateConfig } ); - - // Options properties - - /** - * True if the Calendar should allow multiple selections. False by default. - * @config MULTI_SELECT - * @type Boolean - * @default false - */ - this.cfg.addProperty("MULTI_SELECT", { value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * The weekday the week begins on. Default is 0 (Sunday). - * @config START_WEEKDAY - * @type number - * @default 0 - */ - this.cfg.addProperty("START_WEEKDAY", { value:0, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * True if the Calendar should show weekday labels. True by default. - * @config SHOW_WEEKDAYS - * @type Boolean - * @default true - */ - this.cfg.addProperty("SHOW_WEEKDAYS", { value:true, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row headers. False by default. - * @config SHOW_WEEK_HEADER - * @type Boolean - * @default false - */ - this.cfg.addProperty("SHOW_WEEK_HEADER",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row footers. False by default. - * @config SHOW_WEEK_FOOTER - * @type Boolean - * @default false - */ - this.cfg.addProperty("SHOW_WEEK_FOOTER",{ value:false, 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. - * @config HIDE_BLANK_WEEKS - * @type Boolean - * @default false - */ - this.cfg.addProperty("HIDE_BLANK_WEEKS",{ value:false, handler:this.delegateConfig, validator:this.cfg.checkBoolean } ); - - /** - * The image that should be used for the left navigation arrow. - * @config NAV_ARROW_LEFT - * @type String - * @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:null, handler:this.delegateConfig } ); - - /** - * The image that should be used for the right navigation arrow. - * @config NAV_ARROW_RIGHT - * @type String - * @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:null, handler:this.delegateConfig } ); - - // Locale properties - - /** - * The short month labels for the current locale. - * @config MONTHS_SHORT - * @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 } ); - - /** - * The long month labels for the current locale. - * @config MONTHS_LONG - * @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 } ); - - /** - * The 1-character weekday labels for the current locale. - * @config WEEKDAYS_1CHAR - * @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 } ); - - /** - * The short weekday labels for the current locale. - * @config WEEKDAYS_SHORT - * @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 } ); - - /** - * The medium weekday labels for the current locale. - * @config WEEKDAYS_MEDIUM - * @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 } ); - - /** - * The long weekday labels for the current locale. - * @config WEEKDAYS_LONG - * @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 } ); - - /** - * The setting that determines which length of month labels should be used. Possible values are "short" and "long". - * @config LOCALE_MONTHS - * @type String - * @default "long" - */ - this.cfg.addProperty("LOCALE_MONTHS", { value:"long", handler:this.delegateConfig } ); - - /** - * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". - * @config LOCALE_WEEKDAYS - * @type String - * @default "short" - */ - this.cfg.addProperty("LOCALE_WEEKDAYS", { value:"short", handler:this.delegateConfig } ); - - /** - * The value used to delimit individual dates in a date string passed to various Calendar functions. - * @config DATE_DELIMITER - * @type String - * @default "," - */ - this.cfg.addProperty("DATE_DELIMITER", { value:",", handler:this.delegateConfig } ); - - /** - * The value used to delimit date fields in a date string passed to various Calendar functions. - * @config DATE_FIELD_DELIMITER - * @type String - * @default "/" - */ - this.cfg.addProperty("DATE_FIELD_DELIMITER",{ value:"/", handler:this.delegateConfig } ); - - /** - * The value used to delimit date ranges in a date string passed to various Calendar functions. - * @config DATE_RANGE_DELIMITER - * @type String - * @default "-" - */ - this.cfg.addProperty("DATE_RANGE_DELIMITER",{ value:"-", handler:this.delegateConfig } ); - - /** - * The position of the month in a month/year date string - * @config MY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/year date string - * @config MY_YEAR_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MY_YEAR_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day date string - * @config MD_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MD_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/year date string - * @config MD_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MD_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the month in a month/day/year date string - * @config MDY_MONTH_POSITION - * @type Number - * @default 1 - */ - this.cfg.addProperty("MDY_MONTH_POSITION", { value:1, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the day in a month/day/year date string - * @config MDY_DAY_POSITION - * @type Number - * @default 2 - */ - this.cfg.addProperty("MDY_DAY_POSITION", { value:2, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - - /** - * The position of the year in a month/day/year date string - * @config MDY_YEAR_POSITION - * @type Number - * @default 3 - */ - this.cfg.addProperty("MDY_YEAR_POSITION", { value:3, handler:this.delegateConfig, validator:this.cfg.checkNumber } ); - -}; - -/** -* Initializes CalendarGroup's built-in CustomEvents -* @method initEvents -*/ -YAHOO.widget.CalendarGroup.prototype.initEvents = function() { - var me = this; - - /** - * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents - * @method sub - * @private - * @param {Function} fn The function to subscribe to this CustomEvent - * @param {Object} obj The CustomEvent's scope object - * @param {Boolean} bOverride Whether or not to apply scope correction - */ - var sub = function(fn, obj, bOverride) { - for (var p=0;p<me.pages.length;++p) { - var cal = me.pages[p]; - cal[this.type + "Event"].subscribe(fn, obj, bOverride); - } - }; - - /** - * Proxy unsubscriber to unsubscribe from the CalendarGroup's child Calendars' CustomEvents - * @method unsub - * @private - * @param {Function} fn The function to subscribe to this CustomEvent - * @param {Object} obj The CustomEvent's scope object - */ - var unsub = function(fn, obj) { - for (var p=0;p<me.pages.length;++p) { - var cal = me.pages[p]; - cal[this.type + "Event"].unsubscribe(fn, obj); - } - }; - - /** - * Fired before a selection is made - * @event beforeSelectEvent - */ - this.beforeSelectEvent = new YAHOO.util.CustomEvent("beforeSelect"); - this.beforeSelectEvent.subscribe = sub; this.beforeSelectEvent.unsubscribe = unsub; - - /** - * 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.subscribe = sub; this.selectEvent.unsubscribe = unsub; - - /** - * Fired before a selection is made - * @event beforeDeselectEvent - */ - this.beforeDeselectEvent = new YAHOO.util.CustomEvent("beforeDeselect"); - this.beforeDeselectEvent.subscribe = sub; this.beforeDeselectEvent.unsubscribe = unsub; - - /** - * 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.subscribe = sub; this.deselectEvent.unsubscribe = unsub; - - /** - * Fired when the Calendar page is changed - * @event changePageEvent - */ - this.changePageEvent = new YAHOO.util.CustomEvent("changePage"); - this.changePageEvent.subscribe = sub; this.changePageEvent.unsubscribe = unsub; - - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - this.beforeRenderEvent.subscribe = sub; this.beforeRenderEvent.unsubscribe = unsub; - - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); - this.renderEvent.subscribe = sub; this.renderEvent.unsubscribe = unsub; - - /** - * Fired when the Calendar is reset - * @event resetEvent - */ - this.resetEvent = new YAHOO.util.CustomEvent("reset"); - this.resetEvent.subscribe = sub; this.resetEvent.unsubscribe = unsub; - - /** - * Fired when the Calendar is cleared - * @event clearEvent - */ - this.clearEvent = new YAHOO.util.CustomEvent("clear"); - this.clearEvent.subscribe = sub; this.clearEvent.unsubscribe = unsub; - -}; - -/** -* The default Config handler for the "pages" property -* @method configPages -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.CalendarGroup.prototype.configPages = function(type, args, obj) { - var pageCount = args[0]; - - for (var p=0;p<pageCount;++p) { - var calId = this.id + "_" + p; - var calContainerId = this.containerId + "_" + p; - - var childConfig = this.cfg.getConfig(); - childConfig.close = false; - childConfig.title = false; - - var cal = this.constructChild(calId, calContainerId, childConfig); - var caldate = cal.cfg.getProperty("pagedate"); - this._setMonthOnDate(caldate, caldate.getMonth() + p); - cal.cfg.setProperty("pagedate", caldate); - - YAHOO.util.Dom.removeClass(cal.oDomContainer, this.Style.CSS_SINGLE); - YAHOO.util.Dom.addClass(cal.oDomContainer, "groupcal"); - - if (p===0) { - YAHOO.util.Dom.addClass(cal.oDomContainer, "first"); - } - - if (p==(pageCount-1)) { - YAHOO.util.Dom.addClass(cal.oDomContainer, "last"); - } - - cal.parent = this; - cal.index = p; - - this.pages[this.pages.length] = cal; - } -}; - -/** -* The default Config handler for the "pagedate" property -* @method configPageDate -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.CalendarGroup.prototype.configPageDate = function(type, args, obj) { - var val = args[0]; - var firstPageDate; - - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - if (p === 0) { - firstPageDate = cal._parsePageDate(val); - cal.cfg.setProperty("pagedate", firstPageDate); - } else { - var pageDate = new Date(firstPageDate); - this._setMonthOnDate(pageDate, pageDate.getMonth() + p); - cal.cfg.setProperty("pagedate", pageDate); - } - } -}; - -/** -* Delegates a configuration property to the CustomEvents associated with the CalendarGroup's children -* @method delegateConfig -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.CalendarGroup.prototype.delegateConfig = function(type, args, obj) { - var val = args[0]; - var cal; - - for (var p=0;p<this.pages.length;p++) { - cal = this.pages[p]; - cal.cfg.setProperty(type, val); - } -}; - - -/** -* Adds a function to all child Calendars within this CalendarGroup. -* @method setChildFunction -* @param {String} fnName The name of the function -* @param {Function} fn The function to apply to each Calendar page object -*/ -YAHOO.widget.CalendarGroup.prototype.setChildFunction = function(fnName, fn) { - var pageCount = this.cfg.getProperty("pages"); - - for (var p=0;p<pageCount;++p) { - this.pages[p][fnName] = fn; - } -}; - -/** -* Calls a function within all child Calendars within this CalendarGroup. -* @method callChildFunction -* @param {String} fnName The name of the function -* @param {Array} args The arguments to pass to the function -*/ -YAHOO.widget.CalendarGroup.prototype.callChildFunction = function(fnName, args) { - var pageCount = this.cfg.getProperty("pages"); - - for (var p=0;p<pageCount;++p) { - var page = this.pages[p]; - if (page[fnName]) { - var fn = page[fnName]; - fn.call(page, args); - } - } -}; - -/** -* Constructs a child calendar. This method can be overridden if a subclassed version of the default -* calendar is to be used. -* @method constructChild -* @param {String} id The id of the table element that will represent the calendar widget -* @param {String} containerId The id of the container div element that will wrap the calendar table -* @param {Object} config The configuration object containing the Calendar's arguments -* @return {YAHOO.widget.Calendar} The YAHOO.widget.Calendar instance that is constructed -*/ -YAHOO.widget.CalendarGroup.prototype.constructChild = function(id,containerId,config) { - var container = document.getElementById(containerId); - if (! container) { - container = document.createElement("div"); - container.id = containerId; - this.oDomContainer.appendChild(container); - } - return new YAHOO.widget.Calendar(id,containerId,config); -}; - - -/** -* Sets the calendar group's month explicitly. This month will be set into the first -* page of the multi-page calendar, and all other months will be iterated appropriately. -* @method setMonth -* @param {Number} month The numeric month, from 0 (January) to 11 (December) -*/ -YAHOO.widget.CalendarGroup.prototype.setMonth = function(month) { - month = parseInt(month, 10); - var currYear; - - for (var p=0; p<this.pages.length; ++p) { - var cal = this.pages[p]; - var pageDate = cal.cfg.getProperty("pagedate"); - if (p === 0) { - currYear = pageDate.getFullYear(); - } else { - pageDate.setYear(currYear); - } - this._setMonthOnDate(pageDate, month+p); - cal.cfg.setProperty("pagedate", pageDate); - } -}; - -/** -* Sets the calendar group's year explicitly. This year will be set into the first -* page of the multi-page calendar, and all other months will be iterated appropriately. -* @method setYear -* @param {Number} year The numeric 4-digit year -*/ -YAHOO.widget.CalendarGroup.prototype.setYear = function(year) { - year = parseInt(year, 10); - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - var pageDate = cal.cfg.getProperty("pageDate"); - - if ((pageDate.getMonth()+1) == 1 && p>0) { - year+=1; - } - cal.setYear(year); - } -}; -/** -* Calls the render function of all child calendars within the group. -* @method render -*/ -YAHOO.widget.CalendarGroup.prototype.render = function() { - this.renderHeader(); - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.render(); - } - this.renderFooter(); -}; - -/** -* 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. -* @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). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -*/ -YAHOO.widget.CalendarGroup.prototype.select = function(date) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.select(date); - } - return this.getSelectedDates(); -}; - -/** -* Selects a date on the current calendar by referencing the index of the cell that should be selected. -* This method is used to easily select a single cell (usually with a mouse click) without having to do -* a full render. The selected style is applied to the cell directly. -* @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.CalendarGroup.prototype.selectCell = function(cellIndex) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.selectCell(cellIndex); - } - return this.getSelectedDates(); -}; - -/** -* Deselects a date or a collection of dates on the current calendar. This method, by default, -* does not call the render method explicitly. Once deselection has completed, render must be -* called for the changes to be reflected visually. -* @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). -* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). -* This method can also take a JavaScript Date object or an array of Date objects. -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -*/ -YAHOO.widget.CalendarGroup.prototype.deselect = function(date) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.deselect(date); - } - return this.getSelectedDates(); -}; - -/** -* Deselects all dates on the current calendar. -* @method deselectAll -* @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. -* Assuming that this function executes properly, the return value should be an empty array. -* However, the empty array is returned for the sake of being able to check the selection status -* of the calendar. -*/ -YAHOO.widget.CalendarGroup.prototype.deselectAll = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.deselectAll(); - } - return this.getSelectedDates(); -}; - -/** -* Deselects a date on the current calendar by referencing the index of the cell that should be deselected. -* This method is used to easily deselect a single cell (usually with a mouse click) without having to do -* a full render. The selected style is removed from the cell directly. -* @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.CalendarGroup.prototype.deselectCell = function(cellIndex) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.deselectCell(cellIndex); - } - return this.getSelectedDates(); -}; - -/** -* Resets the calendar widget to the originally selected month and year, and -* sets the calendar to the initial selection(s). -* @method reset -*/ -YAHOO.widget.CalendarGroup.prototype.reset = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.reset(); - } -}; - -/** -* Clears the selected dates in the current calendar widget and sets the calendar -* to the current month and year. -* @method clear -*/ -YAHOO.widget.CalendarGroup.prototype.clear = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.clear(); - } -}; - -/** -* Navigates to the next month page in the calendar widget. -* @method nextMonth -*/ -YAHOO.widget.CalendarGroup.prototype.nextMonth = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.nextMonth(); - } -}; - -/** -* Navigates to the previous month page in the calendar widget. -* @method previousMonth -*/ -YAHOO.widget.CalendarGroup.prototype.previousMonth = function() { - for (var p=this.pages.length-1;p>=0;--p) { - var cal = this.pages[p]; - cal.previousMonth(); - } -}; - -/** -* Navigates to the next year in the currently selected month in the calendar widget. -* @method nextYear -*/ -YAHOO.widget.CalendarGroup.prototype.nextYear = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.nextYear(); - } -}; - -/** -* Navigates to the previous year in the currently selected month in the calendar widget. -* @method previousYear -*/ -YAHOO.widget.CalendarGroup.prototype.previousYear = function() { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.previousYear(); - } -}; - - -/** -* Gets the list of currently selected dates from the calendar. -* @return An array of currently selected JavaScript Date objects. -* @type Date[] -*/ -YAHOO.widget.CalendarGroup.prototype.getSelectedDates = function() { - var returnDates = []; - var selected = this.cfg.getProperty("selected"); - - for (var d=0;d<selected.length;++d) { - var dateArray = selected[d]; - - var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]); - returnDates.push(date); - } - - returnDates.sort( function(a,b) { return a-b; } ); - return returnDates; -}; - -/** -* Adds a renderer to the render stack. The function reference passed to this method will be executed -* when a date cell matches the conditions specified in the date string for this renderer. -* @method addRenderer -* @param {String} sDates A date string to associate with the specified renderer. Valid formats -* include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005) -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.CalendarGroup.prototype.addRenderer = function(sDates, fnRender) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.addRenderer(sDates, fnRender); - } -}; - -/** -* Adds a month to the render stack. The function reference passed to this method will be executed -* when a date cell matches the month passed to this method. -* @method addMonthRenderer -* @param {Number} month The month (1-12) to associate with this renderer -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.CalendarGroup.prototype.addMonthRenderer = function(month, fnRender) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.addMonthRenderer(month, fnRender); - } -}; - -/** -* Adds a weekday to the render stack. The function reference passed to this method will be executed -* when a date cell matches the weekday passed to this method. -* @method addWeekdayRenderer -* @param {Number} weekday The weekday (0-6) to associate with this renderer -* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. -*/ -YAHOO.widget.CalendarGroup.prototype.addWeekdayRenderer = function(weekday, fnRender) { - for (var p=0;p<this.pages.length;++p) { - var cal = this.pages[p]; - cal.addWeekdayRenderer(weekday, fnRender); - } -}; - -/** -* Renders the header for the CalendarGroup. -* @method renderHeader -*/ -YAHOO.widget.CalendarGroup.prototype.renderHeader = function() {}; - -/** -* Renders a footer for the 2-up calendar container. By default, this method is -* unimplemented. -* @method renderFooter -*/ -YAHOO.widget.CalendarGroup.prototype.renderFooter = function() {}; - -/** -* Adds the designated number of months to the current calendar month, and sets the current -* calendar page date to the new month. -* @method addMonths -* @param {Number} count The number of months to add to the current calendar -*/ -YAHOO.widget.CalendarGroup.prototype.addMonths = function(count) { - this.callChildFunction("addMonths", count); -}; - - -/** -* Subtracts the designated number of months from the current calendar month, and sets the current -* calendar page date to the new month. -* @method subtractMonths -* @param {Number} count The number of months to subtract from the current calendar -*/ -YAHOO.widget.CalendarGroup.prototype.subtractMonths = function(count) { - this.callChildFunction("subtractMonths", count); -}; - -/** -* Adds the designated number of years to the current calendar, and sets the current -* calendar page date to the new month. -* @method addYears -* @param {Number} count The number of years to add to the current calendar -*/ -YAHOO.widget.CalendarGroup.prototype.addYears = function(count) { - this.callChildFunction("addYears", count); -}; - -/** -* Subtcats the designated number of years from the current calendar, and sets the current -* calendar page date to the new month. -* @method subtractYears -* @param {Number} count The number of years to subtract from the current calendar -*/ -YAHOO.widget.CalendarGroup.prototype.subtractYears = function(count) { - this.callChildFunction("subtractYears", count); -}; - -/** -* Sets the month on a Date object, taking into account year rollover if the month is less than 0 or greater than 11. -* The Date object passed in is modified. It should be cloned before passing it into this method if the original value needs to be maintained -* @method _setMonthOnDate -* @private -* @param {Date} date The Date object on which to set the month index -* @param {Number} iMonth The month index to set -*/ -YAHOO.widget.CalendarGroup.prototype._setMonthOnDate = function(date, iMonth) { - // BUG in Safari 1.3, 2.0 (WebKit build < 420), Date.setMonth does not work consistently if iMonth is not 0-11 - if (this.browser == "safari" && (iMonth < 0 || iMonth > 11)) { - var DM = YAHOO.widget.DateMath; - var newDate = DM.add(date, DM.MONTH, iMonth-date.getMonth()); - date.setTime(newDate.getTime()); - } else { - date.setMonth(iMonth); - } -}; - - -/** -* CSS class representing the container for the calendar -* @property YAHOO.widget.CalendarGroup.CSS_CONTAINER -* @static -* @final -* @type String -*/ -YAHOO.widget.CalendarGroup.CSS_CONTAINER = "yui-calcontainer"; - -/** -* CSS class representing the container for the calendar -* @property YAHOO.widget.CalendarGroup.CSS_MULTI_UP -* @static -* @final -* @type String -*/ -YAHOO.widget.CalendarGroup.CSS_MULTI_UP = "multi"; - -/** -* CSS class representing the title for the 2-up calendar -* @property YAHOO.widget.CalendarGroup.CSS_2UPTITLE -* @static -* @final -* @type String -*/ -YAHOO.widget.CalendarGroup.CSS_2UPTITLE = "title"; - -/** -* CSS class representing the close icon for the 2-up calendar -* @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 <a href="YAHOO.widget.Calendar.html#Style.CSS_CLOSE">Style.CSS_CLOSE</a> 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", - "buildMonthLabel", - "renderOutOfBoundsDate", - "renderRowHeader", - "renderRowFooter", - "renderCellDefault", - "styleCellDefault", - "renderCellStyleHighlight1", - "renderCellStyleHighlight2", - "renderCellStyleHighlight3", - "renderCellStyleHighlight4", - "renderCellStyleToday", - "renderCellStyleSelected", - "renderCellNotThisMonth", - "renderBodyCellRestricted", - "initStyles", - "configTitle", - "configClose", - "hide", - "show", - "browser"); - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} A string representation of the CalendarGroup object. -*/ -YAHOO.widget.CalendarGroup.prototype.toString = function() { - return "CalendarGroup " + this.id; -}; - -YAHOO.widget.CalGrp = YAHOO.widget.CalendarGroup; - -/** -* @class YAHOO.widget.Calendar2up -* @extends YAHOO.widget.CalendarGroup -* @deprecated The old Calendar2up class is no longer necessary, since CalendarGroup renders in a 2up view by default. -*/ -YAHOO.widget.Calendar2up = function(id, containerId, config) { - this.init(id, containerId, config); -}; - -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; - -YAHOO.register("calendar", YAHOO.widget.Calendar, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/connection/README b/interface/web/js/yui/connection/README deleted file mode 100644 index 8f401c9c9d..0000000000 --- a/interface/web/js/yui/connection/README +++ /dev/null @@ -1,182 +0,0 @@ -Connection Manager Release Notes - -*** version 2.2.0 *** - -* initHeader() now accepts a third argument as a boolean. When set to true, -this specific header will automatically be sent with each transaction. -Otherwise, the header will be set and sent for the specific transaction only. -Example: initHeader('X-YUI-State','Beta', true); all transactions will send this -header. - * resetDefaultHeaders() will clear the default headers collection. - -* All Connection Mananger transactions will broadcast the header: "X-Requested- -With: XMLHttpRequest". - * This can be turned off: YAHOO.util.Connect.setDefaultXhrHeader(false); - -* The HTTP method argument in asyncRequest is now case-insensitive. - -* uploadFile() will now correctly handle the absence of a callback object, -allowing the transaction to complete silently. - -*** version 0.12.2 *** - -* The Opera/Connection Manager concurrent object condition, described in version -0.12.0, no longer tests applies for Opera, version 9.10. - -*** version 0.12.1 *** - -* connection-debug.js corrected and synchronized with connection.js. Code -inconsistencies between the two files existed in 0.12.0. - -*** version 0.12.0 *** - -* When uploading files via setForm() and asyncRequest includes a POST data -argument, appendPostData() will create hidden input fields for each postData -label/value and append each field to the form object. - -* setForm() returns the assembled label/value string of the parsed HTML form -fields. - -* NOTE: Opera 9.02 does not allow for more than 12 concurrent Connection Manager -objects. - -The following example creates 12 requests in a loop: -for(var n=0; n<=12; i++){ - conn[n] = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); -} - -If n > 13, Opera 9.02 will crash. Connection manager objects count n must be <= -12 at all times. This condition was not present in Opera version 9.01. - -This condition does not apply to other A-Grade browsers ( -http://developer.yahoo.com/yui/articles/gbs/gbs_browser-chart.html) - -*** version 0.11.3 *** - -* YUI Event dependency for file uploading is now optional. - -* uploadFile() now sets unique IDs for each file upload transaction to prevent -iframe collisions with parallel uploads. - -* The callback object now has property responseXML to provide support for file -upload transactions that return an XML document. - -* setForm() will verify if a select option value attribute is present and use -its value, including empty string, before using the text node value. - -* Modified polling mechanism in handleReadyState() and -handleTransactionResponse() to prevent infinite polling if JavaScript errors -occur in the user-defined callback. - -* createFrame() will now accept a boolean argument of true to set the frame -source to "javascript:false" to prevent IE from throwing security warnings in an -HTTPS environment. - -* setHeader() now enumerates through the _http_header object using -hasOwnProperty() to prevent collisions with members added to Object via -prototype. - -* If using setForm() and asyncRequest includes a POST data argument, the data -will be concatenated to the HTML form POST message. - -*** version 0.11.2 *** - -* No revisions. - -*** version 0.11.1 *** - -* uploadFile() now verifies the existence of callback.upload before invoking -callback, with or without object scope. - -*** version 0.11.0 *** - -* Each transaction can be defined with a timeout threshold, in milliseconds, -through the callback object. If the threshold is reached, and the transaction -hasn't yet completed, the transaction will call abort(). - -* abort() will now accept a callback object as the second argument. The -failure callback will receive a response object to indicate the transaction was -aborted. - -* setForm() will now support file uploads by setting the second argument to -true (e.g., YAHOO.util.Connect.setForm(formObject, true). File upload does not -use the callback success or failure handler. Instead, it uses a new callback -object handler: upload. - -* HTML form submit will no longer submit form fields without a defined name -attribute. - -* The default POST header of 'Content-Type','application/x-www-form-urlencoded' -can be overridden by calling setDefaultPostHeader(false). This -will remove the default header from non-HTML form, POST submissions. - -* setHeader() now enumerates through the _http_header object with -propertyIsEnumerable to prevent collisions with members added to Object via -prototype. - -*** version 0.10.0 *** - -* handleTransactionResponse() now treats the full HTTP 2xx range as a success -case, instead of just HTTP 200. - -* To accommodate multiple field values in Mozilla/Firefox, multiple initHeader -calls with the same label will now result in the values concatenated to a -comma- delimited string value. -Example: -Setting Content-Type:'application/x-www-form-urlencoded' and Content- -Type:'text/xml' will result in Content-Type:'application/x-www-form-urlencoded, -text/xml'. - -* Default polling interval lowered to 50ms. - -* YAHOO.util.Connect.setPollingInterval() will allow you to set a polling -interval -- in milliseconds -- to override the default value. - -* YAHOO.util.Connect.getResponseHeader[headerLabel] now supported as a response -object property to provide symmetry with the native XHR object's property. -Example: -YAHOO.util.Connect.getResponseHeader['Content-Length'] will return the value -for the Content-Length header, if the header is available. - -* YAHOO.util.Connect.allResponseHeaders property renamed to -getAllResponseHeaders to provide symmetry with the native XHR object's -property. - -* YAHOO.util.Connect.setForm() now supports HTTP GET as well as HTTP POST. - -* YAHOO.util.Connect.setForm() now accepts an HTML form object as well as its -name attribute value. - -* YAHOO.util.Connect.setForm() will not submit HTML form fields that are -disabled or do not have a name attribute value. - -* [FIXED] Response exceptions result in infinite callback loop in -Mozilla/Firefox. - -* [FIXED] YAHOO.util.Connect.abort() now properly clears polling interval. - -* [FIXED] isCallInProgress() now verifies whether XHR instance still exists, -and returns false if the connection object is no longer available. - -*** version 0.9.0 *** - -* Initial release - - - - - - - - - - - - - - - - - - - diff --git a/interface/web/js/yui/connection/connection-debug.js b/interface/web/js/yui/connection/connection-debug.js deleted file mode 100644 index b9b0f3c200..0000000000 --- a/interface/web/js/yui/connection/connection-debug.js +++ /dev/null @@ -1,1082 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The Connection Manager provides a simplified interface to the XMLHttpRequest - * object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the - * interactive states and server response, returning the results to a pre-defined - * callback you create. - * - * @namespace YAHOO.util - * @module connection - * @requires yahoo - */ - -/** - * The Connection Manager singleton provides methods for creating and managing - * asynchronous transactions. - * - * @class Connect - */ - -YAHOO.util.Connect = -{ - /** - * @description Array of MSFT ActiveX ids for XMLHttpRequest. - * @property _msxml_progid - * @private - * @static - * @type array - */ - _msxml_progid:[ - 'MSXML2.XMLHTTP.3.0', - 'MSXML2.XMLHTTP', - 'Microsoft.XMLHTTP' - ], - - /** - * @description Object literal of HTTP header(s) - * @property _http_header - * @private - * @static - * @type object - */ - _http_headers:{}, - - /** - * @description Determines if HTTP headers are set. - * @property _has_http_headers - * @private - * @static - * @type boolean - */ - _has_http_headers:false, - - /** - * @description Determines if a default header of - * Content-Type of 'application/x-www-form-urlencoded' - * will be added to any client HTTP headers sent for POST - * transactions. - * @property _use_default_post_header - * @private - * @static - * @type boolean - */ - _use_default_post_header:true, - - /** - * @description Determines if a default header of - * Content-Type of 'application/x-www-form-urlencoded' - * will be added to client HTTP headers sent for POST - * transactions. - * @property _default_post_header - * @private - * @static - * @type boolean - */ - _default_post_header:'application/x-www-form-urlencoded', - - /** - * @description Determines if a default header of - * 'X-Requested-With: XMLHttpRequest' - * will be added to each transaction. - * @property _use_default_xhr_header - * @private - * @static - * @type boolean - */ - _use_default_xhr_header:true, - - /** - * @description The default header value for the label - * "X-Requested-With". This is sent with each - * transaction, by default, to identify the - * request as being made by YUI Connection Manager. - * @property _default_xhr_header - * @private - * @static - * @type boolean - */ - _default_xhr_header:'XMLHttpRequest', - - /** - * @description Determines if custom, default headers - * are set for each transaction. - * @property _has_default_header - * @private - * @static - * @type boolean - */ - _has_default_headers:true, - - /** - * @description Determines if custom, default headers - * are set for each transaction. - * @property _has_default_header - * @private - * @static - * @type boolean - */ - _default_headers:{}, - - /** - * @description Property modified by setForm() to determine if the data - * should be submitted as an HTML form. - * @property _isFormSubmit - * @private - * @static - * @type boolean - */ - _isFormSubmit:false, - - /** - * @description Property modified by setForm() to determine if a file(s) - * upload is expected. - * @property _isFileUpload - * @private - * @static - * @type boolean - */ - _isFileUpload:false, - - /** - * @description Property modified by setForm() to set a reference to the HTML - * form node if the desired action is file upload. - * @property _formNode - * @private - * @static - * @type object - */ - _formNode:null, - - /** - * @description Property modified by setForm() to set the HTML form data - * for each transaction. - * @property _sFormData - * @private - * @static - * @type string - */ - _sFormData:null, - - /** - * @description Collection of polling references to the polling mechanism in handleReadyState. - * @property _poll - * @private - * @static - * @type object - */ - _poll:{}, - - /** - * @description Queue of timeout values for each transaction callback with a defined timeout value. - * @property _timeOut - * @private - * @static - * @type object - */ - _timeOut:{}, - - /** - * @description The polling frequency, in milliseconds, for HandleReadyState. - * when attempting to determine a transaction's XHR readyState. - * The default is 50 milliseconds. - * @property _polling_interval - * @private - * @static - * @type int - */ - _polling_interval:50, - - /** - * @description A transaction counter that increments the transaction id for each transaction. - * @property _transaction_id - * @private - * @static - * @type int - */ - _transaction_id:0, - - /** - * @description Member to add an ActiveX id to the existing xml_progid array. - * In the event(unlikely) a new ActiveX id is introduced, it can be added - * without internal code modifications. - * @method setProgId - * @public - * @static - * @param {string} id The ActiveX id to be added to initialize the XHR object. - * @return void - */ - setProgId:function(id) - { - this._msxml_progid.unshift(id); - YAHOO.log('ActiveX Program Id ' + id + ' added to _msxml_progid.', 'info', 'Connection'); - }, - - /** - * @description Member to enable or disable the default POST header. - * @method setDefaultPostHeader - * @public - * @static - * @param {boolean} b Set and use default header - true or false . - * @return void - */ - setDefaultPostHeader:function(b) - { - this._use_default_post_header = b; - YAHOO.log('Use default POST header set to ' + b, 'info', 'Connection'); - }, - - /** - * @description Member to enable or disable the default POST header. - * @method setDefaultXhrHeader - * @public - * @static - * @param {boolean} b Set and use default header - true or false . - * @return void - */ - setDefaultXhrHeader:function(b) - { - this._use_default_xhr_header = b; - YAHOO.log('Use default transaction header set to ' + b, 'info', 'Connection'); - }, - - /** - * @description Member to modify the default polling interval. - * @method setPollingInterval - * @public - * @static - * @param {int} i The polling interval in milliseconds. - * @return void - */ - setPollingInterval:function(i) - { - if(typeof i == 'number' && isFinite(i)){ - this._polling_interval = i; - YAHOO.log('Default polling interval set to ' + i +'ms', 'info', 'Connection'); - } - }, - - /** - * @description Instantiates a XMLHttpRequest object and returns an object with two properties: - * the XMLHttpRequest instance and the transaction id. - * @method createXhrObject - * @private - * @static - * @param {int} transactionId Property containing the transaction id for this transaction. - * @return object - */ - createXhrObject:function(transactionId) - { - var obj,http; - try - { - // Instantiates XMLHttpRequest in non-IE browsers and assigns to http. - http = new XMLHttpRequest(); - // Object literal with http and tId properties - obj = { conn:http, tId:transactionId }; - YAHOO.log('XHR object created for transaction ' + transactionId, 'info', 'Connection'); - } - catch(e) - { - for(var i=0; i<this._msxml_progid.length; ++i){ - try - { - // Instantiates XMLHttpRequest for IE and assign to http. - http = new ActiveXObject(this._msxml_progid[i]); - // Object literal with conn and tId properties - obj = { conn:http, tId:transactionId }; - YAHOO.log('ActiveX XHR object created for transaction ' + transactionId, 'info', 'Connection'); - break; - } - catch(e){} - } - } - finally - { - return obj; - } - }, - - /** - * @description This method is called by asyncRequest to create a - * valid connection object for the transaction. It also passes a - * transaction id and increments the transaction id counter. - * @method getConnectionObject - * @private - * @static - * @return {object} - */ - getConnectionObject:function() - { - var o; - var tId = this._transaction_id; - - try - { - o = this.createXhrObject(tId); - if(o){ - this._transaction_id++; - } - } - catch(e){} - finally - { - return o; - } - }, - - /** - * @description Method for initiating an asynchronous request via the XHR object. - * @method asyncRequest - * @public - * @static - * @param {string} method HTTP transaction method - * @param {string} uri Fully qualified path of resource - * @param {callback} callback User-defined callback function or object - * @param {string} postData POST body - * @return {object} Returns the connection object - */ - asyncRequest:function(method, uri, callback, postData) - { - var o = this.getConnectionObject(); - - if(!o){ - YAHOO.log('Unable to create connection object.', 'error', 'Connection'); - return null; - } - else{ - if(this._isFormSubmit){ - if(this._isFileUpload){ - this.uploadFile(o.tId, callback, uri, postData); - this.releaseObject(o); - - return; - } - - //If the specified HTTP method is GET, setForm() will return an - //encoded string that is concatenated to the uri to - //create a querystring. - if(method.toUpperCase() == 'GET'){ - if(this._sFormData.length != 0){ - // If the URI already contains a querystring, append an ampersand - // and then concatenate _sFormData to the URI. - uri += ((uri.indexOf('?') == -1)?'?':'&') + this._sFormData; - } - else{ - uri += "?" + this._sFormData; - } - } - else if(method.toUpperCase() == 'POST'){ - //If POST data exist in addition to the HTML form data, - //it will be concatenated to the form data. - postData = postData?this._sFormData + "&" + postData:this._sFormData; - } - } - - o.conn.open(method, uri, true); - - if(this._use_default_xhr_header){ - if(!this._default_headers['X-Requested-With']){ - this.initHeader('X-Requested-With', this._default_xhr_header, true); - YAHOO.log('Initialize transaction header X-Request-Header to XMLHttpRequest.', 'info', 'Connection'); - } - } - if(this._isFormSubmit || (postData && this._use_default_post_header)){ - this.initHeader('Content-Type', this._default_post_header); - YAHOO.log('Initialize header Content-Type to application/x-www-form-urlencoded for POST transaction.', 'info', 'Connection'); - if(this._isFormSubmit){ - this.resetFormState(); - } - } - - if(this._has_default_headers || this._has_http_headers){ - this.setHeader(o); - } - - this.handleReadyState(o, callback); - o.conn.send(postData || null); - - return o; - } - }, - - /** - * @description This method serves as a timer that polls the XHR object's readyState - * property during a transaction, instead of binding a callback to the - * onreadystatechange event. Upon readyState 4, handleTransactionResponse - * will process the response, and the timer will be cleared. - * @method handleReadyState - * @private - * @static - * @param {object} o The connection object - * @param {callback} callback The user-defined callback object - * @return {void} - */ - handleReadyState:function(o, callback) - { - var oConn = this; - - if(callback && callback.timeout){ - this._timeOut[o.tId] = window.setTimeout(function(){ oConn.abort(o, callback, true); }, callback.timeout); - } - - this._poll[o.tId] = window.setInterval( - function(){ - if(o.conn && o.conn.readyState == 4){ - window.clearInterval(oConn._poll[o.tId]); - delete oConn._poll[o.tId]; - - if(callback && callback.timeout){ - delete oConn._timeOut[o.tId]; - } - - oConn.handleTransactionResponse(o, callback); - } - } - ,this._polling_interval); - }, - - /** - * @description This method attempts to interpret the server response and - * determine whether the transaction was successful, or if an error or - * exception was encountered. - * @method handleTransactionResponse - * @private - * @static - * @param {object} o The connection object - * @param {object} callback The sser-defined callback object - * @param {boolean} isAbort Determines if the transaction was aborted. - * @return {void} - */ - handleTransactionResponse:function(o, callback, isAbort) - { - // If no valid callback is provided, then do not process any callback handling. - if(!callback){ - this.releaseObject(o); - YAHOO.log('No callback object to process. Transaction complete.', 'warn', 'Connection'); - return; - } - - var httpStatus, responseObject; - - try - { - if(o.conn.status !== undefined && o.conn.status != 0){ - httpStatus = o.conn.status; - } - else{ - httpStatus = 13030; - } - } - catch(e){ - // 13030 is the custom code to indicate the condition -- in Mozilla/FF -- - // when the o object's status and statusText properties are - // unavailable, and a query attempt throws an exception. - httpStatus = 13030; - } - - if(httpStatus >= 200 && httpStatus < 300){ - responseObject = this.createResponseObject(o, callback.argument); - if(callback.success){ - if(!callback.scope){ - callback.success(responseObject); - YAHOO.log('Success callback. HTTP code is ' + httpStatus, 'info', 'Connection'); - } - else{ - // If a scope property is defined, the callback will be fired from - // the context of the object. - callback.success.apply(callback.scope, [responseObject]); - YAHOO.log('Success callback with scope. HTTP code is ' + httpStatus, 'info', 'Connection'); - } - } - } - else{ - switch(httpStatus){ - // The following cases are wininet.dll error codes that may be encountered. - case 12002: // Server timeout - case 12029: // 12029 to 12031 correspond to dropped connections. - case 12030: - case 12031: - case 12152: // Connection closed by server. - case 13030: // See above comments for variable status. - responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort?isAbort:false)); - if(callback.failure){ - if(!callback.scope){ - callback.failure(responseObject); - YAHOO.log('Failure callback. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection'); - } - else{ - callback.failure.apply(callback.scope, [responseObject]); - YAHOO.log('Failure callback with scope. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection'); - } - } - break; - default: - responseObject = this.createResponseObject(o, callback.argument); - if(callback.failure){ - if(!callback.scope){ - callback.failure(responseObject); - YAHOO.log('Failure callback. HTTP status code is ' + httpStatus, 'warn', 'Connection'); - } - else{ - callback.failure.apply(callback.scope, [responseObject]); - YAHOO.log('Failure callback with scope. HTTP status code is ' + httpStatus, 'warn', 'Connection'); - } - } - } - } - - this.releaseObject(o); - responseObject = null; - }, - - /** - * @description This method evaluates the server response, creates and returns the results via - * its properties. Success and failure cases will differ in the response - * object's property values. - * @method createResponseObject - * @private - * @static - * @param {object} o The connection object - * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback - * @return {object} - */ - createResponseObject:function(o, callbackArg) - { - var obj = {}; - var headerObj = {}; - - try - { - var headerStr = o.conn.getAllResponseHeaders(); - var header = headerStr.split('\n'); - for(var i=0; i<header.length; i++){ - var delimitPos = header[i].indexOf(':'); - if(delimitPos != -1){ - headerObj[header[i].substring(0,delimitPos)] = header[i].substring(delimitPos+2); - } - } - } - catch(e){} - - obj.tId = o.tId; - obj.status = o.conn.status; - obj.statusText = o.conn.statusText; - obj.getResponseHeader = headerObj; - obj.getAllResponseHeaders = headerStr; - obj.responseText = o.conn.responseText; - obj.responseXML = o.conn.responseXML; - - if(typeof callbackArg !== undefined){ - obj.argument = callbackArg; - } - - return obj; - }, - - /** - * @description If a transaction cannot be completed due to dropped or closed connections, - * there may be not be enough information to build a full response object. - * The failure callback will be fired and this specific condition can be identified - * by a status property value of 0. - * - * If an abort was successful, the status property will report a value of -1. - * - * @method createExceptionObject - * @private - * @static - * @param {int} tId The Transaction Id - * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback - * @param {boolean} isAbort Determines if the exception case is caused by a transaction abort - * @return {object} - */ - createExceptionObject:function(tId, callbackArg, isAbort) - { - var COMM_CODE = 0; - var COMM_ERROR = 'communication failure'; - var ABORT_CODE = -1; - var ABORT_ERROR = 'transaction aborted'; - - var obj = {}; - - obj.tId = tId; - if(isAbort){ - obj.status = ABORT_CODE; - obj.statusText = ABORT_ERROR; - } - else{ - obj.status = COMM_CODE; - obj.statusText = COMM_ERROR; - } - - if(callbackArg){ - obj.argument = callbackArg; - } - - return obj; - }, - - /** - * @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,isDefault) - { - 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, - headerObj[label] = value + "," + headerObj[label]; - } - - 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 - * @private - * @static - * @param {object} o The connection object for the transaction. - * @return {void} - */ - setHeader:function(o) - { - 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'); - } - } - } - - 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. - * @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. - * @return {string} string of the HTML form field name and value pairs.. - */ - setForm:function(formId, isUpload, secureUri) - { - this.resetFormState(); - var oForm; - if(typeof formId == 'string'){ - // Determine if the argument is a form id or a form name. - // Note form name usage is deprecated by supported - // here for legacy reasons. - oForm = (document.getElementById(formId) || document.forms[formId]); - } - else if(typeof formId == 'object'){ - // Treat argument as an HTML form object. - oForm = formId; - } - else{ - YAHOO.log('Unable to create form object ' + formId, 'warn', 'Connection'); - return; - } - - // If the isUpload argument is true, setForm will call createFrame to initialize - // an iframe as the form target. - // - // The argument secureURI is also required by IE in SSL environments - // where the secureURI string is a fully qualified HTTP path, used to set the source - // of the iframe, to a stub resource in the same domain. - if(isUpload){ - - // Create iframe in preparation for file upload. - 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; - var hasSubmit = false; - - // Iterate over the form elements collection to construct the - // label-value pairs. - for (var i=0; i<oForm.elements.length; i++){ - oElement = oForm.elements[i]; - oDisabled = oForm.elements[i].disabled; - oName = oForm.elements[i].name; - oValue = oForm.elements[i].value; - - // Do not submit fields that are disabled or - // do not have a name attribute value. - if(!oDisabled && oName) - { - switch (oElement.type) - { - case 'select-one': - case 'select-multiple': - for(var j=0; j<oElement.options.length; j++){ - if(oElement.options[j].selected){ - if(window.ActiveXObject){ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].attributes['value'].specified?oElement.options[j].value:oElement.options[j].text) + '&'; - } - else{ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text) + '&'; - } - - } - } - break; - case 'radio': - case 'checkbox': - if(oElement.checked){ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; - } - break; - case 'file': - // stub case as XMLHttpRequest will only send the file path as a string. - case undefined: - // stub case for fieldset element which returns undefined. - case 'reset': - // stub case for input type reset button. - case 'button': - // stub case for input type button elements. - break; - case 'submit': - if(hasSubmit == false){ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; - hasSubmit = true; - } - break; - default: - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; - break; - } - } - } - - this._isFormSubmit = true; - this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1); - - YAHOO.log('Form initialized for transaction. HTML form POST message is: ' + this._sFormData, 'info', 'Connection'); - - return this._sFormData; - }, - - /** - * @description Resets HTML form properties when an HTML form or HTML form - * with file upload transaction is sent. - * @method resetFormState - * @private - * @static - * @return {void} - */ - resetFormState:function(){ - this._isFormSubmit = false; - this._isFileUpload = false; - this._formNode = null; - this._sFormData = ""; - }, - - /** - * @description Creates an iframe to be used for form file uploads. It is remove from the - * document upon completion of the upload transaction. - * @method createFrame - * @private - * @static - * @param {string} optional qualified path of iframe resource for SSL in IE. - * @return {void} - */ - createFrame:function(secureUri){ - - // IE does not allow the setting of id and name attributes as object - // properties via createElement(). A different iframe creation - // pattern is required for IE. - var frameId = 'yuiIO' + this._transaction_id; - if(window.ActiveXObject){ - var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />'); - - // IE will throw a security exception in an SSL environment if the - // iframe source is undefined. - if(typeof secureUri == 'boolean'){ - io.src = 'javascript:false'; - } - else if(typeof secureURI == 'string'){ - // Deprecated - io.src = secureUri; - } - } - else{ - var io = document.createElement('iframe'); - io.id = frameId; - io.name = frameId; - } - - io.style.position = 'absolute'; - io.style.top = '-1000px'; - io.style.left = '-1000px'; - - document.body.appendChild(io); - YAHOO.log('File upload iframe created. Id is:' + frameId, 'info', 'Connection'); - }, - - /** - * @description Parses the POST data and creates hidden form elements - * for each key-value, and appends them to the HTML form object. - * @method appendPostData - * @private - * @static - * @param {string} postData The HTTP POST data - * @return {array} formElements Collection of hidden fields. - */ - appendPostData:function(postData) - { - var formElements = []; - var postMessage = postData.split('&'); - for(var i=0; i < postMessage.length; i++){ - var delimitPos = postMessage[i].indexOf('='); - if(delimitPos != -1){ - formElements[i] = document.createElement('input'); - formElements[i].type = 'hidden'; - formElements[i].name = postMessage[i].substring(0,delimitPos); - formElements[i].value = postMessage[i].substring(delimitPos+1); - this._formNode.appendChild(formElements[i]); - } - } - - return formElements; - }, - - /** - * @description Uploads HTML form, including files/attachments, to the - * iframe created in createFrame. - * @method uploadFile - * @private - * @static - * @param {int} id The transaction id. - * @param {object} callback - User-defined callback object. - * @param {string} uri Fully qualified path of resource. - * @return {void} - */ - uploadFile:function(id, callback, uri, postData){ - - // Each iframe has an id prefix of "yuiIO" followed - // by the unique transaction id. - var frameId = 'yuiIO' + id; - var uploadEncoding = 'multipart/form-data'; - var io = document.getElementById(frameId); - - // Initialize the HTML form properties in case they are - // not defined in the HTML form. - this._formNode.action = uri; - this._formNode.method = 'POST'; - this._formNode.target = frameId; - - if(this._formNode.encoding){ - // IE does not respect property enctype for HTML forms. - // Instead it uses the property - "encoding". - this._formNode.encoding = uploadEncoding; - } - else{ - this._formNode.enctype = uploadEncoding; - } - - - if(postData){ - var oElements = this.appendPostData(postData); - } - - this._formNode.submit(); - - if(oElements && oElements.length > 0){ - for(var i=0; i < oElements.length; i++){ - this._formNode.removeChild(oElements[i]); - } - } - - // Reset HTML form status properties. - this.resetFormState(); - - // Create the upload callback handler that fires when the iframe - // receives the load event. Subsequently, the event handler is detached - // and the iframe removed from the document. - - var uploadCallback = function() - { - var obj = {}; - obj.tId = id; - obj.argument = callback.argument; - - try - { - obj.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null; - obj.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document; - } - catch(e){} - - if(callback && callback.upload){ - if(!callback.scope){ - callback.upload(obj); - YAHOO.log('Upload callback.', 'info', 'Connection'); - } - else{ - callback.upload.apply(callback.scope, [obj]); - YAHOO.log('Upload callback with scope.', 'info', 'Connection'); - } - } - - if(YAHOO.util.Event){ - YAHOO.util.Event.removeListener(io, "load", uploadCallback); - } - else if(window.detachEvent){ - io.detachEvent('onload', uploadCallback); - } - else{ - io.removeEventListener('load', uploadCallback, false); - } - setTimeout( - function(){ - document.body.removeChild(io); - YAHOO.log('File upload iframe destroyed. Id is:' + frameId, 'info', 'Connection'); - }, 100); - }; - - - // Bind the onload handler to the iframe to detect the file upload response. - if(YAHOO.util.Event){ - YAHOO.util.Event.addListener(io, "load", uploadCallback); - } - else if(window.attachEvent){ - io.attachEvent('onload', uploadCallback); - } - else{ - io.addEventListener('load', uploadCallback, false); - } - }, - - /** - * @description Method to terminate a transaction, if it has not reached readyState 4. - * @method abort - * @public - * @static - * @param {object} o The connection object returned by asyncRequest. - * @param {object} callback User-defined callback object. - * @param {string} isTimeout boolean to indicate if abort was a timeout. - * @return {boolean} - */ - abort:function(o, callback, isTimeout) - { - if(this.isCallInProgress(o)){ - o.conn.abort(); - window.clearInterval(this._poll[o.tId]); - delete this._poll[o.tId]; - if(isTimeout){ - delete this._timeOut[o.tId]; - } - - this.handleTransactionResponse(o, callback, true); - YAHOO.log('Transaction ' + o.tId + ' aborted.', 'info', 'Connection'); - - return true; - } - else{ - YAHOO.log('Transaction ' + o.tId + ' abort call failed.', 'warn', 'Connection'); - return false; - } - }, - - /** - * Public method to check if the transaction is still being processed. - * - * @method isCallInProgress - * @public - * @static - * @param {object} o The connection object returned by asyncRequest - * @return {boolean} - */ - isCallInProgress:function(o) - { - // if the XHR object assigned to the transaction has not been dereferenced, - // then check its readyState status. Otherwise, return false. - if(o.conn){ - return o.conn.readyState != 4 && o.conn.readyState != 0; - } - else{ - //The XHR object has been destroyed. - return false; - } - }, - - /** - * @description Dereference the XHR instance and the connection object after the transaction is completed. - * @method releaseObject - * @private - * @static - * @param {object} o The connection object - * @return {void} - */ - releaseObject:function(o) - { - //dereference the XHR instance. - o.conn = null; - YAHOO.log('Connection object for transaction ' + o.tId + ' destroyed.', 'info', 'Connection'); - //dereference the connection object. - o = null; - } -}; -YAHOO.register("connection", YAHOO.widget.Module, {version: "2.2.0", build: "127"}); \ No newline at end of file diff --git a/interface/web/js/yui/connection/connection-min.js b/interface/web/js/yui/connection/connection-min.js deleted file mode 100644 index 3f29aa5812..0000000000 --- a/interface/web/js/yui/connection/connection-min.js +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -YAHOO.util.Connect={_msxml_progid:['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'],_http_headers:{},_has_http_headers:false,_use_default_post_header:true,_default_post_header:'application/x-www-form-urlencoded',_use_default_xhr_header:true,_default_xhr_header:'XMLHttpRequest',_has_default_headers:true,_default_headers:{},_isFormSubmit:false,_isFileUpload:false,_formNode:null,_sFormData:null,_poll:{},_timeOut:{},_polling_interval:50,_transaction_id:0,setProgId:function(id) -{this._msxml_progid.unshift(id);},setDefaultPostHeader:function(b) -{this._use_default_post_header=b;},setDefaultXhrHeader:function(b) -{this._use_default_xhr_header=b;},setPollingInterval:function(i) -{if(typeof i=='number'&&isFinite(i)){this._polling_interval=i;}},createXhrObject:function(transactionId) -{var obj,http;try -{http=new XMLHttpRequest();obj={conn:http,tId:transactionId};} -catch(e) -{for(var i=0;i<this._msxml_progid.length;++i){try -{http=new ActiveXObject(this._msxml_progid[i]);obj={conn:http,tId:transactionId};break;} -catch(e){}}} -finally -{return obj;}},getConnectionObject:function() -{var o;var tId=this._transaction_id;try -{o=this.createXhrObject(tId);if(o){this._transaction_id++;}} -catch(e){} -finally -{return o;}},asyncRequest:function(method,uri,callback,postData) -{var o=this.getConnectionObject();if(!o){return null;} -else{if(this._isFormSubmit){if(this._isFileUpload){this.uploadFile(o.tId,callback,uri,postData);this.releaseObject(o);return;} -if(method.toUpperCase()=='GET'){if(this._sFormData.length!=0){uri+=((uri.indexOf('?')==-1)?'?':'&')+this._sFormData;} -else{uri+="?"+this._sFormData;}} -else if(method.toUpperCase()=='POST'){postData=postData?this._sFormData+"&"+postData:this._sFormData;}} -o.conn.open(method,uri,true);if(this._use_default_xhr_header){if(!this._default_headers['X-Requested-With']){this.initHeader('X-Requested-With',this._default_xhr_header,true);}} -if(this._isFormSubmit||(postData&&this._use_default_post_header)){this.initHeader('Content-Type',this._default_post_header);if(this._isFormSubmit){this.resetFormState();}} -if(this._has_default_headers||this._has_http_headers){this.setHeader(o);} -this.handleReadyState(o,callback);o.conn.send(postData||null);return o;}},handleReadyState:function(o,callback) -{var oConn=this;if(callback&&callback.timeout){this._timeOut[o.tId]=window.setTimeout(function(){oConn.abort(o,callback,true);},callback.timeout);} -this._poll[o.tId]=window.setInterval(function(){if(o.conn&&o.conn.readyState==4){window.clearInterval(oConn._poll[o.tId]);delete oConn._poll[o.tId];if(callback&&callback.timeout){delete oConn._timeOut[o.tId];} -oConn.handleTransactionResponse(o,callback);}},this._polling_interval);},handleTransactionResponse:function(o,callback,isAbort) -{if(!callback){this.releaseObject(o);return;} -var httpStatus,responseObject;try -{if(o.conn.status!==undefined&&o.conn.status!=0){httpStatus=o.conn.status;} -else{httpStatus=13030;}} -catch(e){httpStatus=13030;} -if(httpStatus>=200&&httpStatus<300){responseObject=this.createResponseObject(o,callback.argument);if(callback.success){if(!callback.scope){callback.success(responseObject);} -else{callback.success.apply(callback.scope,[responseObject]);}}} -else{switch(httpStatus){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:responseObject=this.createExceptionObject(o.tId,callback.argument,(isAbort?isAbort:false));if(callback.failure){if(!callback.scope){callback.failure(responseObject);} -else{callback.failure.apply(callback.scope,[responseObject]);}} -break;default:responseObject=this.createResponseObject(o,callback.argument);if(callback.failure){if(!callback.scope){callback.failure(responseObject);} -else{callback.failure.apply(callback.scope,[responseObject]);}}}} -this.releaseObject(o);responseObject=null;},createResponseObject:function(o,callbackArg) -{var obj={};var headerObj={};try -{var headerStr=o.conn.getAllResponseHeaders();var header=headerStr.split('\n');for(var i=0;i<header.length;i++){var delimitPos=header[i].indexOf(':');if(delimitPos!=-1){headerObj[header[i].substring(0,delimitPos)]=header[i].substring(delimitPos+2);}}} -catch(e){} -obj.tId=o.tId;obj.status=o.conn.status;obj.statusText=o.conn.statusText;obj.getResponseHeader=headerObj;obj.getAllResponseHeaders=headerStr;obj.responseText=o.conn.responseText;obj.responseXML=o.conn.responseXML;if(typeof callbackArg!==undefined){obj.argument=callbackArg;} -return obj;},createExceptionObject:function(tId,callbackArg,isAbort) -{var COMM_CODE=0;var COMM_ERROR='communication failure';var ABORT_CODE=-1;var ABORT_ERROR='transaction aborted';var obj={};obj.tId=tId;if(isAbort){obj.status=ABORT_CODE;obj.statusText=ABORT_ERROR;} -else{obj.status=COMM_CODE;obj.statusText=COMM_ERROR;} -if(callbackArg){obj.argument=callbackArg;} -return obj;},initHeader:function(label,value,isDefault) -{var headerObj=(isDefault)?this._default_headers:this._http_headers;if(headerObj[label]===undefined){headerObj[label]=value;} -else{headerObj[label]=value+","+headerObj[label];} -if(isDefault){this._has_default_headers=true;} -else{this._has_http_headers=true;}},setHeader:function(o) -{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]);}}} -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]);}} -delete this._http_headers;this._http_headers={};this._has_http_headers=false;}},resetDefaultHeaders:function(){delete this._default_headers -this._default_headers={};this._has_default_headers=false;},setForm:function(formId,isUpload,secureUri) -{this.resetFormState();var oForm;if(typeof formId=='string'){oForm=(document.getElementById(formId)||document.forms[formId]);} -else if(typeof formId=='object'){oForm=formId;} -else{return;} -if(isUpload){this.createFrame(secureUri?secureUri:null);this._isFormSubmit=true;this._isFileUpload=true;this._formNode=oForm;return;} -var oElement,oName,oValue,oDisabled;var hasSubmit=false;for(var i=0;i<oForm.elements.length;i++){oElement=oForm.elements[i];oDisabled=oForm.elements[i].disabled;oName=oForm.elements[i].name;oValue=oForm.elements[i].value;if(!oDisabled&&oName) -{switch(oElement.type) -{case'select-one':case'select-multiple':for(var j=0;j<oElement.options.length;j++){if(oElement.options[j].selected){if(window.ActiveXObject){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oElement.options[j].attributes['value'].specified?oElement.options[j].value:oElement.options[j].text)+'&';} -else{this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text)+'&';}}} -break;case'radio':case'checkbox':if(oElement.checked){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';} -break;case'file':case undefined:case'reset':case'button':break;case'submit':if(hasSubmit==false){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';hasSubmit=true;} -break;default:this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';break;}}} -this._isFormSubmit=true;this._sFormData=this._sFormData.substr(0,this._sFormData.length-1);return this._sFormData;},resetFormState:function(){this._isFormSubmit=false;this._isFileUpload=false;this._formNode=null;this._sFormData="";},createFrame:function(secureUri){var frameId='yuiIO'+this._transaction_id;if(window.ActiveXObject){var io=document.createElement('<iframe id="'+frameId+'" name="'+frameId+'" />');if(typeof secureUri=='boolean'){io.src='javascript:false';} -else if(typeof secureURI=='string'){io.src=secureUri;}} -else{var io=document.createElement('iframe');io.id=frameId;io.name=frameId;} -io.style.position='absolute';io.style.top='-1000px';io.style.left='-1000px';document.body.appendChild(io);},appendPostData:function(postData) -{var formElements=[];var postMessage=postData.split('&');for(var i=0;i<postMessage.length;i++){var delimitPos=postMessage[i].indexOf('=');if(delimitPos!=-1){formElements[i]=document.createElement('input');formElements[i].type='hidden';formElements[i].name=postMessage[i].substring(0,delimitPos);formElements[i].value=postMessage[i].substring(delimitPos+1);this._formNode.appendChild(formElements[i]);}} -return formElements;},uploadFile:function(id,callback,uri,postData){var frameId='yuiIO'+id;var uploadEncoding='multipart/form-data';var io=document.getElementById(frameId);this._formNode.action=uri;this._formNode.method='POST';this._formNode.target=frameId;if(this._formNode.encoding){this._formNode.encoding=uploadEncoding;} -else{this._formNode.enctype=uploadEncoding;} -if(postData){var oElements=this.appendPostData(postData);} -this._formNode.submit();if(oElements&&oElements.length>0){for(var i=0;i<oElements.length;i++){this._formNode.removeChild(oElements[i]);}} -this.resetFormState();var uploadCallback=function() -{var obj={};obj.tId=id;obj.argument=callback.argument;try -{obj.responseText=io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;obj.responseXML=io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;} -catch(e){} -if(callback&&callback.upload){if(!callback.scope){callback.upload(obj);} -else{callback.upload.apply(callback.scope,[obj]);}} -if(YAHOO.util.Event){YAHOO.util.Event.removeListener(io,"load",uploadCallback);} -else if(window.detachEvent){io.detachEvent('onload',uploadCallback);} -else{io.removeEventListener('load',uploadCallback,false);} -setTimeout(function(){document.body.removeChild(io);},100);};if(YAHOO.util.Event){YAHOO.util.Event.addListener(io,"load",uploadCallback);} -else if(window.attachEvent){io.attachEvent('onload',uploadCallback);} -else{io.addEventListener('load',uploadCallback,false);}},abort:function(o,callback,isTimeout) -{if(this.isCallInProgress(o)){o.conn.abort();window.clearInterval(this._poll[o.tId]);delete this._poll[o.tId];if(isTimeout){delete this._timeOut[o.tId];} -this.handleTransactionResponse(o,callback,true);return true;} -else{return false;}},isCallInProgress:function(o) -{if(o.conn){return o.conn.readyState!=4&&o.conn.readyState!=0;} -else{return false;}},releaseObject:function(o) -{o.conn=null;o=null;}}; -YAHOO.register("connection", YAHOO.widget.Module, {version: "2.2.0", build: "127"}); \ No newline at end of file diff --git a/interface/web/js/yui/connection/connection.js b/interface/web/js/yui/connection/connection.js deleted file mode 100644 index 1f1fe81f79..0000000000 --- a/interface/web/js/yui/connection/connection.js +++ /dev/null @@ -1,1054 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The Connection Manager provides a simplified interface to the XMLHttpRequest - * object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the - * interactive states and server response, returning the results to a pre-defined - * callback you create. - * - * @namespace YAHOO.util - * @module connection - * @requires yahoo - */ - -/** - * The Connection Manager singleton provides methods for creating and managing - * asynchronous transactions. - * - * @class Connect - */ - -YAHOO.util.Connect = -{ - /** - * @description Array of MSFT ActiveX ids for XMLHttpRequest. - * @property _msxml_progid - * @private - * @static - * @type array - */ - _msxml_progid:[ - 'MSXML2.XMLHTTP.3.0', - 'MSXML2.XMLHTTP', - 'Microsoft.XMLHTTP' - ], - - /** - * @description Object literal of HTTP header(s) - * @property _http_header - * @private - * @static - * @type object - */ - _http_headers:{}, - - /** - * @description Determines if HTTP headers are set. - * @property _has_http_headers - * @private - * @static - * @type boolean - */ - _has_http_headers:false, - - /** - * @description Determines if a default header of - * Content-Type of 'application/x-www-form-urlencoded' - * will be added to any client HTTP headers sent for POST - * transactions. - * @property _use_default_post_header - * @private - * @static - * @type boolean - */ - _use_default_post_header:true, - - /** - * @description Determines if a default header of - * Content-Type of 'application/x-www-form-urlencoded' - * will be added to client HTTP headers sent for POST - * transactions. - * @property _default_post_header - * @private - * @static - * @type boolean - */ - _default_post_header:'application/x-www-form-urlencoded', - - /** - * @description Determines if a default header of - * 'X-Requested-With: XMLHttpRequest' - * will be added to each transaction. - * @property _use_default_xhr_header - * @private - * @static - * @type boolean - */ - _use_default_xhr_header:true, - - /** - * @description The default header value for the label - * "X-Requested-With". This is sent with each - * transaction, by default, to identify the - * request as being made by YUI Connection Manager. - * @property _default_xhr_header - * @private - * @static - * @type boolean - */ - _default_xhr_header:'XMLHttpRequest', - - /** - * @description Determines if custom, default headers - * are set for each transaction. - * @property _has_default_header - * @private - * @static - * @type boolean - */ - _has_default_headers:true, - - /** - * @description Determines if custom, default headers - * are set for each transaction. - * @property _has_default_header - * @private - * @static - * @type boolean - */ - _default_headers:{}, - - /** - * @description Property modified by setForm() to determine if the data - * should be submitted as an HTML form. - * @property _isFormSubmit - * @private - * @static - * @type boolean - */ - _isFormSubmit:false, - - /** - * @description Property modified by setForm() to determine if a file(s) - * upload is expected. - * @property _isFileUpload - * @private - * @static - * @type boolean - */ - _isFileUpload:false, - - /** - * @description Property modified by setForm() to set a reference to the HTML - * form node if the desired action is file upload. - * @property _formNode - * @private - * @static - * @type object - */ - _formNode:null, - - /** - * @description Property modified by setForm() to set the HTML form data - * for each transaction. - * @property _sFormData - * @private - * @static - * @type string - */ - _sFormData:null, - - /** - * @description Collection of polling references to the polling mechanism in handleReadyState. - * @property _poll - * @private - * @static - * @type object - */ - _poll:{}, - - /** - * @description Queue of timeout values for each transaction callback with a defined timeout value. - * @property _timeOut - * @private - * @static - * @type object - */ - _timeOut:{}, - - /** - * @description The polling frequency, in milliseconds, for HandleReadyState. - * when attempting to determine a transaction's XHR readyState. - * The default is 50 milliseconds. - * @property _polling_interval - * @private - * @static - * @type int - */ - _polling_interval:50, - - /** - * @description A transaction counter that increments the transaction id for each transaction. - * @property _transaction_id - * @private - * @static - * @type int - */ - _transaction_id:0, - - /** - * @description Member to add an ActiveX id to the existing xml_progid array. - * In the event(unlikely) a new ActiveX id is introduced, it can be added - * without internal code modifications. - * @method setProgId - * @public - * @static - * @param {string} id The ActiveX id to be added to initialize the XHR object. - * @return void - */ - setProgId:function(id) - { - this._msxml_progid.unshift(id); - }, - - /** - * @description Member to enable or disable the default POST header. - * @method setDefaultPostHeader - * @public - * @static - * @param {boolean} b Set and use default header - true or false . - * @return void - */ - setDefaultPostHeader:function(b) - { - this._use_default_post_header = b; - }, - - /** - * @description Member to enable or disable the default POST header. - * @method setDefaultXhrHeader - * @public - * @static - * @param {boolean} b Set and use default header - true or false . - * @return void - */ - setDefaultXhrHeader:function(b) - { - this._use_default_xhr_header = b; - }, - - /** - * @description Member to modify the default polling interval. - * @method setPollingInterval - * @public - * @static - * @param {int} i The polling interval in milliseconds. - * @return void - */ - setPollingInterval:function(i) - { - if(typeof i == 'number' && isFinite(i)){ - this._polling_interval = i; - } - }, - - /** - * @description Instantiates a XMLHttpRequest object and returns an object with two properties: - * the XMLHttpRequest instance and the transaction id. - * @method createXhrObject - * @private - * @static - * @param {int} transactionId Property containing the transaction id for this transaction. - * @return object - */ - createXhrObject:function(transactionId) - { - var obj,http; - try - { - // Instantiates XMLHttpRequest in non-IE browsers and assigns to http. - http = new XMLHttpRequest(); - // Object literal with http and tId properties - obj = { conn:http, tId:transactionId }; - } - catch(e) - { - for(var i=0; i<this._msxml_progid.length; ++i){ - try - { - // Instantiates XMLHttpRequest for IE and assign to http. - http = new ActiveXObject(this._msxml_progid[i]); - // Object literal with conn and tId properties - obj = { conn:http, tId:transactionId }; - break; - } - catch(e){} - } - } - finally - { - return obj; - } - }, - - /** - * @description This method is called by asyncRequest to create a - * valid connection object for the transaction. It also passes a - * transaction id and increments the transaction id counter. - * @method getConnectionObject - * @private - * @static - * @return {object} - */ - getConnectionObject:function() - { - var o; - var tId = this._transaction_id; - - try - { - o = this.createXhrObject(tId); - if(o){ - this._transaction_id++; - } - } - catch(e){} - finally - { - return o; - } - }, - - /** - * @description Method for initiating an asynchronous request via the XHR object. - * @method asyncRequest - * @public - * @static - * @param {string} method HTTP transaction method - * @param {string} uri Fully qualified path of resource - * @param {callback} callback User-defined callback function or object - * @param {string} postData POST body - * @return {object} Returns the connection object - */ - asyncRequest:function(method, uri, callback, postData) - { - var o = this.getConnectionObject(); - - if(!o){ - return null; - } - else{ - if(this._isFormSubmit){ - if(this._isFileUpload){ - this.uploadFile(o.tId, callback, uri, postData); - this.releaseObject(o); - - return; - } - - //If the specified HTTP method is GET, setForm() will return an - //encoded string that is concatenated to the uri to - //create a querystring. - if(method.toUpperCase() == 'GET'){ - if(this._sFormData.length != 0){ - // If the URI already contains a querystring, append an ampersand - // and then concatenate _sFormData to the URI. - uri += ((uri.indexOf('?') == -1)?'?':'&') + this._sFormData; - } - else{ - uri += "?" + this._sFormData; - } - } - else if(method.toUpperCase() == 'POST'){ - //If POST data exist in addition to the HTML form data, - //it will be concatenated to the form data. - postData = postData?this._sFormData + "&" + postData:this._sFormData; - } - } - - o.conn.open(method, uri, true); - - if(this._use_default_xhr_header){ - if(!this._default_headers['X-Requested-With']){ - this.initHeader('X-Requested-With', this._default_xhr_header, true); - } - } - if(this._isFormSubmit || (postData && this._use_default_post_header)){ - this.initHeader('Content-Type', this._default_post_header); - if(this._isFormSubmit){ - this.resetFormState(); - } - } - - if(this._has_default_headers || this._has_http_headers){ - this.setHeader(o); - } - - this.handleReadyState(o, callback); - o.conn.send(postData || null); - - return o; - } - }, - - /** - * @description This method serves as a timer that polls the XHR object's readyState - * property during a transaction, instead of binding a callback to the - * onreadystatechange event. Upon readyState 4, handleTransactionResponse - * will process the response, and the timer will be cleared. - * @method handleReadyState - * @private - * @static - * @param {object} o The connection object - * @param {callback} callback The user-defined callback object - * @return {void} - */ - handleReadyState:function(o, callback) - { - var oConn = this; - - if(callback && callback.timeout){ - this._timeOut[o.tId] = window.setTimeout(function(){ oConn.abort(o, callback, true); }, callback.timeout); - } - - this._poll[o.tId] = window.setInterval( - function(){ - if(o.conn && o.conn.readyState == 4){ - window.clearInterval(oConn._poll[o.tId]); - delete oConn._poll[o.tId]; - - if(callback && callback.timeout){ - delete oConn._timeOut[o.tId]; - } - - oConn.handleTransactionResponse(o, callback); - } - } - ,this._polling_interval); - }, - - /** - * @description This method attempts to interpret the server response and - * determine whether the transaction was successful, or if an error or - * exception was encountered. - * @method handleTransactionResponse - * @private - * @static - * @param {object} o The connection object - * @param {object} callback The sser-defined callback object - * @param {boolean} isAbort Determines if the transaction was aborted. - * @return {void} - */ - handleTransactionResponse:function(o, callback, isAbort) - { - // If no valid callback is provided, then do not process any callback handling. - if(!callback){ - this.releaseObject(o); - return; - } - - var httpStatus, responseObject; - - try - { - if(o.conn.status !== undefined && o.conn.status != 0){ - httpStatus = o.conn.status; - } - else{ - httpStatus = 13030; - } - } - catch(e){ - // 13030 is the custom code to indicate the condition -- in Mozilla/FF -- - // when the o object's status and statusText properties are - // unavailable, and a query attempt throws an exception. - httpStatus = 13030; - } - - if(httpStatus >= 200 && httpStatus < 300){ - responseObject = this.createResponseObject(o, callback.argument); - if(callback.success){ - if(!callback.scope){ - callback.success(responseObject); - } - else{ - // If a scope property is defined, the callback will be fired from - // the context of the object. - callback.success.apply(callback.scope, [responseObject]); - } - } - } - else{ - switch(httpStatus){ - // The following cases are wininet.dll error codes that may be encountered. - case 12002: // Server timeout - case 12029: // 12029 to 12031 correspond to dropped connections. - case 12030: - case 12031: - case 12152: // Connection closed by server. - case 13030: // See above comments for variable status. - responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort?isAbort:false)); - if(callback.failure){ - if(!callback.scope){ - callback.failure(responseObject); - } - else{ - callback.failure.apply(callback.scope, [responseObject]); - } - } - break; - default: - responseObject = this.createResponseObject(o, callback.argument); - if(callback.failure){ - if(!callback.scope){ - callback.failure(responseObject); - } - else{ - callback.failure.apply(callback.scope, [responseObject]); - } - } - } - } - - this.releaseObject(o); - responseObject = null; - }, - - /** - * @description This method evaluates the server response, creates and returns the results via - * its properties. Success and failure cases will differ in the response - * object's property values. - * @method createResponseObject - * @private - * @static - * @param {object} o The connection object - * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback - * @return {object} - */ - createResponseObject:function(o, callbackArg) - { - var obj = {}; - var headerObj = {}; - - try - { - var headerStr = o.conn.getAllResponseHeaders(); - var header = headerStr.split('\n'); - for(var i=0; i<header.length; i++){ - var delimitPos = header[i].indexOf(':'); - if(delimitPos != -1){ - headerObj[header[i].substring(0,delimitPos)] = header[i].substring(delimitPos+2); - } - } - } - catch(e){} - - obj.tId = o.tId; - obj.status = o.conn.status; - obj.statusText = o.conn.statusText; - obj.getResponseHeader = headerObj; - obj.getAllResponseHeaders = headerStr; - obj.responseText = o.conn.responseText; - obj.responseXML = o.conn.responseXML; - - if(typeof callbackArg !== undefined){ - obj.argument = callbackArg; - } - - return obj; - }, - - /** - * @description If a transaction cannot be completed due to dropped or closed connections, - * there may be not be enough information to build a full response object. - * The failure callback will be fired and this specific condition can be identified - * by a status property value of 0. - * - * If an abort was successful, the status property will report a value of -1. - * - * @method createExceptionObject - * @private - * @static - * @param {int} tId The Transaction Id - * @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback - * @param {boolean} isAbort Determines if the exception case is caused by a transaction abort - * @return {object} - */ - createExceptionObject:function(tId, callbackArg, isAbort) - { - var COMM_CODE = 0; - var COMM_ERROR = 'communication failure'; - var ABORT_CODE = -1; - var ABORT_ERROR = 'transaction aborted'; - - var obj = {}; - - obj.tId = tId; - if(isAbort){ - obj.status = ABORT_CODE; - obj.statusText = ABORT_ERROR; - } - else{ - obj.status = COMM_CODE; - obj.statusText = COMM_ERROR; - } - - if(callbackArg){ - obj.argument = callbackArg; - } - - return obj; - }, - - /** - * @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,isDefault) - { - 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, - headerObj[label] = value + "," + headerObj[label]; - } - - 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 - * @private - * @static - * @param {object} o The connection object for the transaction. - * @return {void} - */ - setHeader:function(o) - { - 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]); - } - } - } - - 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]); - } - } - 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. - * @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. - * @return {string} string of the HTML form field name and value pairs.. - */ - setForm:function(formId, isUpload, secureUri) - { - this.resetFormState(); - var oForm; - if(typeof formId == 'string'){ - // Determine if the argument is a form id or a form name. - // Note form name usage is deprecated by supported - // here for legacy reasons. - oForm = (document.getElementById(formId) || document.forms[formId]); - } - else if(typeof formId == 'object'){ - // Treat argument as an HTML form object. - oForm = formId; - } - else{ - return; - } - - // If the isUpload argument is true, setForm will call createFrame to initialize - // an iframe as the form target. - // - // The argument secureURI is also required by IE in SSL environments - // where the secureURI string is a fully qualified HTTP path, used to set the source - // of the iframe, to a stub resource in the same domain. - if(isUpload){ - - // Create iframe in preparation for file upload. - 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; - var hasSubmit = false; - - // Iterate over the form elements collection to construct the - // label-value pairs. - for (var i=0; i<oForm.elements.length; i++){ - oElement = oForm.elements[i]; - oDisabled = oForm.elements[i].disabled; - oName = oForm.elements[i].name; - oValue = oForm.elements[i].value; - - // Do not submit fields that are disabled or - // do not have a name attribute value. - if(!oDisabled && oName) - { - switch (oElement.type) - { - case 'select-one': - case 'select-multiple': - for(var j=0; j<oElement.options.length; j++){ - if(oElement.options[j].selected){ - if(window.ActiveXObject){ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].attributes['value'].specified?oElement.options[j].value:oElement.options[j].text) + '&'; - } - else{ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text) + '&'; - } - - } - } - break; - case 'radio': - case 'checkbox': - if(oElement.checked){ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; - } - break; - case 'file': - // stub case as XMLHttpRequest will only send the file path as a string. - case undefined: - // stub case for fieldset element which returns undefined. - case 'reset': - // stub case for input type reset button. - case 'button': - // stub case for input type button elements. - break; - case 'submit': - if(hasSubmit == false){ - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; - hasSubmit = true; - } - break; - default: - this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&'; - break; - } - } - } - - this._isFormSubmit = true; - this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1); - - return this._sFormData; - }, - - /** - * @description Resets HTML form properties when an HTML form or HTML form - * with file upload transaction is sent. - * @method resetFormState - * @private - * @static - * @return {void} - */ - resetFormState:function(){ - this._isFormSubmit = false; - this._isFileUpload = false; - this._formNode = null; - this._sFormData = ""; - }, - - /** - * @description Creates an iframe to be used for form file uploads. It is remove from the - * document upon completion of the upload transaction. - * @method createFrame - * @private - * @static - * @param {string} optional qualified path of iframe resource for SSL in IE. - * @return {void} - */ - createFrame:function(secureUri){ - - // IE does not allow the setting of id and name attributes as object - // properties via createElement(). A different iframe creation - // pattern is required for IE. - var frameId = 'yuiIO' + this._transaction_id; - if(window.ActiveXObject){ - var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />'); - - // IE will throw a security exception in an SSL environment if the - // iframe source is undefined. - if(typeof secureUri == 'boolean'){ - io.src = 'javascript:false'; - } - else if(typeof secureURI == 'string'){ - // Deprecated - io.src = secureUri; - } - } - else{ - var io = document.createElement('iframe'); - io.id = frameId; - io.name = frameId; - } - - io.style.position = 'absolute'; - io.style.top = '-1000px'; - io.style.left = '-1000px'; - - document.body.appendChild(io); - }, - - /** - * @description Parses the POST data and creates hidden form elements - * for each key-value, and appends them to the HTML form object. - * @method appendPostData - * @private - * @static - * @param {string} postData The HTTP POST data - * @return {array} formElements Collection of hidden fields. - */ - appendPostData:function(postData) - { - var formElements = []; - var postMessage = postData.split('&'); - for(var i=0; i < postMessage.length; i++){ - var delimitPos = postMessage[i].indexOf('='); - if(delimitPos != -1){ - formElements[i] = document.createElement('input'); - formElements[i].type = 'hidden'; - formElements[i].name = postMessage[i].substring(0,delimitPos); - formElements[i].value = postMessage[i].substring(delimitPos+1); - this._formNode.appendChild(formElements[i]); - } - } - - return formElements; - }, - - /** - * @description Uploads HTML form, including files/attachments, to the - * iframe created in createFrame. - * @method uploadFile - * @private - * @static - * @param {int} id The transaction id. - * @param {object} callback - User-defined callback object. - * @param {string} uri Fully qualified path of resource. - * @return {void} - */ - uploadFile:function(id, callback, uri, postData){ - - // Each iframe has an id prefix of "yuiIO" followed - // by the unique transaction id. - var frameId = 'yuiIO' + id; - var uploadEncoding = 'multipart/form-data'; - var io = document.getElementById(frameId); - - // Initialize the HTML form properties in case they are - // not defined in the HTML form. - this._formNode.action = uri; - this._formNode.method = 'POST'; - this._formNode.target = frameId; - - if(this._formNode.encoding){ - // IE does not respect property enctype for HTML forms. - // Instead it uses the property - "encoding". - this._formNode.encoding = uploadEncoding; - } - else{ - this._formNode.enctype = uploadEncoding; - } - - - if(postData){ - var oElements = this.appendPostData(postData); - } - - this._formNode.submit(); - - if(oElements && oElements.length > 0){ - for(var i=0; i < oElements.length; i++){ - this._formNode.removeChild(oElements[i]); - } - } - - // Reset HTML form status properties. - this.resetFormState(); - - // Create the upload callback handler that fires when the iframe - // receives the load event. Subsequently, the event handler is detached - // and the iframe removed from the document. - - var uploadCallback = function() - { - var obj = {}; - obj.tId = id; - obj.argument = callback.argument; - - try - { - obj.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null; - obj.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document; - } - catch(e){} - - if(callback && callback.upload){ - if(!callback.scope){ - callback.upload(obj); - } - else{ - callback.upload.apply(callback.scope, [obj]); - } - } - - if(YAHOO.util.Event){ - YAHOO.util.Event.removeListener(io, "load", uploadCallback); - } - else if(window.detachEvent){ - io.detachEvent('onload', uploadCallback); - } - else{ - io.removeEventListener('load', uploadCallback, false); - } - setTimeout( - function(){ - document.body.removeChild(io); - }, 100); - }; - - - // Bind the onload handler to the iframe to detect the file upload response. - if(YAHOO.util.Event){ - YAHOO.util.Event.addListener(io, "load", uploadCallback); - } - else if(window.attachEvent){ - io.attachEvent('onload', uploadCallback); - } - else{ - io.addEventListener('load', uploadCallback, false); - } - }, - - /** - * @description Method to terminate a transaction, if it has not reached readyState 4. - * @method abort - * @public - * @static - * @param {object} o The connection object returned by asyncRequest. - * @param {object} callback User-defined callback object. - * @param {string} isTimeout boolean to indicate if abort was a timeout. - * @return {boolean} - */ - abort:function(o, callback, isTimeout) - { - if(this.isCallInProgress(o)){ - o.conn.abort(); - window.clearInterval(this._poll[o.tId]); - delete this._poll[o.tId]; - if(isTimeout){ - delete this._timeOut[o.tId]; - } - - this.handleTransactionResponse(o, callback, true); - - return true; - } - else{ - return false; - } - }, - - /** - * Public method to check if the transaction is still being processed. - * - * @method isCallInProgress - * @public - * @static - * @param {object} o The connection object returned by asyncRequest - * @return {boolean} - */ - isCallInProgress:function(o) - { - // if the XHR object assigned to the transaction has not been dereferenced, - // then check its readyState status. Otherwise, return false. - if(o.conn){ - return o.conn.readyState != 4 && o.conn.readyState != 0; - } - else{ - //The XHR object has been destroyed. - return false; - } - }, - - /** - * @description Dereference the XHR instance and the connection object after the transaction is completed. - * @method releaseObject - * @private - * @static - * @param {object} o The connection object - * @return {void} - */ - releaseObject:function(o) - { - //dereference the XHR instance. - o.conn = null; - //dereference the connection object. - o = null; - } -}; -YAHOO.register("connection", YAHOO.widget.Module, {version: "2.2.0", build: "127"}); \ No newline at end of file diff --git a/interface/web/js/yui/container/README b/interface/web/js/yui/container/README deleted file mode 100644 index ba484d2632..0000000000 --- a/interface/web/js/yui/container/README +++ /dev/null @@ -1,207 +0,0 @@ -Container Release Notes - -*** version 2.2.0 *** - - Module - - Removed hardcoded file paths for image roots. Affected properties - include: - - YAHOO.widget.Module.IMG_ROOT - - YAHOO.widget.Module.IMG_ROOT_SSL - - HTML elements, created via createElement, now use lowercase. - - Panel - - To shield against CSS class collision, the following references now - have a "yui-" prefix: - - YAHOO.widget.Panel.CSS_PANEL now references CSS class "yui- - panel". - - YAHOO.widget.Panel.CSS_PANEL_CONTAINER now references CSS class - "yui-panel-container". - - Close button can now be configured via the CSS class "container- - close". - - HTML elements, created via createElement, now use lowercase. - - Dialog - - To shield against CSS class collision, the following references now - have a "yui-" prefix: - - YAHOO.widget.Dialog.CSS_DIALOG now references CSS class "yui- - dialog". - - HTML elements, created via createElement, now use lowercase. - - SimpleDialog - - Removed hardcoded file paths for SimpleDialog icons, which are now - configurable in CSS: - - YAHOO.widget.SimpleDialog.ICON_BLOCK now references CSS class - "blckicon". - - YAHOO.widget.SimpleDialog.ICON_ALARM now references CSS class - "alrticon". - - YAHOO.widget.SimpleDialog.ICON_HELP now references CSS class - "hlpicon". - - YAHOO.widget.SimpleDialog.ICON_INFO now references CSS class - "infoicon". - - YAHOO.widget.SimpleDialog.ICON_WARN now references CSS class - "warnicon". - - YAHOO.widget.SimpleDialog.ICON_TIP now references CSS class - "tipicon". - - To provide shield against CSS class collision the following - references now have a "yui-" prefix: - - YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG now references CSS - class "yui-simple-dialog"; - - Tooltip - - To shield against CSS class collision, the following references now - have a "yui-" prefix: - - YAHOO.widget.Tooltip.CSS_TOOLTIP now references CSS class "yui- - tipicon" "yui-tt"; - -*** version 0.12.2 *** - - Module - - Corrected issue where listener was not properly removed from resize - monitor element when "monitorresize" is disabled - - Panel - - Fixed issue that would sometimes prevent select lists from working - properly in Firefox - - Dialog - - Fixed error that would occur when trying to create a Dialog where - the first form element is set to "disabled" - - Modified "close" property handler for Dialog/SimpleDialog to call - "cancel" instead of "hide" - -*** version 0.12.1 *** - - All Classes - - "monitorresize" property now functions in situations where - document.domain has been modified. - - YAHOO.widget.Module.textResizeEvent now fires when the font size is - changed (except for Opera, which uses "zoom" functionality that - prevents this) - - Event listeners attached to container elements are now properly - purged on destroy using YAHOO.util.Event.purgeElement - - Panel - - Fixed issue where focus events were broken on the page when a modal - Panel was created - - Dialog - - Fixed bug where hitting "enter" on a Dialog was forcing the default - submission behavior of the form's action to execute - - Dialog no longer tries to give focus to hidden form elements. - - Replaced references in Panel with   for XHTML - compliance. - - Fixed issue that was preventing Safari from successfully using the - getData() function - -*** version 0.12 *** - - All Classes - - New documentation format implemented, and removed unnecessary - prototype null references previously used for generating - documentation - - Config - - Added 'undefined' check when reading initial properties for - .reset() - - Fixed Firefox warning on .resetProperty() - - Fixed issue preventing resetProperty() from resetting values - correctly - - Module - - Removed unused "childNodesInDom" property - - Overlay - - Converted center() to use Dom utility - - Fixed configVisible() to properly detect actual visible/hidden - status in Internet Explorer, which reports "inherit" for all elements - by default. - - Updated onDomResize to properly reapply "context" property - - Unified scroll/resize handlers so that they fire properly (when the - event has completed) as opposed to constantly (as seen in Mozilla- - based browsers) - - Panel - - Modified modality mask to show before Panel is shown (prior to any - animation) - - Modified buildWrapper to eliminate cloning of the initial markup - module, which fixes issues with select options not maintaining their - default selections in IE - - Modality mask is now z-indexed properly so that the mask z-index is - always one less than the Panel z-index - - Dialog - - Fixed Connection to get "action" attribute using getAttribute, to - allow for form fields named "action" - - Added support for "GET" by retrieving the form "method" rather than - always defaulting to "POST" - - KeyListener - - Fixed to work properly with Safari 2.0 by matching against keyCode - or charCode - -*** version 0.11.4 *** - - - Panel: Modality mask is now properly removed from DOM on Panel - destroy. - -*** version 0.11.3 *** - - - Module: Fixed SSL warning issue in IE - - Overlay: Fixed memory leak related to iframe shim in IE - - Panel: No focusable elements under the mask can now be tabbed to - - Panel: Set Panel container overflow to hidden to fix scrolling issue - in Opera 9 - -*** version 0.11.2 *** - - - All: JsLint optimization - - Overlay: Fixed SSL issues with monitorresize property - - OverlayManager: Fixed z-index incrementing issues - - Dialog: Form elements called "name" will now function properly - - Dialog: Removed unnecessary scope:this reference - -*** version 0.11.1 *** - - - Tooltip: Removed incorrect logger statement - - Dialog: Corrected logic that was causing browser lockup in IE for - SimpleDialog - - Dialog: Fixed "firstButtom" typo - -*** version 0.11.0 *** - - - toString function added to all classes for easy logging - - YAHOO.extend is now being used for inheritance on all container - classes - - Module: monitorresize feature now works on all browsers - - Module: Fixed bug with image root and isSecure - - Overlay: Fixed bugs related to IFRAME shim positioning - - Overlay: center() now works in quirks mode - - Overlay: Overlay now has a custom destroy() method that also removes - the IFRAME shim - - OverlayManager: Fixed bug in the prototype that was preventing - multiple Managers on one page - - OverlayManager: focusEvent now fires at all appropriate times - - Tooltip: context can now be specified as an array, so Tooltips can be - reused across multiple context elements - - Tooltip: preventoverlap now functions properly for large context - elements (i.e, images) - - Tooltip: fixed bugs regarding setTimeout - - Tooltip: added mousemove event to allow for more accurate Tooltip - positioning - - Panel: added dragEvent for monitoring all event handlers for drag and - drop - - Panel: modality mask is now resized on scroll - - Panel: KeyListeners are now properly destroyed when the Panel is - destroyed - - Panel: Header is now sized properly in quirks mode - - Dialog: Blinking cursor issue is fixed for Firefox - - Dialog: callback object for Connection is now public (this.callback) - - Dialog: onsuccess/onfailure properties removed (as a result of the - public callback object) - - Dialog: Dialog is now invisible by default - - Dialog: Buttons are now properly cleaned up on destroy - -*** version 0.10.0 *** - -* Initial release - diff --git a/interface/web/js/yui/container/assets/alrt16_1.gif b/interface/web/js/yui/container/assets/alrt16_1.gif deleted file mode 100644 index 443d39bbfcdb29d508f2f0d632ee15d72579005c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 971 zcmZ?wbhEHb6krfw`0mT_Vuj7`SDU^+*!lD9j92^3o-eU|xzpn17Rwi_te?$sc(LB< z`69b#bM2qaw|lwG^2HjPmpd$8tg(Kv(dxwptLMvXpD(q2xykCqTI>I}<~*C}@N9;| z|NsA=EwFpJ-~8Duhv%zpo=tOjvC8JfTC11aEne+4d$G;p=@iFjvmIXTGJmnj^5t&x zr&AqYZnu2C(C+0{%NHwcUM#bHwa@(3Zu94hZJ#f+eLBtY*<_~|n=N1MF@Ler`q^B& z=Zo#W-Ku@Q+~(ON$ETAWU+pt{x!3&pJiF%$?4B>Pd9lIz<sS2wK*NDvSZDRHT>8}k zv#+Op7)HTp2w)2V#h)yU3=F;uIv`0<o?zfu!7!Uc#$&?*$42jIG9oKn9yGMDaPTBp zY)G8k?%goKpeQ9txZ8GCLWGk7gRm%@g2jOgDo+lm%KDsY2zb=MD!`V^a`Qk-YqzwJ z$OD}Y=2lM?F|`hk#EA<U1#M>dcnCdYow$ryRwm)l6DB4Gk+g(dC56_L><QdD84Fwv zI4}zN)UDl+&@q8U?v~M>4~z^wOeRtW784ndaCP%f(TF<}v9Z6kOWey$LV&><04x5_ Al>h($ diff --git a/interface/web/js/yui/container/assets/blck16_1.gif b/interface/web/js/yui/container/assets/blck16_1.gif deleted file mode 100644 index 56689611db271fcafe42e652c6496b703f38d9e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 591 zcmZ?wbhEHb6krfwcox9$rM&!ief{ri*M2G}{3$H|$;0!--TkMg=1&okpCKVXxwt;N zxcth@c*Vv2Q&{-tkt5$~YJLa`{ycj0>&%&7XV3nrrS+MI=d+K`XHn5_?d?BJO@AsW z{Zv)`YG(E_BlD|}&_^rl?}CEgy1RcG8h!;T5EXr^r~ge|{U;yaPbsON?(SbLEx!~N zewCB^p{Ms#Qu3>h&(GwzuioCjFJJy*Wc1VC{%e2#Pd2unyu9D6tbX$I|8#Tv8W#4` z*!ZWP-%n1?Zxt0Ei;A9yhW*sn|0yl~B{cM_i_2#lo8P&)@4~{r#K!(ijJwXn^eM>g z=bk;^jExxv8BqMm!pOi7z@P(i7bs2`*w-`!G&Q%hw)(O7cKNdSwFUV3dV3pk+G$z# zwM?AM$uQsA)PL55N#5K{&1U{<W-;>ctY~3a<L}ty%gDB}No1=tyTXoLO+v0~r1acn z_ztrLIBc~Q=T~C(X>#+}>aQ#-+$7*~BS71qnO#&}r^Q57t%-%1S=z?9MTNskuE|eA zUvtWbrb&uSd}>SPv=lTvVCIq34bX6?IN{XT%~f}2LB<KsNo+ndOaz>`yc8I$0kO%o As{jB1 diff --git a/interface/web/js/yui/container/assets/close12_1.gif b/interface/web/js/yui/container/assets/close12_1.gif deleted file mode 100644 index e2f67d72efc158da4e069822cbe338915761e396..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 85 zcmZ?wbhEHb<YC}pn8?5ooUrHA&F?kc7v6mRqxh4B0R(hF1W2BNNo`8M`DtDwmkh>z lf$Gy9znh?Y?^x%Bps9Cfw!UsJn!aoAS>7kV)`>G%0|4uCA&me4 diff --git a/interface/web/js/yui/container/assets/container.css b/interface/web/js/yui/container/assets/container.css deleted file mode 100644 index edac1dd135..0000000000 --- a/interface/web/js/yui/container/assets/container.css +++ /dev/null @@ -1,230 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -.yui-overlay { - position:absolute; - display:block; -} - -.yui-tt { - visibility:hidden; - position:absolute; - color:#333; - background-color:#FDFFB4; - font-family:arial,helvetica,verdana,sans-serif; - padding:2px; - border:1px solid #FCC90D; - font:100% sans-serif; - width:auto; -} - -* html body.masked select { - visibility:hidden; -} - -* html div.yui-panel-container select { - visibility:inherit; -} - -* html div.drag select { - visibility:hidden; -} - -* html div.hide-select select { - visibility:hidden; -} - -.mask { - z-index:0; - display:none; - position:absolute; - top:0; - left:0; - -moz-opacity: 0.5; - opacity:.50; - filter: alpha(opacity=50); - background-color:#CCC; -} - -.hide-scrollbars * { - overflow:hidden; -} - -.hide-scrollbars textarea, .hide-scrollbars select { - overflow:hidden; - display:none; -} - -.show-scrollbars textarea, .show-scrollbars select { - overflow:visible; -} - -.yui-panel-container { - position:absolute; - background-color:transparent; - z-index:6; - visibility:hidden; - overflow:visible; - width:auto; -} - -.yui-panel-container.focused { -} - - -.yui-panel-container.matte { - padding:3px; - background-color:#FFF; -} - -.yui-panel-container.matte .underlay { - display:none; -} - -.yui-panel-container.shadow { - padding:0px; - background-color:transparent; -} - -.yui-panel-container.shadow .underlay { - visibility:inherit; - position:absolute; - background-color:#CCC; - top:3px;left:3px; - z-index:0; - width:100%; - height:100%; - -moz-opacity: 0.7; - opacity:.70; - filter:alpha(opacity=70); - zoom:1; -} - -.yui-panel { - visibility:hidden; - border-collapse:separate; - position:relative; - left:0px;top:0px; - font:1em Arial; - background-color:#FFF; - border:1px solid #000; - z-index:1; - overflow:hidden; -} - -.yui-panel .hd { - background-color:#3d77cb; - color:#FFF; - font-size:100%; - line-height:100%; - border:1px solid #FFF; - border-bottom:1px solid #000; - font-weight:bold; - overflow:hidden; - padding:4px; -} - -.yui-panel .bd { - overflow:hidden; - padding:4px; -} - -.yui-panel .bd p { - margin:0 0 1em; -} - -.yui-panel .container-close { - position:absolute; - top:5px; - right:4px; - z-index:6; - height:12px; - width:12px; - margin:0px; - padding:0px; - background:url(close12_1.gif) no-repeat; - cursor:pointer; - visibility:inherit; -} - -.yui-panel .ft { - padding:4px; - overflow:hidden; -} - -.yui-simple-dialog .bd .yui-icon { - background-repeat:no-repeat; - width:16px; - height:16px; - margin-right:10px; - float:left; -} - -.yui-simple-dialog .bd span.blckicon { - background: url("blck16_1.gif") no-repeat; -} - -.yui-simple-dialog .bd span.alrticon { - background: url("alrt16_1.gif") no-repeat; -} - -.yui-simple-dialog .bd span.hlpicon { - background: url("hlp16_1.gif") no-repeat; -} - -.yui-simple-dialog .bd span.infoicon { - background: url("info16_1.gif") no-repeat; -} - -.yui-simple-dialog .bd span.warnicon { - background: url("warn16_1.gif") no-repeat; -} - -.yui-simple-dialog .bd span.tipicon { - background: url("tip16_1.gif") no-repeat; -} - -.yui-dialog .ft, .simple-dialog .ft { - padding-bottom:5px; - padding-right:5px; - text-align:right; -} - -.yui-dialog form, .yui-simple-dialog form { - margin:0; -} - -.button-group button { - font:100 76% verdana; - text-decoration:none; - background-color: #E4E4E4; - color: #333; - cursor: hand; - vertical-align: middle; - border: 2px solid #797979; - border-top-color:#FFF; - border-left-color:#FFF; - margin:2px; - padding:2px; -} - -.button-group button.default { - font-weight:bold; -} - -.button-group button:hover, .button-group button.hover { - border:2px solid #90A029; - background-color:#EBF09E; - border-top-color:#FFF; - border-left-color:#FFF; -} - -.button-group button:active { - border:2px solid #E4E4E4; - background-color:#BBB; - border-top-color:#333; - border-left-color:#333; -} \ No newline at end of file diff --git a/interface/web/js/yui/container/assets/hlp16_1.gif b/interface/web/js/yui/container/assets/hlp16_1.gif deleted file mode 100644 index 4645c8fdfa693126bd5fe969737dc1ccac1e62e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 928 zcmZ?wbhEHb6krfw_-?>(y^ZbFe)X>pdVXIIcs^hJNiYA4HF8fnd0uW*csg0|*(}jl z`_x|_)OfyJ`t<?L*9SD7bn(5~s{Cq?`tv2yulA@uZs&QmQ}y{m$(P%dU+q<UwOj4Q zO4+AVg<l`ke7#@&`Er@(OC+Do5qq&j>cvW#7eMYJ$(NgzUhYtNHbdmqF11(tG+wNe ze>Pv@+j-kFHC!JrMKFwl(GZ|x2q^w!VPs%1V9){C3Ca@;9JLII94(3qS`Uipv+%@l zJbu8yCTA2-aZun`HzT7AOT>bMhd6me#LFrcC_U-sP!kYHkZ^G7YSj;u&^QoqpnHNC zZ;t}w0;My&@@fnRB0st^3#zvLlHqv7#J$v;RfvPpREvjIBSs+hlwxDp>V#Uch7Y1| R8o5%}?uytg>gK>;4FF6EfMoyx diff --git a/interface/web/js/yui/container/assets/info16_1.gif b/interface/web/js/yui/container/assets/info16_1.gif deleted file mode 100644 index 22f697a9917f3bae423726ef6c541e618e7a0221..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 601 zcmZ?wbhEHb6krfwc*ekR^2`$>r}fqW+ji}_yJYokZHxH}m!7X}I}?_)$H;t^iq<51 z=Q+}%ZYnzMy4K6|tXJyWt`_1CmRGK`4ch7!yH!cOTSh)#$8w3X<^)ZX8Jjj7)YD4R zv0UsNwN+Im+c|Qxyi$XTZl|efbxhsqsOlp&_LH02_MbZYysT(KOUEHeshsMn1>ULK zcJ8{NpjI!y<89(Jm7mMa#AU9wZo~BX*R*u%c{v<Zv?d!nEYvWby=mh?5y4Oyac_H< zd5Ws-B0|yIcU+QJso-I=QP${_RVuD1otDsg(Is-Rnts1y<nGwU^9DL;T4oDd+7Aix z`EK8KUPeAwLAAQRew}C7_QvMz<{qm9^N;P=dCf2Dh@Q<NE8k7tX$OtWXR7K<R?(a& zCYmH6nWk<yT}w4Y$9#^yalg93RD0Kjr_aAuH=L+%xAy=4{|uA?#h)yU3=G)}Iv`^} zal*j9ts%RqxuvyLGmR@wf?KUEo0&6NR+y3BCpJa5h1py_jFBaaB{S1fA-p+8Bw}fL zR{GM+MB^r33opi{!5kc$GKGS&Z9_dbv74~(PgTlxj@q?u!+!DjY*9C+P3t%Ax6igy zzIEwtCZC63wyI9_?F|Alk{OQD*&zlhk*uuhSqvEr7vE?otvDtq$-wx7JEQTqf`V2I pg9*a{1_uqN5`n5mj6PEYGNc3w4>=rOEb1M1WP>7`>p}+xYXGoF!2kdN diff --git a/interface/web/js/yui/container/assets/tip16_1.gif b/interface/web/js/yui/container/assets/tip16_1.gif deleted file mode 100644 index 8f0be2b8d1fc2151459ddf48c8676f296489a32e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 552 zcmZ?wbhEHb6krfwcoxdAqKt250pG88J6`NoJHNgC#7vPV=gNM)KlSdk<?bnx=Qesg z-75d_vh&vm!N=BSUt6d2>6-h;E3R*j89zJi_ws<w^&?$(7qGlPXR~Fh*V&CBw-5MU z+GzOsruU28s!ujay*^_2>8jg}jVf1H%U_x=y1GH>{3efE$9ulq^}jNY_s7%7Yg^Q> zZ&AOxukg+`jfa=Ee7NLzbDQSVEiw;Q@LgK3a&HmayE9fFE_$AvDtPZi>Gka<>-s%k z9n`(GMepbgxjmD_e!N<=V~Wp)c9DO7zkGWX`t@GmmMQi>->ki{LVRtP{*x0vzu)HE z*rxgVklvf)rq8x3zBy*}WTVvm#T@rfmVUgN{`~e~hJgl(KUo+V7(y9zKn?-L2?Kj; zLugZTOKTgOrGd7zMO(9!ryG-*zam#3o3IlTuYjqwl1`hJJ(HKFjJS^<XPY;Vy0eP{ zhX}V_n=yyJAUnG}bAV%8kgkw#a4@qWD_@@~zwAjlR@c5JN%xaR9@m@HGy+Y;B<_WZ kGQMQAdKU8T{WBH@8)XKEXL>5O<_s*)niv=?xL6ph0rg?UhX4Qo diff --git a/interface/web/js/yui/container/assets/warn16_1.gif b/interface/web/js/yui/container/assets/warn16_1.gif deleted file mode 100644 index d679df5aae924ed5a4b16a921c3c4578cd6ea970..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 580 zcmZ?wbhEHb6krfwc*el+xK`w8Ci9Cj{%bZ0KW-lQw59R=42!=X9>1HQ`TNnaZ`+e^ zxiCGg7yWvC!5vSgkFyM)RZCt{XMB>%`sdC4t0s)k%aq@3nExPx>EmqU4>OHk)k?l; zmwHep@UB<k+o{<X<QZO82|uY9|FEa?NgDHYE5>KJ>`yaTpH~^(FBLo^!f?M>@KLq! zyFQK2XP13hAOB*u@2iQ4XT=z<nK6CZ-1y^Q$%kp$A7>l<xN+d;tsVCQnO?R?yy<uP z{p$YLO%bo^#NKo$JxbvCu(t75DEF&Qr*{jIem%Ny)1K*yF5}lVuCIHXUiUhkm0-9Z z%Jg}$^_@_TNAb)rDnz~=>AmgF^t_P!+l2!krs_OSVY}-K<O)AZ68bpT^y|?DFKU#3 z9IJnn<M^Ob=xwL;|Ns9PXa*F2vM@3*Br)iKYyiax1N*{;q^9PU*0v;8Mn=~578XW{ zP)3&CCTsgxE+((3ysEZ|?9yt{y)il_iHQkJqV2}P9(t=162cr?g(D=**cNV8h_q>O z3Gm&T$hkGa!JyeyIZAdbXW(hOppYg{Dbv$z99yjz{Nj?#h4@c%Sjh2c$H!|Ji8%`> xGW^tE_3^J0v%kfc?(0rR4(Mwo&Dn84<+vz2ch7_c1uBQyRW;c{tVB2%tO4c8+`#|< diff --git a/interface/web/js/yui/container/container-debug.js b/interface/web/js/yui/container/container-debug.js deleted file mode 100644 index ce59595090..0000000000 --- a/interface/web/js/yui/container/container-debug.js +++ /dev/null @@ -1,4752 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** -* 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); - } - if (!owner) { 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<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - - if (queueItem) { - var queueItemKey = queueItem[0]; - var queueItemValue = queueItem[1]; - - if (queueItemKey.toLowerCase() == key) { - // found a dupe... push to end of queue, null current item, and break - eventQueue[i] = null; - eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]); - foundDuplicate = true; - break; - } - } - } - - if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue - eventQueue.push([key, value]); - } - } - - if (property.supercedes) { - for (var s=0;s<property.supercedes.length;s++) { - var supercedesCheck = property.supercedes[s]; - - for (var q=0;q<eventQueue.length;q++) { - var queueItemCheck = eventQueue[q]; - - if (queueItemCheck) { - var queueItemCheckKey = queueItemCheck[0]; - var queueItemCheckValue = queueItemCheck[1]; - - if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) { - eventQueue.push([queueItemCheckKey, queueItemCheckValue]); - eventQueue[q] = null; - break; - } - } - } - } - } - YAHOO.log("Config event queue: " + this.outputEventQueue(), "info"); - - return true; - } else { - return false; - } - }; - - /** - * Fires the event for a property using the property's current value. - * @method refireEvent - * @param {String} key The name of the property - */ - this.refireEvent = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') { - if (this.queueInProgress) { - this.queueProperty(key); - } else { - fireEvent(key, property.value); - } - } - }; - - /** - * Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their associated events to execute. - * @method applyConfig - * @param {Object} userConfig The configuration Object literal - * @param {Boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. - */ - this.applyConfig = function(userConfig, init) { - if (init) { - initialConfig = userConfig; - } - for (var prop in userConfig) { - this.queueProperty(prop, userConfig[prop]); - } - }; - - /** - * Refires the events for all configuration properties using their current values. - * @method refresh - */ - this.refresh = function() { - for (var prop in config) { - this.refireEvent(prop); - } - }; - - /** - * Fires the normalized list of queued property change events - * @method fireQueue - */ - this.fireQueue = function() { - this.queueInProgress = true; - for (var i=0;i<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - if (queueItem) { - var key = queueItem[0]; - var value = queueItem[1]; - - var property = config[key]; - property.value = value; - - fireEvent(key,value); - } - } - - this.queueInProgress = false; - eventQueue = []; - }; - - /** - * Subscribes an external handler to the change event for any given property. - * @method subscribeToConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @param {Boolean} override Optional. If true, will override "this" within the handler to map to the scope Object passed into the method. - * @return {Boolean} True, if the subscription was successful, otherwise false. - */ - this.subscribeToConfigEvent = function(key, handler, obj, override) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) { - property.event.subscribe(handler, obj, override); - } - return true; - } else { - return false; - } - }; - - /** - * Unsubscribes an external handler from the change event for any given property. - * @method unsubscribeFromConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @return {Boolean} True, if the unsubscription was successful, otherwise false. - */ - this.unsubscribeFromConfigEvent = function(key, handler, obj) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.event.unsubscribe(handler, obj); - } else { - return false; - } - }; - - /** - * Returns a string representation of the Config object - * @method toString - * @return {String} The Config object in string format. - */ - this.toString = function() { - var output = "Config"; - if (this.owner) { - output += " [" + this.owner.toString() + "]"; - } - return output; - }; - - /** - * Returns a string representation of the Config object's current CustomEvent queue - * @method outputEventQueue - * @return {String} The string list of CustomEvents currently queued for execution - */ - this.outputEventQueue = function() { - var output = ""; - for (var q=0;q<eventQueue.length;q++) { - var queueItem = eventQueue[q]; - if (queueItem) { - output += queueItem[0] + "=" + queueItem[1] + ", "; - } - } - return output; - }; -}; - -/** -* Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent -* @method YAHOO.util.Config.alreadySubscribed -* @static -* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions -* @param {Function} fn The function to look for in the subscribers list -* @param {Object} obj The execution scope Object for the subscription -* @return {Boolean} true, if the function/Object pair is already subscribed to the CustomEvent passed in -*/ -YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) { - for (var e=0;e<evt.subscribers.length;e++) { - var subsc = evt.subscribers[e]; - if (subsc && subsc.obj == obj && subsc.fn == fn) { - return true; - } - } - return false; -}; - -/** -* The Container family of components is designed to enable developers to create different kinds of content-containing modules on the web. Module and Overlay are the most basic containers, and they can be used directly or extended to build custom containers. Also part of the Container family are four UI controls that extend Module and Overlay: Tooltip, Panel, Dialog, and SimpleDialog. -* @module container -* @title Container -* @requires yahoo,dom,event,dragdrop,animation -*/ - -/** -* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package. -* @namespace YAHOO.widget -* @class Module -* @constructor -* @param {String} el The element ID representing the Module <em>OR</em> -* @param {HTMLElement} el The element representing the Module -* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. -*/ -YAHOO.widget.Module = function(el, userConfig) { - if (el) { - this.init(el, userConfig); - } else { - YAHOO.log("No element or element ID specified for Module instantiation", "error"); - } -}; - -/** -* Constant representing the prefix path to use for non-secure images -* @property YAHOO.widget.Module.IMG_ROOT -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.IMG_ROOT = null; - -/** -* Constant representing the prefix path to use for securely served images -* @property YAHOO.widget.Module.IMG_ROOT_SSL -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.IMG_ROOT_SSL = null; - -/** -* Constant for the default CSS class name that represents a Module -* @property YAHOO.widget.Module.CSS_MODULE -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_MODULE = "module"; - -/** -* Constant representing the module header -* @property YAHOO.widget.Module.CSS_HEADER -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_HEADER = "hd"; - -/** -* Constant representing the module body -* @property YAHOO.widget.Module.CSS_BODY -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_BODY = "bd"; - -/** -* Constant representing the module footer -* @property YAHOO.widget.Module.CSS_FOOTER -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_FOOTER = "ft"; - -/** -* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size -* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;"; - -/** -* Singleton CustomEvent fired when the font size is changed in the browser. -* Opera's "zoom" functionality currently does not support text size detection. -* @event YAHOO.widget.Module.textResizeEvent -*/ -YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize"); - -YAHOO.widget.Module.prototype = { - /** - * The class's constructor function - * @property contructor - * @type Function - */ - constructor : YAHOO.widget.Module, - - /** - * The main module element that contains the header, body, and footer - * @property element - * @type HTMLElement - */ - element : null, - - /** - * The header element, denoted with CSS class "hd" - * @property header - * @type HTMLElement - */ - header : null, - - /** - * The body element, denoted with CSS class "bd" - * @property body - * @type HTMLElement - */ - body : null, - - /** - * The footer element, denoted with CSS class "ft" - * @property footer - * @type HTMLElement - */ - footer : null, - - /** - * The id of the element - * @property id - * @type String - */ - id : null, - - /** - * The String representing the image root - * @property imageRoot - * @type String - */ - imageRoot : YAHOO.widget.Module.IMG_ROOT, - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - * @method initEvents - */ - initEvents : function() { - - /** - * CustomEvent fired prior to class initalization. - * @event beforeInitEvent - * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - */ - this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); - - /** - * CustomEvent fired after class initalization. - * @event initEvent - * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - */ - this.initEvent = new YAHOO.util.CustomEvent("init"); - - /** - * CustomEvent fired when the Module is appended to the DOM - * @event appendEvent - */ - this.appendEvent = new YAHOO.util.CustomEvent("append"); - - /** - * CustomEvent fired before the Module is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - - /** - * CustomEvent fired after the Module is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); - - /** - * CustomEvent fired when the header content of the Module is modified - * @event changeHeaderEvent - * @param {String/HTMLElement} content String/element representing the new header content - */ - this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); - - /** - * CustomEvent fired when the body content of the Module is modified - * @event changeBodyEvent - * @param {String/HTMLElement} content String/element representing the new body content - */ - this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); - - /** - * CustomEvent fired when the footer content of the Module is modified - * @event changeFooterEvent - * @param {String/HTMLElement} content String/element representing the new footer content - */ - this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); - - /** - * CustomEvent fired when the content of the Module is modified - * @event changeContentEvent - */ - this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); - - /** - * CustomEvent fired when the Module is destroyed - * @event destroyEvent - */ - this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); - - /** - * CustomEvent fired before the Module is shown - * @event beforeShowEvent - */ - this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); - - /** - * CustomEvent fired after the Module is shown - * @event showEvent - */ - this.showEvent = new YAHOO.util.CustomEvent("show"); - - /** - * CustomEvent fired before the Module is hidden - * @event beforeHideEvent - */ - this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); - - /** - * CustomEvent fired after the Module is hidden - * @event hideEvent - */ - this.hideEvent = new YAHOO.util.CustomEvent("hide"); - }, - - /** - * String representing the current user-agent platform - * @property platform - * @type String - */ - platform : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) { - return "windows"; - } else if (ua.indexOf("macintosh") != -1) { - return "mac"; - } else { - return false; - } - }(), - - /** - * String representing the current user-agent browser - * @property browser - * @type String - */ - browser : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) - return 'opera'; - } else if (ua.indexOf('msie 7')!=-1) { // IE7 - return 'ie7'; - } else if (ua.indexOf('msie') !=-1) { // IE - return 'ie'; - } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") - return 'safari'; - } else if (ua.indexOf('gecko') != -1) { // Gecko - return 'gecko'; - } else { - return false; - } - }(), - - /** - * Boolean representing whether or not the current browsing context is secure (https) - * @property isSecure - * @type Boolean - */ - isSecure : function() { - if (window.location.href.toLowerCase().indexOf("https") === 0) { - return true; - } else { - return false; - } - }(), - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - */ - initDefaultConfig : function() { - // Add properties // - - /** - * Specifies whether the Module is visible on the page. - * @config visible - * @type Boolean - * @default true - */ - this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } ); - - /** - * Object or array of objects representing the ContainerEffect classes that are active for animating the container. - * @config effect - * @type Object - * @default null - */ - this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } ); - - /** - * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document - * @config monitorresize - * @type Boolean - * @default true - */ - this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } ); - }, - - /** - * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. - * @method init - * @param {String} el The element ID representing the Module <em>OR</em> - * @param {HTMLElement} el The element representing the Module - * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. - */ - init : function(el, userConfig) { - - this.initEvents(); - - this.beforeInitEvent.fire(YAHOO.widget.Module); - - /** - * The Module's Config object used for monitoring configuration properties. - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - if (this.isSecure) { - this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL; - } - - if (typeof el == "string") { - var elId = el; - - el = document.getElementById(el); - if (! el) { - el = document.createElement("div"); - el.id = elId; - } - } - - this.element = el; - - if (el.id) { - this.id = el.id; - } - - var childNodes = this.element.childNodes; - - if (childNodes) { - for (var i=0;i<childNodes.length;i++) { - var child = childNodes[i]; - switch (child.className) { - case YAHOO.widget.Module.CSS_HEADER: - this.header = child; - break; - case YAHOO.widget.Module.CSS_BODY: - this.body = child; - break; - case YAHOO.widget.Module.CSS_FOOTER: - this.footer = child; - break; - } - } - } - - this.initDefaultConfig(); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - // Subscribe to the fireQueue() method of Config so that any queued configuration changes are - // excecuted upon render of the Module - if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) { - this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true); - } - - this.initEvent.fire(YAHOO.widget.Module); - }, - - /** - * Initialized an empty IFRAME that is placed out of the visible area that can be used to detect text resize. - * @method initResizeMonitor - */ - initResizeMonitor : function() { - - if(this.browser != "opera") { - - var resizeMonitor = document.getElementById("_yuiResizeMonitor"); - - if (! resizeMonitor) { - - resizeMonitor = document.createElement("iframe"); - - var bIE = (this.browser.indexOf("ie") === 0); - - if(this.isSecure && YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL && bIE) { - resizeMonitor.src = YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL; - } - - resizeMonitor.id = "_yuiResizeMonitor"; - resizeMonitor.style.visibility = "hidden"; - - document.body.appendChild(resizeMonitor); - - resizeMonitor.style.width = "10em"; - resizeMonitor.style.height = "10em"; - resizeMonitor.style.position = "absolute"; - - var nLeft = -1 * resizeMonitor.offsetWidth; - var nTop = -1 * resizeMonitor.offsetHeight; - - resizeMonitor.style.top = nTop + "px"; - resizeMonitor.style.left = nLeft + "px"; - resizeMonitor.style.borderStyle = "none"; - resizeMonitor.style.borderWidth = "0"; - YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0"); - - resizeMonitor.style.visibility = "visible"; - - if(!bIE) { - - var doc = resizeMonitor.contentWindow.document; - - doc.open(); - doc.close(); - - } - } - - var fireTextResize = function() { - YAHOO.widget.Module.textResizeEvent.fire(); - }; - - if(resizeMonitor && resizeMonitor.contentWindow) { - this.resizeMonitor = resizeMonitor; - - YAHOO.widget.Module.textResizeEvent.subscribe(this.onDomResize, this, true); - - if (! YAHOO.widget.Module.textResizeInitialized) { - if (! YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", fireTextResize)) { - // This will fail in IE if document.domain has changed, so we must change the listener to - // use the resizeMonitor element instead - YAHOO.util.Event.addListener(this.resizeMonitor, "resize", fireTextResize); - } - YAHOO.widget.Module.textResizeInitialized = true; - } - } - - } - - }, - - /** - * Event handler fired when the resize monitor element is resized. - * @method onDomResize - * @param {DOMEvent} e The DOM resize event - * @param {Object} obj The scope object passed to the handler - */ - onDomResize : function(e, obj) { - - var nLeft = -1 * this.resizeMonitor.offsetWidth, - nTop = -1 * this.resizeMonitor.offsetHeight; - - this.resizeMonitor.style.top = nTop + "px"; - this.resizeMonitor.style.left = nLeft + "px"; - - }, - - /** - * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created. - * @method setHeader - * @param {String} headerContent The HTML used to set the header <em>OR</em> - * @param {HTMLElement} headerContent The HTMLElement to append to the header - */ - setHeader : function(headerContent) { - if (! this.header) { - this.header = document.createElement("div"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - if (typeof headerContent == "string") { - this.header.innerHTML = headerContent; - } else { - this.header.innerHTML = ""; - this.header.appendChild(headerContent); - } - - this.changeHeaderEvent.fire(headerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the header. If no header is present, one will be automatically created. - * @method appendToHeader - * @param {HTMLElement} element The element to append to the header - */ - appendToHeader : function(element) { - if (! this.header) { - this.header = document.createElement("div"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - this.header.appendChild(element); - this.changeHeaderEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created. - * @method setBody - * @param {String} bodyContent The HTML used to set the body <em>OR</em> - * @param {HTMLElement} bodyContent The HTMLElement to append to the body - */ - setBody : function(bodyContent) { - if (! this.body) { - this.body = document.createElement("div"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - if (typeof bodyContent == "string") - { - this.body.innerHTML = bodyContent; - } else { - this.body.innerHTML = ""; - this.body.appendChild(bodyContent); - } - - this.changeBodyEvent.fire(bodyContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the body. If no body is present, one will be automatically created. - * @method appendToBody - * @param {HTMLElement} element The element to append to the body - */ - appendToBody : function(element) { - if (! this.body) { - this.body = document.createElement("div"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - this.body.appendChild(element); - this.changeBodyEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created. - * @method setFooter - * @param {String} footerContent The HTML used to set the footer <em>OR</em> - * @param {HTMLElement} footerContent The HTMLElement to append to the footer - */ - setFooter : function(footerContent) { - if (! this.footer) { - this.footer = document.createElement("div"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - if (typeof footerContent == "string") { - this.footer.innerHTML = footerContent; - } else { - this.footer.innerHTML = ""; - this.footer.appendChild(footerContent); - } - - this.changeFooterEvent.fire(footerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the footer. If no footer is present, one will be automatically created. - * @method appendToFooter - * @param {HTMLElement} element The element to append to the footer - */ - appendToFooter : function(element) { - if (! this.footer) { - this.footer = document.createElement("div"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - this.footer.appendChild(element); - this.changeFooterEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. - * @method render - * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em> - * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering - * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container. - * @return {Boolean} Success or failure of the render - */ - render : function(appendToNode, moduleElement) { - this.beforeRenderEvent.fire(); - - if (! moduleElement) { - moduleElement = this.element; - } - - var me = this; - var appendTo = function(element) { - if (typeof element == "string") { - element = document.getElementById(element); - } - - if (element) { - element.appendChild(me.element); - me.appendEvent.fire(); - } - }; - - if (appendToNode) { - appendTo(appendToNode); - } else { // No node was passed in. If the element is not pre-marked up, this fails - if (! YAHOO.util.Dom.inDocument(this.element)) { - YAHOO.log("Render failed. Must specify appendTo node if Module isn't already in the DOM.", "error"); - return false; - } - } - - // Need to get everything into the DOM if it isn't already - - if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) { - // There is a header, but it's not in the DOM yet... need to add it - var firstChild = moduleElement.firstChild; - if (firstChild) { // Insert before first child if exists - moduleElement.insertBefore(this.header, firstChild); - } else { // Append to empty body because there are no children - moduleElement.appendChild(this.header); - } - } - - if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) { - // There is a body, but it's not in the DOM yet... need to add it - if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM - moduleElement.insertBefore(this.body, this.footer); - } else { // Append to element because there is no footer - moduleElement.appendChild(this.body); - } - } - - if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) { - // There is a footer, but it's not in the DOM yet... need to add it - moduleElement.appendChild(this.footer); - } - - this.renderEvent.fire(); - return true; - }, - - /** - * Removes the Module element from the DOM and sets all child elements to null. - * @method destroy - */ - destroy : function() { - var parent; - - if (this.element) { - YAHOO.util.Event.purgeElement(this.element, true); - parent = this.element.parentNode; - } - if (parent) { - parent.removeChild(this.element); - } - - this.element = null; - this.header = null; - this.body = null; - this.footer = null; - - for (var e in this) { - if (e instanceof YAHOO.util.CustomEvent) { - e.unsubscribeAll(); - } - } - - YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this); - - this.destroyEvent.fire(); - }, - - /** - * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after. - * @method show - */ - show : function() { - this.cfg.setProperty("visible", true); - }, - - /** - * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after. - * @method hide - */ - hide : function() { - this.cfg.setProperty("visible", false); - }, - - // BUILT-IN EVENT HANDLERS FOR MODULE // - - /** - * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none". - * This method is responsible for firing showEvent and hideEvent. - * @param {String} type The CustomEvent type (usually the property name) - * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. - * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. - * @method configVisible - */ - configVisible : function(type, args, obj) { - var visible = args[0]; - if (visible) { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "block"); - this.showEvent.fire(); - } else { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "none"); - this.hideEvent.fire(); - } - }, - - /** - * Default event handler for the "monitorresize" configuration property - * @param {String} type The CustomEvent type (usually the property name) - * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. - * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. - * @method configMonitorResize - */ - configMonitorResize : function(type, args, obj) { - var monitor = args[0]; - if (monitor) { - this.initResizeMonitor(); - } else { - YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true); - this.resizeMonitor = null; - } - } -}; - -/** -* Returns a String representation of the Object. -* @method toString -* @return {String} The string representation of the Module -*/ -YAHOO.widget.Module.prototype.toString = function() { - return "Module " + this.id; -}; - -/** -* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements. -* @namespace YAHOO.widget -* @class Overlay -* @extends YAHOO.widget.Module -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Overlay = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module); - -/** -* The URL that will be placed in the iframe -* @property YAHOO.widget.Overlay.IFRAME_SRC -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;"; - -/** -* Constant representing the top left corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.TOP_LEFT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.TOP_LEFT = "tl"; - -/** -* Constant representing the top right corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.TOP_RIGHT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.TOP_RIGHT = "tr"; - -/** -* Constant representing the top bottom left corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.BOTTOM_LEFT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.BOTTOM_LEFT = "bl"; - -/** -* Constant representing the bottom right corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.BOTTOM_RIGHT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.BOTTOM_RIGHT = "br"; - -/** -* Constant representing the default CSS class used for an Overlay -* @property YAHOO.widget.Overlay.CSS_OVERLAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.CSS_OVERLAY = "yui-overlay"; - -/** -* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Overlay.prototype.init = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Overlay); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - if (this.platform == "mac" && this.browser == "gecko") { - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) { - this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) { - this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true); - } - } - - this.initEvent.fire(YAHOO.widget.Overlay); - -}; - -/** -* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class. -* @method initEvents -*/ -YAHOO.widget.Overlay.prototype.initEvents = function() { - YAHOO.widget.Overlay.superclass.initEvents.call(this); - - /** - * CustomEvent fired before the Overlay is moved. - * @event beforeMoveEvent - * @param {Number} x x coordinate - * @param {Number} y y coordinate - */ - this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this); - - /** - * CustomEvent fired after the Overlay is moved. - * @event moveEvent - * @param {Number} x x coordinate - * @param {Number} y y coordinate - */ - this.moveEvent = new YAHOO.util.CustomEvent("move", this); -}; - -/** -* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Overlay.prototype.initDefaultConfig = function() { - YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this); - - // Add overlay config properties // - - /** - * The absolute x-coordinate position of the Overlay - * @config x - * @type Number - * @default null - */ - this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * The absolute y-coordinate position of the Overlay - * @config y - * @type Number - * @default null - */ - this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * An array with the absolute x and y positions of the Overlay - * @config xy - * @type Number[] - * @default null - */ - this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner. - * @config context - * @type Array - * @default null - */ - this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * True if the Overlay should be anchored to the center of the viewport. - * @config fixedcenter - * @type Boolean - * @default false - */ - this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } ); - - /** - * CSS width of the Overlay. - * @config width - * @type String - * @default null - */ - this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * CSS height of the Overlay. - * @config height - * @type String - * @default null - */ - this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * CSS z-index of the Overlay. - * @config zIndex - * @type Number - * @default null - */ - this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } ); - - /** - * True if the Overlay should be prevented from being positioned out of the viewport. - * @config constraintoviewport - * @type Boolean - * @default false - */ - this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } ); - - /** - * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below). - * @config iframe - * @type Boolean - * @default true for IE6 and below, false for all others - */ - this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } ); -}; - -/** -* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]); -* @method moveTo -* @param {Number} x The Overlay's new x position -* @param {Number} y The Overlay's new y position -*/ -YAHOO.widget.Overlay.prototype.moveTo = function(x, y) { - this.cfg.setProperty("xy",[x,y]); -}; - -/** -* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -* @method hideMacGeckoScrollbars -*/ -YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "show-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "hide-scrollbars"); -}; - -/** -* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -* @method showMacGeckoScrollbars -*/ -YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "show-scrollbars"); -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent. -* @method configVisible -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) { - var visible = args[0]; - var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility"); - - if (currentVis == "inherit") { - var e = this.element.parentNode; - while (e.nodeType != 9 && e.nodeType != 11) { - currentVis = YAHOO.util.Dom.getStyle(e, "visibility"); - if (currentVis != "inherit") { break; } - e = e.parentNode; - } - if (currentVis == "inherit") { - currentVis = "visible"; - } - } - - var effect = this.cfg.getProperty("effect"); - - var effectInstances = []; - if (effect) { - if (effect instanceof Array) { - for (var i=0;i<effect.length;i++) { - var eff = effect[i]; - effectInstances[effectInstances.length] = eff.effect(this, eff.duration); - } - } else { - effectInstances[effectInstances.length] = effect.effect(this, effect.duration); - } - } - - var isMacGecko = (this.platform == "mac" && this.browser == "gecko"); - - if (visible) { // Show - if (isMacGecko) { - this.showMacGeckoScrollbars(); - } - - if (effect) { // Animate in - if (visible) { // Animate in if not showing - if (currentVis != "visible" || currentVis === "") { - this.beforeShowEvent.fire(); - for (var j=0;j<effectInstances.length;j++) { - var ei = effectInstances[j]; - if (j === 0 && ! YAHOO.util.Config.alreadySubscribed(ei.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) { - ei.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete - } - ei.animateIn(); - } - } - } - } else { // Show - if (currentVis != "visible" || currentVis === "") { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "visibility", "visible"); - this.cfg.refireEvent("iframe"); - this.showEvent.fire(); - } - } - - } else { // Hide - if (isMacGecko) { - this.hideMacGeckoScrollbars(); - } - - if (effect) { // Animate out if showing - if (currentVis == "visible") { - this.beforeHideEvent.fire(); - for (var k=0;k<effectInstances.length;k++) { - var h = effectInstances[k]; - if (k === 0 && ! YAHOO.util.Config.alreadySubscribed(h.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) { - h.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete - } - h.animateOut(); - } - } else if (currentVis === "") { - YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden"); - } - } else { // Simple hide - if (currentVis == "visible" || currentVis === "") { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden"); - this.cfg.refireEvent("iframe"); - this.hideEvent.fire(); - } - } - } -}; - -/** -* Center event handler used for centering on scroll/resize, but only if the Overlay is visible -* @method doCenterOnDOMEvent -*/ -YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() { - if (this.cfg.getProperty("visible")) { - this.center(); - } -}; - -/** -* The default event handler fired when the "fixedcenter" property is changed. -* @method configFixedCenter -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) { - var val = args[0]; - - if (val) { - this.center(); - - if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) { - this.beforeShowEvent.subscribe(this.center, this, true); - } - - if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) { - YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true); - } - - if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) { - YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true); - } - } else { - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); - } -}; - -/** -* The default event handler fired when the "height" property is changed. -* @method configHeight -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) { - var height = args[0]; - var el = this.element; - YAHOO.util.Dom.setStyle(el, "height", height); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "width" property is changed. -* @method configWidth -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) { - var width = args[0]; - var el = this.element; - YAHOO.util.Dom.setStyle(el, "width", width); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "zIndex" property is changed. -* @method configzIndex -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) { - var zIndex = args[0]; - - var el = this.element; - - if (! zIndex) { - zIndex = YAHOO.util.Dom.getStyle(el, "zIndex"); - if (! zIndex || isNaN(zIndex)) { - zIndex = 0; - } - } - - if (this.iframe) { - if (zIndex <= 0) { - zIndex = 1; - } - YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1)); - } - - YAHOO.util.Dom.setStyle(el, "zIndex", zIndex); - this.cfg.setProperty("zIndex", zIndex, true); -}; - -/** -* The default event handler fired when the "xy" property is changed. -* @method configXY -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) { - var pos = args[0]; - var x = pos[0]; - var y = pos[1]; - - this.cfg.setProperty("x", x); - this.cfg.setProperty("y", y); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.log("xy: " + [x,y], "iframe"); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x,y]); -}; - -/** -* The default event handler fired when the "x" property is changed. -* @method configX -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) { - var x = args[0]; - var y = this.cfg.getProperty("y"); - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.util.Dom.setX(this.element, x, true); - - this.cfg.setProperty("xy", [x, y], true); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x, y]); -}; - -/** -* The default event handler fired when the "y" property is changed. -* @method configY -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) { - var x = this.cfg.getProperty("x"); - var y = args[0]; - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.util.Dom.setY(this.element, y, true); - - this.cfg.setProperty("xy", [x, y], true); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x, y]); -}; - -/** -* Shows the iframe shim, if it has been enabled -* @method showIframe -*/ -YAHOO.widget.Overlay.prototype.showIframe = function() { - if (this.iframe) { - this.iframe.style.display = "block"; - } -}; - -/** -* Hides the iframe shim, if it has been enabled -* @method hideIframe -*/ -YAHOO.widget.Overlay.prototype.hideIframe = function() { - if (this.iframe) { - this.iframe.style.display = "none"; - } -}; - -/** -* The default event handler fired when the "iframe" property is changed. -* @method configIframe -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) { - - var val = args[0]; - - if (val) { // IFRAME shim is enabled - - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, this.showIframe, this)) { - this.showEvent.subscribe(this.showIframe, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, this.hideIframe, this)) { - this.hideEvent.subscribe(this.hideIframe, this, true); - } - - var x = this.cfg.getProperty("x"); - var y = this.cfg.getProperty("y"); - - if (! x || ! y) { - this.syncPosition(); - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - } - - YAHOO.log("iframe positioning to: " + [x,y], "iframe"); - - if (! isNaN(x) && ! isNaN(y)) { - if (! this.iframe) { - this.iframe = document.createElement("iframe"); - if (this.isSecure) { - this.iframe.src = YAHOO.widget.Overlay.IFRAME_SRC; - } - - var parent = this.element.parentNode; - if (parent) { - parent.appendChild(this.iframe); - } else { - document.body.appendChild(this.iframe); - } - - YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute"); - YAHOO.util.Dom.setStyle(this.iframe, "border", "none"); - YAHOO.util.Dom.setStyle(this.iframe, "margin", "0"); - YAHOO.util.Dom.setStyle(this.iframe, "padding", "0"); - YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); - if (this.cfg.getProperty("visible")) { - this.showIframe(); - } else { - this.hideIframe(); - } - } - - var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display"); - - if (iframeDisplay == "none") { - this.iframe.style.display = "block"; - } - - YAHOO.util.Dom.setXY(this.iframe, [x,y]); - - var width = this.element.clientWidth; - var height = this.element.clientHeight; - - YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px"); - YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px"); - - if (iframeDisplay == "none") { - this.iframe.style.display = "none"; - } - } - } else { - if (this.iframe) { - this.iframe.style.display = "none"; - } - this.showEvent.unsubscribe(this.showIframe, this); - this.hideEvent.unsubscribe(this.hideIframe, this); - } -}; - - -/** -* The default event handler fired when the "constraintoviewport" property is changed. -* @method configConstrainToViewport -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) { - var val = args[0]; - if (val) { - if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) { - this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true); - } - } else { - this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this); - } -}; - -/** -* The default event handler fired when the "context" property is changed. -* @method configContext -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) { - var contextArgs = args[0]; - - if (contextArgs) { - var contextEl = contextArgs[0]; - var elementMagnetCorner = contextArgs[1]; - var contextMagnetCorner = contextArgs[2]; - - if (contextEl) { - if (typeof contextEl == "string") { - this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true); - } - - if (elementMagnetCorner && contextMagnetCorner) { - this.align(elementMagnetCorner, contextMagnetCorner); - } - } - } -}; - - -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT. -* @method align -* @param {String} elementAlign The String representing the corner of the Overlay that should be aligned to the context element -* @param {String} contextAlign The corner of the context element that the elementAlign corner should stick to. -*/ -YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) { - var contextArgs = this.cfg.getProperty("context"); - if (contextArgs) { - var context = contextArgs[0]; - - var element = this.element; - var me = this; - - if (! elementAlign) { - elementAlign = contextArgs[1]; - } - - if (! contextAlign) { - contextAlign = contextArgs[2]; - } - - if (element && context) { - var contextRegion = YAHOO.util.Dom.getRegion(context); - - var doAlign = function(v,h) { - switch (elementAlign) { - case YAHOO.widget.Overlay.TOP_LEFT: - me.moveTo(h,v); - break; - case YAHOO.widget.Overlay.TOP_RIGHT: - me.moveTo(h-element.offsetWidth,v); - break; - case YAHOO.widget.Overlay.BOTTOM_LEFT: - me.moveTo(h,v-element.offsetHeight); - break; - case YAHOO.widget.Overlay.BOTTOM_RIGHT: - me.moveTo(h-element.offsetWidth,v-element.offsetHeight); - break; - } - }; - - switch (contextAlign) { - case YAHOO.widget.Overlay.TOP_LEFT: - doAlign(contextRegion.top, contextRegion.left); - break; - case YAHOO.widget.Overlay.TOP_RIGHT: - doAlign(contextRegion.top, contextRegion.right); - break; - case YAHOO.widget.Overlay.BOTTOM_LEFT: - doAlign(contextRegion.bottom, contextRegion.left); - break; - case YAHOO.widget.Overlay.BOTTOM_RIGHT: - doAlign(contextRegion.bottom, contextRegion.right); - break; - } - } - } -}; - -/** -* The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true. -* @method enforceConstraints -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) { - var pos = args[0]; - - var x = pos[0]; - var y = pos[1]; - - var offsetHeight = this.element.offsetHeight; - var offsetWidth = this.element.offsetWidth; - - var viewPortWidth = YAHOO.util.Dom.getViewportWidth(); - var viewPortHeight = YAHOO.util.Dom.getViewportHeight(); - - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var topConstraint = scrollY + 10; - var leftConstraint = scrollX + 10; - var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10; - var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10; - - if (x < leftConstraint) { - x = leftConstraint; - } else if (x > rightConstraint) { - x = rightConstraint; - } - - if (y < topConstraint) { - y = topConstraint; - } else if (y > bottomConstraint) { - y = bottomConstraint; - } - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - this.cfg.setProperty("xy", [x,y], true); -}; - -/** -* Centers the container in the viewport. -* @method center -*/ -YAHOO.widget.Overlay.prototype.center = function() { - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var viewPortWidth = YAHOO.util.Dom.getClientWidth(); - var viewPortHeight = YAHOO.util.Dom.getClientHeight(); - - var elementWidth = this.element.offsetWidth; - var elementHeight = this.element.offsetHeight; - - var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX; - var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY; - - this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]); - - this.cfg.refireEvent("iframe"); -}; - -/** -* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop. -* @method syncPosition -*/ -YAHOO.widget.Overlay.prototype.syncPosition = function() { - var pos = YAHOO.util.Dom.getXY(this.element); - this.cfg.setProperty("x", pos[0], true); - this.cfg.setProperty("y", pos[1], true); - this.cfg.setProperty("xy", pos, true); -}; - -/** -* Event handler fired when the resize monitor element is resized. -* @method onDomResize -* @param {DOMEvent} e The resize DOM event -* @param {Object} obj The scope object -*/ -YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) { - YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj); - var me = this; - setTimeout(function() { - me.syncPosition(); - me.cfg.refireEvent("iframe"); - me.cfg.refireEvent("context"); - }, 0); -}; - -/** -* Removes the Overlay element from the DOM and sets all child elements to null. -* @method destroy -*/ -YAHOO.widget.Overlay.prototype.destroy = function() { - if (this.iframe) { - this.iframe.parentNode.removeChild(this.iframe); - } - - this.iframe = null; - - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); - - YAHOO.widget.Overlay.superclass.destroy.call(this); -}; - -/** -* Returns a String representation of the object. -* @method toString -* @return {String} The string representation of the Overlay. -*/ -YAHOO.widget.Overlay.prototype.toString = function() { - return "Overlay " + this.id; -}; - -/** -* A singleton CustomEvent used for reacting to the DOM event for window scroll -* @event YAHOO.widget.Overlay.windowScrollEvent -*/ -YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll"); - -/** -* A singleton CustomEvent used for reacting to the DOM event for window resize -* @event YAHOO.widget.Overlay.windowResizeEvent -*/ -YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize"); - -/** -* The DOM event handler used to fire the CustomEvent for window scroll -* @method YAHOO.widget.Overlay.windowScrollHandler -* @static -* @param {DOMEvent} e The DOM scroll event -*/ -YAHOO.widget.Overlay.windowScrollHandler = function(e) { - if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { - if (! window.scrollEnd) { - window.scrollEnd = -1; - } - clearTimeout(window.scrollEnd); - window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1); - } else { - YAHOO.widget.Overlay.windowScrollEvent.fire(); - } -}; - -/** -* The DOM event handler used to fire the CustomEvent for window resize -* @method YAHOO.widget.Overlay.windowResizeHandler -* @static -* @param {DOMEvent} e The DOM resize event -*/ -YAHOO.widget.Overlay.windowResizeHandler = function(e) { - if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { - if (! window.resizeEnd) { - window.resizeEnd = -1; - } - clearTimeout(window.resizeEnd); - window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100); - } else { - YAHOO.widget.Overlay.windowResizeEvent.fire(); - } -}; - -/** -* A boolean that indicated whether the window resize and scroll events have already been subscribed to. -* @property YAHOO.widget.Overlay._initialized -* @private -* @type Boolean -*/ -YAHOO.widget.Overlay._initialized = null; - -if (YAHOO.widget.Overlay._initialized === null) { - YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler); - YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler); - - YAHOO.widget.Overlay._initialized = true; -} - -/** -* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget -* @namespace YAHOO.widget -* @class OverlayManager -* @constructor -* @param {Array} overlays Optional. A collection of Overlays to register with the manager. -* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager -*/ -YAHOO.widget.OverlayManager = function(userConfig) { - this.init(userConfig); -}; - -/** -* The CSS class representing a focused Overlay -* @property YAHOO.widget.OverlayManager.CSS_FOCUSED -* @static -* @final -* @type String -*/ -YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused"; - -YAHOO.widget.OverlayManager.prototype = { - /** - * The class's constructor function - * @property contructor - * @type Function - */ - constructor : YAHOO.widget.OverlayManager, - - /** - * The array of Overlays that are currently registered - * @property overlays - * @type YAHOO.widget.Overlay[] - */ - overlays : null, - - /** - * Initializes the default configuration of the OverlayManager - * @method initDefaultConfig - */ - initDefaultConfig : function() { - /** - * The collection of registered Overlays in use by the OverlayManager - * @config overlays - * @type YAHOO.widget.Overlay[] - * @default null - */ - this.cfg.addProperty("overlays", { suppressEvent:true } ); - - /** - * The default DOM event that should be used to focus an Overlay - * @config focusevent - * @type String - * @default "mousedown" - */ - this.cfg.addProperty("focusevent", { value:"mousedown" } ); - }, - - /** - * Initializes the OverlayManager - * @method init - * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager. - * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager - */ - init : function(userConfig) { - /** - * The OverlayManager's Config object used for monitoring configuration properties. - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - this.initDefaultConfig(); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - this.cfg.fireQueue(); - - /** - * The currently activated Overlay - * @property activeOverlay - * @private - * @type YAHOO.widget.Overlay - */ - var activeOverlay = null; - - /** - * Returns the currently focused Overlay - * @method getActive - * @return {YAHOO.widget.Overlay} The currently focused Overlay - */ - this.getActive = function() { - return activeOverlay; - }; - - /** - * Focuses the specified Overlay - * @method focus - * @param {YAHOO.widget.Overlay} overlay The Overlay to focus - * @param {String} overlay The id of the Overlay to focus - */ - this.focus = function(overlay) { - var o = this.find(overlay); - if (o) { - this.blurAll(); - activeOverlay = o; - YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - this.overlays.sort(this.compareZIndexDesc); - var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex"); - if (! isNaN(topZIndex) && this.overlays[0] != overlay) { - activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2)); - } - this.overlays.sort(this.compareZIndexDesc); - } - }; - - /** - * Removes the specified Overlay from the manager - * @method remove - * @param {YAHOO.widget.Overlay} overlay The Overlay to remove - * @param {String} overlay The id of the Overlay to remove - */ - this.remove = function(overlay) { - var o = this.find(overlay); - if (o) { - var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex"); - o.cfg.setProperty("zIndex", -1000, true); - this.overlays.sort(this.compareZIndexDesc); - this.overlays = this.overlays.slice(0, this.overlays.length-1); - o.cfg.setProperty("zIndex", originalZ, true); - - o.cfg.setProperty("manager", null); - o.focusEvent = null; - o.blurEvent = null; - o.focus = null; - o.blur = null; - } - }; - - /** - * Removes focus from all registered Overlays in the manager - * @method blurAll - */ - this.blurAll = function() { - activeOverlay = null; - for (var o=0;o<this.overlays.length;o++) { - YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - } - }; - - var overlays = this.cfg.getProperty("overlays"); - - if (! this.overlays) { - this.overlays = []; - } - - if (overlays) { - this.register(overlays); - this.overlays.sort(this.compareZIndexDesc); - } - }, - - /** - * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each. - * @method register - * @param {YAHOO.widget.Overlay} overlay An Overlay to register with the manager. - * @param {YAHOO.widget.Overlay[]} overlay An array of Overlays to register with the manager. - * @return {Boolean} True if any Overlays are registered. - */ - register : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - overlay.cfg.addProperty("manager", { value:this } ); - - overlay.focusEvent = new YAHOO.util.CustomEvent("focus"); - overlay.blurEvent = new YAHOO.util.CustomEvent("blur"); - - var mgr=this; - - overlay.focus = function() { - mgr.focus(this); - this.focusEvent.fire(); - }; - - overlay.blur = function() { - mgr.blurAll(); - this.blurEvent.fire(); - }; - - var focusOnDomEvent = function(e,obj) { - overlay.focus(); - }; - - var focusevent = this.cfg.getProperty("focusevent"); - YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true); - - var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex"); - if (! isNaN(zIndex)) { - overlay.cfg.setProperty("zIndex", parseInt(zIndex, 10)); - } else { - overlay.cfg.setProperty("zIndex", 0); - } - - this.overlays.push(overlay); - return true; - } else if (overlay instanceof Array) { - var regcount = 0; - for (var i=0;i<overlay.length;i++) { - if (this.register(overlay[i])) { - regcount++; - } - } - if (regcount > 0) { - return true; - } - } else { - return false; - } - }, - - /** - * Attempts to locate an Overlay by instance or ID. - * @method find - * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager - * @param {String} overlay An Overlay id to locate within the manager - * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located. - */ - find : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - for (var o=0;o<this.overlays.length;o++) { - if (this.overlays[o] == overlay) { - return this.overlays[o]; - } - } - } else if (typeof overlay == "string") { - for (var p=0;p<this.overlays.length;p++) { - if (this.overlays[p].id == overlay) { - return this.overlays[p]; - } - } - } - return null; - }, - - /** - * Used for sorting the manager's Overlays by z-index. - * @method compareZIndexDesc - * @private - * @return {Number} 0, 1, or -1, depending on where the Overlay should fall in the stacking order. - */ - compareZIndexDesc : function(o1, o2) { - var zIndex1 = o1.cfg.getProperty("zIndex"); - var zIndex2 = o2.cfg.getProperty("zIndex"); - - if (zIndex1 > zIndex2) { - return -1; - } else if (zIndex1 < zIndex2) { - return 1; - } else { - return 0; - } - }, - - /** - * Shows all Overlays in the manager. - * @method showAll - */ - showAll : function() { - for (var o=0;o<this.overlays.length;o++) { - this.overlays[o].show(); - } - }, - - /** - * Hides all Overlays in the manager. - * @method hideAll - */ - hideAll : function() { - for (var o=0;o<this.overlays.length;o++) { - this.overlays[o].hide(); - } - }, - - /** - * Returns a string representation of the object. - * @method toString - * @return {String} The string representation of the OverlayManager - */ - toString : function() { - return "OverlayManager"; - } - -}; - -/** -* KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements. -* @namespace YAHOO.util -* @class KeyListener -* @constructor -* @param {HTMLElement} attachTo The element or element ID to which the key event should be attached -* @param {String} attachTo The element or element ID to which the key event should be attached -* @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). -* @param {Function} handler The CustomEvent handler to fire when the key event is detected -* @param {Object} handler An object literal representing the handler. -* @param {String} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown. -*/ -YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) { - if (! attachTo) { - YAHOO.log("No attachTo element specified", "error"); - } - if (! keyData) { - YAHOO.log("No keyData specified", "error"); - } - if (! handler) { - YAHOO.log("No handler specified", "error"); - } - - if (! event) { - event = YAHOO.util.KeyListener.KEYDOWN; - } - - /** - * The CustomEvent fired internally when a key is pressed - * @event keyEvent - * @private - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - var keyEvent = new YAHOO.util.CustomEvent("keyPressed"); - - /** - * The CustomEvent fired when the KeyListener is enabled via the enable() function - * @event enabledEvent - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - this.enabledEvent = new YAHOO.util.CustomEvent("enabled"); - - /** - * The CustomEvent fired when the KeyListener is disabled via the disable() function - * @event disabledEvent - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - this.disabledEvent = new YAHOO.util.CustomEvent("disabled"); - - if (typeof attachTo == 'string') { - attachTo = document.getElementById(attachTo); - } - - if (typeof handler == 'function') { - keyEvent.subscribe(handler); - } else { - keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope); - } - - /** - * Handles the key event when a key is pressed. - * @method handleKeyPress - * @param {DOMEvent} e The keypress DOM event - * @param {Object} obj The DOM event scope object - * @private - */ - function handleKeyPress(e, obj) { - if (! keyData.shift) { - keyData.shift = false; - } - if (! keyData.alt) { - keyData.alt = false; - } - if (! keyData.ctrl) { - keyData.ctrl = false; - } - - // check held down modifying keys first - if (e.shiftKey == keyData.shift && - e.altKey == keyData.alt && - e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match - - var dataItem; - var keyPressed; - - if (keyData.keys instanceof Array) { - for (var i=0;i<keyData.keys.length;i++) { - dataItem = keyData.keys[i]; - - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - break; - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - break; - } - } - } else { - dataItem = keyData.keys; - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - } - } - } - } - - /** - * Enables the KeyListener by attaching the DOM event listeners to the target DOM element - * @method enable - */ - this.enable = function() { - if (! this.enabled) { - YAHOO.util.Event.addListener(attachTo, event, handleKeyPress); - this.enabledEvent.fire(keyData); - } - /** - * Boolean indicating the enabled/disabled state of the Tooltip - * @property enabled - * @type Boolean - */ - this.enabled = true; - }; - - /** - * Disables the KeyListener by removing the DOM event listeners from the target DOM element - * @method disable - */ - this.disable = function() { - if (this.enabled) { - YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress); - this.disabledEvent.fire(keyData); - } - this.enabled = false; - }; - - /** - * Returns a String representation of the object. - * @method toString - * @return {String} The string representation of the KeyListener - */ - this.toString = function() { - return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : ""); - }; - -}; - -/** -* Constant representing the DOM "keydown" event. -* @property YAHOO.util.KeyListener.KEYDOWN -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYDOWN = "keydown"; - -/** -* Constant representing the DOM "keyup" event. -* @property YAHOO.util.KeyListener.KEYUP -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYUP = "keyup"; - -/** -* Tooltip is an implementation of Overlay that behaves like an OS tooltip, displaying when the user mouses over a particular element, and disappearing on mouse out. -* @namespace YAHOO.widget -* @class Tooltip -* @extends YAHOO.widget.Overlay -* @constructor -* @param {String} el The element ID representing the Tooltip <em>OR</em> -* @param {HTMLElement} el The element representing the Tooltip -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Tooltip = function(el, userConfig) { - YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay); - -/** -* Constant representing the Tooltip CSS class -* @property YAHOO.widget.Tooltip.CSS_TOOLTIP -* @static -* @final -* @type String -*/ -YAHOO.widget.Tooltip.CSS_TOOLTIP = "yui-tt"; - -/** -* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well. -* @method init -* @param {String} el The element ID representing the Tooltip <em>OR</em> -* @param {HTMLElement} el The element representing the Tooltip -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details. -*/ -YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) { - this.logger = YAHOO.widget.Tooltip.logger; - - if (document.readyState && document.readyState != "complete") { - var deferredInit = function() { - this.init(el, userConfig); - }; - YAHOO.util.Event.addListener(window, "load", deferredInit, this, true); - } else { - YAHOO.widget.Tooltip.superclass.init.call(this, el); - - this.beforeInitEvent.fire(YAHOO.widget.Tooltip); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.cfg.queueProperty("visible",false); - this.cfg.queueProperty("constraintoviewport",true); - - this.setBody(""); - this.render(this.cfg.getProperty("container")); - - this.initEvent.fire(YAHOO.widget.Tooltip); - } -}; - -/** -* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() { - YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this); - - /** - * Specifies whether the Tooltip should be kept from overlapping its context element. - * @config preventoverlap - * @type Boolean - * @default true - */ - this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } ); - - /** - * The number of milliseconds to wait before showing a Tooltip on mouseover. - * @config showdelay - * @type Number - * @default 200 - */ - this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } ); - - /** - * The number of milliseconds to wait before automatically dismissing a Tooltip after the mouse has been resting on the context element. - * @config autodismissdelay - * @type Number - * @default 5000 - */ - this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } ); - - /** - * The number of milliseconds to wait before hiding a Tooltip on mouseover. - * @config hidedelay - * @type Number - * @default 250 - */ - this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } ); - - /** - * Specifies the Tooltip's text. - * @config text - * @type String - * @default null - */ - this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } ); - - /** - * Specifies the container element that the Tooltip's markup should be rendered into. - * @config container - * @type HTMLElement/String - * @default document.body - */ - this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } ); - - /** - * Specifies the element or elements that the Tooltip should be anchored to on mouseover. - * @config context - * @type HTMLElement[]/String[] - * @default null - */ - -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "text" property is changed. -* @method configText -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) { - var text = args[0]; - if (text) { - this.setBody(text); - } -}; - -/** -* The default event handler fired when the "container" property is changed. -* @method configContainer -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) { - var container = args[0]; - if (typeof container == 'string') { - this.cfg.setProperty("container", document.getElementById(container), true); - } -}; - -/** -* The default event handler fired when the "context" property is changed. -* @method configContext -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) { - var context = args[0]; - if (context) { - - // Normalize parameter into an array - if (! (context instanceof Array)) { - if (typeof context == "string") { - this.cfg.setProperty("context", [document.getElementById(context)], true); - } else { // Assuming this is an element - this.cfg.setProperty("context", [context], true); - } - context = this.cfg.getProperty("context"); - } - - - // Remove any existing mouseover/mouseout listeners - if (this._context) { - for (var c=0;c<this._context.length;++c) { - var el = this._context[c]; - YAHOO.util.Event.removeListener(el, "mouseover", this.onContextMouseOver); - YAHOO.util.Event.removeListener(el, "mousemove", this.onContextMouseMove); - YAHOO.util.Event.removeListener(el, "mouseout", this.onContextMouseOut); - } - } - - // Add mouseover/mouseout listeners to context elements - this._context = context; - for (var d=0;d<this._context.length;++d) { - var el2 = this._context[d]; - YAHOO.util.Event.addListener(el2, "mouseover", this.onContextMouseOver, this); - YAHOO.util.Event.addListener(el2, "mousemove", this.onContextMouseMove, this); - YAHOO.util.Event.addListener(el2, "mouseout", this.onContextMouseOut, this); - } - } -}; - -// END BUILT-IN PROPERTY EVENT HANDLERS // - -// BEGIN BUILT-IN DOM EVENT HANDLERS // - -/** -* The default event handler fired when the user moves the mouse while over the context element. -* @method onContextMouseMove -* @param {DOMEvent} e The current DOM event -* @param {Object} obj The object argument -*/ -YAHOO.widget.Tooltip.prototype.onContextMouseMove = function(e, obj) { - obj.pageX = YAHOO.util.Event.getPageX(e); - obj.pageY = YAHOO.util.Event.getPageY(e); - -}; - -/** -* The default event handler fired when the user mouses over the context element. -* @method onContextMouseOver -* @param {DOMEvent} e The current DOM event -* @param {Object} obj The object argument -*/ -YAHOO.widget.Tooltip.prototype.onContextMouseOver = function(e, obj) { - - if (obj.hideProcId) { - clearTimeout(obj.hideProcId); - obj.logger.log("Clearing hide timer: " + obj.hideProcId, "time"); - obj.hideProcId = null; - } - - var context = this; - YAHOO.util.Event.addListener(context, "mousemove", obj.onContextMouseMove, obj); - - if (context.title) { - obj._tempTitle = context.title; - context.title = ""; - } - - /** - * The unique process ID associated with the thread responsible for showing the Tooltip. - * @type int - */ - obj.showProcId = obj.doShow(e, context); - obj.logger.log("Setting show tooltip timeout: " + this.showProcId, "time"); -}; - -/** -* The default event handler fired when the user mouses out of the context element. -* @method onContextMouseOut -* @param {DOMEvent} e The current DOM event -* @param {Object} obj The object argument -*/ -YAHOO.widget.Tooltip.prototype.onContextMouseOut = function(e, obj) { - var el = this; - - if (obj._tempTitle) { - el.title = obj._tempTitle; - obj._tempTitle = null; - } - - if (obj.showProcId) { - clearTimeout(obj.showProcId); - obj.logger.log("Clearing show timer: " + obj.showProcId, "time"); - obj.showProcId = null; - } - - if (obj.hideProcId) { - clearTimeout(obj.hideProcId); - obj.logger.log("Clearing hide timer: " + obj.hideProcId, "time"); - obj.hideProcId = null; - } - - - obj.hideProcId = setTimeout(function() { - obj.hide(); - }, obj.cfg.getProperty("hidedelay")); -}; - -// END BUILT-IN DOM EVENT HANDLERS // - -/** -* Processes the showing of the Tooltip by setting the timeout delay and offset of the Tooltip. -* @method doShow -* @param {DOMEvent} e The current DOM event -* @return {Number} The process ID of the timeout function associated with doShow -*/ -YAHOO.widget.Tooltip.prototype.doShow = function(e, context) { - - var yOffset = 25; - if (this.browser == "opera" && context.tagName == "A") { - yOffset += 12; - } - - var me = this; - return setTimeout( - function() { - if (me._tempTitle) { - me.setBody(me._tempTitle); - } else { - me.cfg.refireEvent("text"); - } - - me.logger.log("Show tooltip", "time"); - me.moveTo(me.pageX, me.pageY + yOffset); - if (me.cfg.getProperty("preventoverlap")) { - me.preventOverlap(me.pageX, me.pageY); - } - - YAHOO.util.Event.removeListener(context, "mousemove", me.onContextMouseMove); - - me.show(); - me.hideProcId = me.doHide(); - me.logger.log("Hide tooltip time active: " + me.hideProcId, "time"); - }, - this.cfg.getProperty("showdelay")); -}; - -/** -* Sets the timeout for the auto-dismiss delay, which by default is 5 seconds, meaning that a tooltip will automatically dismiss itself after 5 seconds of being displayed. -* @method doHide -*/ -YAHOO.widget.Tooltip.prototype.doHide = function() { - var me = this; - me.logger.log("Setting hide tooltip timeout", "time"); - return setTimeout( - function() { - me.logger.log("Hide tooltip", "time"); - me.hide(); - }, - this.cfg.getProperty("autodismissdelay")); -}; - -/** -* Fired when the Tooltip is moved, this event handler is used to prevent the Tooltip from overlapping with its context element. -* @method preventOverlay -* @param {Number} pageX The x coordinate position of the mouse pointer -* @param {Number} pageY The y coordinate position of the mouse pointer -*/ -YAHOO.widget.Tooltip.prototype.preventOverlap = function(pageX, pageY) { - - var height = this.element.offsetHeight; - - var elementRegion = YAHOO.util.Dom.getRegion(this.element); - - elementRegion.top -= 5; - elementRegion.left -= 5; - elementRegion.right += 5; - elementRegion.bottom += 5; - - var mousePoint = new YAHOO.util.Point(pageX, pageY); - - this.logger.log("context " + elementRegion, "ttip"); - this.logger.log("mouse " + mousePoint, "ttip"); - - if (elementRegion.contains(mousePoint)) { - this.logger.log("OVERLAP", "warn"); - this.cfg.setProperty("y", (pageY-height-5)); - } -}; - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the Tooltip -*/ -YAHOO.widget.Tooltip.prototype.toString = function() { - return "Tooltip " + this.id; -}; - -/** -* Panel is an implementation of Overlay that behaves like an OS window, with a draggable header and an optional close icon at the top right. -* @namespace YAHOO.widget -* @class Panel -* @extends YAHOO.widget.Overlay -* @constructor -* @param {String} el The element ID representing the Panel <em>OR</em> -* @param {HTMLElement} el The element representing the Panel -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details. -*/ -YAHOO.widget.Panel = function(el, userConfig) { - YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay); - -/** -* Constant representing the default CSS class used for a Panel -* @property YAHOO.widget.Panel.CSS_PANEL -* @static -* @final -* @type String -*/ -YAHOO.widget.Panel.CSS_PANEL = "yui-panel"; - -/** -* Constant representing the default CSS class used for a Panel's wrapping container -* @property YAHOO.widget.Panel.CSS_PANEL_CONTAINER -* @static -* @final -* @type String -*/ -YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "yui-panel-container"; - -/** -* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Panel.prototype.init = function(el, userConfig) { - YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Panel); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL); - - this.buildWrapper(); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.beforeRenderEvent.subscribe(function() { - var draggable = this.cfg.getProperty("draggable"); - if (draggable) { - if (! this.header) { - this.setHeader(" "); - } - } - }, this, true); - - var me = this; - - var doBlur = function() { - this.blur(); - }; - - this.showMaskEvent.subscribe(function() { - var checkFocusable = function(el) { - if ((el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA") && el.type != "hidden") { - if (! YAHOO.util.Dom.isAncestor(me.element, el)) { - YAHOO.util.Event.addListener(el, "focus", doBlur, el, true); - return true; - } - } else { - return false; - } - }; - - this.focusableElements = YAHOO.util.Dom.getElementsBy(checkFocusable); - }, this, true); - - this.hideMaskEvent.subscribe(function() { - for (var i=0;i<this.focusableElements.length;i++) { - var el2 = this.focusableElements[i]; - YAHOO.util.Event.removeListener(el2, "focus", doBlur); - } - }, this, true); - - this.beforeShowEvent.subscribe(function() { - this.cfg.refireEvent("underlay"); - }, this, true); - this.initEvent.fire(YAHOO.widget.Panel); -}; - -/** -* Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. -*/ -YAHOO.widget.Panel.prototype.initEvents = function() { - YAHOO.widget.Panel.superclass.initEvents.call(this); - - /** - * CustomEvent fired after the modality mask is shown - * @event showMaskEvent - */ - this.showMaskEvent = new YAHOO.util.CustomEvent("showMask"); - - /** - * CustomEvent fired after the modality mask is hidden - * @event hideMaskEvent - */ - this.hideMaskEvent = new YAHOO.util.CustomEvent("hideMask"); - - /** - * CustomEvent when the Panel is dragged - * @event dragEvent - */ - this.dragEvent = new YAHOO.util.CustomEvent("drag"); -}; - -/** -* Initializes the class's configurable properties which can be changed using the Panel's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Panel.prototype.initDefaultConfig = function() { - YAHOO.widget.Panel.superclass.initDefaultConfig.call(this); - - // Add panel config properties // - - /** - * True if the Panel should display a "close" button - * @config close - * @type Boolean - * @default true - */ - this.cfg.addProperty("close", { value:true, handler:this.configClose, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - - /** - * True if the Panel should be draggable - * @config draggable - * @type Boolean - * @default true - */ - this.cfg.addProperty("draggable", { value:true, handler:this.configDraggable, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - - /** - * Sets the type of underlay to display for the Panel. Valid values are "shadow", "matte", and "none". - * @config underlay - * @type String - * @default shadow - */ - this.cfg.addProperty("underlay", { value:"shadow", handler:this.configUnderlay, supercedes:["visible"] } ); - - /** - * True if the Panel should be displayed in a modal fashion, automatically creating a transparent mask over the document that will not be removed until the Panel is dismissed. - * @config modal - * @type Boolean - * @default false - */ - this.cfg.addProperty("modal", { value:false, handler:this.configModal, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - - /** - * A KeyListener (or array of KeyListeners) that will be enabled when the Panel is shown, and disabled when the Panel is hidden. - * @config keylisteners - * @type YAHOO.util.KeyListener[] - * @default null - */ - this.cfg.addProperty("keylisteners", { handler:this.configKeyListeners, suppressEvent:true, supercedes:["visible"] } ); -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Panel. -* @method configClose -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configClose = function(type, args, obj) { - var val = args[0]; - - var doHide = function(e, obj) { - obj.hide(); - }; - - if (val) { - if (! this.close) { - this.close = document.createElement("span"); - YAHOO.util.Dom.addClass(this.close, "container-close"); - this.close.innerHTML = " "; - this.innerElement.appendChild(this.close); - YAHOO.util.Event.addListener(this.close, "click", doHide, this); - } else { - this.close.style.display = "block"; - } - } else { - if (this.close) { - this.close.style.display = "none"; - } - } -}; - -/** -* The default event handler fired when the "draggable" property is changed. -* @method configDraggable -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configDraggable = function(type, args, obj) { - var val = args[0]; - if (val) { - if (this.header) { - YAHOO.util.Dom.setStyle(this.header,"cursor","move"); - this.registerDragDrop(); - } - } else { - if (this.dd) { - this.dd.unreg(); - } - if (this.header) { - YAHOO.util.Dom.setStyle(this.header,"cursor","auto"); - } - } -}; - -/** -* The default event handler fired when the "underlay" property is changed. -* @method configUnderlay -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configUnderlay = function(type, args, obj) { - var val = args[0]; - - switch (val.toLowerCase()) { - case "shadow": - YAHOO.util.Dom.removeClass(this.element, "matte"); - YAHOO.util.Dom.addClass(this.element, "shadow"); - - if (! this.underlay) { // create if not already in DOM - this.underlay = document.createElement("div"); - this.underlay.className = "underlay"; - this.underlay.innerHTML = " "; - this.element.appendChild(this.underlay); - } - - this.sizeUnderlay(); - break; - case "matte": - YAHOO.util.Dom.removeClass(this.element, "shadow"); - YAHOO.util.Dom.addClass(this.element, "matte"); - break; - default: - YAHOO.util.Dom.removeClass(this.element, "shadow"); - YAHOO.util.Dom.removeClass(this.element, "matte"); - break; - } -}; - -/** -* The default event handler fired when the "modal" property is changed. This handler subscribes or unsubscribes to the show and hide events to handle the display or hide of the modality mask. -* @method configModal -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configModal = function(type, args, obj) { - var modal = args[0]; - - if (modal) { - this.buildMask(); - - if (! YAHOO.util.Config.alreadySubscribed( this.beforeShowEvent, this.showMask, this ) ) { - this.beforeShowEvent.subscribe(this.showMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( this.hideEvent, this.hideMask, this) ) { - this.hideEvent.subscribe(this.hideMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowResizeEvent, this.sizeMask, this ) ) { - YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( this.destroyEvent, this.removeMask, this) ) { - this.destroyEvent.subscribe(this.removeMask, this, true); - } - - this.cfg.refireEvent("zIndex"); - } else { - this.beforeShowEvent.unsubscribe(this.showMask, this); - this.hideEvent.unsubscribe(this.hideMask, this); - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask, this); - this.destroyEvent.unsubscribe(this.removeMask, this); - } -}; - -/** -* Removes the modality mask. -* @method removeMask -*/ -YAHOO.widget.Panel.prototype.removeMask = function() { - if (this.mask) { - if (this.mask.parentNode) { - this.mask.parentNode.removeChild(this.mask); - } - this.mask = null; - } -}; - -/** -* The default event handler fired when the "keylisteners" property is changed. -* @method configKeyListeners -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configKeyListeners = function(type, args, obj) { - var listeners = args[0]; - - if (listeners) { - if (listeners instanceof Array) { - for (var i=0;i<listeners.length;i++) { - var listener = listeners[i]; - - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listener.enable, listener)) { - this.showEvent.subscribe(listener.enable, listener, true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listener.disable, listener)) { - this.hideEvent.subscribe(listener.disable, listener, true); - this.destroyEvent.subscribe(listener.disable, listener, true); - } - } - } else { - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listeners.enable, listeners)) { - this.showEvent.subscribe(listeners.enable, listeners, true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listeners.disable, listeners)) { - this.hideEvent.subscribe(listeners.disable, listeners, true); - this.destroyEvent.subscribe(listeners.disable, listeners, true); - } - } - } -}; - -/** -* The default event handler fired when the "height" property is changed. -* @method configHeight -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configHeight = function(type, args, obj) { - var height = args[0]; - var el = this.innerElement; - YAHOO.util.Dom.setStyle(el, "height", height); - this.cfg.refireEvent("underlay"); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "width" property is changed. -* @method configWidth -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configWidth = function(type, args, obj) { - var width = args[0]; - var el = this.innerElement; - YAHOO.util.Dom.setStyle(el, "width", width); - this.cfg.refireEvent("underlay"); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "zIndex" property is changed. -* @method configzIndex -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configzIndex = function(type, args, obj) { - YAHOO.widget.Panel.superclass.configzIndex.call(this, type, args, obj); - - var maskZ = 0; - var currentZ = YAHOO.util.Dom.getStyle(this.element, "zIndex"); - - if (this.mask) { - if (! currentZ || isNaN(currentZ)) { - currentZ = 0; - } - - if (currentZ === 0) { - this.cfg.setProperty("zIndex", 1); - } else { - maskZ = currentZ - 1; - YAHOO.util.Dom.setStyle(this.mask, "zIndex", maskZ); - } - - } -}; - -// END BUILT-IN PROPERTY EVENT HANDLERS // - - -/** -* Builds the wrapping container around the Panel that is used for positioning the shadow and matte underlays. The container element is assigned to a local instance variable called container, and the element is reinserted inside of it. -* @method buildWrapper -*/ -YAHOO.widget.Panel.prototype.buildWrapper = function() { - var elementParent = this.element.parentNode; - var originalElement = this.element; - - var wrapper = document.createElement("div"); - wrapper.className = YAHOO.widget.Panel.CSS_PANEL_CONTAINER; - wrapper.id = originalElement.id + "_c"; - - if (elementParent) { - elementParent.insertBefore(wrapper, originalElement); - } - - wrapper.appendChild(originalElement); - - this.element = wrapper; - this.innerElement = originalElement; - - YAHOO.util.Dom.setStyle(this.innerElement, "visibility", "inherit"); -}; - -/** -* Adjusts the size of the shadow based on the size of the element. -* @method sizeUnderlay -*/ -YAHOO.widget.Panel.prototype.sizeUnderlay = function() { - if (this.underlay && this.browser != "gecko" && this.browser != "safari") { - this.underlay.style.width = this.innerElement.offsetWidth + "px"; - this.underlay.style.height = this.innerElement.offsetHeight + "px"; - } -}; - -/** -* Event handler fired when the resize monitor element is resized. -* @method onDomResize -* @param {DOMEvent} e The resize DOM event -* @param {Object} obj The scope object -*/ -YAHOO.widget.Panel.prototype.onDomResize = function(e, obj) { - YAHOO.widget.Panel.superclass.onDomResize.call(this, e, obj); - var me = this; - setTimeout(function() { - me.sizeUnderlay(); - }, 0); -}; - -/** -* Registers the Panel's header for drag & drop capability. -* @method registerDragDrop -*/ -YAHOO.widget.Panel.prototype.registerDragDrop = function() { - if (this.header) { - this.dd = new YAHOO.util.DD(this.element.id, this.id); - - if (! this.header.id) { - this.header.id = this.id + "_h"; - } - - var me = this; - - this.dd.startDrag = function() { - - if (me.browser == "ie") { - YAHOO.util.Dom.addClass(me.element,"drag"); - } - - if (me.cfg.getProperty("constraintoviewport")) { - var offsetHeight = me.element.offsetHeight; - var offsetWidth = me.element.offsetWidth; - - var viewPortWidth = YAHOO.util.Dom.getViewportWidth(); - var viewPortHeight = YAHOO.util.Dom.getViewportHeight(); - - var scrollX = window.scrollX || document.documentElement.scrollLeft; - var scrollY = window.scrollY || document.documentElement.scrollTop; - - var topConstraint = scrollY + 10; - var leftConstraint = scrollX + 10; - var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10; - var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10; - - this.minX = leftConstraint; - this.maxX = rightConstraint; - this.constrainX = true; - - this.minY = topConstraint; - this.maxY = bottomConstraint; - this.constrainY = true; - } else { - this.constrainX = false; - this.constrainY = false; - } - - me.dragEvent.fire("startDrag", arguments); - }; - - this.dd.onDrag = function() { - me.syncPosition(); - me.cfg.refireEvent("iframe"); - if (this.platform == "mac" && this.browser == "gecko") { - this.showMacGeckoScrollbars(); - } - - me.dragEvent.fire("onDrag", arguments); - }; - - this.dd.endDrag = function() { - if (me.browser == "ie") { - YAHOO.util.Dom.removeClass(me.element,"drag"); - } - - me.dragEvent.fire("endDrag", arguments); - }; - - this.dd.setHandleElId(this.header.id); - this.dd.addInvalidHandleType("INPUT"); - this.dd.addInvalidHandleType("SELECT"); - this.dd.addInvalidHandleType("TEXTAREA"); - } -}; - -/** -* Builds the mask that is laid over the document when the Panel is configured to be modal. -* @method buildMask -*/ -YAHOO.widget.Panel.prototype.buildMask = function() { - if (! this.mask) { - this.mask = document.createElement("div"); - this.mask.id = this.id + "_mask"; - this.mask.className = "mask"; - this.mask.innerHTML = " "; - - var maskClick = function(e, obj) { - YAHOO.util.Event.stopEvent(e); - }; - - var firstChild = document.body.firstChild; - if (firstChild) { - document.body.insertBefore(this.mask, document.body.firstChild); - } else { - document.body.appendChild(this.mask); - } - } -}; - -/** -* Hides the modality mask. -* @method hideMask -*/ -YAHOO.widget.Panel.prototype.hideMask = function() { - if (this.cfg.getProperty("modal") && this.mask) { - this.mask.style.display = "none"; - this.hideMaskEvent.fire(); - YAHOO.util.Dom.removeClass(document.body, "masked"); - } -}; - -/** -* Shows the modality mask. -* @method showMask -*/ -YAHOO.widget.Panel.prototype.showMask = function() { - if (this.cfg.getProperty("modal") && this.mask) { - YAHOO.util.Dom.addClass(document.body, "masked"); - this.sizeMask(); - this.mask.style.display = "block"; - this.showMaskEvent.fire(); - } -}; - -/** -* Sets the size of the modality mask to cover the entire scrollable area of the document -* @method sizeMask -*/ -YAHOO.widget.Panel.prototype.sizeMask = function() { - if (this.mask) { - this.mask.style.height = YAHOO.util.Dom.getDocumentHeight()+"px"; - this.mask.style.width = YAHOO.util.Dom.getDocumentWidth()+"px"; - } -}; - -/** -* Renders the Panel by inserting the elements that are not already in the main Panel into their correct places. Optionally appends the Panel to the specified node prior to the render's execution. NOTE: For Panels without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. -* @method render -* @param {String} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em> -* @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering -* @return {boolean} Success or failure of the render -*/ -YAHOO.widget.Panel.prototype.render = function(appendToNode) { - return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement); -}; - -/** -* Returns a String representation of the object. -* @method toString -* @return {String} The string representation of the Panel. -*/ -YAHOO.widget.Panel.prototype.toString = function() { - return "Panel " + this.id; -}; - -/** -* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually. -* @namespace YAHOO.widget -* @class Dialog -* @extends YAHOO.widget.Panel -* @constructor -* @param {String} el The element ID representing the Dialog <em>OR</em> -* @param {HTMLElement} el The element representing the Dialog -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details. -*/ -YAHOO.widget.Dialog = function(el, userConfig) { - YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel); - -/** -* Constant representing the default CSS class used for a Dialog -* @property YAHOO.widget.Dialog.CSS_DIALOG -* @static -* @final -* @type String -*/ -YAHOO.widget.Dialog.CSS_DIALOG = "yui-dialog"; - -/** -* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Dialog.prototype.initDefaultConfig = function() { - YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this); - - /** - * The internally maintained callback object for use with the Connection utility - * @property callback - * @type Object - */ - this.callback = { - /** - * The function to execute upon success of the Connection submission - * @property callback.success - * @type Function - */ - success : null, - /** - * The function to execute upon failure of the Connection submission - * @property callback.failure - * @type Function - */ - failure : null, - /** - * The arbitraty argument or arguments to pass to the Connection callback functions - * @property callback.argument - * @type Object - */ - argument: null - }; - - // Add form dialog config properties // - - /** - * The method to use for posting the Dialog's form. Possible values are "async", "form", and "manual". - * @config postmethod - * @type String - * @default async - */ - this.cfg.addProperty("postmethod", { value:"async", handler:this.configPostMethod, validator:function(val) { - if (val != "form" && val != "async" && val != "none" && val != "manual") { - return false; - } else { - return true; - } - } }); - - /** - * Object literal(s) defining the buttons for the Dialog's footer. - * @config buttons - * @type Object[] - * @default "none" - */ - this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } ); -}; - -/** -* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class. -* @method initEvents -*/ -YAHOO.widget.Dialog.prototype.initEvents = function() { - YAHOO.widget.Dialog.superclass.initEvents.call(this); - - /** - * CustomEvent fired prior to submission - * @event beforeSumitEvent - */ - this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit"); - - /** - * CustomEvent fired after submission - * @event submitEvent - */ - this.submitEvent = new YAHOO.util.CustomEvent("submit"); - - /** - * CustomEvent fired prior to manual submission - * @event manualSubmitEvent - */ - this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit"); - - /** - * CustomEvent fired prior to asynchronous submission - * @event asyncSubmitEvent - */ - this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit"); - - /** - * CustomEvent fired prior to form-based submission - * @event formSubmitEvent - */ - this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit"); - - /** - * CustomEvent fired after cancel - * @event cancelEvent - */ - this.cancelEvent = new YAHOO.util.CustomEvent("cancel"); -}; - -/** -* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the Dialog <em>OR</em> -* @param {HTMLElement} el The element representing the Dialog -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details. -*/ -YAHOO.widget.Dialog.prototype.init = function(el, userConfig) { - YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Dialog); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG); - - this.cfg.setProperty("visible", false); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.showEvent.subscribe(this.focusFirst, this, true); - this.beforeHideEvent.subscribe(this.blurButtons, this, true); - - this.beforeRenderEvent.subscribe(function() { - var buttonCfg = this.cfg.getProperty("buttons"); - if (buttonCfg && buttonCfg != "none") { - if (! this.footer) { - this.setFooter(""); - } - } - }, this, true); - - this.initEvent.fire(YAHOO.widget.Dialog); -}; - -/** -* Performs the submission of the Dialog form depending on the value of "postmethod" property. -* @method doSubmit -*/ -YAHOO.widget.Dialog.prototype.doSubmit = function() { - var pm = this.cfg.getProperty("postmethod"); - switch (pm) { - case "async": - var method = this.form.getAttribute("method") || 'POST'; - method = method.toUpperCase(); - YAHOO.util.Connect.setForm(this.form); - var cObj = YAHOO.util.Connect.asyncRequest(method, this.form.getAttribute("action"), this.callback); - this.asyncSubmitEvent.fire(); - break; - case "form": - this.form.submit(); - this.formSubmitEvent.fire(); - break; - case "none": - case "manual": - this.manualSubmitEvent.fire(); - break; - } -}; - -/** -* Prepares the Dialog's internal FORM object, creating one if one is not currently present. -* @method registerForm -*/ -YAHOO.widget.Dialog.prototype.registerForm = function() { - var form = this.element.getElementsByTagName("form")[0]; - - if (! form) { - var formHTML = "<form name=\"frm_" + this.id + "\" action=\"\"></form>"; - this.body.innerHTML += formHTML; - form = this.element.getElementsByTagName("form")[0]; - } - - this.firstFormElement = function() { - for (var f=0;f<form.elements.length;f++ ) { - var el = form.elements[f]; - if (el.focus && ! el.disabled) { - if (el.type && el.type != "hidden") { - return el; - } - } - } - return null; - }(); - - this.lastFormElement = function() { - for (var f=form.elements.length-1;f>=0;f-- ) { - var el = form.elements[f]; - if (el.focus && ! el.disabled) { - if (el.type && el.type != "hidden") { - return el; - } - } - } - return null; - }(); - - this.form = form; - - if (this.cfg.getProperty("modal") && this.form) { - - var me = this; - - var firstElement = this.firstFormElement || this.firstButton; - if (firstElement) { - this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} ); - this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true); - this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true); - } - - var lastElement = this.lastButton || this.lastFormElement; - if (lastElement) { - this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} ); - this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true); - this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true); - } - } -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Dialog. -* @method configClose -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Dialog.prototype.configClose = function(type, args, obj) { - var val = args[0]; - - var doCancel = function(e, obj) { - obj.cancel(); - }; - - if (val) { - if (! this.close) { - this.close = document.createElement("div"); - YAHOO.util.Dom.addClass(this.close, "container-close"); - - this.close.innerHTML = " "; - this.innerElement.appendChild(this.close); - YAHOO.util.Event.addListener(this.close, "click", doCancel, this); - } else { - this.close.style.display = "block"; - } - } else { - if (this.close) { - this.close.style.display = "none"; - } - } -}; - -/** -* The default event handler for the "buttons" configuration property -* @method configButtons -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) { - var buttons = args[0]; - if (buttons != "none") { - this.buttonSpan = null; - this.buttonSpan = document.createElement("span"); - this.buttonSpan.className = "button-group"; - - for (var b=0;b<buttons.length;b++) { - var button = buttons[b]; - - var htmlButton = document.createElement("button"); - htmlButton.setAttribute("type", "button"); - - if (button.isDefault) { - htmlButton.className = "default"; - this.defaultHtmlButton = htmlButton; - } - - htmlButton.appendChild(document.createTextNode(button.text)); - YAHOO.util.Event.addListener(htmlButton, "click", button.handler, this, true); - - this.buttonSpan.appendChild(htmlButton); - button.htmlButton = htmlButton; - - if (b === 0) { - this.firstButton = button.htmlButton; - } - - if (b == (buttons.length-1)) { - this.lastButton = button.htmlButton; - } - - } - - this.setFooter(this.buttonSpan); - - this.cfg.refireEvent("iframe"); - this.cfg.refireEvent("underlay"); - } else { // Do cleanup - if (this.buttonSpan) { - if (this.buttonSpan.parentNode) { - this.buttonSpan.parentNode.removeChild(this.buttonSpan); - } - - this.buttonSpan = null; - this.firstButton = null; - this.lastButton = null; - this.defaultHtmlButton = null; - } - } -}; - - -/** -* The default event handler used to focus the first field of the form when the Dialog is shown. -* @method focusFirst -*/ -YAHOO.widget.Dialog.prototype.focusFirst = function(type,args,obj) { - if (args) { - var e = args[1]; - if (e) { - YAHOO.util.Event.stopEvent(e); - } - } - - if (this.firstFormElement) { - this.firstFormElement.focus(); - } else { - this.focusDefaultButton(); - } -}; - -/** -* Sets the focus to the last button in the button or form element in the Dialog -* @method focusLast -*/ -YAHOO.widget.Dialog.prototype.focusLast = function(type,args,obj) { - if (args) { - var e = args[1]; - if (e) { - YAHOO.util.Event.stopEvent(e); - } - } - - var buttons = this.cfg.getProperty("buttons"); - if (buttons && buttons instanceof Array) { - this.focusLastButton(); - } else { - if (this.lastFormElement) { - this.lastFormElement.focus(); - } - } -}; - -/** -* Sets the focus to the button that is designated as the default. By default, his handler is executed when the show event is fired. -* @method focusDefaultButton -*/ -YAHOO.widget.Dialog.prototype.focusDefaultButton = function() { - if (this.defaultHtmlButton) { - this.defaultHtmlButton.focus(); - } -}; - -/** -* Blurs all the html buttons -* @method blurButtons -*/ -YAHOO.widget.Dialog.prototype.blurButtons = function() { - var buttons = this.cfg.getProperty("buttons"); - if (buttons && buttons instanceof Array) { - var html = buttons[0].htmlButton; - if (html) { - html.blur(); - } - } -}; - -/** -* Sets the focus to the first button in the button list -* @method focusFirstButton -*/ -YAHOO.widget.Dialog.prototype.focusFirstButton = function() { - var buttons = this.cfg.getProperty("buttons"); - if (buttons && buttons instanceof Array) { - var html = buttons[0].htmlButton; - if (html) { - html.focus(); - } - } -}; - -/** -* Sets the focus to the first button in the button list -* @method focusLastButton -*/ -YAHOO.widget.Dialog.prototype.focusLastButton = function() { - var buttons = this.cfg.getProperty("buttons"); - if (buttons && buttons instanceof Array) { - var html = buttons[buttons.length-1].htmlButton; - if (html) { - html.focus(); - } - } -}; - -/** -* The default event handler for the "postmethod" configuration property -* @method configPostMethod -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Dialog.prototype.configPostMethod = function(type, args, obj) { - var postmethod = args[0]; - - this.registerForm(); - YAHOO.util.Event.addListener(this.form, "submit", function(e) { - YAHOO.util.Event.stopEvent(e); - this.submit(); - this.form.blur(); - }, this, true); -}; - -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Built-in function hook for writing a validation function that will be checked for a "true" value prior to a submit. This function, as implemented by default, always returns true, so it should be overridden if validation is necessary. -* @method validate -*/ -YAHOO.widget.Dialog.prototype.validate = function() { - return true; -}; - -/** -* Executes a submit of the Dialog followed by a hide, if validation is successful. -* @method submit -*/ -YAHOO.widget.Dialog.prototype.submit = function() { - if (this.validate()) { - this.beforeSubmitEvent.fire(); - this.doSubmit(); - this.submitEvent.fire(); - this.hide(); - return true; - } else { - return false; - } -}; - -/** -* Executes the cancel of the Dialog followed by a hide. -* @method cancel -*/ -YAHOO.widget.Dialog.prototype.cancel = function() { - this.cancelEvent.fire(); - this.hide(); -}; - -/** -* Returns a JSON-compatible data structure representing the data currently contained in the form. -* @method getData -* @return {Object} A JSON object reprsenting the data of the current form. -*/ -YAHOO.widget.Dialog.prototype.getData = function() { - - var oForm = this.form; - - if(oForm) { - - var aElements = oForm.elements, - nTotalElements = aElements.length, - oData = {}, - sName, - oElement; - - - for(var i=0; i<nTotalElements; i++) { - - sName = aElements[i].name, - oElement = aElements[sName]; - - - if(oElement) { - - if(oElement.tagName) { - - var sType = oElement.type, - sTagName = oElement.tagName.toUpperCase(); - - switch(sTagName) { - - case "INPUT": - - if(sType == "checkbox") { - - oData[sName] = oElement.checked; - - } - else if(sType != "radio") { - - oData[sName] = oElement.value; - - } - - break; - - case "TEXTAREA": - - oData[sName] = oElement.value; - - break; - - case "SELECT": - - var aOptions = oElement.options, - nOptions = aOptions.length, - aValues = [], - oOption, - sValue; - - - for(var n=0; n<nOptions; n++) { - - oOption = aOptions[n]; - - if(oOption.selected) { - - sValue = oOption.value; - - if(!sValue || sValue === "") { - - sValue = oOption.text; - - } - - aValues[aValues.length] = sValue; - - } - - } - - oData[sName] = aValues; - - break; - - } - - - } - else { - - var nElements = oElement.length, - sType = oElement[0].type, - sTagName = oElement[0].tagName.toUpperCase(); - - - switch(sType) { - - case "radio": - - var oRadio; - - for(var n=0; n<nElements; n++) { - - oRadio = oElement[n]; - - if(oRadio.checked) { - - oData[sName] = oRadio.value; - break; - - } - - } - - break; - - case "checkbox": - - var aValues = [], - oCheckbox; - - for(var n=0; n<nElements; n++) { - - oCheckbox = oElement[n]; - - if(oCheckbox.checked) { - - aValues[aValues.length] = oCheckbox.value; - - } - - } - - oData[sName] = aValues; - - break; - - } - - } - - } - - } - - } - - - return oData; - -}; - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the Dialog -*/ -YAHOO.widget.Dialog.prototype.toString = function() { - return "Dialog " + this.id; -}; - -/** -* SimpleDialog is a simple implementation of Dialog that can be used to submit a single value. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually. -* @namespace YAHOO.widget -* @class SimpleDialog -* @extends YAHOO.widget.Dialog -* @constructor -* @param {String} el The element ID representing the SimpleDialog <em>OR</em> -* @param {HTMLElement} el The element representing the SimpleDialog -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details. -*/ -YAHOO.widget.SimpleDialog = function(el, userConfig) { - YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog); - -/** -* Constant for the standard network icon for a blocking action -* @property YAHOO.widget.SimpleDialog.ICON_BLOCK -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_BLOCK = "blckicon"; - -/** -* Constant for the standard network icon for alarm -* @property YAHOO.widget.SimpleDialog.ICON_ALARM -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_ALARM = "alrticon"; - -/** -* Constant for the standard network icon for help -* @property YAHOO.widget.SimpleDialog.ICON_HELP -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_HELP = "hlpicon"; - -/** -* Constant for the standard network icon for info -* @property YAHOO.widget.SimpleDialog.ICON_INFO -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_INFO = "infoicon"; - -/** -* Constant for the standard network icon for warn -* @property YAHOO.widget.SimpleDialog.ICON_WARN -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_WARN = "warnicon"; - -/** -* Constant for the standard network icon for a tip -* @property YAHOO.widget.SimpleDialog.ICON_TIP -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_TIP = "tipicon"; - -/** -* Constant representing the default CSS class used for a SimpleDialog -* @property YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "yui-simple-dialog"; - -/** -* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() { - YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this); - - // Add dialog config properties // - - /** - * Sets the informational icon for the SimpleDialog - * @config icon - * @type String - * @default "none" - */ - this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } ); - - /** - * Sets the text for the SimpleDialog - * @config text - * @type String - * @default "" - */ - this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } ); -}; - - -/** -* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the SimpleDialog <em>OR</em> -* @param {HTMLElement} el The element representing the SimpleDialog -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details. -*/ -YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) { - YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG); - - this.cfg.queueProperty("postmethod", "manual"); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.beforeRenderEvent.subscribe(function() { - if (! this.body) { - this.setBody(""); - } - }, this, true); - - this.initEvent.fire(YAHOO.widget.SimpleDialog); - -}; -/** -* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field. -* @method registerForm -*/ -YAHOO.widget.SimpleDialog.prototype.registerForm = function() { - YAHOO.widget.SimpleDialog.superclass.registerForm.call(this); - this.form.innerHTML += "<input type=\"hidden\" name=\"" + this.id + "\" value=\"\"/>"; -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Fired when the "icon" property is set. -* @method configIcon -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) { - var icon = args[0]; - if (icon && icon != "none") { - var iconHTML = ""; - if (icon.indexOf(".") == -1) { - iconHTML = "<span class=\"yui-icon " + icon +"\" > </span>"; - } else { - iconHTML = "<img src=\"" + this.imageRoot + icon + "\" class=\"yui-icon\" />"; - } - this.body.innerHTML = iconHTML + this.body.innerHTML; - } -}; - -/** -* Fired when the "text" property is set. -* @method configText -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) { - var text = args[0]; - if (text) { - this.setBody(text); - this.cfg.refireEvent("icon"); - } -}; -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the SimpleDialog -*/ -YAHOO.widget.SimpleDialog.prototype.toString = function() { - return "SimpleDialog " + this.id; -}; - -/** -* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden. -* @namespace YAHOO.widget -* @class ContainerEffect -* @constructor -* @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with -* @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element. -* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion. -*/ -YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) { - if (! animClass) { - animClass = YAHOO.util.Anim; - } - - /** - * The overlay to animate - * @property overlay - * @type YAHOO.widget.Overlay - */ - this.overlay = overlay; - /** - * The animation attributes to use when transitioning into view - * @property attrIn - * @type Object - */ - this.attrIn = attrIn; - /** - * The animation attributes to use when transitioning out of view - * @property attrOut - * @type Object - */ - this.attrOut = attrOut; - /** - * The target element to be animated - * @property targetElement - * @type HTMLElement - */ - this.targetElement = targetElement || overlay.element; - /** - * The animation class to use for animating the overlay - * @property animClass - * @type class - */ - this.animClass = animClass; -}; - -/** -* Initializes the animation classes and events. -* @method init -*/ -YAHOO.widget.ContainerEffect.prototype.init = function() { - this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn"); - this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut"); - - this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete"); - this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete"); - - this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method); - this.animIn.onStart.subscribe(this.handleStartAnimateIn, this); - this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this); - this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this); - - this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method); - this.animOut.onStart.subscribe(this.handleStartAnimateOut, this); - this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this); - this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this); -}; - -/** -* Triggers the in-animation. -* @method animateIn -*/ -YAHOO.widget.ContainerEffect.prototype.animateIn = function() { - this.beforeAnimateInEvent.fire(); - this.animIn.animate(); -}; - -/** -* Triggers the out-animation. -* @method animateOut -*/ -YAHOO.widget.ContainerEffect.prototype.animateOut = function() { - this.beforeAnimateOutEvent.fire(); - this.animOut.animate(); -}; - -/** -* The default onStart handler for the in-animation. -* @method handleStartAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { }; -/** -* The default onTween handler for the in-animation. -* @method handleTweenAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { }; -/** -* The default onComplete handler for the in-animation. -* @method handleCompleteAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { }; - -/** -* The default onStart handler for the out-animation. -* @method handleStartAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { }; -/** -* The default onTween handler for the out-animation. -* @method handleTweenAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { }; -/** -* The default onComplete handler for the out-animation. -* @method handleCompleteAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { }; - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the ContainerEffect -*/ -YAHOO.widget.ContainerEffect.prototype.toString = function() { - var output = "ContainerEffect"; - if (this.overlay) { - output += " [" + this.overlay.toString() + "]"; - } - return output; -}; - -/** -* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out. -* @method FADE -* @static -* @param {Overlay} overlay The Overlay object to animate -* @param {Number} dur The duration of the animation -* @return {ContainerEffect} The configured ContainerEffect object -*/ -YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) { - var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element ); - - fade.handleStartAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (! obj.overlay.underlay) { - obj.overlay.cfg.refireEvent("underlay"); - } - - if (obj.overlay.underlay) { - obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity"); - obj.overlay.underlay.style.filter = null; - } - - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0); - }; - - fade.handleCompleteAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - - if (obj.overlay.underlay) { - YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity); - } - - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - }; - - fade.handleStartAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.underlay) { - obj.overlay.underlay.style.filter = null; - } - }; - - fade.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1); - - obj.overlay.cfg.refireEvent("iframe"); - - obj.animateOutCompleteEvent.fire(); - }; - - fade.init(); - return fade; -}; - - -/** -* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out. -* @method SLIDE -* @static -* @param {Overlay} overlay The Overlay object to animate -* @param {Number} dur The duration of the animation -* @return {ContainerEffect} The configured ContainerEffect object -*/ -YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) { - var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element); - var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element); - - var clientWidth = YAHOO.util.Dom.getClientWidth(); - var offsetWidth = overlay.element.offsetWidth; - - var slide = new YAHOO.widget.ContainerEffect(overlay, { - attributes:{ points: { to:[x, y] } }, - duration:dur, - method:YAHOO.util.Easing.easeIn - }, - { - attributes:{ points: { to:[(clientWidth+25), y] } }, - duration:dur, - method:YAHOO.util.Easing.easeOut - }, - overlay.element, - YAHOO.util.Motion); - - - slide.handleStartAnimateIn = function(type,args,obj) { - obj.overlay.element.style.left = (-25-offsetWidth) + "px"; - obj.overlay.element.style.top = y + "px"; - }; - - slide.handleTweenAnimateIn = function(type, args, obj) { - - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var currentX = pos[0]; - var currentY = pos[1]; - - if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - } - - obj.overlay.cfg.setProperty("xy", [currentX,currentY], true); - obj.overlay.cfg.refireEvent("iframe"); - }; - - slide.handleCompleteAnimateIn = function(type, args, obj) { - obj.overlay.cfg.setProperty("xy", [x,y], true); - obj.startX = x; - obj.startY = y; - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - }; - - slide.handleStartAnimateOut = function(type, args, obj) { - var vw = YAHOO.util.Dom.getViewportWidth(); - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var yso = pos[1]; - - var currentTo = obj.animOut.attributes.points.to; - obj.animOut.attributes.points.to = [(vw+25), yso]; - }; - - slide.handleTweenAnimateOut = function(type, args, obj) { - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var xto = pos[0]; - var yto = pos[1]; - - obj.overlay.cfg.setProperty("xy", [xto,yto], true); - obj.overlay.cfg.refireEvent("iframe"); - }; - - slide.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - - obj.overlay.cfg.setProperty("xy", [x,y]); - obj.animateOutCompleteEvent.fire(); - }; - - slide.init(); - return slide; -}; - -YAHOO.register("container", YAHOO.widget.Module, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/container/container-min.js b/interface/web/js/yui/container/container-min.js deleted file mode 100644 index 928553b48b..0000000000 --- a/interface/web/js/yui/container/container-min.js +++ /dev/null @@ -1,159 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var queueItemKey=queueItem[0];var queueItemValue=queueItem[1];if(queueItemKey.toLowerCase()==key){eventQueue[i]=null;eventQueue.push([key,(typeof value!='undefined'?value:queueItemValue)]);foundDuplicate=true;break;}}} -if(!foundDuplicate&&typeof value!='undefined'){eventQueue.push([key,value]);}} -if(property.supercedes){for(var s=0;s<property.supercedes.length;s++){var supercedesCheck=property.supercedes[s];for(var q=0;q<eventQueue.length;q++){var queueItemCheck=eventQueue[q];if(queueItemCheck){var queueItemCheckKey=queueItemCheck[0];var queueItemCheckValue=queueItemCheck[1];if(queueItemCheckKey.toLowerCase()==supercedesCheck.toLowerCase()){eventQueue.push([queueItemCheckKey,queueItemCheckValue]);eventQueue[q]=null;break;}}}}} -return true;}else{return false;}};this.refireEvent=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event&&typeof property.value!='undefined'){if(this.queueInProgress){this.queueProperty(key);}else{fireEvent(key,property.value);}}};this.applyConfig=function(userConfig,init){if(init){initialConfig=userConfig;} -for(var prop in userConfig){this.queueProperty(prop,userConfig[prop]);}};this.refresh=function(){for(var prop in config){this.refireEvent(prop);}};this.fireQueue=function(){this.queueInProgress=true;for(var i=0;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var key=queueItem[0];var value=queueItem[1];var property=config[key];property.value=value;fireEvent(key,value);}} -this.queueInProgress=false;eventQueue=[];};this.subscribeToConfigEvent=function(key,handler,obj,override){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(!YAHOO.util.Config.alreadySubscribed(property.event,handler,obj)){property.event.subscribe(handler,obj,override);} -return true;}else{return false;}};this.unsubscribeFromConfigEvent=function(key,handler,obj){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){return property.event.unsubscribe(handler,obj);}else{return false;}};this.toString=function(){var output="Config";if(this.owner){output+=" ["+this.owner.toString()+"]";} -return output;};this.outputEventQueue=function(){var output="";for(var q=0;q<eventQueue.length;q++){var queueItem=eventQueue[q];if(queueItem){output+=queueItem[0]+"="+queueItem[1]+", ";}} -return output;};};YAHOO.util.Config.alreadySubscribed=function(evt,fn,obj){for(var e=0;e<evt.subscribers.length;e++){var subsc=evt.subscribers[e];if(subsc&&subsc.obj==obj&&subsc.fn==fn){return true;}} -return false;};YAHOO.widget.Module=function(el,userConfig){if(el){this.init(el,userConfig);}else{}};YAHOO.widget.Module.IMG_ROOT=null;YAHOO.widget.Module.IMG_ROOT_SSL=null;YAHOO.widget.Module.CSS_MODULE="module";YAHOO.widget.Module.CSS_HEADER="hd";YAHOO.widget.Module.CSS_BODY="bd";YAHOO.widget.Module.CSS_FOOTER="ft";YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL="javascript:false;";YAHOO.widget.Module.textResizeEvent=new YAHOO.util.CustomEvent("textResize");YAHOO.widget.Module.prototype={constructor:YAHOO.widget.Module,element:null,header:null,body:null,footer:null,id:null,imageRoot:YAHOO.widget.Module.IMG_ROOT,initEvents:function(){this.beforeInitEvent=new YAHOO.util.CustomEvent("beforeInit");this.initEvent=new YAHOO.util.CustomEvent("init");this.appendEvent=new YAHOO.util.CustomEvent("append");this.beforeRenderEvent=new YAHOO.util.CustomEvent("beforeRender");this.renderEvent=new YAHOO.util.CustomEvent("render");this.changeHeaderEvent=new YAHOO.util.CustomEvent("changeHeader");this.changeBodyEvent=new YAHOO.util.CustomEvent("changeBody");this.changeFooterEvent=new YAHOO.util.CustomEvent("changeFooter");this.changeContentEvent=new YAHOO.util.CustomEvent("changeContent");this.destroyEvent=new YAHOO.util.CustomEvent("destroy");this.beforeShowEvent=new YAHOO.util.CustomEvent("beforeShow");this.showEvent=new YAHOO.util.CustomEvent("show");this.beforeHideEvent=new YAHOO.util.CustomEvent("beforeHide");this.hideEvent=new YAHOO.util.CustomEvent("hide");},platform:function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1){return"windows";}else if(ua.indexOf("macintosh")!=-1){return"mac";}else{return false;}}(),browser:function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('opera')!=-1){return'opera';}else if(ua.indexOf('msie 7')!=-1){return'ie7';}else if(ua.indexOf('msie')!=-1){return'ie';}else if(ua.indexOf('safari')!=-1){return'safari';}else if(ua.indexOf('gecko')!=-1){return'gecko';}else{return false;}}(),isSecure:function(){if(window.location.href.toLowerCase().indexOf("https")===0){return true;}else{return false;}}(),initDefaultConfig:function(){this.cfg.addProperty("visible",{value:true,handler:this.configVisible,validator:this.cfg.checkBoolean});this.cfg.addProperty("effect",{suppressEvent:true,supercedes:["visible"]});this.cfg.addProperty("monitorresize",{value:true,handler:this.configMonitorResize});},init:function(el,userConfig){this.initEvents();this.beforeInitEvent.fire(YAHOO.widget.Module);this.cfg=new YAHOO.util.Config(this);if(this.isSecure){this.imageRoot=YAHOO.widget.Module.IMG_ROOT_SSL;} -if(typeof el=="string"){var elId=el;el=document.getElementById(el);if(!el){el=document.createElement("div");el.id=elId;}} -this.element=el;if(el.id){this.id=el.id;} -var childNodes=this.element.childNodes;if(childNodes){for(var i=0;i<childNodes.length;i++){var child=childNodes[i];switch(child.className){case YAHOO.widget.Module.CSS_HEADER:this.header=child;break;case YAHOO.widget.Module.CSS_BODY:this.body=child;break;case YAHOO.widget.Module.CSS_FOOTER:this.footer=child;break;}}} -this.initDefaultConfig();YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Module.CSS_MODULE);if(userConfig){this.cfg.applyConfig(userConfig,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.renderEvent,this.cfg.fireQueue,this.cfg)){this.renderEvent.subscribe(this.cfg.fireQueue,this.cfg,true);} -this.initEvent.fire(YAHOO.widget.Module);},initResizeMonitor:function(){if(this.browser!="opera"){var resizeMonitor=document.getElementById("_yuiResizeMonitor");if(!resizeMonitor){resizeMonitor=document.createElement("iframe");var bIE=(this.browser.indexOf("ie")===0);if(this.isSecure&&YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL&&bIE){resizeMonitor.src=YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL;} -resizeMonitor.id="_yuiResizeMonitor";resizeMonitor.style.visibility="hidden";document.body.appendChild(resizeMonitor);resizeMonitor.style.width="10em";resizeMonitor.style.height="10em";resizeMonitor.style.position="absolute";var nLeft=-1*resizeMonitor.offsetWidth;var nTop=-1*resizeMonitor.offsetHeight;resizeMonitor.style.top=nTop+"px";resizeMonitor.style.left=nLeft+"px";resizeMonitor.style.borderStyle="none";resizeMonitor.style.borderWidth="0";YAHOO.util.Dom.setStyle(resizeMonitor,"opacity","0");resizeMonitor.style.visibility="visible";if(!bIE){var doc=resizeMonitor.contentWindow.document;doc.open();doc.close();}} -var fireTextResize=function(){YAHOO.widget.Module.textResizeEvent.fire();};if(resizeMonitor&&resizeMonitor.contentWindow){this.resizeMonitor=resizeMonitor;YAHOO.widget.Module.textResizeEvent.subscribe(this.onDomResize,this,true);if(!YAHOO.widget.Module.textResizeInitialized){if(!YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow,"resize",fireTextResize)){YAHOO.util.Event.addListener(this.resizeMonitor,"resize",fireTextResize);} -YAHOO.widget.Module.textResizeInitialized=true;}}}},onDomResize:function(e,obj){var nLeft=-1*this.resizeMonitor.offsetWidth,nTop=-1*this.resizeMonitor.offsetHeight;this.resizeMonitor.style.top=nTop+"px";this.resizeMonitor.style.left=nLeft+"px";},setHeader:function(headerContent){if(!this.header){this.header=document.createElement("div");this.header.className=YAHOO.widget.Module.CSS_HEADER;} -if(typeof headerContent=="string"){this.header.innerHTML=headerContent;}else{this.header.innerHTML="";this.header.appendChild(headerContent);} -this.changeHeaderEvent.fire(headerContent);this.changeContentEvent.fire();},appendToHeader:function(element){if(!this.header){this.header=document.createElement("div");this.header.className=YAHOO.widget.Module.CSS_HEADER;} -this.header.appendChild(element);this.changeHeaderEvent.fire(element);this.changeContentEvent.fire();},setBody:function(bodyContent){if(!this.body){this.body=document.createElement("div");this.body.className=YAHOO.widget.Module.CSS_BODY;} -if(typeof bodyContent=="string") -{this.body.innerHTML=bodyContent;}else{this.body.innerHTML="";this.body.appendChild(bodyContent);} -this.changeBodyEvent.fire(bodyContent);this.changeContentEvent.fire();},appendToBody:function(element){if(!this.body){this.body=document.createElement("div");this.body.className=YAHOO.widget.Module.CSS_BODY;} -this.body.appendChild(element);this.changeBodyEvent.fire(element);this.changeContentEvent.fire();},setFooter:function(footerContent){if(!this.footer){this.footer=document.createElement("div");this.footer.className=YAHOO.widget.Module.CSS_FOOTER;} -if(typeof footerContent=="string"){this.footer.innerHTML=footerContent;}else{this.footer.innerHTML="";this.footer.appendChild(footerContent);} -this.changeFooterEvent.fire(footerContent);this.changeContentEvent.fire();},appendToFooter:function(element){if(!this.footer){this.footer=document.createElement("div");this.footer.className=YAHOO.widget.Module.CSS_FOOTER;} -this.footer.appendChild(element);this.changeFooterEvent.fire(element);this.changeContentEvent.fire();},render:function(appendToNode,moduleElement){this.beforeRenderEvent.fire();if(!moduleElement){moduleElement=this.element;} -var me=this;var appendTo=function(element){if(typeof element=="string"){element=document.getElementById(element);} -if(element){element.appendChild(me.element);me.appendEvent.fire();}};if(appendToNode){appendTo(appendToNode);}else{if(!YAHOO.util.Dom.inDocument(this.element)){return false;}} -if(this.header&&!YAHOO.util.Dom.inDocument(this.header)){var firstChild=moduleElement.firstChild;if(firstChild){moduleElement.insertBefore(this.header,firstChild);}else{moduleElement.appendChild(this.header);}} -if(this.body&&!YAHOO.util.Dom.inDocument(this.body)){if(this.footer&&YAHOO.util.Dom.isAncestor(this.moduleElement,this.footer)){moduleElement.insertBefore(this.body,this.footer);}else{moduleElement.appendChild(this.body);}} -if(this.footer&&!YAHOO.util.Dom.inDocument(this.footer)){moduleElement.appendChild(this.footer);} -this.renderEvent.fire();return true;},destroy:function(){var parent;if(this.element){YAHOO.util.Event.purgeElement(this.element,true);parent=this.element.parentNode;} -if(parent){parent.removeChild(this.element);} -this.element=null;this.header=null;this.body=null;this.footer=null;for(var e in this){if(e instanceof YAHOO.util.CustomEvent){e.unsubscribeAll();}} -YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize,this);this.destroyEvent.fire();},show:function(){this.cfg.setProperty("visible",true);},hide:function(){this.cfg.setProperty("visible",false);},configVisible:function(type,args,obj){var visible=args[0];if(visible){this.beforeShowEvent.fire();YAHOO.util.Dom.setStyle(this.element,"display","block");this.showEvent.fire();}else{this.beforeHideEvent.fire();YAHOO.util.Dom.setStyle(this.element,"display","none");this.hideEvent.fire();}},configMonitorResize:function(type,args,obj){var monitor=args[0];if(monitor){this.initResizeMonitor();}else{YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize,this,true);this.resizeMonitor=null;}}};YAHOO.widget.Module.prototype.toString=function(){return"Module "+this.id;};YAHOO.widget.Overlay=function(el,userConfig){YAHOO.widget.Overlay.superclass.constructor.call(this,el,userConfig);};YAHOO.extend(YAHOO.widget.Overlay,YAHOO.widget.Module);YAHOO.widget.Overlay.IFRAME_SRC="javascript:false;";YAHOO.widget.Overlay.TOP_LEFT="tl";YAHOO.widget.Overlay.TOP_RIGHT="tr";YAHOO.widget.Overlay.BOTTOM_LEFT="bl";YAHOO.widget.Overlay.BOTTOM_RIGHT="br";YAHOO.widget.Overlay.CSS_OVERLAY="yui-overlay";YAHOO.widget.Overlay.prototype.init=function(el,userConfig){YAHOO.widget.Overlay.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Overlay);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Overlay.CSS_OVERLAY);if(userConfig){this.cfg.applyConfig(userConfig,true);} -if(this.platform=="mac"&&this.browser=="gecko"){if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)){this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)){this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);}} -this.initEvent.fire(YAHOO.widget.Overlay);};YAHOO.widget.Overlay.prototype.initEvents=function(){YAHOO.widget.Overlay.superclass.initEvents.call(this);this.beforeMoveEvent=new YAHOO.util.CustomEvent("beforeMove",this);this.moveEvent=new YAHOO.util.CustomEvent("move",this);};YAHOO.widget.Overlay.prototype.initDefaultConfig=function(){YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);this.cfg.addProperty("x",{handler:this.configX,validator:this.cfg.checkNumber,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("y",{handler:this.configY,validator:this.cfg.checkNumber,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("xy",{handler:this.configXY,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("context",{handler:this.configContext,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("fixedcenter",{value:false,handler:this.configFixedCenter,validator:this.cfg.checkBoolean,supercedes:["iframe","visible"]});this.cfg.addProperty("width",{handler:this.configWidth,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("height",{handler:this.configHeight,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("zIndex",{value:null,handler:this.configzIndex});this.cfg.addProperty("constraintoviewport",{value:false,handler:this.configConstrainToViewport,validator:this.cfg.checkBoolean,supercedes:["iframe","x","y","xy"]});this.cfg.addProperty("iframe",{value:(this.browser=="ie"?true:false),handler:this.configIframe,validator:this.cfg.checkBoolean,supercedes:["zIndex"]});};YAHOO.widget.Overlay.prototype.moveTo=function(x,y){this.cfg.setProperty("xy",[x,y]);};YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars=function(){YAHOO.util.Dom.removeClass(this.element,"show-scrollbars");YAHOO.util.Dom.addClass(this.element,"hide-scrollbars");};YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars=function(){YAHOO.util.Dom.removeClass(this.element,"hide-scrollbars");YAHOO.util.Dom.addClass(this.element,"show-scrollbars");};YAHOO.widget.Overlay.prototype.configVisible=function(type,args,obj){var visible=args[0];var currentVis=YAHOO.util.Dom.getStyle(this.element,"visibility");if(currentVis=="inherit"){var e=this.element.parentNode;while(e.nodeType!=9&&e.nodeType!=11){currentVis=YAHOO.util.Dom.getStyle(e,"visibility");if(currentVis!="inherit"){break;} -e=e.parentNode;} -if(currentVis=="inherit"){currentVis="visible";}} -var effect=this.cfg.getProperty("effect");var effectInstances=[];if(effect){if(effect instanceof Array){for(var i=0;i<effect.length;i++){var eff=effect[i];effectInstances[effectInstances.length]=eff.effect(this,eff.duration);}}else{effectInstances[effectInstances.length]=effect.effect(this,effect.duration);}} -var isMacGecko=(this.platform=="mac"&&this.browser=="gecko");if(visible){if(isMacGecko){this.showMacGeckoScrollbars();} -if(effect){if(visible){if(currentVis!="visible"||currentVis===""){this.beforeShowEvent.fire();for(var j=0;j<effectInstances.length;j++){var ei=effectInstances[j];if(j===0&&!YAHOO.util.Config.alreadySubscribed(ei.animateInCompleteEvent,this.showEvent.fire,this.showEvent)){ei.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true);} -ei.animateIn();}}}}else{if(currentVis!="visible"||currentVis===""){this.beforeShowEvent.fire();YAHOO.util.Dom.setStyle(this.element,"visibility","visible");this.cfg.refireEvent("iframe");this.showEvent.fire();}}}else{if(isMacGecko){this.hideMacGeckoScrollbars();} -if(effect){if(currentVis=="visible"){this.beforeHideEvent.fire();for(var k=0;k<effectInstances.length;k++){var h=effectInstances[k];if(k===0&&!YAHOO.util.Config.alreadySubscribed(h.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)){h.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true);} -h.animateOut();}}else if(currentVis===""){YAHOO.util.Dom.setStyle(this.element,"visibility","hidden");}}else{if(currentVis=="visible"||currentVis===""){this.beforeHideEvent.fire();YAHOO.util.Dom.setStyle(this.element,"visibility","hidden");this.cfg.refireEvent("iframe");this.hideEvent.fire();}}}};YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent=function(){if(this.cfg.getProperty("visible")){this.center();}};YAHOO.widget.Overlay.prototype.configFixedCenter=function(type,args,obj){var val=args[0];if(val){this.center();if(!YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent,this.center,this)){this.beforeShowEvent.subscribe(this.center,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent,this.doCenterOnDOMEvent,this)){YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent,this.doCenterOnDOMEvent,this)){YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.doCenterOnDOMEvent,this,true);}}else{YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);}};YAHOO.widget.Overlay.prototype.configHeight=function(type,args,obj){var height=args[0];var el=this.element;YAHOO.util.Dom.setStyle(el,"height",height);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.configWidth=function(type,args,obj){var width=args[0];var el=this.element;YAHOO.util.Dom.setStyle(el,"width",width);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.configzIndex=function(type,args,obj){var zIndex=args[0];var el=this.element;if(!zIndex){zIndex=YAHOO.util.Dom.getStyle(el,"zIndex");if(!zIndex||isNaN(zIndex)){zIndex=0;}} -if(this.iframe){if(zIndex<=0){zIndex=1;} -YAHOO.util.Dom.setStyle(this.iframe,"zIndex",(zIndex-1));} -YAHOO.util.Dom.setStyle(el,"zIndex",zIndex);this.cfg.setProperty("zIndex",zIndex,true);};YAHOO.widget.Overlay.prototype.configXY=function(type,args,obj){var pos=args[0];var x=pos[0];var y=pos[1];this.cfg.setProperty("x",x);this.cfg.setProperty("y",y);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);};YAHOO.widget.Overlay.prototype.configX=function(type,args,obj){var x=args[0];var y=this.cfg.getProperty("y");this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");YAHOO.util.Dom.setX(this.element,x,true);this.cfg.setProperty("xy",[x,y],true);this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);};YAHOO.widget.Overlay.prototype.configY=function(type,args,obj){var x=this.cfg.getProperty("x");var y=args[0];this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");YAHOO.util.Dom.setY(this.element,y,true);this.cfg.setProperty("xy",[x,y],true);this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);};YAHOO.widget.Overlay.prototype.showIframe=function(){if(this.iframe){this.iframe.style.display="block";}};YAHOO.widget.Overlay.prototype.hideIframe=function(){if(this.iframe){this.iframe.style.display="none";}};YAHOO.widget.Overlay.prototype.configIframe=function(type,args,obj){var val=args[0];if(val){if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showIframe,this)){this.showEvent.subscribe(this.showIframe,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideIframe,this)){this.hideEvent.subscribe(this.hideIframe,this,true);} -var x=this.cfg.getProperty("x");var y=this.cfg.getProperty("y");if(!x||!y){this.syncPosition();x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");} -if(!isNaN(x)&&!isNaN(y)){if(!this.iframe){this.iframe=document.createElement("iframe");if(this.isSecure){this.iframe.src=YAHOO.widget.Overlay.IFRAME_SRC;} -var parent=this.element.parentNode;if(parent){parent.appendChild(this.iframe);}else{document.body.appendChild(this.iframe);} -YAHOO.util.Dom.setStyle(this.iframe,"position","absolute");YAHOO.util.Dom.setStyle(this.iframe,"border","none");YAHOO.util.Dom.setStyle(this.iframe,"margin","0");YAHOO.util.Dom.setStyle(this.iframe,"padding","0");YAHOO.util.Dom.setStyle(this.iframe,"opacity","0");if(this.cfg.getProperty("visible")){this.showIframe();}else{this.hideIframe();}} -var iframeDisplay=YAHOO.util.Dom.getStyle(this.iframe,"display");if(iframeDisplay=="none"){this.iframe.style.display="block";} -YAHOO.util.Dom.setXY(this.iframe,[x,y]);var width=this.element.clientWidth;var height=this.element.clientHeight;YAHOO.util.Dom.setStyle(this.iframe,"width",(width+2)+"px");YAHOO.util.Dom.setStyle(this.iframe,"height",(height+2)+"px");if(iframeDisplay=="none"){this.iframe.style.display="none";}}}else{if(this.iframe){this.iframe.style.display="none";} -this.showEvent.unsubscribe(this.showIframe,this);this.hideEvent.unsubscribe(this.hideIframe,this);}};YAHOO.widget.Overlay.prototype.configConstrainToViewport=function(type,args,obj){var val=args[0];if(val){if(!YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent,this.enforceConstraints,this)){this.beforeMoveEvent.subscribe(this.enforceConstraints,this,true);}}else{this.beforeMoveEvent.unsubscribe(this.enforceConstraints,this);}};YAHOO.widget.Overlay.prototype.configContext=function(type,args,obj){var contextArgs=args[0];if(contextArgs){var contextEl=contextArgs[0];var elementMagnetCorner=contextArgs[1];var contextMagnetCorner=contextArgs[2];if(contextEl){if(typeof contextEl=="string"){this.cfg.setProperty("context",[document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner],true);} -if(elementMagnetCorner&&contextMagnetCorner){this.align(elementMagnetCorner,contextMagnetCorner);}}}};YAHOO.widget.Overlay.prototype.align=function(elementAlign,contextAlign){var contextArgs=this.cfg.getProperty("context");if(contextArgs){var context=contextArgs[0];var element=this.element;var me=this;if(!elementAlign){elementAlign=contextArgs[1];} -if(!contextAlign){contextAlign=contextArgs[2];} -if(element&&context){var contextRegion=YAHOO.util.Dom.getRegion(context);var doAlign=function(v,h){switch(elementAlign){case YAHOO.widget.Overlay.TOP_LEFT:me.moveTo(h,v);break;case YAHOO.widget.Overlay.TOP_RIGHT:me.moveTo(h-element.offsetWidth,v);break;case YAHOO.widget.Overlay.BOTTOM_LEFT:me.moveTo(h,v-element.offsetHeight);break;case YAHOO.widget.Overlay.BOTTOM_RIGHT:me.moveTo(h-element.offsetWidth,v-element.offsetHeight);break;}};switch(contextAlign){case YAHOO.widget.Overlay.TOP_LEFT:doAlign(contextRegion.top,contextRegion.left);break;case YAHOO.widget.Overlay.TOP_RIGHT:doAlign(contextRegion.top,contextRegion.right);break;case YAHOO.widget.Overlay.BOTTOM_LEFT:doAlign(contextRegion.bottom,contextRegion.left);break;case YAHOO.widget.Overlay.BOTTOM_RIGHT:doAlign(contextRegion.bottom,contextRegion.right);break;}}}};YAHOO.widget.Overlay.prototype.enforceConstraints=function(type,args,obj){var pos=args[0];var x=pos[0];var y=pos[1];var offsetHeight=this.element.offsetHeight;var offsetWidth=this.element.offsetWidth;var viewPortWidth=YAHOO.util.Dom.getViewportWidth();var viewPortHeight=YAHOO.util.Dom.getViewportHeight();var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var topConstraint=scrollY+10;var leftConstraint=scrollX+10;var bottomConstraint=scrollY+viewPortHeight-offsetHeight-10;var rightConstraint=scrollX+viewPortWidth-offsetWidth-10;if(x<leftConstraint){x=leftConstraint;}else if(x>rightConstraint){x=rightConstraint;} -if(y<topConstraint){y=topConstraint;}else if(y>bottomConstraint){y=bottomConstraint;} -this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.cfg.setProperty("xy",[x,y],true);};YAHOO.widget.Overlay.prototype.center=function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var x=(viewPortWidth/2)-(elementWidth/2)+scrollX;var y=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.cfg.setProperty("xy",[parseInt(x,10),parseInt(y,10)]);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.syncPosition=function(){var pos=YAHOO.util.Dom.getXY(this.element);this.cfg.setProperty("x",pos[0],true);this.cfg.setProperty("y",pos[1],true);this.cfg.setProperty("xy",pos,true);};YAHOO.widget.Overlay.prototype.onDomResize=function(e,obj){YAHOO.widget.Overlay.superclass.onDomResize.call(this,e,obj);var me=this;setTimeout(function(){me.syncPosition();me.cfg.refireEvent("iframe");me.cfg.refireEvent("context");},0);};YAHOO.widget.Overlay.prototype.destroy=function(){if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);} -this.iframe=null;YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.superclass.destroy.call(this);};YAHOO.widget.Overlay.prototype.toString=function(){return"Overlay "+this.id;};YAHOO.widget.Overlay.windowScrollEvent=new YAHOO.util.CustomEvent("windowScroll");YAHOO.widget.Overlay.windowResizeEvent=new YAHOO.util.CustomEvent("windowResize");YAHOO.widget.Overlay.windowScrollHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.scrollEnd){window.scrollEnd=-1;} -clearTimeout(window.scrollEnd);window.scrollEnd=setTimeout(function(){YAHOO.widget.Overlay.windowScrollEvent.fire();},1);}else{YAHOO.widget.Overlay.windowScrollEvent.fire();}};YAHOO.widget.Overlay.windowResizeHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.resizeEnd){window.resizeEnd=-1;} -clearTimeout(window.resizeEnd);window.resizeEnd=setTimeout(function(){YAHOO.widget.Overlay.windowResizeEvent.fire();},100);}else{YAHOO.widget.Overlay.windowResizeEvent.fire();}};YAHOO.widget.Overlay._initialized=null;if(YAHOO.widget.Overlay._initialized===null){YAHOO.util.Event.addListener(window,"scroll",YAHOO.widget.Overlay.windowScrollHandler);YAHOO.util.Event.addListener(window,"resize",YAHOO.widget.Overlay.windowResizeHandler);YAHOO.widget.Overlay._initialized=true;} -YAHOO.widget.OverlayManager=function(userConfig){this.init(userConfig);};YAHOO.widget.OverlayManager.CSS_FOCUSED="focused";YAHOO.widget.OverlayManager.prototype={constructor:YAHOO.widget.OverlayManager,overlays:null,initDefaultConfig:function(){this.cfg.addProperty("overlays",{suppressEvent:true});this.cfg.addProperty("focusevent",{value:"mousedown"});},init:function(userConfig){this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();if(userConfig){this.cfg.applyConfig(userConfig,true);} -this.cfg.fireQueue();var activeOverlay=null;this.getActive=function(){return activeOverlay;};this.focus=function(overlay){var o=this.find(overlay);if(o){this.blurAll();activeOverlay=o;YAHOO.util.Dom.addClass(activeOverlay.element,YAHOO.widget.OverlayManager.CSS_FOCUSED);this.overlays.sort(this.compareZIndexDesc);var topZIndex=YAHOO.util.Dom.getStyle(this.overlays[0].element,"zIndex");if(!isNaN(topZIndex)&&this.overlays[0]!=overlay){activeOverlay.cfg.setProperty("zIndex",(parseInt(topZIndex,10)+2));} -this.overlays.sort(this.compareZIndexDesc);}};this.remove=function(overlay){var o=this.find(overlay);if(o){var originalZ=YAHOO.util.Dom.getStyle(o.element,"zIndex");o.cfg.setProperty("zIndex",-1000,true);this.overlays.sort(this.compareZIndexDesc);this.overlays=this.overlays.slice(0,this.overlays.length-1);o.cfg.setProperty("zIndex",originalZ,true);o.cfg.setProperty("manager",null);o.focusEvent=null;o.blurEvent=null;o.focus=null;o.blur=null;}};this.blurAll=function(){activeOverlay=null;for(var o=0;o<this.overlays.length;o++){YAHOO.util.Dom.removeClass(this.overlays[o].element,YAHOO.widget.OverlayManager.CSS_FOCUSED);}};var overlays=this.cfg.getProperty("overlays");if(!this.overlays){this.overlays=[];} -if(overlays){this.register(overlays);this.overlays.sort(this.compareZIndexDesc);}},register:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){overlay.cfg.addProperty("manager",{value:this});overlay.focusEvent=new YAHOO.util.CustomEvent("focus");overlay.blurEvent=new YAHOO.util.CustomEvent("blur");var mgr=this;overlay.focus=function(){mgr.focus(this);this.focusEvent.fire();};overlay.blur=function(){mgr.blurAll();this.blurEvent.fire();};var focusOnDomEvent=function(e,obj){overlay.focus();};var focusevent=this.cfg.getProperty("focusevent");YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);var zIndex=YAHOO.util.Dom.getStyle(overlay.element,"zIndex");if(!isNaN(zIndex)){overlay.cfg.setProperty("zIndex",parseInt(zIndex,10));}else{overlay.cfg.setProperty("zIndex",0);} -this.overlays.push(overlay);return true;}else if(overlay instanceof Array){var regcount=0;for(var i=0;i<overlay.length;i++){if(this.register(overlay[i])){regcount++;}} -if(regcount>0){return true;}}else{return false;}},find:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){for(var o=0;o<this.overlays.length;o++){if(this.overlays[o]==overlay){return this.overlays[o];}}}else if(typeof overlay=="string"){for(var p=0;p<this.overlays.length;p++){if(this.overlays[p].id==overlay){return this.overlays[p];}}} -return null;},compareZIndexDesc:function(o1,o2){var zIndex1=o1.cfg.getProperty("zIndex");var zIndex2=o2.cfg.getProperty("zIndex");if(zIndex1>zIndex2){return-1;}else if(zIndex1<zIndex2){return 1;}else{return 0;}},showAll:function(){for(var o=0;o<this.overlays.length;o++){this.overlays[o].show();}},hideAll:function(){for(var o=0;o<this.overlays.length;o++){this.overlays[o].hide();}},toString:function(){return"OverlayManager";}};YAHOO.util.KeyListener=function(attachTo,keyData,handler,event){if(!attachTo){} -if(!keyData){} -if(!handler){} -if(!event){event=YAHOO.util.KeyListener.KEYDOWN;} -var keyEvent=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof attachTo=='string'){attachTo=document.getElementById(attachTo);} -if(typeof handler=='function'){keyEvent.subscribe(handler);}else{keyEvent.subscribe(handler.fn,handler.scope,handler.correctScope);} -function handleKeyPress(e,obj){if(!keyData.shift){keyData.shift=false;} -if(!keyData.alt){keyData.alt=false;} -if(!keyData.ctrl){keyData.ctrl=false;} -if(e.shiftKey==keyData.shift&&e.altKey==keyData.alt&&e.ctrlKey==keyData.ctrl){var dataItem;var keyPressed;if(keyData.keys instanceof Array){for(var i=0;i<keyData.keys.length;i++){dataItem=keyData.keys[i];if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);break;}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);break;}}}else{dataItem=keyData.keys;if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);}}}} -this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(attachTo,event,handleKeyPress);this.enabledEvent.fire(keyData);} -this.enabled=true;};this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(attachTo,event,handleKeyPress);this.disabledEvent.fire(keyData);} -this.enabled=false;};this.toString=function(){return"KeyListener ["+keyData.keys+"] "+attachTo.tagName+(attachTo.id?"["+attachTo.id+"]":"");};};YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.widget.Tooltip=function(el,userConfig){YAHOO.widget.Tooltip.superclass.constructor.call(this,el,userConfig);};YAHOO.extend(YAHOO.widget.Tooltip,YAHOO.widget.Overlay);YAHOO.widget.Tooltip.CSS_TOOLTIP="yui-tt";YAHOO.widget.Tooltip.prototype.init=function(el,userConfig){if(document.readyState&&document.readyState!="complete"){var deferredInit=function(){this.init(el,userConfig);};YAHOO.util.Event.addListener(window,"load",deferredInit,this,true);}else{YAHOO.widget.Tooltip.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Tooltip);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Tooltip.CSS_TOOLTIP);if(userConfig){this.cfg.applyConfig(userConfig,true);} -this.cfg.queueProperty("visible",false);this.cfg.queueProperty("constraintoviewport",true);this.setBody("");this.render(this.cfg.getProperty("container"));this.initEvent.fire(YAHOO.widget.Tooltip);}};YAHOO.widget.Tooltip.prototype.initDefaultConfig=function(){YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);this.cfg.addProperty("preventoverlap",{value:true,validator:this.cfg.checkBoolean,supercedes:["x","y","xy"]});this.cfg.addProperty("showdelay",{value:200,handler:this.configShowDelay,validator:this.cfg.checkNumber});this.cfg.addProperty("autodismissdelay",{value:5000,handler:this.configAutoDismissDelay,validator:this.cfg.checkNumber});this.cfg.addProperty("hidedelay",{value:250,handler:this.configHideDelay,validator:this.cfg.checkNumber});this.cfg.addProperty("text",{handler:this.configText,suppressEvent:true});this.cfg.addProperty("container",{value:document.body,handler:this.configContainer});};YAHOO.widget.Tooltip.prototype.configText=function(type,args,obj){var text=args[0];if(text){this.setBody(text);}};YAHOO.widget.Tooltip.prototype.configContainer=function(type,args,obj){var container=args[0];if(typeof container=='string'){this.cfg.setProperty("container",document.getElementById(container),true);}};YAHOO.widget.Tooltip.prototype.configContext=function(type,args,obj){var context=args[0];if(context){if(!(context instanceof Array)){if(typeof context=="string"){this.cfg.setProperty("context",[document.getElementById(context)],true);}else{this.cfg.setProperty("context",[context],true);} -context=this.cfg.getProperty("context");} -if(this._context){for(var c=0;c<this._context.length;++c){var el=this._context[c];YAHOO.util.Event.removeListener(el,"mouseover",this.onContextMouseOver);YAHOO.util.Event.removeListener(el,"mousemove",this.onContextMouseMove);YAHOO.util.Event.removeListener(el,"mouseout",this.onContextMouseOut);}} -this._context=context;for(var d=0;d<this._context.length;++d){var el2=this._context[d];YAHOO.util.Event.addListener(el2,"mouseover",this.onContextMouseOver,this);YAHOO.util.Event.addListener(el2,"mousemove",this.onContextMouseMove,this);YAHOO.util.Event.addListener(el2,"mouseout",this.onContextMouseOut,this);}}};YAHOO.widget.Tooltip.prototype.onContextMouseMove=function(e,obj){obj.pageX=YAHOO.util.Event.getPageX(e);obj.pageY=YAHOO.util.Event.getPageY(e);};YAHOO.widget.Tooltip.prototype.onContextMouseOver=function(e,obj){if(obj.hideProcId){clearTimeout(obj.hideProcId);obj.hideProcId=null;} -var context=this;YAHOO.util.Event.addListener(context,"mousemove",obj.onContextMouseMove,obj);if(context.title){obj._tempTitle=context.title;context.title="";} -obj.showProcId=obj.doShow(e,context);};YAHOO.widget.Tooltip.prototype.onContextMouseOut=function(e,obj){var el=this;if(obj._tempTitle){el.title=obj._tempTitle;obj._tempTitle=null;} -if(obj.showProcId){clearTimeout(obj.showProcId);obj.showProcId=null;} -if(obj.hideProcId){clearTimeout(obj.hideProcId);obj.hideProcId=null;} -obj.hideProcId=setTimeout(function(){obj.hide();},obj.cfg.getProperty("hidedelay"));};YAHOO.widget.Tooltip.prototype.doShow=function(e,context){var yOffset=25;if(this.browser=="opera"&&context.tagName=="A"){yOffset+=12;} -var me=this;return setTimeout(function(){if(me._tempTitle){me.setBody(me._tempTitle);}else{me.cfg.refireEvent("text");} -me.moveTo(me.pageX,me.pageY+yOffset);if(me.cfg.getProperty("preventoverlap")){me.preventOverlap(me.pageX,me.pageY);} -YAHOO.util.Event.removeListener(context,"mousemove",me.onContextMouseMove);me.show();me.hideProcId=me.doHide();},this.cfg.getProperty("showdelay"));};YAHOO.widget.Tooltip.prototype.doHide=function(){var me=this;return setTimeout(function(){me.hide();},this.cfg.getProperty("autodismissdelay"));};YAHOO.widget.Tooltip.prototype.preventOverlap=function(pageX,pageY){var height=this.element.offsetHeight;var elementRegion=YAHOO.util.Dom.getRegion(this.element);elementRegion.top-=5;elementRegion.left-=5;elementRegion.right+=5;elementRegion.bottom+=5;var mousePoint=new YAHOO.util.Point(pageX,pageY);if(elementRegion.contains(mousePoint)){this.cfg.setProperty("y",(pageY-height-5));}};YAHOO.widget.Tooltip.prototype.toString=function(){return"Tooltip "+this.id;};YAHOO.widget.Panel=function(el,userConfig){YAHOO.widget.Panel.superclass.constructor.call(this,el,userConfig);};YAHOO.extend(YAHOO.widget.Panel,YAHOO.widget.Overlay);YAHOO.widget.Panel.CSS_PANEL="yui-panel";YAHOO.widget.Panel.CSS_PANEL_CONTAINER="yui-panel-container";YAHOO.widget.Panel.prototype.init=function(el,userConfig){YAHOO.widget.Panel.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Panel);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Panel.CSS_PANEL);this.buildWrapper();if(userConfig){this.cfg.applyConfig(userConfig,true);} -this.beforeRenderEvent.subscribe(function(){var draggable=this.cfg.getProperty("draggable");if(draggable){if(!this.header){this.setHeader(" ");}}},this,true);var me=this;var doBlur=function(){this.blur();};this.showMaskEvent.subscribe(function(){var checkFocusable=function(el){if((el.tagName=="A"||el.tagName=="BUTTON"||el.tagName=="SELECT"||el.tagName=="INPUT"||el.tagName=="TEXTAREA")&&el.type!="hidden"){if(!YAHOO.util.Dom.isAncestor(me.element,el)){YAHOO.util.Event.addListener(el,"focus",doBlur,el,true);return true;}}else{return false;}};this.focusableElements=YAHOO.util.Dom.getElementsBy(checkFocusable);},this,true);this.hideMaskEvent.subscribe(function(){for(var i=0;i<this.focusableElements.length;i++){var el2=this.focusableElements[i];YAHOO.util.Event.removeListener(el2,"focus",doBlur);}},this,true);this.beforeShowEvent.subscribe(function(){this.cfg.refireEvent("underlay");},this,true);this.initEvent.fire(YAHOO.widget.Panel);};YAHOO.widget.Panel.prototype.initEvents=function(){YAHOO.widget.Panel.superclass.initEvents.call(this);this.showMaskEvent=new YAHOO.util.CustomEvent("showMask");this.hideMaskEvent=new YAHOO.util.CustomEvent("hideMask");this.dragEvent=new YAHOO.util.CustomEvent("drag");};YAHOO.widget.Panel.prototype.initDefaultConfig=function(){YAHOO.widget.Panel.superclass.initDefaultConfig.call(this);this.cfg.addProperty("close",{value:true,handler:this.configClose,validator:this.cfg.checkBoolean,supercedes:["visible"]});this.cfg.addProperty("draggable",{value:true,handler:this.configDraggable,validator:this.cfg.checkBoolean,supercedes:["visible"]});this.cfg.addProperty("underlay",{value:"shadow",handler:this.configUnderlay,supercedes:["visible"]});this.cfg.addProperty("modal",{value:false,handler:this.configModal,validator:this.cfg.checkBoolean,supercedes:["visible"]});this.cfg.addProperty("keylisteners",{handler:this.configKeyListeners,suppressEvent:true,supercedes:["visible"]});};YAHOO.widget.Panel.prototype.configClose=function(type,args,obj){var val=args[0];var doHide=function(e,obj){obj.hide();};if(val){if(!this.close){this.close=document.createElement("span");YAHOO.util.Dom.addClass(this.close,"container-close");this.close.innerHTML=" ";this.innerElement.appendChild(this.close);YAHOO.util.Event.addListener(this.close,"click",doHide,this);}else{this.close.style.display="block";}}else{if(this.close){this.close.style.display="none";}}};YAHOO.widget.Panel.prototype.configDraggable=function(type,args,obj){var val=args[0];if(val){if(this.header){YAHOO.util.Dom.setStyle(this.header,"cursor","move");this.registerDragDrop();}}else{if(this.dd){this.dd.unreg();} -if(this.header){YAHOO.util.Dom.setStyle(this.header,"cursor","auto");}}};YAHOO.widget.Panel.prototype.configUnderlay=function(type,args,obj){var val=args[0];switch(val.toLowerCase()){case"shadow":YAHOO.util.Dom.removeClass(this.element,"matte");YAHOO.util.Dom.addClass(this.element,"shadow");if(!this.underlay){this.underlay=document.createElement("div");this.underlay.className="underlay";this.underlay.innerHTML=" ";this.element.appendChild(this.underlay);} -this.sizeUnderlay();break;case"matte":YAHOO.util.Dom.removeClass(this.element,"shadow");YAHOO.util.Dom.addClass(this.element,"matte");break;default:YAHOO.util.Dom.removeClass(this.element,"shadow");YAHOO.util.Dom.removeClass(this.element,"matte");break;}};YAHOO.widget.Panel.prototype.configModal=function(type,args,obj){var modal=args[0];if(modal){this.buildMask();if(!YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent,this.showMask,this)){this.beforeShowEvent.subscribe(this.showMask,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMask,this)){this.hideEvent.subscribe(this.hideMask,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent,this.sizeMask,this)){YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.destroyEvent,this.removeMask,this)){this.destroyEvent.subscribe(this.removeMask,this,true);} -this.cfg.refireEvent("zIndex");}else{this.beforeShowEvent.unsubscribe(this.showMask,this);this.hideEvent.unsubscribe(this.hideMask,this);YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask,this);this.destroyEvent.unsubscribe(this.removeMask,this);}};YAHOO.widget.Panel.prototype.removeMask=function(){if(this.mask){if(this.mask.parentNode){this.mask.parentNode.removeChild(this.mask);} -this.mask=null;}};YAHOO.widget.Panel.prototype.configKeyListeners=function(type,args,obj){var listeners=args[0];if(listeners){if(listeners instanceof Array){for(var i=0;i<listeners.length;i++){var listener=listeners[i];if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,listener.enable,listener)){this.showEvent.subscribe(listener.enable,listener,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,listener.disable,listener)){this.hideEvent.subscribe(listener.disable,listener,true);this.destroyEvent.subscribe(listener.disable,listener,true);}}}else{if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,listeners.enable,listeners)){this.showEvent.subscribe(listeners.enable,listeners,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,listeners.disable,listeners)){this.hideEvent.subscribe(listeners.disable,listeners,true);this.destroyEvent.subscribe(listeners.disable,listeners,true);}}}};YAHOO.widget.Panel.prototype.configHeight=function(type,args,obj){var height=args[0];var el=this.innerElement;YAHOO.util.Dom.setStyle(el,"height",height);this.cfg.refireEvent("underlay");this.cfg.refireEvent("iframe");};YAHOO.widget.Panel.prototype.configWidth=function(type,args,obj){var width=args[0];var el=this.innerElement;YAHOO.util.Dom.setStyle(el,"width",width);this.cfg.refireEvent("underlay");this.cfg.refireEvent("iframe");};YAHOO.widget.Panel.prototype.configzIndex=function(type,args,obj){YAHOO.widget.Panel.superclass.configzIndex.call(this,type,args,obj);var maskZ=0;var currentZ=YAHOO.util.Dom.getStyle(this.element,"zIndex");if(this.mask){if(!currentZ||isNaN(currentZ)){currentZ=0;} -if(currentZ===0){this.cfg.setProperty("zIndex",1);}else{maskZ=currentZ-1;YAHOO.util.Dom.setStyle(this.mask,"zIndex",maskZ);}}};YAHOO.widget.Panel.prototype.buildWrapper=function(){var elementParent=this.element.parentNode;var originalElement=this.element;var wrapper=document.createElement("div");wrapper.className=YAHOO.widget.Panel.CSS_PANEL_CONTAINER;wrapper.id=originalElement.id+"_c";if(elementParent){elementParent.insertBefore(wrapper,originalElement);} -wrapper.appendChild(originalElement);this.element=wrapper;this.innerElement=originalElement;YAHOO.util.Dom.setStyle(this.innerElement,"visibility","inherit");};YAHOO.widget.Panel.prototype.sizeUnderlay=function(){if(this.underlay&&this.browser!="gecko"&&this.browser!="safari"){this.underlay.style.width=this.innerElement.offsetWidth+"px";this.underlay.style.height=this.innerElement.offsetHeight+"px";}};YAHOO.widget.Panel.prototype.onDomResize=function(e,obj){YAHOO.widget.Panel.superclass.onDomResize.call(this,e,obj);var me=this;setTimeout(function(){me.sizeUnderlay();},0);};YAHOO.widget.Panel.prototype.registerDragDrop=function(){if(this.header){this.dd=new YAHOO.util.DD(this.element.id,this.id);if(!this.header.id){this.header.id=this.id+"_h";} -var me=this;this.dd.startDrag=function(){if(me.browser=="ie"){YAHOO.util.Dom.addClass(me.element,"drag");} -if(me.cfg.getProperty("constraintoviewport")){var offsetHeight=me.element.offsetHeight;var offsetWidth=me.element.offsetWidth;var viewPortWidth=YAHOO.util.Dom.getViewportWidth();var viewPortHeight=YAHOO.util.Dom.getViewportHeight();var scrollX=window.scrollX||document.documentElement.scrollLeft;var scrollY=window.scrollY||document.documentElement.scrollTop;var topConstraint=scrollY+10;var leftConstraint=scrollX+10;var bottomConstraint=scrollY+viewPortHeight-offsetHeight-10;var rightConstraint=scrollX+viewPortWidth-offsetWidth-10;this.minX=leftConstraint;this.maxX=rightConstraint;this.constrainX=true;this.minY=topConstraint;this.maxY=bottomConstraint;this.constrainY=true;}else{this.constrainX=false;this.constrainY=false;} -me.dragEvent.fire("startDrag",arguments);};this.dd.onDrag=function(){me.syncPosition();me.cfg.refireEvent("iframe");if(this.platform=="mac"&&this.browser=="gecko"){this.showMacGeckoScrollbars();} -me.dragEvent.fire("onDrag",arguments);};this.dd.endDrag=function(){if(me.browser=="ie"){YAHOO.util.Dom.removeClass(me.element,"drag");} -me.dragEvent.fire("endDrag",arguments);};this.dd.setHandleElId(this.header.id);this.dd.addInvalidHandleType("INPUT");this.dd.addInvalidHandleType("SELECT");this.dd.addInvalidHandleType("TEXTAREA");}};YAHOO.widget.Panel.prototype.buildMask=function(){if(!this.mask){this.mask=document.createElement("div");this.mask.id=this.id+"_mask";this.mask.className="mask";this.mask.innerHTML=" ";var maskClick=function(e,obj){YAHOO.util.Event.stopEvent(e);};var firstChild=document.body.firstChild;if(firstChild){document.body.insertBefore(this.mask,document.body.firstChild);}else{document.body.appendChild(this.mask);}}};YAHOO.widget.Panel.prototype.hideMask=function(){if(this.cfg.getProperty("modal")&&this.mask){this.mask.style.display="none";this.hideMaskEvent.fire();YAHOO.util.Dom.removeClass(document.body,"masked");}};YAHOO.widget.Panel.prototype.showMask=function(){if(this.cfg.getProperty("modal")&&this.mask){YAHOO.util.Dom.addClass(document.body,"masked");this.sizeMask();this.mask.style.display="block";this.showMaskEvent.fire();}};YAHOO.widget.Panel.prototype.sizeMask=function(){if(this.mask){this.mask.style.height=YAHOO.util.Dom.getDocumentHeight()+"px";this.mask.style.width=YAHOO.util.Dom.getDocumentWidth()+"px";}};YAHOO.widget.Panel.prototype.render=function(appendToNode){return YAHOO.widget.Panel.superclass.render.call(this,appendToNode,this.innerElement);};YAHOO.widget.Panel.prototype.toString=function(){return"Panel "+this.id;};YAHOO.widget.Dialog=function(el,userConfig){YAHOO.widget.Dialog.superclass.constructor.call(this,el,userConfig);};YAHOO.extend(YAHOO.widget.Dialog,YAHOO.widget.Panel);YAHOO.widget.Dialog.CSS_DIALOG="yui-dialog";YAHOO.widget.Dialog.prototype.initDefaultConfig=function(){YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);this.callback={success:null,failure:null,argument:null};this.cfg.addProperty("postmethod",{value:"async",handler:this.configPostMethod,validator:function(val){if(val!="form"&&val!="async"&&val!="none"&&val!="manual"){return false;}else{return true;}}});this.cfg.addProperty("buttons",{value:"none",handler:this.configButtons});};YAHOO.widget.Dialog.prototype.initEvents=function(){YAHOO.widget.Dialog.superclass.initEvents.call(this);this.beforeSubmitEvent=new YAHOO.util.CustomEvent("beforeSubmit");this.submitEvent=new YAHOO.util.CustomEvent("submit");this.manualSubmitEvent=new YAHOO.util.CustomEvent("manualSubmit");this.asyncSubmitEvent=new YAHOO.util.CustomEvent("asyncSubmit");this.formSubmitEvent=new YAHOO.util.CustomEvent("formSubmit");this.cancelEvent=new YAHOO.util.CustomEvent("cancel");};YAHOO.widget.Dialog.prototype.init=function(el,userConfig){YAHOO.widget.Dialog.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Dialog);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Dialog.CSS_DIALOG);this.cfg.setProperty("visible",false);if(userConfig){this.cfg.applyConfig(userConfig,true);} -this.showEvent.subscribe(this.focusFirst,this,true);this.beforeHideEvent.subscribe(this.blurButtons,this,true);this.beforeRenderEvent.subscribe(function(){var buttonCfg=this.cfg.getProperty("buttons");if(buttonCfg&&buttonCfg!="none"){if(!this.footer){this.setFooter("");}}},this,true);this.initEvent.fire(YAHOO.widget.Dialog);};YAHOO.widget.Dialog.prototype.doSubmit=function(){var pm=this.cfg.getProperty("postmethod");switch(pm){case"async":var method=this.form.getAttribute("method")||'POST';method=method.toUpperCase();YAHOO.util.Connect.setForm(this.form);var cObj=YAHOO.util.Connect.asyncRequest(method,this.form.getAttribute("action"),this.callback);this.asyncSubmitEvent.fire();break;case"form":this.form.submit();this.formSubmitEvent.fire();break;case"none":case"manual":this.manualSubmitEvent.fire();break;}};YAHOO.widget.Dialog.prototype.registerForm=function(){var form=this.element.getElementsByTagName("form")[0];if(!form){var formHTML="<form name=\"frm_"+this.id+"\" action=\"\"></form>";this.body.innerHTML+=formHTML;form=this.element.getElementsByTagName("form")[0];} -this.firstFormElement=function(){for(var f=0;f<form.elements.length;f++){var el=form.elements[f];if(el.focus&&!el.disabled){if(el.type&&el.type!="hidden"){return el;}}} -return null;}();this.lastFormElement=function(){for(var f=form.elements.length-1;f>=0;f--){var el=form.elements[f];if(el.focus&&!el.disabled){if(el.type&&el.type!="hidden"){return el;}}} -return null;}();this.form=form;if(this.cfg.getProperty("modal")&&this.form){var me=this;var firstElement=this.firstFormElement||this.firstButton;if(firstElement){this.preventBackTab=new YAHOO.util.KeyListener(firstElement,{shift:true,keys:9},{fn:me.focusLast,scope:me,correctScope:true});this.showEvent.subscribe(this.preventBackTab.enable,this.preventBackTab,true);this.hideEvent.subscribe(this.preventBackTab.disable,this.preventBackTab,true);} -var lastElement=this.lastButton||this.lastFormElement;if(lastElement){this.preventTabOut=new YAHOO.util.KeyListener(lastElement,{shift:false,keys:9},{fn:me.focusFirst,scope:me,correctScope:true});this.showEvent.subscribe(this.preventTabOut.enable,this.preventTabOut,true);this.hideEvent.subscribe(this.preventTabOut.disable,this.preventTabOut,true);}}};YAHOO.widget.Dialog.prototype.configClose=function(type,args,obj){var val=args[0];var doCancel=function(e,obj){obj.cancel();};if(val){if(!this.close){this.close=document.createElement("div");YAHOO.util.Dom.addClass(this.close,"container-close");this.close.innerHTML=" ";this.innerElement.appendChild(this.close);YAHOO.util.Event.addListener(this.close,"click",doCancel,this);}else{this.close.style.display="block";}}else{if(this.close){this.close.style.display="none";}}};YAHOO.widget.Dialog.prototype.configButtons=function(type,args,obj){var buttons=args[0];if(buttons!="none"){this.buttonSpan=null;this.buttonSpan=document.createElement("span");this.buttonSpan.className="button-group";for(var b=0;b<buttons.length;b++){var button=buttons[b];var htmlButton=document.createElement("button");htmlButton.setAttribute("type","button");if(button.isDefault){htmlButton.className="default";this.defaultHtmlButton=htmlButton;} -htmlButton.appendChild(document.createTextNode(button.text));YAHOO.util.Event.addListener(htmlButton,"click",button.handler,this,true);this.buttonSpan.appendChild(htmlButton);button.htmlButton=htmlButton;if(b===0){this.firstButton=button.htmlButton;} -if(b==(buttons.length-1)){this.lastButton=button.htmlButton;}} -this.setFooter(this.buttonSpan);this.cfg.refireEvent("iframe");this.cfg.refireEvent("underlay");}else{if(this.buttonSpan){if(this.buttonSpan.parentNode){this.buttonSpan.parentNode.removeChild(this.buttonSpan);} -this.buttonSpan=null;this.firstButton=null;this.lastButton=null;this.defaultHtmlButton=null;}}};YAHOO.widget.Dialog.prototype.focusFirst=function(type,args,obj){if(args){var e=args[1];if(e){YAHOO.util.Event.stopEvent(e);}} -if(this.firstFormElement){this.firstFormElement.focus();}else{this.focusDefaultButton();}};YAHOO.widget.Dialog.prototype.focusLast=function(type,args,obj){if(args){var e=args[1];if(e){YAHOO.util.Event.stopEvent(e);}} -var buttons=this.cfg.getProperty("buttons");if(buttons&&buttons instanceof Array){this.focusLastButton();}else{if(this.lastFormElement){this.lastFormElement.focus();}}};YAHOO.widget.Dialog.prototype.focusDefaultButton=function(){if(this.defaultHtmlButton){this.defaultHtmlButton.focus();}};YAHOO.widget.Dialog.prototype.blurButtons=function(){var buttons=this.cfg.getProperty("buttons");if(buttons&&buttons instanceof Array){var html=buttons[0].htmlButton;if(html){html.blur();}}};YAHOO.widget.Dialog.prototype.focusFirstButton=function(){var buttons=this.cfg.getProperty("buttons");if(buttons&&buttons instanceof Array){var html=buttons[0].htmlButton;if(html){html.focus();}}};YAHOO.widget.Dialog.prototype.focusLastButton=function(){var buttons=this.cfg.getProperty("buttons");if(buttons&&buttons instanceof Array){var html=buttons[buttons.length-1].htmlButton;if(html){html.focus();}}};YAHOO.widget.Dialog.prototype.configPostMethod=function(type,args,obj){var postmethod=args[0];this.registerForm();YAHOO.util.Event.addListener(this.form,"submit",function(e){YAHOO.util.Event.stopEvent(e);this.submit();this.form.blur();},this,true);};YAHOO.widget.Dialog.prototype.validate=function(){return true;};YAHOO.widget.Dialog.prototype.submit=function(){if(this.validate()){this.beforeSubmitEvent.fire();this.doSubmit();this.submitEvent.fire();this.hide();return true;}else{return false;}};YAHOO.widget.Dialog.prototype.cancel=function(){this.cancelEvent.fire();this.hide();};YAHOO.widget.Dialog.prototype.getData=function(){var oForm=this.form;if(oForm){var aElements=oForm.elements,nTotalElements=aElements.length,oData={},sName,oElement;for(var i=0;i<nTotalElements;i++){sName=aElements[i].name,oElement=aElements[sName];if(oElement){if(oElement.tagName){var sType=oElement.type,sTagName=oElement.tagName.toUpperCase();switch(sTagName){case"INPUT":if(sType=="checkbox"){oData[sName]=oElement.checked;} -else if(sType!="radio"){oData[sName]=oElement.value;} -break;case"TEXTAREA":oData[sName]=oElement.value;break;case"SELECT":var aOptions=oElement.options,nOptions=aOptions.length,aValues=[],oOption,sValue;for(var n=0;n<nOptions;n++){oOption=aOptions[n];if(oOption.selected){sValue=oOption.value;if(!sValue||sValue===""){sValue=oOption.text;} -aValues[aValues.length]=sValue;}} -oData[sName]=aValues;break;}} -else{var nElements=oElement.length,sType=oElement[0].type,sTagName=oElement[0].tagName.toUpperCase();switch(sType){case"radio":var oRadio;for(var n=0;n<nElements;n++){oRadio=oElement[n];if(oRadio.checked){oData[sName]=oRadio.value;break;}} -break;case"checkbox":var aValues=[],oCheckbox;for(var n=0;n<nElements;n++){oCheckbox=oElement[n];if(oCheckbox.checked){aValues[aValues.length]=oCheckbox.value;}} -oData[sName]=aValues;break;}}}}} -return oData;};YAHOO.widget.Dialog.prototype.toString=function(){return"Dialog "+this.id;};YAHOO.widget.SimpleDialog=function(el,userConfig){YAHOO.widget.SimpleDialog.superclass.constructor.call(this,el,userConfig);};YAHOO.extend(YAHOO.widget.SimpleDialog,YAHOO.widget.Dialog);YAHOO.widget.SimpleDialog.ICON_BLOCK="blckicon";YAHOO.widget.SimpleDialog.ICON_ALARM="alrticon";YAHOO.widget.SimpleDialog.ICON_HELP="hlpicon";YAHOO.widget.SimpleDialog.ICON_INFO="infoicon";YAHOO.widget.SimpleDialog.ICON_WARN="warnicon";YAHOO.widget.SimpleDialog.ICON_TIP="tipicon";YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG="yui-simple-dialog";YAHOO.widget.SimpleDialog.prototype.initDefaultConfig=function(){YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);this.cfg.addProperty("icon",{value:"none",handler:this.configIcon,suppressEvent:true});this.cfg.addProperty("text",{value:"",handler:this.configText,suppressEvent:true,supercedes:["icon"]});};YAHOO.widget.SimpleDialog.prototype.init=function(el,userConfig){YAHOO.widget.SimpleDialog.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);this.cfg.queueProperty("postmethod","manual");if(userConfig){this.cfg.applyConfig(userConfig,true);} -this.beforeRenderEvent.subscribe(function(){if(!this.body){this.setBody("");}},this,true);this.initEvent.fire(YAHOO.widget.SimpleDialog);};YAHOO.widget.SimpleDialog.prototype.registerForm=function(){YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);this.form.innerHTML+="<input type=\"hidden\" name=\""+this.id+"\" value=\"\"/>";};YAHOO.widget.SimpleDialog.prototype.configIcon=function(type,args,obj){var icon=args[0];if(icon&&icon!="none"){var iconHTML="";if(icon.indexOf(".")==-1){iconHTML="<span class=\"yui-icon "+icon+"\" > </span>";}else{iconHTML="<img src=\""+this.imageRoot+icon+"\" class=\"yui-icon\" />";} -this.body.innerHTML=iconHTML+this.body.innerHTML;}};YAHOO.widget.SimpleDialog.prototype.configText=function(type,args,obj){var text=args[0];if(text){this.setBody(text);this.cfg.refireEvent("icon");}};YAHOO.widget.SimpleDialog.prototype.toString=function(){return"SimpleDialog "+this.id;};YAHOO.widget.ContainerEffect=function(overlay,attrIn,attrOut,targetElement,animClass){if(!animClass){animClass=YAHOO.util.Anim;} -this.overlay=overlay;this.attrIn=attrIn;this.attrOut=attrOut;this.targetElement=targetElement||overlay.element;this.animClass=animClass;};YAHOO.widget.ContainerEffect.prototype.init=function(){this.beforeAnimateInEvent=new YAHOO.util.CustomEvent("beforeAnimateIn");this.beforeAnimateOutEvent=new YAHOO.util.CustomEvent("beforeAnimateOut");this.animateInCompleteEvent=new YAHOO.util.CustomEvent("animateInComplete");this.animateOutCompleteEvent=new YAHOO.util.CustomEvent("animateOutComplete");this.animIn=new this.animClass(this.targetElement,this.attrIn.attributes,this.attrIn.duration,this.attrIn.method);this.animIn.onStart.subscribe(this.handleStartAnimateIn,this);this.animIn.onTween.subscribe(this.handleTweenAnimateIn,this);this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn,this);this.animOut=new this.animClass(this.targetElement,this.attrOut.attributes,this.attrOut.duration,this.attrOut.method);this.animOut.onStart.subscribe(this.handleStartAnimateOut,this);this.animOut.onTween.subscribe(this.handleTweenAnimateOut,this);this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut,this);};YAHOO.widget.ContainerEffect.prototype.animateIn=function(){this.beforeAnimateInEvent.fire();this.animIn.animate();};YAHOO.widget.ContainerEffect.prototype.animateOut=function(){this.beforeAnimateOutEvent.fire();this.animOut.animate();};YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.toString=function(){var output="ContainerEffect";if(this.overlay){output+=" ["+this.overlay.toString()+"]";} -return output;};YAHOO.widget.ContainerEffect.FADE=function(overlay,dur){var fade=new YAHOO.widget.ContainerEffect(overlay,{attributes:{opacity:{from:0,to:1}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{opacity:{to:0}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element);fade.handleStartAnimateIn=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(!obj.overlay.underlay){obj.overlay.cfg.refireEvent("underlay");} -if(obj.overlay.underlay){obj.initialUnderlayOpacity=YAHOO.util.Dom.getStyle(obj.overlay.underlay,"opacity");obj.overlay.underlay.style.filter=null;} -YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","visible");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",0);};fade.handleCompleteAnimateIn=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;} -if(obj.overlay.underlay){YAHOO.util.Dom.setStyle(obj.overlay.underlay,"opacity",obj.initialUnderlayOpacity);} -obj.overlay.cfg.refireEvent("iframe");obj.animateInCompleteEvent.fire();};fade.handleStartAnimateOut=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(obj.overlay.underlay){obj.overlay.underlay.style.filter=null;}};fade.handleCompleteAnimateOut=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;} -YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","hidden");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",1);obj.overlay.cfg.refireEvent("iframe");obj.animateOutCompleteEvent.fire();};fade.init();return fade;};YAHOO.widget.ContainerEffect.SLIDE=function(overlay,dur){var x=overlay.cfg.getProperty("x")||YAHOO.util.Dom.getX(overlay.element);var y=overlay.cfg.getProperty("y")||YAHOO.util.Dom.getY(overlay.element);var clientWidth=YAHOO.util.Dom.getClientWidth();var offsetWidth=overlay.element.offsetWidth;var slide=new YAHOO.widget.ContainerEffect(overlay,{attributes:{points:{to:[x,y]}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{points:{to:[(clientWidth+25),y]}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element,YAHOO.util.Motion);slide.handleStartAnimateIn=function(type,args,obj){obj.overlay.element.style.left=(-25-offsetWidth)+"px";obj.overlay.element.style.top=y+"px";};slide.handleTweenAnimateIn=function(type,args,obj){var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var currentX=pos[0];var currentY=pos[1];if(YAHOO.util.Dom.getStyle(obj.overlay.element,"visibility")=="hidden"&¤tX<x){YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","visible");} -obj.overlay.cfg.setProperty("xy",[currentX,currentY],true);obj.overlay.cfg.refireEvent("iframe");};slide.handleCompleteAnimateIn=function(type,args,obj){obj.overlay.cfg.setProperty("xy",[x,y],true);obj.startX=x;obj.startY=y;obj.overlay.cfg.refireEvent("iframe");obj.animateInCompleteEvent.fire();};slide.handleStartAnimateOut=function(type,args,obj){var vw=YAHOO.util.Dom.getViewportWidth();var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var yso=pos[1];var currentTo=obj.animOut.attributes.points.to;obj.animOut.attributes.points.to=[(vw+25),yso];};slide.handleTweenAnimateOut=function(type,args,obj){var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var xto=pos[0];var yto=pos[1];obj.overlay.cfg.setProperty("xy",[xto,yto],true);obj.overlay.cfg.refireEvent("iframe");};slide.handleCompleteAnimateOut=function(type,args,obj){YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","hidden");obj.overlay.cfg.setProperty("xy",[x,y]);obj.animateOutCompleteEvent.fire();};slide.init();return slide;};YAHOO.register("container",YAHOO.widget.Module,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/container/container.js b/interface/web/js/yui/container/container.js deleted file mode 100644 index 52db840e24..0000000000 --- a/interface/web/js/yui/container/container.js +++ /dev/null @@ -1,4727 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** -* 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<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - - if (queueItem) { - var queueItemKey = queueItem[0]; - var queueItemValue = queueItem[1]; - - if (queueItemKey.toLowerCase() == key) { - // found a dupe... push to end of queue, null current item, and break - eventQueue[i] = null; - eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]); - foundDuplicate = true; - break; - } - } - } - - if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue - eventQueue.push([key, value]); - } - } - - if (property.supercedes) { - for (var s=0;s<property.supercedes.length;s++) { - var supercedesCheck = property.supercedes[s]; - - for (var q=0;q<eventQueue.length;q++) { - var queueItemCheck = eventQueue[q]; - - if (queueItemCheck) { - var queueItemCheckKey = queueItemCheck[0]; - var queueItemCheckValue = queueItemCheck[1]; - - if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) { - eventQueue.push([queueItemCheckKey, queueItemCheckValue]); - eventQueue[q] = null; - break; - } - } - } - } - } - - return true; - } else { - return false; - } - }; - - /** - * Fires the event for a property using the property's current value. - * @method refireEvent - * @param {String} key The name of the property - */ - this.refireEvent = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') { - if (this.queueInProgress) { - this.queueProperty(key); - } else { - fireEvent(key, property.value); - } - } - }; - - /** - * Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their associated events to execute. - * @method applyConfig - * @param {Object} userConfig The configuration Object literal - * @param {Boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. - */ - this.applyConfig = function(userConfig, init) { - if (init) { - initialConfig = userConfig; - } - for (var prop in userConfig) { - this.queueProperty(prop, userConfig[prop]); - } - }; - - /** - * Refires the events for all configuration properties using their current values. - * @method refresh - */ - this.refresh = function() { - for (var prop in config) { - this.refireEvent(prop); - } - }; - - /** - * Fires the normalized list of queued property change events - * @method fireQueue - */ - this.fireQueue = function() { - this.queueInProgress = true; - for (var i=0;i<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - if (queueItem) { - var key = queueItem[0]; - var value = queueItem[1]; - - var property = config[key]; - property.value = value; - - fireEvent(key,value); - } - } - - this.queueInProgress = false; - eventQueue = []; - }; - - /** - * Subscribes an external handler to the change event for any given property. - * @method subscribeToConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @param {Boolean} override Optional. If true, will override "this" within the handler to map to the scope Object passed into the method. - * @return {Boolean} True, if the subscription was successful, otherwise false. - */ - this.subscribeToConfigEvent = function(key, handler, obj, override) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) { - property.event.subscribe(handler, obj, override); - } - return true; - } else { - return false; - } - }; - - /** - * Unsubscribes an external handler from the change event for any given property. - * @method unsubscribeFromConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @return {Boolean} True, if the unsubscription was successful, otherwise false. - */ - this.unsubscribeFromConfigEvent = function(key, handler, obj) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.event.unsubscribe(handler, obj); - } else { - return false; - } - }; - - /** - * Returns a string representation of the Config object - * @method toString - * @return {String} The Config object in string format. - */ - this.toString = function() { - var output = "Config"; - if (this.owner) { - output += " [" + this.owner.toString() + "]"; - } - return output; - }; - - /** - * Returns a string representation of the Config object's current CustomEvent queue - * @method outputEventQueue - * @return {String} The string list of CustomEvents currently queued for execution - */ - this.outputEventQueue = function() { - var output = ""; - for (var q=0;q<eventQueue.length;q++) { - var queueItem = eventQueue[q]; - if (queueItem) { - output += queueItem[0] + "=" + queueItem[1] + ", "; - } - } - return output; - }; -}; - -/** -* Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent -* @method YAHOO.util.Config.alreadySubscribed -* @static -* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions -* @param {Function} fn The function to look for in the subscribers list -* @param {Object} obj The execution scope Object for the subscription -* @return {Boolean} true, if the function/Object pair is already subscribed to the CustomEvent passed in -*/ -YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) { - for (var e=0;e<evt.subscribers.length;e++) { - var subsc = evt.subscribers[e]; - if (subsc && subsc.obj == obj && subsc.fn == fn) { - return true; - } - } - return false; -}; - -/** -* The Container family of components is designed to enable developers to create different kinds of content-containing modules on the web. Module and Overlay are the most basic containers, and they can be used directly or extended to build custom containers. Also part of the Container family are four UI controls that extend Module and Overlay: Tooltip, Panel, Dialog, and SimpleDialog. -* @module container -* @title Container -* @requires yahoo,dom,event,dragdrop,animation -*/ - -/** -* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package. -* @namespace YAHOO.widget -* @class Module -* @constructor -* @param {String} el The element ID representing the Module <em>OR</em> -* @param {HTMLElement} el The element representing the Module -* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. -*/ -YAHOO.widget.Module = function(el, userConfig) { - if (el) { - this.init(el, userConfig); - } else { - } -}; - -/** -* Constant representing the prefix path to use for non-secure images -* @property YAHOO.widget.Module.IMG_ROOT -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.IMG_ROOT = null; - -/** -* Constant representing the prefix path to use for securely served images -* @property YAHOO.widget.Module.IMG_ROOT_SSL -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.IMG_ROOT_SSL = null; - -/** -* Constant for the default CSS class name that represents a Module -* @property YAHOO.widget.Module.CSS_MODULE -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_MODULE = "module"; - -/** -* Constant representing the module header -* @property YAHOO.widget.Module.CSS_HEADER -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_HEADER = "hd"; - -/** -* Constant representing the module body -* @property YAHOO.widget.Module.CSS_BODY -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_BODY = "bd"; - -/** -* Constant representing the module footer -* @property YAHOO.widget.Module.CSS_FOOTER -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_FOOTER = "ft"; - -/** -* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size -* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;"; - -/** -* Singleton CustomEvent fired when the font size is changed in the browser. -* Opera's "zoom" functionality currently does not support text size detection. -* @event YAHOO.widget.Module.textResizeEvent -*/ -YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize"); - -YAHOO.widget.Module.prototype = { - /** - * The class's constructor function - * @property contructor - * @type Function - */ - constructor : YAHOO.widget.Module, - - /** - * The main module element that contains the header, body, and footer - * @property element - * @type HTMLElement - */ - element : null, - - /** - * The header element, denoted with CSS class "hd" - * @property header - * @type HTMLElement - */ - header : null, - - /** - * The body element, denoted with CSS class "bd" - * @property body - * @type HTMLElement - */ - body : null, - - /** - * The footer element, denoted with CSS class "ft" - * @property footer - * @type HTMLElement - */ - footer : null, - - /** - * The id of the element - * @property id - * @type String - */ - id : null, - - /** - * The String representing the image root - * @property imageRoot - * @type String - */ - imageRoot : YAHOO.widget.Module.IMG_ROOT, - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - * @method initEvents - */ - initEvents : function() { - - /** - * CustomEvent fired prior to class initalization. - * @event beforeInitEvent - * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - */ - this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); - - /** - * CustomEvent fired after class initalization. - * @event initEvent - * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - */ - this.initEvent = new YAHOO.util.CustomEvent("init"); - - /** - * CustomEvent fired when the Module is appended to the DOM - * @event appendEvent - */ - this.appendEvent = new YAHOO.util.CustomEvent("append"); - - /** - * CustomEvent fired before the Module is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - - /** - * CustomEvent fired after the Module is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); - - /** - * CustomEvent fired when the header content of the Module is modified - * @event changeHeaderEvent - * @param {String/HTMLElement} content String/element representing the new header content - */ - this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); - - /** - * CustomEvent fired when the body content of the Module is modified - * @event changeBodyEvent - * @param {String/HTMLElement} content String/element representing the new body content - */ - this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); - - /** - * CustomEvent fired when the footer content of the Module is modified - * @event changeFooterEvent - * @param {String/HTMLElement} content String/element representing the new footer content - */ - this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); - - /** - * CustomEvent fired when the content of the Module is modified - * @event changeContentEvent - */ - this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); - - /** - * CustomEvent fired when the Module is destroyed - * @event destroyEvent - */ - this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); - - /** - * CustomEvent fired before the Module is shown - * @event beforeShowEvent - */ - this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); - - /** - * CustomEvent fired after the Module is shown - * @event showEvent - */ - this.showEvent = new YAHOO.util.CustomEvent("show"); - - /** - * CustomEvent fired before the Module is hidden - * @event beforeHideEvent - */ - this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); - - /** - * CustomEvent fired after the Module is hidden - * @event hideEvent - */ - this.hideEvent = new YAHOO.util.CustomEvent("hide"); - }, - - /** - * String representing the current user-agent platform - * @property platform - * @type String - */ - platform : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) { - return "windows"; - } else if (ua.indexOf("macintosh") != -1) { - return "mac"; - } else { - return false; - } - }(), - - /** - * String representing the current user-agent browser - * @property browser - * @type String - */ - browser : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) - return 'opera'; - } else if (ua.indexOf('msie 7')!=-1) { // IE7 - return 'ie7'; - } else if (ua.indexOf('msie') !=-1) { // IE - return 'ie'; - } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") - return 'safari'; - } else if (ua.indexOf('gecko') != -1) { // Gecko - return 'gecko'; - } else { - return false; - } - }(), - - /** - * Boolean representing whether or not the current browsing context is secure (https) - * @property isSecure - * @type Boolean - */ - isSecure : function() { - if (window.location.href.toLowerCase().indexOf("https") === 0) { - return true; - } else { - return false; - } - }(), - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - */ - initDefaultConfig : function() { - // Add properties // - - /** - * Specifies whether the Module is visible on the page. - * @config visible - * @type Boolean - * @default true - */ - this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } ); - - /** - * Object or array of objects representing the ContainerEffect classes that are active for animating the container. - * @config effect - * @type Object - * @default null - */ - this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } ); - - /** - * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document - * @config monitorresize - * @type Boolean - * @default true - */ - this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } ); - }, - - /** - * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. - * @method init - * @param {String} el The element ID representing the Module <em>OR</em> - * @param {HTMLElement} el The element representing the Module - * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. - */ - init : function(el, userConfig) { - - this.initEvents(); - - this.beforeInitEvent.fire(YAHOO.widget.Module); - - /** - * The Module's Config object used for monitoring configuration properties. - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - if (this.isSecure) { - this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL; - } - - if (typeof el == "string") { - var elId = el; - - el = document.getElementById(el); - if (! el) { - el = document.createElement("div"); - el.id = elId; - } - } - - this.element = el; - - if (el.id) { - this.id = el.id; - } - - var childNodes = this.element.childNodes; - - if (childNodes) { - for (var i=0;i<childNodes.length;i++) { - var child = childNodes[i]; - switch (child.className) { - case YAHOO.widget.Module.CSS_HEADER: - this.header = child; - break; - case YAHOO.widget.Module.CSS_BODY: - this.body = child; - break; - case YAHOO.widget.Module.CSS_FOOTER: - this.footer = child; - break; - } - } - } - - this.initDefaultConfig(); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - // Subscribe to the fireQueue() method of Config so that any queued configuration changes are - // excecuted upon render of the Module - if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) { - this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true); - } - - this.initEvent.fire(YAHOO.widget.Module); - }, - - /** - * Initialized an empty IFRAME that is placed out of the visible area that can be used to detect text resize. - * @method initResizeMonitor - */ - initResizeMonitor : function() { - - if(this.browser != "opera") { - - var resizeMonitor = document.getElementById("_yuiResizeMonitor"); - - if (! resizeMonitor) { - - resizeMonitor = document.createElement("iframe"); - - var bIE = (this.browser.indexOf("ie") === 0); - - if(this.isSecure && YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL && bIE) { - resizeMonitor.src = YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL; - } - - resizeMonitor.id = "_yuiResizeMonitor"; - resizeMonitor.style.visibility = "hidden"; - - document.body.appendChild(resizeMonitor); - - resizeMonitor.style.width = "10em"; - resizeMonitor.style.height = "10em"; - resizeMonitor.style.position = "absolute"; - - var nLeft = -1 * resizeMonitor.offsetWidth; - var nTop = -1 * resizeMonitor.offsetHeight; - - resizeMonitor.style.top = nTop + "px"; - resizeMonitor.style.left = nLeft + "px"; - resizeMonitor.style.borderStyle = "none"; - resizeMonitor.style.borderWidth = "0"; - YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0"); - - resizeMonitor.style.visibility = "visible"; - - if(!bIE) { - - var doc = resizeMonitor.contentWindow.document; - - doc.open(); - doc.close(); - - } - } - - var fireTextResize = function() { - YAHOO.widget.Module.textResizeEvent.fire(); - }; - - if(resizeMonitor && resizeMonitor.contentWindow) { - this.resizeMonitor = resizeMonitor; - - YAHOO.widget.Module.textResizeEvent.subscribe(this.onDomResize, this, true); - - if (! YAHOO.widget.Module.textResizeInitialized) { - if (! YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", fireTextResize)) { - // This will fail in IE if document.domain has changed, so we must change the listener to - // use the resizeMonitor element instead - YAHOO.util.Event.addListener(this.resizeMonitor, "resize", fireTextResize); - } - YAHOO.widget.Module.textResizeInitialized = true; - } - } - - } - - }, - - /** - * Event handler fired when the resize monitor element is resized. - * @method onDomResize - * @param {DOMEvent} e The DOM resize event - * @param {Object} obj The scope object passed to the handler - */ - onDomResize : function(e, obj) { - - var nLeft = -1 * this.resizeMonitor.offsetWidth, - nTop = -1 * this.resizeMonitor.offsetHeight; - - this.resizeMonitor.style.top = nTop + "px"; - this.resizeMonitor.style.left = nLeft + "px"; - - }, - - /** - * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created. - * @method setHeader - * @param {String} headerContent The HTML used to set the header <em>OR</em> - * @param {HTMLElement} headerContent The HTMLElement to append to the header - */ - setHeader : function(headerContent) { - if (! this.header) { - this.header = document.createElement("div"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - if (typeof headerContent == "string") { - this.header.innerHTML = headerContent; - } else { - this.header.innerHTML = ""; - this.header.appendChild(headerContent); - } - - this.changeHeaderEvent.fire(headerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the header. If no header is present, one will be automatically created. - * @method appendToHeader - * @param {HTMLElement} element The element to append to the header - */ - appendToHeader : function(element) { - if (! this.header) { - this.header = document.createElement("div"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - this.header.appendChild(element); - this.changeHeaderEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created. - * @method setBody - * @param {String} bodyContent The HTML used to set the body <em>OR</em> - * @param {HTMLElement} bodyContent The HTMLElement to append to the body - */ - setBody : function(bodyContent) { - if (! this.body) { - this.body = document.createElement("div"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - if (typeof bodyContent == "string") - { - this.body.innerHTML = bodyContent; - } else { - this.body.innerHTML = ""; - this.body.appendChild(bodyContent); - } - - this.changeBodyEvent.fire(bodyContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the body. If no body is present, one will be automatically created. - * @method appendToBody - * @param {HTMLElement} element The element to append to the body - */ - appendToBody : function(element) { - if (! this.body) { - this.body = document.createElement("div"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - this.body.appendChild(element); - this.changeBodyEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created. - * @method setFooter - * @param {String} footerContent The HTML used to set the footer <em>OR</em> - * @param {HTMLElement} footerContent The HTMLElement to append to the footer - */ - setFooter : function(footerContent) { - if (! this.footer) { - this.footer = document.createElement("div"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - if (typeof footerContent == "string") { - this.footer.innerHTML = footerContent; - } else { - this.footer.innerHTML = ""; - this.footer.appendChild(footerContent); - } - - this.changeFooterEvent.fire(footerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the footer. If no footer is present, one will be automatically created. - * @method appendToFooter - * @param {HTMLElement} element The element to append to the footer - */ - appendToFooter : function(element) { - if (! this.footer) { - this.footer = document.createElement("div"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - this.footer.appendChild(element); - this.changeFooterEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. - * @method render - * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em> - * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering - * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container. - * @return {Boolean} Success or failure of the render - */ - render : function(appendToNode, moduleElement) { - this.beforeRenderEvent.fire(); - - if (! moduleElement) { - moduleElement = this.element; - } - - var me = this; - var appendTo = function(element) { - if (typeof element == "string") { - element = document.getElementById(element); - } - - if (element) { - element.appendChild(me.element); - me.appendEvent.fire(); - } - }; - - if (appendToNode) { - appendTo(appendToNode); - } else { // No node was passed in. If the element is not pre-marked up, this fails - if (! YAHOO.util.Dom.inDocument(this.element)) { - return false; - } - } - - // Need to get everything into the DOM if it isn't already - - if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) { - // There is a header, but it's not in the DOM yet... need to add it - var firstChild = moduleElement.firstChild; - if (firstChild) { // Insert before first child if exists - moduleElement.insertBefore(this.header, firstChild); - } else { // Append to empty body because there are no children - moduleElement.appendChild(this.header); - } - } - - if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) { - // There is a body, but it's not in the DOM yet... need to add it - if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM - moduleElement.insertBefore(this.body, this.footer); - } else { // Append to element because there is no footer - moduleElement.appendChild(this.body); - } - } - - if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) { - // There is a footer, but it's not in the DOM yet... need to add it - moduleElement.appendChild(this.footer); - } - - this.renderEvent.fire(); - return true; - }, - - /** - * Removes the Module element from the DOM and sets all child elements to null. - * @method destroy - */ - destroy : function() { - var parent; - - if (this.element) { - YAHOO.util.Event.purgeElement(this.element, true); - parent = this.element.parentNode; - } - if (parent) { - parent.removeChild(this.element); - } - - this.element = null; - this.header = null; - this.body = null; - this.footer = null; - - for (var e in this) { - if (e instanceof YAHOO.util.CustomEvent) { - e.unsubscribeAll(); - } - } - - YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this); - - this.destroyEvent.fire(); - }, - - /** - * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after. - * @method show - */ - show : function() { - this.cfg.setProperty("visible", true); - }, - - /** - * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after. - * @method hide - */ - hide : function() { - this.cfg.setProperty("visible", false); - }, - - // BUILT-IN EVENT HANDLERS FOR MODULE // - - /** - * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none". - * This method is responsible for firing showEvent and hideEvent. - * @param {String} type The CustomEvent type (usually the property name) - * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. - * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. - * @method configVisible - */ - configVisible : function(type, args, obj) { - var visible = args[0]; - if (visible) { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "block"); - this.showEvent.fire(); - } else { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "none"); - this.hideEvent.fire(); - } - }, - - /** - * Default event handler for the "monitorresize" configuration property - * @param {String} type The CustomEvent type (usually the property name) - * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. - * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. - * @method configMonitorResize - */ - configMonitorResize : function(type, args, obj) { - var monitor = args[0]; - if (monitor) { - this.initResizeMonitor(); - } else { - YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true); - this.resizeMonitor = null; - } - } -}; - -/** -* Returns a String representation of the Object. -* @method toString -* @return {String} The string representation of the Module -*/ -YAHOO.widget.Module.prototype.toString = function() { - return "Module " + this.id; -}; - -/** -* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements. -* @namespace YAHOO.widget -* @class Overlay -* @extends YAHOO.widget.Module -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Overlay = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module); - -/** -* The URL that will be placed in the iframe -* @property YAHOO.widget.Overlay.IFRAME_SRC -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;"; - -/** -* Constant representing the top left corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.TOP_LEFT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.TOP_LEFT = "tl"; - -/** -* Constant representing the top right corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.TOP_RIGHT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.TOP_RIGHT = "tr"; - -/** -* Constant representing the top bottom left corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.BOTTOM_LEFT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.BOTTOM_LEFT = "bl"; - -/** -* Constant representing the bottom right corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.BOTTOM_RIGHT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.BOTTOM_RIGHT = "br"; - -/** -* Constant representing the default CSS class used for an Overlay -* @property YAHOO.widget.Overlay.CSS_OVERLAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.CSS_OVERLAY = "yui-overlay"; - -/** -* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Overlay.prototype.init = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Overlay); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - if (this.platform == "mac" && this.browser == "gecko") { - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) { - this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) { - this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true); - } - } - - this.initEvent.fire(YAHOO.widget.Overlay); - -}; - -/** -* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class. -* @method initEvents -*/ -YAHOO.widget.Overlay.prototype.initEvents = function() { - YAHOO.widget.Overlay.superclass.initEvents.call(this); - - /** - * CustomEvent fired before the Overlay is moved. - * @event beforeMoveEvent - * @param {Number} x x coordinate - * @param {Number} y y coordinate - */ - this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this); - - /** - * CustomEvent fired after the Overlay is moved. - * @event moveEvent - * @param {Number} x x coordinate - * @param {Number} y y coordinate - */ - this.moveEvent = new YAHOO.util.CustomEvent("move", this); -}; - -/** -* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Overlay.prototype.initDefaultConfig = function() { - YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this); - - // Add overlay config properties // - - /** - * The absolute x-coordinate position of the Overlay - * @config x - * @type Number - * @default null - */ - this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * The absolute y-coordinate position of the Overlay - * @config y - * @type Number - * @default null - */ - this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * An array with the absolute x and y positions of the Overlay - * @config xy - * @type Number[] - * @default null - */ - this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner. - * @config context - * @type Array - * @default null - */ - this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * True if the Overlay should be anchored to the center of the viewport. - * @config fixedcenter - * @type Boolean - * @default false - */ - this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } ); - - /** - * CSS width of the Overlay. - * @config width - * @type String - * @default null - */ - this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * CSS height of the Overlay. - * @config height - * @type String - * @default null - */ - this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * CSS z-index of the Overlay. - * @config zIndex - * @type Number - * @default null - */ - this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } ); - - /** - * True if the Overlay should be prevented from being positioned out of the viewport. - * @config constraintoviewport - * @type Boolean - * @default false - */ - this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } ); - - /** - * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below). - * @config iframe - * @type Boolean - * @default true for IE6 and below, false for all others - */ - this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } ); -}; - -/** -* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]); -* @method moveTo -* @param {Number} x The Overlay's new x position -* @param {Number} y The Overlay's new y position -*/ -YAHOO.widget.Overlay.prototype.moveTo = function(x, y) { - this.cfg.setProperty("xy",[x,y]); -}; - -/** -* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -* @method hideMacGeckoScrollbars -*/ -YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "show-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "hide-scrollbars"); -}; - -/** -* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -* @method showMacGeckoScrollbars -*/ -YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "show-scrollbars"); -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent. -* @method configVisible -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) { - var visible = args[0]; - var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility"); - - if (currentVis == "inherit") { - var e = this.element.parentNode; - while (e.nodeType != 9 && e.nodeType != 11) { - currentVis = YAHOO.util.Dom.getStyle(e, "visibility"); - if (currentVis != "inherit") { break; } - e = e.parentNode; - } - if (currentVis == "inherit") { - currentVis = "visible"; - } - } - - var effect = this.cfg.getProperty("effect"); - - var effectInstances = []; - if (effect) { - if (effect instanceof Array) { - for (var i=0;i<effect.length;i++) { - var eff = effect[i]; - effectInstances[effectInstances.length] = eff.effect(this, eff.duration); - } - } else { - effectInstances[effectInstances.length] = effect.effect(this, effect.duration); - } - } - - var isMacGecko = (this.platform == "mac" && this.browser == "gecko"); - - if (visible) { // Show - if (isMacGecko) { - this.showMacGeckoScrollbars(); - } - - if (effect) { // Animate in - if (visible) { // Animate in if not showing - if (currentVis != "visible" || currentVis === "") { - this.beforeShowEvent.fire(); - for (var j=0;j<effectInstances.length;j++) { - var ei = effectInstances[j]; - if (j === 0 && ! YAHOO.util.Config.alreadySubscribed(ei.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) { - ei.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete - } - ei.animateIn(); - } - } - } - } else { // Show - if (currentVis != "visible" || currentVis === "") { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "visibility", "visible"); - this.cfg.refireEvent("iframe"); - this.showEvent.fire(); - } - } - - } else { // Hide - if (isMacGecko) { - this.hideMacGeckoScrollbars(); - } - - if (effect) { // Animate out if showing - if (currentVis == "visible") { - this.beforeHideEvent.fire(); - for (var k=0;k<effectInstances.length;k++) { - var h = effectInstances[k]; - if (k === 0 && ! YAHOO.util.Config.alreadySubscribed(h.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) { - h.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete - } - h.animateOut(); - } - } else if (currentVis === "") { - YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden"); - } - } else { // Simple hide - if (currentVis == "visible" || currentVis === "") { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden"); - this.cfg.refireEvent("iframe"); - this.hideEvent.fire(); - } - } - } -}; - -/** -* Center event handler used for centering on scroll/resize, but only if the Overlay is visible -* @method doCenterOnDOMEvent -*/ -YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() { - if (this.cfg.getProperty("visible")) { - this.center(); - } -}; - -/** -* The default event handler fired when the "fixedcenter" property is changed. -* @method configFixedCenter -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) { - var val = args[0]; - - if (val) { - this.center(); - - if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) { - this.beforeShowEvent.subscribe(this.center, this, true); - } - - if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) { - YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true); - } - - if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) { - YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true); - } - } else { - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); - } -}; - -/** -* The default event handler fired when the "height" property is changed. -* @method configHeight -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) { - var height = args[0]; - var el = this.element; - YAHOO.util.Dom.setStyle(el, "height", height); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "width" property is changed. -* @method configWidth -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) { - var width = args[0]; - var el = this.element; - YAHOO.util.Dom.setStyle(el, "width", width); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "zIndex" property is changed. -* @method configzIndex -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) { - var zIndex = args[0]; - - var el = this.element; - - if (! zIndex) { - zIndex = YAHOO.util.Dom.getStyle(el, "zIndex"); - if (! zIndex || isNaN(zIndex)) { - zIndex = 0; - } - } - - if (this.iframe) { - if (zIndex <= 0) { - zIndex = 1; - } - YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1)); - } - - YAHOO.util.Dom.setStyle(el, "zIndex", zIndex); - this.cfg.setProperty("zIndex", zIndex, true); -}; - -/** -* The default event handler fired when the "xy" property is changed. -* @method configXY -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) { - var pos = args[0]; - var x = pos[0]; - var y = pos[1]; - - this.cfg.setProperty("x", x); - this.cfg.setProperty("y", y); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x,y]); -}; - -/** -* The default event handler fired when the "x" property is changed. -* @method configX -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) { - var x = args[0]; - var y = this.cfg.getProperty("y"); - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.util.Dom.setX(this.element, x, true); - - this.cfg.setProperty("xy", [x, y], true); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x, y]); -}; - -/** -* The default event handler fired when the "y" property is changed. -* @method configY -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) { - var x = this.cfg.getProperty("x"); - var y = args[0]; - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.util.Dom.setY(this.element, y, true); - - this.cfg.setProperty("xy", [x, y], true); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x, y]); -}; - -/** -* Shows the iframe shim, if it has been enabled -* @method showIframe -*/ -YAHOO.widget.Overlay.prototype.showIframe = function() { - if (this.iframe) { - this.iframe.style.display = "block"; - } -}; - -/** -* Hides the iframe shim, if it has been enabled -* @method hideIframe -*/ -YAHOO.widget.Overlay.prototype.hideIframe = function() { - if (this.iframe) { - this.iframe.style.display = "none"; - } -}; - -/** -* The default event handler fired when the "iframe" property is changed. -* @method configIframe -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) { - - var val = args[0]; - - if (val) { // IFRAME shim is enabled - - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, this.showIframe, this)) { - this.showEvent.subscribe(this.showIframe, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, this.hideIframe, this)) { - this.hideEvent.subscribe(this.hideIframe, this, true); - } - - var x = this.cfg.getProperty("x"); - var y = this.cfg.getProperty("y"); - - if (! x || ! y) { - this.syncPosition(); - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - } - - - if (! isNaN(x) && ! isNaN(y)) { - if (! this.iframe) { - this.iframe = document.createElement("iframe"); - if (this.isSecure) { - this.iframe.src = YAHOO.widget.Overlay.IFRAME_SRC; - } - - var parent = this.element.parentNode; - if (parent) { - parent.appendChild(this.iframe); - } else { - document.body.appendChild(this.iframe); - } - - YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute"); - YAHOO.util.Dom.setStyle(this.iframe, "border", "none"); - YAHOO.util.Dom.setStyle(this.iframe, "margin", "0"); - YAHOO.util.Dom.setStyle(this.iframe, "padding", "0"); - YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); - if (this.cfg.getProperty("visible")) { - this.showIframe(); - } else { - this.hideIframe(); - } - } - - var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display"); - - if (iframeDisplay == "none") { - this.iframe.style.display = "block"; - } - - YAHOO.util.Dom.setXY(this.iframe, [x,y]); - - var width = this.element.clientWidth; - var height = this.element.clientHeight; - - YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px"); - YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px"); - - if (iframeDisplay == "none") { - this.iframe.style.display = "none"; - } - } - } else { - if (this.iframe) { - this.iframe.style.display = "none"; - } - this.showEvent.unsubscribe(this.showIframe, this); - this.hideEvent.unsubscribe(this.hideIframe, this); - } -}; - - -/** -* The default event handler fired when the "constraintoviewport" property is changed. -* @method configConstrainToViewport -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) { - var val = args[0]; - if (val) { - if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) { - this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true); - } - } else { - this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this); - } -}; - -/** -* The default event handler fired when the "context" property is changed. -* @method configContext -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) { - var contextArgs = args[0]; - - if (contextArgs) { - var contextEl = contextArgs[0]; - var elementMagnetCorner = contextArgs[1]; - var contextMagnetCorner = contextArgs[2]; - - if (contextEl) { - if (typeof contextEl == "string") { - this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true); - } - - if (elementMagnetCorner && contextMagnetCorner) { - this.align(elementMagnetCorner, contextMagnetCorner); - } - } - } -}; - - -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT. -* @method align -* @param {String} elementAlign The String representing the corner of the Overlay that should be aligned to the context element -* @param {String} contextAlign The corner of the context element that the elementAlign corner should stick to. -*/ -YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) { - var contextArgs = this.cfg.getProperty("context"); - if (contextArgs) { - var context = contextArgs[0]; - - var element = this.element; - var me = this; - - if (! elementAlign) { - elementAlign = contextArgs[1]; - } - - if (! contextAlign) { - contextAlign = contextArgs[2]; - } - - if (element && context) { - var contextRegion = YAHOO.util.Dom.getRegion(context); - - var doAlign = function(v,h) { - switch (elementAlign) { - case YAHOO.widget.Overlay.TOP_LEFT: - me.moveTo(h,v); - break; - case YAHOO.widget.Overlay.TOP_RIGHT: - me.moveTo(h-element.offsetWidth,v); - break; - case YAHOO.widget.Overlay.BOTTOM_LEFT: - me.moveTo(h,v-element.offsetHeight); - break; - case YAHOO.widget.Overlay.BOTTOM_RIGHT: - me.moveTo(h-element.offsetWidth,v-element.offsetHeight); - break; - } - }; - - switch (contextAlign) { - case YAHOO.widget.Overlay.TOP_LEFT: - doAlign(contextRegion.top, contextRegion.left); - break; - case YAHOO.widget.Overlay.TOP_RIGHT: - doAlign(contextRegion.top, contextRegion.right); - break; - case YAHOO.widget.Overlay.BOTTOM_LEFT: - doAlign(contextRegion.bottom, contextRegion.left); - break; - case YAHOO.widget.Overlay.BOTTOM_RIGHT: - doAlign(contextRegion.bottom, contextRegion.right); - break; - } - } - } -}; - -/** -* The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true. -* @method enforceConstraints -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) { - var pos = args[0]; - - var x = pos[0]; - var y = pos[1]; - - var offsetHeight = this.element.offsetHeight; - var offsetWidth = this.element.offsetWidth; - - var viewPortWidth = YAHOO.util.Dom.getViewportWidth(); - var viewPortHeight = YAHOO.util.Dom.getViewportHeight(); - - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var topConstraint = scrollY + 10; - var leftConstraint = scrollX + 10; - var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10; - var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10; - - if (x < leftConstraint) { - x = leftConstraint; - } else if (x > rightConstraint) { - x = rightConstraint; - } - - if (y < topConstraint) { - y = topConstraint; - } else if (y > bottomConstraint) { - y = bottomConstraint; - } - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - this.cfg.setProperty("xy", [x,y], true); -}; - -/** -* Centers the container in the viewport. -* @method center -*/ -YAHOO.widget.Overlay.prototype.center = function() { - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var viewPortWidth = YAHOO.util.Dom.getClientWidth(); - var viewPortHeight = YAHOO.util.Dom.getClientHeight(); - - var elementWidth = this.element.offsetWidth; - var elementHeight = this.element.offsetHeight; - - var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX; - var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY; - - this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]); - - this.cfg.refireEvent("iframe"); -}; - -/** -* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop. -* @method syncPosition -*/ -YAHOO.widget.Overlay.prototype.syncPosition = function() { - var pos = YAHOO.util.Dom.getXY(this.element); - this.cfg.setProperty("x", pos[0], true); - this.cfg.setProperty("y", pos[1], true); - this.cfg.setProperty("xy", pos, true); -}; - -/** -* Event handler fired when the resize monitor element is resized. -* @method onDomResize -* @param {DOMEvent} e The resize DOM event -* @param {Object} obj The scope object -*/ -YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) { - YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj); - var me = this; - setTimeout(function() { - me.syncPosition(); - me.cfg.refireEvent("iframe"); - me.cfg.refireEvent("context"); - }, 0); -}; - -/** -* Removes the Overlay element from the DOM and sets all child elements to null. -* @method destroy -*/ -YAHOO.widget.Overlay.prototype.destroy = function() { - if (this.iframe) { - this.iframe.parentNode.removeChild(this.iframe); - } - - this.iframe = null; - - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); - - YAHOO.widget.Overlay.superclass.destroy.call(this); -}; - -/** -* Returns a String representation of the object. -* @method toString -* @return {String} The string representation of the Overlay. -*/ -YAHOO.widget.Overlay.prototype.toString = function() { - return "Overlay " + this.id; -}; - -/** -* A singleton CustomEvent used for reacting to the DOM event for window scroll -* @event YAHOO.widget.Overlay.windowScrollEvent -*/ -YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll"); - -/** -* A singleton CustomEvent used for reacting to the DOM event for window resize -* @event YAHOO.widget.Overlay.windowResizeEvent -*/ -YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize"); - -/** -* The DOM event handler used to fire the CustomEvent for window scroll -* @method YAHOO.widget.Overlay.windowScrollHandler -* @static -* @param {DOMEvent} e The DOM scroll event -*/ -YAHOO.widget.Overlay.windowScrollHandler = function(e) { - if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { - if (! window.scrollEnd) { - window.scrollEnd = -1; - } - clearTimeout(window.scrollEnd); - window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1); - } else { - YAHOO.widget.Overlay.windowScrollEvent.fire(); - } -}; - -/** -* The DOM event handler used to fire the CustomEvent for window resize -* @method YAHOO.widget.Overlay.windowResizeHandler -* @static -* @param {DOMEvent} e The DOM resize event -*/ -YAHOO.widget.Overlay.windowResizeHandler = function(e) { - if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { - if (! window.resizeEnd) { - window.resizeEnd = -1; - } - clearTimeout(window.resizeEnd); - window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100); - } else { - YAHOO.widget.Overlay.windowResizeEvent.fire(); - } -}; - -/** -* A boolean that indicated whether the window resize and scroll events have already been subscribed to. -* @property YAHOO.widget.Overlay._initialized -* @private -* @type Boolean -*/ -YAHOO.widget.Overlay._initialized = null; - -if (YAHOO.widget.Overlay._initialized === null) { - YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler); - YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler); - - YAHOO.widget.Overlay._initialized = true; -} - -/** -* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget -* @namespace YAHOO.widget -* @class OverlayManager -* @constructor -* @param {Array} overlays Optional. A collection of Overlays to register with the manager. -* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager -*/ -YAHOO.widget.OverlayManager = function(userConfig) { - this.init(userConfig); -}; - -/** -* The CSS class representing a focused Overlay -* @property YAHOO.widget.OverlayManager.CSS_FOCUSED -* @static -* @final -* @type String -*/ -YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused"; - -YAHOO.widget.OverlayManager.prototype = { - /** - * The class's constructor function - * @property contructor - * @type Function - */ - constructor : YAHOO.widget.OverlayManager, - - /** - * The array of Overlays that are currently registered - * @property overlays - * @type YAHOO.widget.Overlay[] - */ - overlays : null, - - /** - * Initializes the default configuration of the OverlayManager - * @method initDefaultConfig - */ - initDefaultConfig : function() { - /** - * The collection of registered Overlays in use by the OverlayManager - * @config overlays - * @type YAHOO.widget.Overlay[] - * @default null - */ - this.cfg.addProperty("overlays", { suppressEvent:true } ); - - /** - * The default DOM event that should be used to focus an Overlay - * @config focusevent - * @type String - * @default "mousedown" - */ - this.cfg.addProperty("focusevent", { value:"mousedown" } ); - }, - - /** - * Initializes the OverlayManager - * @method init - * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager. - * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager - */ - init : function(userConfig) { - /** - * The OverlayManager's Config object used for monitoring configuration properties. - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - this.initDefaultConfig(); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - this.cfg.fireQueue(); - - /** - * The currently activated Overlay - * @property activeOverlay - * @private - * @type YAHOO.widget.Overlay - */ - var activeOverlay = null; - - /** - * Returns the currently focused Overlay - * @method getActive - * @return {YAHOO.widget.Overlay} The currently focused Overlay - */ - this.getActive = function() { - return activeOverlay; - }; - - /** - * Focuses the specified Overlay - * @method focus - * @param {YAHOO.widget.Overlay} overlay The Overlay to focus - * @param {String} overlay The id of the Overlay to focus - */ - this.focus = function(overlay) { - var o = this.find(overlay); - if (o) { - this.blurAll(); - activeOverlay = o; - YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - this.overlays.sort(this.compareZIndexDesc); - var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex"); - if (! isNaN(topZIndex) && this.overlays[0] != overlay) { - activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2)); - } - this.overlays.sort(this.compareZIndexDesc); - } - }; - - /** - * Removes the specified Overlay from the manager - * @method remove - * @param {YAHOO.widget.Overlay} overlay The Overlay to remove - * @param {String} overlay The id of the Overlay to remove - */ - this.remove = function(overlay) { - var o = this.find(overlay); - if (o) { - var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex"); - o.cfg.setProperty("zIndex", -1000, true); - this.overlays.sort(this.compareZIndexDesc); - this.overlays = this.overlays.slice(0, this.overlays.length-1); - o.cfg.setProperty("zIndex", originalZ, true); - - o.cfg.setProperty("manager", null); - o.focusEvent = null; - o.blurEvent = null; - o.focus = null; - o.blur = null; - } - }; - - /** - * Removes focus from all registered Overlays in the manager - * @method blurAll - */ - this.blurAll = function() { - activeOverlay = null; - for (var o=0;o<this.overlays.length;o++) { - YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - } - }; - - var overlays = this.cfg.getProperty("overlays"); - - if (! this.overlays) { - this.overlays = []; - } - - if (overlays) { - this.register(overlays); - this.overlays.sort(this.compareZIndexDesc); - } - }, - - /** - * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each. - * @method register - * @param {YAHOO.widget.Overlay} overlay An Overlay to register with the manager. - * @param {YAHOO.widget.Overlay[]} overlay An array of Overlays to register with the manager. - * @return {Boolean} True if any Overlays are registered. - */ - register : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - overlay.cfg.addProperty("manager", { value:this } ); - - overlay.focusEvent = new YAHOO.util.CustomEvent("focus"); - overlay.blurEvent = new YAHOO.util.CustomEvent("blur"); - - var mgr=this; - - overlay.focus = function() { - mgr.focus(this); - this.focusEvent.fire(); - }; - - overlay.blur = function() { - mgr.blurAll(); - this.blurEvent.fire(); - }; - - var focusOnDomEvent = function(e,obj) { - overlay.focus(); - }; - - var focusevent = this.cfg.getProperty("focusevent"); - YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true); - - var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex"); - if (! isNaN(zIndex)) { - overlay.cfg.setProperty("zIndex", parseInt(zIndex, 10)); - } else { - overlay.cfg.setProperty("zIndex", 0); - } - - this.overlays.push(overlay); - return true; - } else if (overlay instanceof Array) { - var regcount = 0; - for (var i=0;i<overlay.length;i++) { - if (this.register(overlay[i])) { - regcount++; - } - } - if (regcount > 0) { - return true; - } - } else { - return false; - } - }, - - /** - * Attempts to locate an Overlay by instance or ID. - * @method find - * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager - * @param {String} overlay An Overlay id to locate within the manager - * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located. - */ - find : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - for (var o=0;o<this.overlays.length;o++) { - if (this.overlays[o] == overlay) { - return this.overlays[o]; - } - } - } else if (typeof overlay == "string") { - for (var p=0;p<this.overlays.length;p++) { - if (this.overlays[p].id == overlay) { - return this.overlays[p]; - } - } - } - return null; - }, - - /** - * Used for sorting the manager's Overlays by z-index. - * @method compareZIndexDesc - * @private - * @return {Number} 0, 1, or -1, depending on where the Overlay should fall in the stacking order. - */ - compareZIndexDesc : function(o1, o2) { - var zIndex1 = o1.cfg.getProperty("zIndex"); - var zIndex2 = o2.cfg.getProperty("zIndex"); - - if (zIndex1 > zIndex2) { - return -1; - } else if (zIndex1 < zIndex2) { - return 1; - } else { - return 0; - } - }, - - /** - * Shows all Overlays in the manager. - * @method showAll - */ - showAll : function() { - for (var o=0;o<this.overlays.length;o++) { - this.overlays[o].show(); - } - }, - - /** - * Hides all Overlays in the manager. - * @method hideAll - */ - hideAll : function() { - for (var o=0;o<this.overlays.length;o++) { - this.overlays[o].hide(); - } - }, - - /** - * Returns a string representation of the object. - * @method toString - * @return {String} The string representation of the OverlayManager - */ - toString : function() { - return "OverlayManager"; - } - -}; - -/** -* KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements. -* @namespace YAHOO.util -* @class KeyListener -* @constructor -* @param {HTMLElement} attachTo The element or element ID to which the key event should be attached -* @param {String} attachTo The element or element ID to which the key event should be attached -* @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). -* @param {Function} handler The CustomEvent handler to fire when the key event is detected -* @param {Object} handler An object literal representing the handler. -* @param {String} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown. -*/ -YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) { - if (! attachTo) { - } - if (! keyData) { - } - if (! handler) { - } - - if (! event) { - event = YAHOO.util.KeyListener.KEYDOWN; - } - - /** - * The CustomEvent fired internally when a key is pressed - * @event keyEvent - * @private - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - var keyEvent = new YAHOO.util.CustomEvent("keyPressed"); - - /** - * The CustomEvent fired when the KeyListener is enabled via the enable() function - * @event enabledEvent - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - this.enabledEvent = new YAHOO.util.CustomEvent("enabled"); - - /** - * The CustomEvent fired when the KeyListener is disabled via the disable() function - * @event disabledEvent - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - this.disabledEvent = new YAHOO.util.CustomEvent("disabled"); - - if (typeof attachTo == 'string') { - attachTo = document.getElementById(attachTo); - } - - if (typeof handler == 'function') { - keyEvent.subscribe(handler); - } else { - keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope); - } - - /** - * Handles the key event when a key is pressed. - * @method handleKeyPress - * @param {DOMEvent} e The keypress DOM event - * @param {Object} obj The DOM event scope object - * @private - */ - function handleKeyPress(e, obj) { - if (! keyData.shift) { - keyData.shift = false; - } - if (! keyData.alt) { - keyData.alt = false; - } - if (! keyData.ctrl) { - keyData.ctrl = false; - } - - // check held down modifying keys first - if (e.shiftKey == keyData.shift && - e.altKey == keyData.alt && - e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match - - var dataItem; - var keyPressed; - - if (keyData.keys instanceof Array) { - for (var i=0;i<keyData.keys.length;i++) { - dataItem = keyData.keys[i]; - - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - break; - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - break; - } - } - } else { - dataItem = keyData.keys; - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - } - } - } - } - - /** - * Enables the KeyListener by attaching the DOM event listeners to the target DOM element - * @method enable - */ - this.enable = function() { - if (! this.enabled) { - YAHOO.util.Event.addListener(attachTo, event, handleKeyPress); - this.enabledEvent.fire(keyData); - } - /** - * Boolean indicating the enabled/disabled state of the Tooltip - * @property enabled - * @type Boolean - */ - this.enabled = true; - }; - - /** - * Disables the KeyListener by removing the DOM event listeners from the target DOM element - * @method disable - */ - this.disable = function() { - if (this.enabled) { - YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress); - this.disabledEvent.fire(keyData); - } - this.enabled = false; - }; - - /** - * Returns a String representation of the object. - * @method toString - * @return {String} The string representation of the KeyListener - */ - this.toString = function() { - return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : ""); - }; - -}; - -/** -* Constant representing the DOM "keydown" event. -* @property YAHOO.util.KeyListener.KEYDOWN -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYDOWN = "keydown"; - -/** -* Constant representing the DOM "keyup" event. -* @property YAHOO.util.KeyListener.KEYUP -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYUP = "keyup"; - -/** -* Tooltip is an implementation of Overlay that behaves like an OS tooltip, displaying when the user mouses over a particular element, and disappearing on mouse out. -* @namespace YAHOO.widget -* @class Tooltip -* @extends YAHOO.widget.Overlay -* @constructor -* @param {String} el The element ID representing the Tooltip <em>OR</em> -* @param {HTMLElement} el The element representing the Tooltip -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Tooltip = function(el, userConfig) { - YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay); - -/** -* Constant representing the Tooltip CSS class -* @property YAHOO.widget.Tooltip.CSS_TOOLTIP -* @static -* @final -* @type String -*/ -YAHOO.widget.Tooltip.CSS_TOOLTIP = "yui-tt"; - -/** -* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well. -* @method init -* @param {String} el The element ID representing the Tooltip <em>OR</em> -* @param {HTMLElement} el The element representing the Tooltip -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details. -*/ -YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) { - - if (document.readyState && document.readyState != "complete") { - var deferredInit = function() { - this.init(el, userConfig); - }; - YAHOO.util.Event.addListener(window, "load", deferredInit, this, true); - } else { - YAHOO.widget.Tooltip.superclass.init.call(this, el); - - this.beforeInitEvent.fire(YAHOO.widget.Tooltip); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.cfg.queueProperty("visible",false); - this.cfg.queueProperty("constraintoviewport",true); - - this.setBody(""); - this.render(this.cfg.getProperty("container")); - - this.initEvent.fire(YAHOO.widget.Tooltip); - } -}; - -/** -* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() { - YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this); - - /** - * Specifies whether the Tooltip should be kept from overlapping its context element. - * @config preventoverlap - * @type Boolean - * @default true - */ - this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } ); - - /** - * The number of milliseconds to wait before showing a Tooltip on mouseover. - * @config showdelay - * @type Number - * @default 200 - */ - this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } ); - - /** - * The number of milliseconds to wait before automatically dismissing a Tooltip after the mouse has been resting on the context element. - * @config autodismissdelay - * @type Number - * @default 5000 - */ - this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } ); - - /** - * The number of milliseconds to wait before hiding a Tooltip on mouseover. - * @config hidedelay - * @type Number - * @default 250 - */ - this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } ); - - /** - * Specifies the Tooltip's text. - * @config text - * @type String - * @default null - */ - this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } ); - - /** - * Specifies the container element that the Tooltip's markup should be rendered into. - * @config container - * @type HTMLElement/String - * @default document.body - */ - this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } ); - - /** - * Specifies the element or elements that the Tooltip should be anchored to on mouseover. - * @config context - * @type HTMLElement[]/String[] - * @default null - */ - -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "text" property is changed. -* @method configText -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) { - var text = args[0]; - if (text) { - this.setBody(text); - } -}; - -/** -* The default event handler fired when the "container" property is changed. -* @method configContainer -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) { - var container = args[0]; - if (typeof container == 'string') { - this.cfg.setProperty("container", document.getElementById(container), true); - } -}; - -/** -* The default event handler fired when the "context" property is changed. -* @method configContext -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) { - var context = args[0]; - if (context) { - - // Normalize parameter into an array - if (! (context instanceof Array)) { - if (typeof context == "string") { - this.cfg.setProperty("context", [document.getElementById(context)], true); - } else { // Assuming this is an element - this.cfg.setProperty("context", [context], true); - } - context = this.cfg.getProperty("context"); - } - - - // Remove any existing mouseover/mouseout listeners - if (this._context) { - for (var c=0;c<this._context.length;++c) { - var el = this._context[c]; - YAHOO.util.Event.removeListener(el, "mouseover", this.onContextMouseOver); - YAHOO.util.Event.removeListener(el, "mousemove", this.onContextMouseMove); - YAHOO.util.Event.removeListener(el, "mouseout", this.onContextMouseOut); - } - } - - // Add mouseover/mouseout listeners to context elements - this._context = context; - for (var d=0;d<this._context.length;++d) { - var el2 = this._context[d]; - YAHOO.util.Event.addListener(el2, "mouseover", this.onContextMouseOver, this); - YAHOO.util.Event.addListener(el2, "mousemove", this.onContextMouseMove, this); - YAHOO.util.Event.addListener(el2, "mouseout", this.onContextMouseOut, this); - } - } -}; - -// END BUILT-IN PROPERTY EVENT HANDLERS // - -// BEGIN BUILT-IN DOM EVENT HANDLERS // - -/** -* The default event handler fired when the user moves the mouse while over the context element. -* @method onContextMouseMove -* @param {DOMEvent} e The current DOM event -* @param {Object} obj The object argument -*/ -YAHOO.widget.Tooltip.prototype.onContextMouseMove = function(e, obj) { - obj.pageX = YAHOO.util.Event.getPageX(e); - obj.pageY = YAHOO.util.Event.getPageY(e); - -}; - -/** -* The default event handler fired when the user mouses over the context element. -* @method onContextMouseOver -* @param {DOMEvent} e The current DOM event -* @param {Object} obj The object argument -*/ -YAHOO.widget.Tooltip.prototype.onContextMouseOver = function(e, obj) { - - if (obj.hideProcId) { - clearTimeout(obj.hideProcId); - obj.hideProcId = null; - } - - var context = this; - YAHOO.util.Event.addListener(context, "mousemove", obj.onContextMouseMove, obj); - - if (context.title) { - obj._tempTitle = context.title; - context.title = ""; - } - - /** - * The unique process ID associated with the thread responsible for showing the Tooltip. - * @type int - */ - obj.showProcId = obj.doShow(e, context); -}; - -/** -* The default event handler fired when the user mouses out of the context element. -* @method onContextMouseOut -* @param {DOMEvent} e The current DOM event -* @param {Object} obj The object argument -*/ -YAHOO.widget.Tooltip.prototype.onContextMouseOut = function(e, obj) { - var el = this; - - if (obj._tempTitle) { - el.title = obj._tempTitle; - obj._tempTitle = null; - } - - if (obj.showProcId) { - clearTimeout(obj.showProcId); - obj.showProcId = null; - } - - if (obj.hideProcId) { - clearTimeout(obj.hideProcId); - obj.hideProcId = null; - } - - - obj.hideProcId = setTimeout(function() { - obj.hide(); - }, obj.cfg.getProperty("hidedelay")); -}; - -// END BUILT-IN DOM EVENT HANDLERS // - -/** -* Processes the showing of the Tooltip by setting the timeout delay and offset of the Tooltip. -* @method doShow -* @param {DOMEvent} e The current DOM event -* @return {Number} The process ID of the timeout function associated with doShow -*/ -YAHOO.widget.Tooltip.prototype.doShow = function(e, context) { - - var yOffset = 25; - if (this.browser == "opera" && context.tagName == "A") { - yOffset += 12; - } - - var me = this; - return setTimeout( - function() { - if (me._tempTitle) { - me.setBody(me._tempTitle); - } else { - me.cfg.refireEvent("text"); - } - - me.moveTo(me.pageX, me.pageY + yOffset); - if (me.cfg.getProperty("preventoverlap")) { - me.preventOverlap(me.pageX, me.pageY); - } - - YAHOO.util.Event.removeListener(context, "mousemove", me.onContextMouseMove); - - me.show(); - me.hideProcId = me.doHide(); - }, - this.cfg.getProperty("showdelay")); -}; - -/** -* Sets the timeout for the auto-dismiss delay, which by default is 5 seconds, meaning that a tooltip will automatically dismiss itself after 5 seconds of being displayed. -* @method doHide -*/ -YAHOO.widget.Tooltip.prototype.doHide = function() { - var me = this; - return setTimeout( - function() { - me.hide(); - }, - this.cfg.getProperty("autodismissdelay")); -}; - -/** -* Fired when the Tooltip is moved, this event handler is used to prevent the Tooltip from overlapping with its context element. -* @method preventOverlay -* @param {Number} pageX The x coordinate position of the mouse pointer -* @param {Number} pageY The y coordinate position of the mouse pointer -*/ -YAHOO.widget.Tooltip.prototype.preventOverlap = function(pageX, pageY) { - - var height = this.element.offsetHeight; - - var elementRegion = YAHOO.util.Dom.getRegion(this.element); - - elementRegion.top -= 5; - elementRegion.left -= 5; - elementRegion.right += 5; - elementRegion.bottom += 5; - - var mousePoint = new YAHOO.util.Point(pageX, pageY); - - - if (elementRegion.contains(mousePoint)) { - this.cfg.setProperty("y", (pageY-height-5)); - } -}; - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the Tooltip -*/ -YAHOO.widget.Tooltip.prototype.toString = function() { - return "Tooltip " + this.id; -}; - -/** -* Panel is an implementation of Overlay that behaves like an OS window, with a draggable header and an optional close icon at the top right. -* @namespace YAHOO.widget -* @class Panel -* @extends YAHOO.widget.Overlay -* @constructor -* @param {String} el The element ID representing the Panel <em>OR</em> -* @param {HTMLElement} el The element representing the Panel -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details. -*/ -YAHOO.widget.Panel = function(el, userConfig) { - YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay); - -/** -* Constant representing the default CSS class used for a Panel -* @property YAHOO.widget.Panel.CSS_PANEL -* @static -* @final -* @type String -*/ -YAHOO.widget.Panel.CSS_PANEL = "yui-panel"; - -/** -* Constant representing the default CSS class used for a Panel's wrapping container -* @property YAHOO.widget.Panel.CSS_PANEL_CONTAINER -* @static -* @final -* @type String -*/ -YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "yui-panel-container"; - -/** -* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Panel.prototype.init = function(el, userConfig) { - YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Panel); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL); - - this.buildWrapper(); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.beforeRenderEvent.subscribe(function() { - var draggable = this.cfg.getProperty("draggable"); - if (draggable) { - if (! this.header) { - this.setHeader(" "); - } - } - }, this, true); - - var me = this; - - var doBlur = function() { - this.blur(); - }; - - this.showMaskEvent.subscribe(function() { - var checkFocusable = function(el) { - if ((el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA") && el.type != "hidden") { - if (! YAHOO.util.Dom.isAncestor(me.element, el)) { - YAHOO.util.Event.addListener(el, "focus", doBlur, el, true); - return true; - } - } else { - return false; - } - }; - - this.focusableElements = YAHOO.util.Dom.getElementsBy(checkFocusable); - }, this, true); - - this.hideMaskEvent.subscribe(function() { - for (var i=0;i<this.focusableElements.length;i++) { - var el2 = this.focusableElements[i]; - YAHOO.util.Event.removeListener(el2, "focus", doBlur); - } - }, this, true); - - this.beforeShowEvent.subscribe(function() { - this.cfg.refireEvent("underlay"); - }, this, true); - this.initEvent.fire(YAHOO.widget.Panel); -}; - -/** -* Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. -*/ -YAHOO.widget.Panel.prototype.initEvents = function() { - YAHOO.widget.Panel.superclass.initEvents.call(this); - - /** - * CustomEvent fired after the modality mask is shown - * @event showMaskEvent - */ - this.showMaskEvent = new YAHOO.util.CustomEvent("showMask"); - - /** - * CustomEvent fired after the modality mask is hidden - * @event hideMaskEvent - */ - this.hideMaskEvent = new YAHOO.util.CustomEvent("hideMask"); - - /** - * CustomEvent when the Panel is dragged - * @event dragEvent - */ - this.dragEvent = new YAHOO.util.CustomEvent("drag"); -}; - -/** -* Initializes the class's configurable properties which can be changed using the Panel's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Panel.prototype.initDefaultConfig = function() { - YAHOO.widget.Panel.superclass.initDefaultConfig.call(this); - - // Add panel config properties // - - /** - * True if the Panel should display a "close" button - * @config close - * @type Boolean - * @default true - */ - this.cfg.addProperty("close", { value:true, handler:this.configClose, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - - /** - * True if the Panel should be draggable - * @config draggable - * @type Boolean - * @default true - */ - this.cfg.addProperty("draggable", { value:true, handler:this.configDraggable, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - - /** - * Sets the type of underlay to display for the Panel. Valid values are "shadow", "matte", and "none". - * @config underlay - * @type String - * @default shadow - */ - this.cfg.addProperty("underlay", { value:"shadow", handler:this.configUnderlay, supercedes:["visible"] } ); - - /** - * True if the Panel should be displayed in a modal fashion, automatically creating a transparent mask over the document that will not be removed until the Panel is dismissed. - * @config modal - * @type Boolean - * @default false - */ - this.cfg.addProperty("modal", { value:false, handler:this.configModal, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - - /** - * A KeyListener (or array of KeyListeners) that will be enabled when the Panel is shown, and disabled when the Panel is hidden. - * @config keylisteners - * @type YAHOO.util.KeyListener[] - * @default null - */ - this.cfg.addProperty("keylisteners", { handler:this.configKeyListeners, suppressEvent:true, supercedes:["visible"] } ); -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Panel. -* @method configClose -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configClose = function(type, args, obj) { - var val = args[0]; - - var doHide = function(e, obj) { - obj.hide(); - }; - - if (val) { - if (! this.close) { - this.close = document.createElement("span"); - YAHOO.util.Dom.addClass(this.close, "container-close"); - this.close.innerHTML = " "; - this.innerElement.appendChild(this.close); - YAHOO.util.Event.addListener(this.close, "click", doHide, this); - } else { - this.close.style.display = "block"; - } - } else { - if (this.close) { - this.close.style.display = "none"; - } - } -}; - -/** -* The default event handler fired when the "draggable" property is changed. -* @method configDraggable -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configDraggable = function(type, args, obj) { - var val = args[0]; - if (val) { - if (this.header) { - YAHOO.util.Dom.setStyle(this.header,"cursor","move"); - this.registerDragDrop(); - } - } else { - if (this.dd) { - this.dd.unreg(); - } - if (this.header) { - YAHOO.util.Dom.setStyle(this.header,"cursor","auto"); - } - } -}; - -/** -* The default event handler fired when the "underlay" property is changed. -* @method configUnderlay -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configUnderlay = function(type, args, obj) { - var val = args[0]; - - switch (val.toLowerCase()) { - case "shadow": - YAHOO.util.Dom.removeClass(this.element, "matte"); - YAHOO.util.Dom.addClass(this.element, "shadow"); - - if (! this.underlay) { // create if not already in DOM - this.underlay = document.createElement("div"); - this.underlay.className = "underlay"; - this.underlay.innerHTML = " "; - this.element.appendChild(this.underlay); - } - - this.sizeUnderlay(); - break; - case "matte": - YAHOO.util.Dom.removeClass(this.element, "shadow"); - YAHOO.util.Dom.addClass(this.element, "matte"); - break; - default: - YAHOO.util.Dom.removeClass(this.element, "shadow"); - YAHOO.util.Dom.removeClass(this.element, "matte"); - break; - } -}; - -/** -* The default event handler fired when the "modal" property is changed. This handler subscribes or unsubscribes to the show and hide events to handle the display or hide of the modality mask. -* @method configModal -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configModal = function(type, args, obj) { - var modal = args[0]; - - if (modal) { - this.buildMask(); - - if (! YAHOO.util.Config.alreadySubscribed( this.beforeShowEvent, this.showMask, this ) ) { - this.beforeShowEvent.subscribe(this.showMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( this.hideEvent, this.hideMask, this) ) { - this.hideEvent.subscribe(this.hideMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowResizeEvent, this.sizeMask, this ) ) { - YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( this.destroyEvent, this.removeMask, this) ) { - this.destroyEvent.subscribe(this.removeMask, this, true); - } - - this.cfg.refireEvent("zIndex"); - } else { - this.beforeShowEvent.unsubscribe(this.showMask, this); - this.hideEvent.unsubscribe(this.hideMask, this); - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask, this); - this.destroyEvent.unsubscribe(this.removeMask, this); - } -}; - -/** -* Removes the modality mask. -* @method removeMask -*/ -YAHOO.widget.Panel.prototype.removeMask = function() { - if (this.mask) { - if (this.mask.parentNode) { - this.mask.parentNode.removeChild(this.mask); - } - this.mask = null; - } -}; - -/** -* The default event handler fired when the "keylisteners" property is changed. -* @method configKeyListeners -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configKeyListeners = function(type, args, obj) { - var listeners = args[0]; - - if (listeners) { - if (listeners instanceof Array) { - for (var i=0;i<listeners.length;i++) { - var listener = listeners[i]; - - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listener.enable, listener)) { - this.showEvent.subscribe(listener.enable, listener, true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listener.disable, listener)) { - this.hideEvent.subscribe(listener.disable, listener, true); - this.destroyEvent.subscribe(listener.disable, listener, true); - } - } - } else { - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listeners.enable, listeners)) { - this.showEvent.subscribe(listeners.enable, listeners, true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listeners.disable, listeners)) { - this.hideEvent.subscribe(listeners.disable, listeners, true); - this.destroyEvent.subscribe(listeners.disable, listeners, true); - } - } - } -}; - -/** -* The default event handler fired when the "height" property is changed. -* @method configHeight -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configHeight = function(type, args, obj) { - var height = args[0]; - var el = this.innerElement; - YAHOO.util.Dom.setStyle(el, "height", height); - this.cfg.refireEvent("underlay"); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "width" property is changed. -* @method configWidth -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configWidth = function(type, args, obj) { - var width = args[0]; - var el = this.innerElement; - YAHOO.util.Dom.setStyle(el, "width", width); - this.cfg.refireEvent("underlay"); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "zIndex" property is changed. -* @method configzIndex -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Panel.prototype.configzIndex = function(type, args, obj) { - YAHOO.widget.Panel.superclass.configzIndex.call(this, type, args, obj); - - var maskZ = 0; - var currentZ = YAHOO.util.Dom.getStyle(this.element, "zIndex"); - - if (this.mask) { - if (! currentZ || isNaN(currentZ)) { - currentZ = 0; - } - - if (currentZ === 0) { - this.cfg.setProperty("zIndex", 1); - } else { - maskZ = currentZ - 1; - YAHOO.util.Dom.setStyle(this.mask, "zIndex", maskZ); - } - - } -}; - -// END BUILT-IN PROPERTY EVENT HANDLERS // - - -/** -* Builds the wrapping container around the Panel that is used for positioning the shadow and matte underlays. The container element is assigned to a local instance variable called container, and the element is reinserted inside of it. -* @method buildWrapper -*/ -YAHOO.widget.Panel.prototype.buildWrapper = function() { - var elementParent = this.element.parentNode; - var originalElement = this.element; - - var wrapper = document.createElement("div"); - wrapper.className = YAHOO.widget.Panel.CSS_PANEL_CONTAINER; - wrapper.id = originalElement.id + "_c"; - - if (elementParent) { - elementParent.insertBefore(wrapper, originalElement); - } - - wrapper.appendChild(originalElement); - - this.element = wrapper; - this.innerElement = originalElement; - - YAHOO.util.Dom.setStyle(this.innerElement, "visibility", "inherit"); -}; - -/** -* Adjusts the size of the shadow based on the size of the element. -* @method sizeUnderlay -*/ -YAHOO.widget.Panel.prototype.sizeUnderlay = function() { - if (this.underlay && this.browser != "gecko" && this.browser != "safari") { - this.underlay.style.width = this.innerElement.offsetWidth + "px"; - this.underlay.style.height = this.innerElement.offsetHeight + "px"; - } -}; - -/** -* Event handler fired when the resize monitor element is resized. -* @method onDomResize -* @param {DOMEvent} e The resize DOM event -* @param {Object} obj The scope object -*/ -YAHOO.widget.Panel.prototype.onDomResize = function(e, obj) { - YAHOO.widget.Panel.superclass.onDomResize.call(this, e, obj); - var me = this; - setTimeout(function() { - me.sizeUnderlay(); - }, 0); -}; - -/** -* Registers the Panel's header for drag & drop capability. -* @method registerDragDrop -*/ -YAHOO.widget.Panel.prototype.registerDragDrop = function() { - if (this.header) { - this.dd = new YAHOO.util.DD(this.element.id, this.id); - - if (! this.header.id) { - this.header.id = this.id + "_h"; - } - - var me = this; - - this.dd.startDrag = function() { - - if (me.browser == "ie") { - YAHOO.util.Dom.addClass(me.element,"drag"); - } - - if (me.cfg.getProperty("constraintoviewport")) { - var offsetHeight = me.element.offsetHeight; - var offsetWidth = me.element.offsetWidth; - - var viewPortWidth = YAHOO.util.Dom.getViewportWidth(); - var viewPortHeight = YAHOO.util.Dom.getViewportHeight(); - - var scrollX = window.scrollX || document.documentElement.scrollLeft; - var scrollY = window.scrollY || document.documentElement.scrollTop; - - var topConstraint = scrollY + 10; - var leftConstraint = scrollX + 10; - var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10; - var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10; - - this.minX = leftConstraint; - this.maxX = rightConstraint; - this.constrainX = true; - - this.minY = topConstraint; - this.maxY = bottomConstraint; - this.constrainY = true; - } else { - this.constrainX = false; - this.constrainY = false; - } - - me.dragEvent.fire("startDrag", arguments); - }; - - this.dd.onDrag = function() { - me.syncPosition(); - me.cfg.refireEvent("iframe"); - if (this.platform == "mac" && this.browser == "gecko") { - this.showMacGeckoScrollbars(); - } - - me.dragEvent.fire("onDrag", arguments); - }; - - this.dd.endDrag = function() { - if (me.browser == "ie") { - YAHOO.util.Dom.removeClass(me.element,"drag"); - } - - me.dragEvent.fire("endDrag", arguments); - }; - - this.dd.setHandleElId(this.header.id); - this.dd.addInvalidHandleType("INPUT"); - this.dd.addInvalidHandleType("SELECT"); - this.dd.addInvalidHandleType("TEXTAREA"); - } -}; - -/** -* Builds the mask that is laid over the document when the Panel is configured to be modal. -* @method buildMask -*/ -YAHOO.widget.Panel.prototype.buildMask = function() { - if (! this.mask) { - this.mask = document.createElement("div"); - this.mask.id = this.id + "_mask"; - this.mask.className = "mask"; - this.mask.innerHTML = " "; - - var maskClick = function(e, obj) { - YAHOO.util.Event.stopEvent(e); - }; - - var firstChild = document.body.firstChild; - if (firstChild) { - document.body.insertBefore(this.mask, document.body.firstChild); - } else { - document.body.appendChild(this.mask); - } - } -}; - -/** -* Hides the modality mask. -* @method hideMask -*/ -YAHOO.widget.Panel.prototype.hideMask = function() { - if (this.cfg.getProperty("modal") && this.mask) { - this.mask.style.display = "none"; - this.hideMaskEvent.fire(); - YAHOO.util.Dom.removeClass(document.body, "masked"); - } -}; - -/** -* Shows the modality mask. -* @method showMask -*/ -YAHOO.widget.Panel.prototype.showMask = function() { - if (this.cfg.getProperty("modal") && this.mask) { - YAHOO.util.Dom.addClass(document.body, "masked"); - this.sizeMask(); - this.mask.style.display = "block"; - this.showMaskEvent.fire(); - } -}; - -/** -* Sets the size of the modality mask to cover the entire scrollable area of the document -* @method sizeMask -*/ -YAHOO.widget.Panel.prototype.sizeMask = function() { - if (this.mask) { - this.mask.style.height = YAHOO.util.Dom.getDocumentHeight()+"px"; - this.mask.style.width = YAHOO.util.Dom.getDocumentWidth()+"px"; - } -}; - -/** -* Renders the Panel by inserting the elements that are not already in the main Panel into their correct places. Optionally appends the Panel to the specified node prior to the render's execution. NOTE: For Panels without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. -* @method render -* @param {String} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em> -* @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering -* @return {boolean} Success or failure of the render -*/ -YAHOO.widget.Panel.prototype.render = function(appendToNode) { - return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement); -}; - -/** -* Returns a String representation of the object. -* @method toString -* @return {String} The string representation of the Panel. -*/ -YAHOO.widget.Panel.prototype.toString = function() { - return "Panel " + this.id; -}; - -/** -* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually. -* @namespace YAHOO.widget -* @class Dialog -* @extends YAHOO.widget.Panel -* @constructor -* @param {String} el The element ID representing the Dialog <em>OR</em> -* @param {HTMLElement} el The element representing the Dialog -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details. -*/ -YAHOO.widget.Dialog = function(el, userConfig) { - YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel); - -/** -* Constant representing the default CSS class used for a Dialog -* @property YAHOO.widget.Dialog.CSS_DIALOG -* @static -* @final -* @type String -*/ -YAHOO.widget.Dialog.CSS_DIALOG = "yui-dialog"; - -/** -* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Dialog.prototype.initDefaultConfig = function() { - YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this); - - /** - * The internally maintained callback object for use with the Connection utility - * @property callback - * @type Object - */ - this.callback = { - /** - * The function to execute upon success of the Connection submission - * @property callback.success - * @type Function - */ - success : null, - /** - * The function to execute upon failure of the Connection submission - * @property callback.failure - * @type Function - */ - failure : null, - /** - * The arbitraty argument or arguments to pass to the Connection callback functions - * @property callback.argument - * @type Object - */ - argument: null - }; - - // Add form dialog config properties // - - /** - * The method to use for posting the Dialog's form. Possible values are "async", "form", and "manual". - * @config postmethod - * @type String - * @default async - */ - this.cfg.addProperty("postmethod", { value:"async", handler:this.configPostMethod, validator:function(val) { - if (val != "form" && val != "async" && val != "none" && val != "manual") { - return false; - } else { - return true; - } - } }); - - /** - * Object literal(s) defining the buttons for the Dialog's footer. - * @config buttons - * @type Object[] - * @default "none" - */ - this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } ); -}; - -/** -* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class. -* @method initEvents -*/ -YAHOO.widget.Dialog.prototype.initEvents = function() { - YAHOO.widget.Dialog.superclass.initEvents.call(this); - - /** - * CustomEvent fired prior to submission - * @event beforeSumitEvent - */ - this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit"); - - /** - * CustomEvent fired after submission - * @event submitEvent - */ - this.submitEvent = new YAHOO.util.CustomEvent("submit"); - - /** - * CustomEvent fired prior to manual submission - * @event manualSubmitEvent - */ - this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit"); - - /** - * CustomEvent fired prior to asynchronous submission - * @event asyncSubmitEvent - */ - this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit"); - - /** - * CustomEvent fired prior to form-based submission - * @event formSubmitEvent - */ - this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit"); - - /** - * CustomEvent fired after cancel - * @event cancelEvent - */ - this.cancelEvent = new YAHOO.util.CustomEvent("cancel"); -}; - -/** -* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the Dialog <em>OR</em> -* @param {HTMLElement} el The element representing the Dialog -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details. -*/ -YAHOO.widget.Dialog.prototype.init = function(el, userConfig) { - YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Dialog); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG); - - this.cfg.setProperty("visible", false); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.showEvent.subscribe(this.focusFirst, this, true); - this.beforeHideEvent.subscribe(this.blurButtons, this, true); - - this.beforeRenderEvent.subscribe(function() { - var buttonCfg = this.cfg.getProperty("buttons"); - if (buttonCfg && buttonCfg != "none") { - if (! this.footer) { - this.setFooter(""); - } - } - }, this, true); - - this.initEvent.fire(YAHOO.widget.Dialog); -}; - -/** -* Performs the submission of the Dialog form depending on the value of "postmethod" property. -* @method doSubmit -*/ -YAHOO.widget.Dialog.prototype.doSubmit = function() { - var pm = this.cfg.getProperty("postmethod"); - switch (pm) { - case "async": - var method = this.form.getAttribute("method") || 'POST'; - method = method.toUpperCase(); - YAHOO.util.Connect.setForm(this.form); - var cObj = YAHOO.util.Connect.asyncRequest(method, this.form.getAttribute("action"), this.callback); - this.asyncSubmitEvent.fire(); - break; - case "form": - this.form.submit(); - this.formSubmitEvent.fire(); - break; - case "none": - case "manual": - this.manualSubmitEvent.fire(); - break; - } -}; - -/** -* Prepares the Dialog's internal FORM object, creating one if one is not currently present. -* @method registerForm -*/ -YAHOO.widget.Dialog.prototype.registerForm = function() { - var form = this.element.getElementsByTagName("form")[0]; - - if (! form) { - var formHTML = "<form name=\"frm_" + this.id + "\" action=\"\"></form>"; - this.body.innerHTML += formHTML; - form = this.element.getElementsByTagName("form")[0]; - } - - this.firstFormElement = function() { - for (var f=0;f<form.elements.length;f++ ) { - var el = form.elements[f]; - if (el.focus && ! el.disabled) { - if (el.type && el.type != "hidden") { - return el; - } - } - } - return null; - }(); - - this.lastFormElement = function() { - for (var f=form.elements.length-1;f>=0;f-- ) { - var el = form.elements[f]; - if (el.focus && ! el.disabled) { - if (el.type && el.type != "hidden") { - return el; - } - } - } - return null; - }(); - - this.form = form; - - if (this.cfg.getProperty("modal") && this.form) { - - var me = this; - - var firstElement = this.firstFormElement || this.firstButton; - if (firstElement) { - this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} ); - this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true); - this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true); - } - - var lastElement = this.lastButton || this.lastFormElement; - if (lastElement) { - this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} ); - this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true); - this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true); - } - } -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Dialog. -* @method configClose -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Dialog.prototype.configClose = function(type, args, obj) { - var val = args[0]; - - var doCancel = function(e, obj) { - obj.cancel(); - }; - - if (val) { - if (! this.close) { - this.close = document.createElement("div"); - YAHOO.util.Dom.addClass(this.close, "container-close"); - - this.close.innerHTML = " "; - this.innerElement.appendChild(this.close); - YAHOO.util.Event.addListener(this.close, "click", doCancel, this); - } else { - this.close.style.display = "block"; - } - } else { - if (this.close) { - this.close.style.display = "none"; - } - } -}; - -/** -* The default event handler for the "buttons" configuration property -* @method configButtons -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) { - var buttons = args[0]; - if (buttons != "none") { - this.buttonSpan = null; - this.buttonSpan = document.createElement("span"); - this.buttonSpan.className = "button-group"; - - for (var b=0;b<buttons.length;b++) { - var button = buttons[b]; - - var htmlButton = document.createElement("button"); - htmlButton.setAttribute("type", "button"); - - if (button.isDefault) { - htmlButton.className = "default"; - this.defaultHtmlButton = htmlButton; - } - - htmlButton.appendChild(document.createTextNode(button.text)); - YAHOO.util.Event.addListener(htmlButton, "click", button.handler, this, true); - - this.buttonSpan.appendChild(htmlButton); - button.htmlButton = htmlButton; - - if (b === 0) { - this.firstButton = button.htmlButton; - } - - if (b == (buttons.length-1)) { - this.lastButton = button.htmlButton; - } - - } - - this.setFooter(this.buttonSpan); - - this.cfg.refireEvent("iframe"); - this.cfg.refireEvent("underlay"); - } else { // Do cleanup - if (this.buttonSpan) { - if (this.buttonSpan.parentNode) { - this.buttonSpan.parentNode.removeChild(this.buttonSpan); - } - - this.buttonSpan = null; - this.firstButton = null; - this.lastButton = null; - this.defaultHtmlButton = null; - } - } -}; - - -/** -* The default event handler used to focus the first field of the form when the Dialog is shown. -* @method focusFirst -*/ -YAHOO.widget.Dialog.prototype.focusFirst = function(type,args,obj) { - if (args) { - var e = args[1]; - if (e) { - YAHOO.util.Event.stopEvent(e); - } - } - - if (this.firstFormElement) { - this.firstFormElement.focus(); - } else { - this.focusDefaultButton(); - } -}; - -/** -* Sets the focus to the last button in the button or form element in the Dialog -* @method focusLast -*/ -YAHOO.widget.Dialog.prototype.focusLast = function(type,args,obj) { - if (args) { - var e = args[1]; - if (e) { - YAHOO.util.Event.stopEvent(e); - } - } - - var buttons = this.cfg.getProperty("buttons"); - if (buttons && buttons instanceof Array) { - this.focusLastButton(); - } else { - if (this.lastFormElement) { - this.lastFormElement.focus(); - } - } -}; - -/** -* Sets the focus to the button that is designated as the default. By default, his handler is executed when the show event is fired. -* @method focusDefaultButton -*/ -YAHOO.widget.Dialog.prototype.focusDefaultButton = function() { - if (this.defaultHtmlButton) { - this.defaultHtmlButton.focus(); - } -}; - -/** -* Blurs all the html buttons -* @method blurButtons -*/ -YAHOO.widget.Dialog.prototype.blurButtons = function() { - var buttons = this.cfg.getProperty("buttons"); - if (buttons && buttons instanceof Array) { - var html = buttons[0].htmlButton; - if (html) { - html.blur(); - } - } -}; - -/** -* Sets the focus to the first button in the button list -* @method focusFirstButton -*/ -YAHOO.widget.Dialog.prototype.focusFirstButton = function() { - var buttons = this.cfg.getProperty("buttons"); - if (buttons && buttons instanceof Array) { - var html = buttons[0].htmlButton; - if (html) { - html.focus(); - } - } -}; - -/** -* Sets the focus to the first button in the button list -* @method focusLastButton -*/ -YAHOO.widget.Dialog.prototype.focusLastButton = function() { - var buttons = this.cfg.getProperty("buttons"); - if (buttons && buttons instanceof Array) { - var html = buttons[buttons.length-1].htmlButton; - if (html) { - html.focus(); - } - } -}; - -/** -* The default event handler for the "postmethod" configuration property -* @method configPostMethod -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Dialog.prototype.configPostMethod = function(type, args, obj) { - var postmethod = args[0]; - - this.registerForm(); - YAHOO.util.Event.addListener(this.form, "submit", function(e) { - YAHOO.util.Event.stopEvent(e); - this.submit(); - this.form.blur(); - }, this, true); -}; - -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Built-in function hook for writing a validation function that will be checked for a "true" value prior to a submit. This function, as implemented by default, always returns true, so it should be overridden if validation is necessary. -* @method validate -*/ -YAHOO.widget.Dialog.prototype.validate = function() { - return true; -}; - -/** -* Executes a submit of the Dialog followed by a hide, if validation is successful. -* @method submit -*/ -YAHOO.widget.Dialog.prototype.submit = function() { - if (this.validate()) { - this.beforeSubmitEvent.fire(); - this.doSubmit(); - this.submitEvent.fire(); - this.hide(); - return true; - } else { - return false; - } -}; - -/** -* Executes the cancel of the Dialog followed by a hide. -* @method cancel -*/ -YAHOO.widget.Dialog.prototype.cancel = function() { - this.cancelEvent.fire(); - this.hide(); -}; - -/** -* Returns a JSON-compatible data structure representing the data currently contained in the form. -* @method getData -* @return {Object} A JSON object reprsenting the data of the current form. -*/ -YAHOO.widget.Dialog.prototype.getData = function() { - - var oForm = this.form; - - if(oForm) { - - var aElements = oForm.elements, - nTotalElements = aElements.length, - oData = {}, - sName, - oElement; - - - for(var i=0; i<nTotalElements; i++) { - - sName = aElements[i].name, - oElement = aElements[sName]; - - - if(oElement) { - - if(oElement.tagName) { - - var sType = oElement.type, - sTagName = oElement.tagName.toUpperCase(); - - switch(sTagName) { - - case "INPUT": - - if(sType == "checkbox") { - - oData[sName] = oElement.checked; - - } - else if(sType != "radio") { - - oData[sName] = oElement.value; - - } - - break; - - case "TEXTAREA": - - oData[sName] = oElement.value; - - break; - - case "SELECT": - - var aOptions = oElement.options, - nOptions = aOptions.length, - aValues = [], - oOption, - sValue; - - - for(var n=0; n<nOptions; n++) { - - oOption = aOptions[n]; - - if(oOption.selected) { - - sValue = oOption.value; - - if(!sValue || sValue === "") { - - sValue = oOption.text; - - } - - aValues[aValues.length] = sValue; - - } - - } - - oData[sName] = aValues; - - break; - - } - - - } - else { - - var nElements = oElement.length, - sType = oElement[0].type, - sTagName = oElement[0].tagName.toUpperCase(); - - - switch(sType) { - - case "radio": - - var oRadio; - - for(var n=0; n<nElements; n++) { - - oRadio = oElement[n]; - - if(oRadio.checked) { - - oData[sName] = oRadio.value; - break; - - } - - } - - break; - - case "checkbox": - - var aValues = [], - oCheckbox; - - for(var n=0; n<nElements; n++) { - - oCheckbox = oElement[n]; - - if(oCheckbox.checked) { - - aValues[aValues.length] = oCheckbox.value; - - } - - } - - oData[sName] = aValues; - - break; - - } - - } - - } - - } - - } - - - return oData; - -}; - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the Dialog -*/ -YAHOO.widget.Dialog.prototype.toString = function() { - return "Dialog " + this.id; -}; - -/** -* SimpleDialog is a simple implementation of Dialog that can be used to submit a single value. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually. -* @namespace YAHOO.widget -* @class SimpleDialog -* @extends YAHOO.widget.Dialog -* @constructor -* @param {String} el The element ID representing the SimpleDialog <em>OR</em> -* @param {HTMLElement} el The element representing the SimpleDialog -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details. -*/ -YAHOO.widget.SimpleDialog = function(el, userConfig) { - YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog); - -/** -* Constant for the standard network icon for a blocking action -* @property YAHOO.widget.SimpleDialog.ICON_BLOCK -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_BLOCK = "blckicon"; - -/** -* Constant for the standard network icon for alarm -* @property YAHOO.widget.SimpleDialog.ICON_ALARM -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_ALARM = "alrticon"; - -/** -* Constant for the standard network icon for help -* @property YAHOO.widget.SimpleDialog.ICON_HELP -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_HELP = "hlpicon"; - -/** -* Constant for the standard network icon for info -* @property YAHOO.widget.SimpleDialog.ICON_INFO -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_INFO = "infoicon"; - -/** -* Constant for the standard network icon for warn -* @property YAHOO.widget.SimpleDialog.ICON_WARN -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_WARN = "warnicon"; - -/** -* Constant for the standard network icon for a tip -* @property YAHOO.widget.SimpleDialog.ICON_TIP -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.ICON_TIP = "tipicon"; - -/** -* Constant representing the default CSS class used for a SimpleDialog -* @property YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG -* @static -* @final -* @type String -*/ -YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "yui-simple-dialog"; - -/** -* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() { - YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this); - - // Add dialog config properties // - - /** - * Sets the informational icon for the SimpleDialog - * @config icon - * @type String - * @default "none" - */ - this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } ); - - /** - * Sets the text for the SimpleDialog - * @config text - * @type String - * @default "" - */ - this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } ); -}; - - -/** -* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the SimpleDialog <em>OR</em> -* @param {HTMLElement} el The element representing the SimpleDialog -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details. -*/ -YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) { - YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG); - - this.cfg.queueProperty("postmethod", "manual"); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.beforeRenderEvent.subscribe(function() { - if (! this.body) { - this.setBody(""); - } - }, this, true); - - this.initEvent.fire(YAHOO.widget.SimpleDialog); - -}; -/** -* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field. -* @method registerForm -*/ -YAHOO.widget.SimpleDialog.prototype.registerForm = function() { - YAHOO.widget.SimpleDialog.superclass.registerForm.call(this); - this.form.innerHTML += "<input type=\"hidden\" name=\"" + this.id + "\" value=\"\"/>"; -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Fired when the "icon" property is set. -* @method configIcon -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) { - var icon = args[0]; - if (icon && icon != "none") { - var iconHTML = ""; - if (icon.indexOf(".") == -1) { - iconHTML = "<span class=\"yui-icon " + icon +"\" > </span>"; - } else { - iconHTML = "<img src=\"" + this.imageRoot + icon + "\" class=\"yui-icon\" />"; - } - this.body.innerHTML = iconHTML + this.body.innerHTML; - } -}; - -/** -* Fired when the "text" property is set. -* @method configText -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) { - var text = args[0]; - if (text) { - this.setBody(text); - this.cfg.refireEvent("icon"); - } -}; -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the SimpleDialog -*/ -YAHOO.widget.SimpleDialog.prototype.toString = function() { - return "SimpleDialog " + this.id; -}; - -/** -* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden. -* @namespace YAHOO.widget -* @class ContainerEffect -* @constructor -* @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with -* @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element. -* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion. -*/ -YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) { - if (! animClass) { - animClass = YAHOO.util.Anim; - } - - /** - * The overlay to animate - * @property overlay - * @type YAHOO.widget.Overlay - */ - this.overlay = overlay; - /** - * The animation attributes to use when transitioning into view - * @property attrIn - * @type Object - */ - this.attrIn = attrIn; - /** - * The animation attributes to use when transitioning out of view - * @property attrOut - * @type Object - */ - this.attrOut = attrOut; - /** - * The target element to be animated - * @property targetElement - * @type HTMLElement - */ - this.targetElement = targetElement || overlay.element; - /** - * The animation class to use for animating the overlay - * @property animClass - * @type class - */ - this.animClass = animClass; -}; - -/** -* Initializes the animation classes and events. -* @method init -*/ -YAHOO.widget.ContainerEffect.prototype.init = function() { - this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn"); - this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut"); - - this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete"); - this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete"); - - this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method); - this.animIn.onStart.subscribe(this.handleStartAnimateIn, this); - this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this); - this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this); - - this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method); - this.animOut.onStart.subscribe(this.handleStartAnimateOut, this); - this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this); - this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this); -}; - -/** -* Triggers the in-animation. -* @method animateIn -*/ -YAHOO.widget.ContainerEffect.prototype.animateIn = function() { - this.beforeAnimateInEvent.fire(); - this.animIn.animate(); -}; - -/** -* Triggers the out-animation. -* @method animateOut -*/ -YAHOO.widget.ContainerEffect.prototype.animateOut = function() { - this.beforeAnimateOutEvent.fire(); - this.animOut.animate(); -}; - -/** -* The default onStart handler for the in-animation. -* @method handleStartAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { }; -/** -* The default onTween handler for the in-animation. -* @method handleTweenAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { }; -/** -* The default onComplete handler for the in-animation. -* @method handleCompleteAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { }; - -/** -* The default onStart handler for the out-animation. -* @method handleStartAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { }; -/** -* The default onTween handler for the out-animation. -* @method handleTweenAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { }; -/** -* The default onComplete handler for the out-animation. -* @method handleCompleteAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { }; - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the ContainerEffect -*/ -YAHOO.widget.ContainerEffect.prototype.toString = function() { - var output = "ContainerEffect"; - if (this.overlay) { - output += " [" + this.overlay.toString() + "]"; - } - return output; -}; - -/** -* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out. -* @method FADE -* @static -* @param {Overlay} overlay The Overlay object to animate -* @param {Number} dur The duration of the animation -* @return {ContainerEffect} The configured ContainerEffect object -*/ -YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) { - var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element ); - - fade.handleStartAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (! obj.overlay.underlay) { - obj.overlay.cfg.refireEvent("underlay"); - } - - if (obj.overlay.underlay) { - obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity"); - obj.overlay.underlay.style.filter = null; - } - - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0); - }; - - fade.handleCompleteAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - - if (obj.overlay.underlay) { - YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity); - } - - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - }; - - fade.handleStartAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.underlay) { - obj.overlay.underlay.style.filter = null; - } - }; - - fade.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1); - - obj.overlay.cfg.refireEvent("iframe"); - - obj.animateOutCompleteEvent.fire(); - }; - - fade.init(); - return fade; -}; - - -/** -* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out. -* @method SLIDE -* @static -* @param {Overlay} overlay The Overlay object to animate -* @param {Number} dur The duration of the animation -* @return {ContainerEffect} The configured ContainerEffect object -*/ -YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) { - var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element); - var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element); - - var clientWidth = YAHOO.util.Dom.getClientWidth(); - var offsetWidth = overlay.element.offsetWidth; - - var slide = new YAHOO.widget.ContainerEffect(overlay, { - attributes:{ points: { to:[x, y] } }, - duration:dur, - method:YAHOO.util.Easing.easeIn - }, - { - attributes:{ points: { to:[(clientWidth+25), y] } }, - duration:dur, - method:YAHOO.util.Easing.easeOut - }, - overlay.element, - YAHOO.util.Motion); - - - slide.handleStartAnimateIn = function(type,args,obj) { - obj.overlay.element.style.left = (-25-offsetWidth) + "px"; - obj.overlay.element.style.top = y + "px"; - }; - - slide.handleTweenAnimateIn = function(type, args, obj) { - - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var currentX = pos[0]; - var currentY = pos[1]; - - if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - } - - obj.overlay.cfg.setProperty("xy", [currentX,currentY], true); - obj.overlay.cfg.refireEvent("iframe"); - }; - - slide.handleCompleteAnimateIn = function(type, args, obj) { - obj.overlay.cfg.setProperty("xy", [x,y], true); - obj.startX = x; - obj.startY = y; - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - }; - - slide.handleStartAnimateOut = function(type, args, obj) { - var vw = YAHOO.util.Dom.getViewportWidth(); - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var yso = pos[1]; - - var currentTo = obj.animOut.attributes.points.to; - obj.animOut.attributes.points.to = [(vw+25), yso]; - }; - - slide.handleTweenAnimateOut = function(type, args, obj) { - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var xto = pos[0]; - var yto = pos[1]; - - obj.overlay.cfg.setProperty("xy", [xto,yto], true); - obj.overlay.cfg.refireEvent("iframe"); - }; - - slide.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - - obj.overlay.cfg.setProperty("xy", [x,y]); - obj.animateOutCompleteEvent.fire(); - }; - - slide.init(); - return slide; -}; - -YAHOO.register("container", YAHOO.widget.Module, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/container/container_core-debug.js b/interface/web/js/yui/container/container_core-debug.js deleted file mode 100644 index c4a587d8fb..0000000000 --- a/interface/web/js/yui/container/container_core-debug.js +++ /dev/null @@ -1,2932 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** -* 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); - } - if (!owner) { 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<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - - if (queueItem) { - var queueItemKey = queueItem[0]; - var queueItemValue = queueItem[1]; - - if (queueItemKey.toLowerCase() == key) { - // found a dupe... push to end of queue, null current item, and break - eventQueue[i] = null; - eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]); - foundDuplicate = true; - break; - } - } - } - - if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue - eventQueue.push([key, value]); - } - } - - if (property.supercedes) { - for (var s=0;s<property.supercedes.length;s++) { - var supercedesCheck = property.supercedes[s]; - - for (var q=0;q<eventQueue.length;q++) { - var queueItemCheck = eventQueue[q]; - - if (queueItemCheck) { - var queueItemCheckKey = queueItemCheck[0]; - var queueItemCheckValue = queueItemCheck[1]; - - if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) { - eventQueue.push([queueItemCheckKey, queueItemCheckValue]); - eventQueue[q] = null; - break; - } - } - } - } - } - YAHOO.log("Config event queue: " + this.outputEventQueue(), "info"); - - return true; - } else { - return false; - } - }; - - /** - * Fires the event for a property using the property's current value. - * @method refireEvent - * @param {String} key The name of the property - */ - this.refireEvent = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') { - if (this.queueInProgress) { - this.queueProperty(key); - } else { - fireEvent(key, property.value); - } - } - }; - - /** - * Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their associated events to execute. - * @method applyConfig - * @param {Object} userConfig The configuration Object literal - * @param {Boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. - */ - this.applyConfig = function(userConfig, init) { - if (init) { - initialConfig = userConfig; - } - for (var prop in userConfig) { - this.queueProperty(prop, userConfig[prop]); - } - }; - - /** - * Refires the events for all configuration properties using their current values. - * @method refresh - */ - this.refresh = function() { - for (var prop in config) { - this.refireEvent(prop); - } - }; - - /** - * Fires the normalized list of queued property change events - * @method fireQueue - */ - this.fireQueue = function() { - this.queueInProgress = true; - for (var i=0;i<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - if (queueItem) { - var key = queueItem[0]; - var value = queueItem[1]; - - var property = config[key]; - property.value = value; - - fireEvent(key,value); - } - } - - this.queueInProgress = false; - eventQueue = []; - }; - - /** - * Subscribes an external handler to the change event for any given property. - * @method subscribeToConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @param {Boolean} override Optional. If true, will override "this" within the handler to map to the scope Object passed into the method. - * @return {Boolean} True, if the subscription was successful, otherwise false. - */ - this.subscribeToConfigEvent = function(key, handler, obj, override) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) { - property.event.subscribe(handler, obj, override); - } - return true; - } else { - return false; - } - }; - - /** - * Unsubscribes an external handler from the change event for any given property. - * @method unsubscribeFromConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @return {Boolean} True, if the unsubscription was successful, otherwise false. - */ - this.unsubscribeFromConfigEvent = function(key, handler, obj) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.event.unsubscribe(handler, obj); - } else { - return false; - } - }; - - /** - * Returns a string representation of the Config object - * @method toString - * @return {String} The Config object in string format. - */ - this.toString = function() { - var output = "Config"; - if (this.owner) { - output += " [" + this.owner.toString() + "]"; - } - return output; - }; - - /** - * Returns a string representation of the Config object's current CustomEvent queue - * @method outputEventQueue - * @return {String} The string list of CustomEvents currently queued for execution - */ - this.outputEventQueue = function() { - var output = ""; - for (var q=0;q<eventQueue.length;q++) { - var queueItem = eventQueue[q]; - if (queueItem) { - output += queueItem[0] + "=" + queueItem[1] + ", "; - } - } - return output; - }; -}; - -/** -* Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent -* @method YAHOO.util.Config.alreadySubscribed -* @static -* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions -* @param {Function} fn The function to look for in the subscribers list -* @param {Object} obj The execution scope Object for the subscription -* @return {Boolean} true, if the function/Object pair is already subscribed to the CustomEvent passed in -*/ -YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) { - for (var e=0;e<evt.subscribers.length;e++) { - var subsc = evt.subscribers[e]; - if (subsc && subsc.obj == obj && subsc.fn == fn) { - return true; - } - } - return false; -}; - -/** -* The Container family of components is designed to enable developers to create different kinds of content-containing modules on the web. Module and Overlay are the most basic containers, and they can be used directly or extended to build custom containers. Also part of the Container family are four UI controls that extend Module and Overlay: Tooltip, Panel, Dialog, and SimpleDialog. -* @module container -* @title Container -* @requires yahoo,dom,event,dragdrop,animation -*/ - -/** -* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package. -* @namespace YAHOO.widget -* @class Module -* @constructor -* @param {String} el The element ID representing the Module <em>OR</em> -* @param {HTMLElement} el The element representing the Module -* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. -*/ -YAHOO.widget.Module = function(el, userConfig) { - if (el) { - this.init(el, userConfig); - } else { - YAHOO.log("No element or element ID specified for Module instantiation", "error"); - } -}; - -/** -* Constant representing the prefix path to use for non-secure images -* @property YAHOO.widget.Module.IMG_ROOT -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.IMG_ROOT = null; - -/** -* Constant representing the prefix path to use for securely served images -* @property YAHOO.widget.Module.IMG_ROOT_SSL -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.IMG_ROOT_SSL = null; - -/** -* Constant for the default CSS class name that represents a Module -* @property YAHOO.widget.Module.CSS_MODULE -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_MODULE = "module"; - -/** -* Constant representing the module header -* @property YAHOO.widget.Module.CSS_HEADER -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_HEADER = "hd"; - -/** -* Constant representing the module body -* @property YAHOO.widget.Module.CSS_BODY -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_BODY = "bd"; - -/** -* Constant representing the module footer -* @property YAHOO.widget.Module.CSS_FOOTER -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_FOOTER = "ft"; - -/** -* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size -* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;"; - -/** -* Singleton CustomEvent fired when the font size is changed in the browser. -* Opera's "zoom" functionality currently does not support text size detection. -* @event YAHOO.widget.Module.textResizeEvent -*/ -YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize"); - -YAHOO.widget.Module.prototype = { - /** - * The class's constructor function - * @property contructor - * @type Function - */ - constructor : YAHOO.widget.Module, - - /** - * The main module element that contains the header, body, and footer - * @property element - * @type HTMLElement - */ - element : null, - - /** - * The header element, denoted with CSS class "hd" - * @property header - * @type HTMLElement - */ - header : null, - - /** - * The body element, denoted with CSS class "bd" - * @property body - * @type HTMLElement - */ - body : null, - - /** - * The footer element, denoted with CSS class "ft" - * @property footer - * @type HTMLElement - */ - footer : null, - - /** - * The id of the element - * @property id - * @type String - */ - id : null, - - /** - * The String representing the image root - * @property imageRoot - * @type String - */ - imageRoot : YAHOO.widget.Module.IMG_ROOT, - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - * @method initEvents - */ - initEvents : function() { - - /** - * CustomEvent fired prior to class initalization. - * @event beforeInitEvent - * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - */ - this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); - - /** - * CustomEvent fired after class initalization. - * @event initEvent - * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - */ - this.initEvent = new YAHOO.util.CustomEvent("init"); - - /** - * CustomEvent fired when the Module is appended to the DOM - * @event appendEvent - */ - this.appendEvent = new YAHOO.util.CustomEvent("append"); - - /** - * CustomEvent fired before the Module is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - - /** - * CustomEvent fired after the Module is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); - - /** - * CustomEvent fired when the header content of the Module is modified - * @event changeHeaderEvent - * @param {String/HTMLElement} content String/element representing the new header content - */ - this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); - - /** - * CustomEvent fired when the body content of the Module is modified - * @event changeBodyEvent - * @param {String/HTMLElement} content String/element representing the new body content - */ - this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); - - /** - * CustomEvent fired when the footer content of the Module is modified - * @event changeFooterEvent - * @param {String/HTMLElement} content String/element representing the new footer content - */ - this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); - - /** - * CustomEvent fired when the content of the Module is modified - * @event changeContentEvent - */ - this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); - - /** - * CustomEvent fired when the Module is destroyed - * @event destroyEvent - */ - this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); - - /** - * CustomEvent fired before the Module is shown - * @event beforeShowEvent - */ - this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); - - /** - * CustomEvent fired after the Module is shown - * @event showEvent - */ - this.showEvent = new YAHOO.util.CustomEvent("show"); - - /** - * CustomEvent fired before the Module is hidden - * @event beforeHideEvent - */ - this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); - - /** - * CustomEvent fired after the Module is hidden - * @event hideEvent - */ - this.hideEvent = new YAHOO.util.CustomEvent("hide"); - }, - - /** - * String representing the current user-agent platform - * @property platform - * @type String - */ - platform : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) { - return "windows"; - } else if (ua.indexOf("macintosh") != -1) { - return "mac"; - } else { - return false; - } - }(), - - /** - * String representing the current user-agent browser - * @property browser - * @type String - */ - browser : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) - return 'opera'; - } else if (ua.indexOf('msie 7')!=-1) { // IE7 - return 'ie7'; - } else if (ua.indexOf('msie') !=-1) { // IE - return 'ie'; - } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") - return 'safari'; - } else if (ua.indexOf('gecko') != -1) { // Gecko - return 'gecko'; - } else { - return false; - } - }(), - - /** - * Boolean representing whether or not the current browsing context is secure (https) - * @property isSecure - * @type Boolean - */ - isSecure : function() { - if (window.location.href.toLowerCase().indexOf("https") === 0) { - return true; - } else { - return false; - } - }(), - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - */ - initDefaultConfig : function() { - // Add properties // - - /** - * Specifies whether the Module is visible on the page. - * @config visible - * @type Boolean - * @default true - */ - this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } ); - - /** - * Object or array of objects representing the ContainerEffect classes that are active for animating the container. - * @config effect - * @type Object - * @default null - */ - this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } ); - - /** - * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document - * @config monitorresize - * @type Boolean - * @default true - */ - this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } ); - }, - - /** - * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. - * @method init - * @param {String} el The element ID representing the Module <em>OR</em> - * @param {HTMLElement} el The element representing the Module - * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. - */ - init : function(el, userConfig) { - - this.initEvents(); - - this.beforeInitEvent.fire(YAHOO.widget.Module); - - /** - * The Module's Config object used for monitoring configuration properties. - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - if (this.isSecure) { - this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL; - } - - if (typeof el == "string") { - var elId = el; - - el = document.getElementById(el); - if (! el) { - el = document.createElement("div"); - el.id = elId; - } - } - - this.element = el; - - if (el.id) { - this.id = el.id; - } - - var childNodes = this.element.childNodes; - - if (childNodes) { - for (var i=0;i<childNodes.length;i++) { - var child = childNodes[i]; - switch (child.className) { - case YAHOO.widget.Module.CSS_HEADER: - this.header = child; - break; - case YAHOO.widget.Module.CSS_BODY: - this.body = child; - break; - case YAHOO.widget.Module.CSS_FOOTER: - this.footer = child; - break; - } - } - } - - this.initDefaultConfig(); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - // Subscribe to the fireQueue() method of Config so that any queued configuration changes are - // excecuted upon render of the Module - if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) { - this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true); - } - - this.initEvent.fire(YAHOO.widget.Module); - }, - - /** - * Initialized an empty IFRAME that is placed out of the visible area that can be used to detect text resize. - * @method initResizeMonitor - */ - initResizeMonitor : function() { - - if(this.browser != "opera") { - - var resizeMonitor = document.getElementById("_yuiResizeMonitor"); - - if (! resizeMonitor) { - - resizeMonitor = document.createElement("iframe"); - - var bIE = (this.browser.indexOf("ie") === 0); - - if(this.isSecure && YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL && bIE) { - resizeMonitor.src = YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL; - } - - resizeMonitor.id = "_yuiResizeMonitor"; - resizeMonitor.style.visibility = "hidden"; - - document.body.appendChild(resizeMonitor); - - resizeMonitor.style.width = "10em"; - resizeMonitor.style.height = "10em"; - resizeMonitor.style.position = "absolute"; - - var nLeft = -1 * resizeMonitor.offsetWidth; - var nTop = -1 * resizeMonitor.offsetHeight; - - resizeMonitor.style.top = nTop + "px"; - resizeMonitor.style.left = nLeft + "px"; - resizeMonitor.style.borderStyle = "none"; - resizeMonitor.style.borderWidth = "0"; - YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0"); - - resizeMonitor.style.visibility = "visible"; - - if(!bIE) { - - var doc = resizeMonitor.contentWindow.document; - - doc.open(); - doc.close(); - - } - } - - var fireTextResize = function() { - YAHOO.widget.Module.textResizeEvent.fire(); - }; - - if(resizeMonitor && resizeMonitor.contentWindow) { - this.resizeMonitor = resizeMonitor; - - YAHOO.widget.Module.textResizeEvent.subscribe(this.onDomResize, this, true); - - if (! YAHOO.widget.Module.textResizeInitialized) { - if (! YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", fireTextResize)) { - // This will fail in IE if document.domain has changed, so we must change the listener to - // use the resizeMonitor element instead - YAHOO.util.Event.addListener(this.resizeMonitor, "resize", fireTextResize); - } - YAHOO.widget.Module.textResizeInitialized = true; - } - } - - } - - }, - - /** - * Event handler fired when the resize monitor element is resized. - * @method onDomResize - * @param {DOMEvent} e The DOM resize event - * @param {Object} obj The scope object passed to the handler - */ - onDomResize : function(e, obj) { - - var nLeft = -1 * this.resizeMonitor.offsetWidth, - nTop = -1 * this.resizeMonitor.offsetHeight; - - this.resizeMonitor.style.top = nTop + "px"; - this.resizeMonitor.style.left = nLeft + "px"; - - }, - - /** - * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created. - * @method setHeader - * @param {String} headerContent The HTML used to set the header <em>OR</em> - * @param {HTMLElement} headerContent The HTMLElement to append to the header - */ - setHeader : function(headerContent) { - if (! this.header) { - this.header = document.createElement("div"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - if (typeof headerContent == "string") { - this.header.innerHTML = headerContent; - } else { - this.header.innerHTML = ""; - this.header.appendChild(headerContent); - } - - this.changeHeaderEvent.fire(headerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the header. If no header is present, one will be automatically created. - * @method appendToHeader - * @param {HTMLElement} element The element to append to the header - */ - appendToHeader : function(element) { - if (! this.header) { - this.header = document.createElement("div"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - this.header.appendChild(element); - this.changeHeaderEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created. - * @method setBody - * @param {String} bodyContent The HTML used to set the body <em>OR</em> - * @param {HTMLElement} bodyContent The HTMLElement to append to the body - */ - setBody : function(bodyContent) { - if (! this.body) { - this.body = document.createElement("div"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - if (typeof bodyContent == "string") - { - this.body.innerHTML = bodyContent; - } else { - this.body.innerHTML = ""; - this.body.appendChild(bodyContent); - } - - this.changeBodyEvent.fire(bodyContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the body. If no body is present, one will be automatically created. - * @method appendToBody - * @param {HTMLElement} element The element to append to the body - */ - appendToBody : function(element) { - if (! this.body) { - this.body = document.createElement("div"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - this.body.appendChild(element); - this.changeBodyEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created. - * @method setFooter - * @param {String} footerContent The HTML used to set the footer <em>OR</em> - * @param {HTMLElement} footerContent The HTMLElement to append to the footer - */ - setFooter : function(footerContent) { - if (! this.footer) { - this.footer = document.createElement("div"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - if (typeof footerContent == "string") { - this.footer.innerHTML = footerContent; - } else { - this.footer.innerHTML = ""; - this.footer.appendChild(footerContent); - } - - this.changeFooterEvent.fire(footerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the footer. If no footer is present, one will be automatically created. - * @method appendToFooter - * @param {HTMLElement} element The element to append to the footer - */ - appendToFooter : function(element) { - if (! this.footer) { - this.footer = document.createElement("div"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - this.footer.appendChild(element); - this.changeFooterEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. - * @method render - * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em> - * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering - * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container. - * @return {Boolean} Success or failure of the render - */ - render : function(appendToNode, moduleElement) { - this.beforeRenderEvent.fire(); - - if (! moduleElement) { - moduleElement = this.element; - } - - var me = this; - var appendTo = function(element) { - if (typeof element == "string") { - element = document.getElementById(element); - } - - if (element) { - element.appendChild(me.element); - me.appendEvent.fire(); - } - }; - - if (appendToNode) { - appendTo(appendToNode); - } else { // No node was passed in. If the element is not pre-marked up, this fails - if (! YAHOO.util.Dom.inDocument(this.element)) { - YAHOO.log("Render failed. Must specify appendTo node if Module isn't already in the DOM.", "error"); - return false; - } - } - - // Need to get everything into the DOM if it isn't already - - if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) { - // There is a header, but it's not in the DOM yet... need to add it - var firstChild = moduleElement.firstChild; - if (firstChild) { // Insert before first child if exists - moduleElement.insertBefore(this.header, firstChild); - } else { // Append to empty body because there are no children - moduleElement.appendChild(this.header); - } - } - - if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) { - // There is a body, but it's not in the DOM yet... need to add it - if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM - moduleElement.insertBefore(this.body, this.footer); - } else { // Append to element because there is no footer - moduleElement.appendChild(this.body); - } - } - - if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) { - // There is a footer, but it's not in the DOM yet... need to add it - moduleElement.appendChild(this.footer); - } - - this.renderEvent.fire(); - return true; - }, - - /** - * Removes the Module element from the DOM and sets all child elements to null. - * @method destroy - */ - destroy : function() { - var parent; - - if (this.element) { - YAHOO.util.Event.purgeElement(this.element, true); - parent = this.element.parentNode; - } - if (parent) { - parent.removeChild(this.element); - } - - this.element = null; - this.header = null; - this.body = null; - this.footer = null; - - for (var e in this) { - if (e instanceof YAHOO.util.CustomEvent) { - e.unsubscribeAll(); - } - } - - YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this); - - this.destroyEvent.fire(); - }, - - /** - * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after. - * @method show - */ - show : function() { - this.cfg.setProperty("visible", true); - }, - - /** - * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after. - * @method hide - */ - hide : function() { - this.cfg.setProperty("visible", false); - }, - - // BUILT-IN EVENT HANDLERS FOR MODULE // - - /** - * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none". - * This method is responsible for firing showEvent and hideEvent. - * @param {String} type The CustomEvent type (usually the property name) - * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. - * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. - * @method configVisible - */ - configVisible : function(type, args, obj) { - var visible = args[0]; - if (visible) { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "block"); - this.showEvent.fire(); - } else { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "none"); - this.hideEvent.fire(); - } - }, - - /** - * Default event handler for the "monitorresize" configuration property - * @param {String} type The CustomEvent type (usually the property name) - * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. - * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. - * @method configMonitorResize - */ - configMonitorResize : function(type, args, obj) { - var monitor = args[0]; - if (monitor) { - this.initResizeMonitor(); - } else { - YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true); - this.resizeMonitor = null; - } - } -}; - -/** -* Returns a String representation of the Object. -* @method toString -* @return {String} The string representation of the Module -*/ -YAHOO.widget.Module.prototype.toString = function() { - return "Module " + this.id; -}; - -/** -* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements. -* @namespace YAHOO.widget -* @class Overlay -* @extends YAHOO.widget.Module -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Overlay = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module); - -/** -* The URL that will be placed in the iframe -* @property YAHOO.widget.Overlay.IFRAME_SRC -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;"; - -/** -* Constant representing the top left corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.TOP_LEFT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.TOP_LEFT = "tl"; - -/** -* Constant representing the top right corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.TOP_RIGHT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.TOP_RIGHT = "tr"; - -/** -* Constant representing the top bottom left corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.BOTTOM_LEFT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.BOTTOM_LEFT = "bl"; - -/** -* Constant representing the bottom right corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.BOTTOM_RIGHT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.BOTTOM_RIGHT = "br"; - -/** -* Constant representing the default CSS class used for an Overlay -* @property YAHOO.widget.Overlay.CSS_OVERLAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.CSS_OVERLAY = "yui-overlay"; - -/** -* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Overlay.prototype.init = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Overlay); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - if (this.platform == "mac" && this.browser == "gecko") { - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) { - this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) { - this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true); - } - } - - this.initEvent.fire(YAHOO.widget.Overlay); - -}; - -/** -* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class. -* @method initEvents -*/ -YAHOO.widget.Overlay.prototype.initEvents = function() { - YAHOO.widget.Overlay.superclass.initEvents.call(this); - - /** - * CustomEvent fired before the Overlay is moved. - * @event beforeMoveEvent - * @param {Number} x x coordinate - * @param {Number} y y coordinate - */ - this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this); - - /** - * CustomEvent fired after the Overlay is moved. - * @event moveEvent - * @param {Number} x x coordinate - * @param {Number} y y coordinate - */ - this.moveEvent = new YAHOO.util.CustomEvent("move", this); -}; - -/** -* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Overlay.prototype.initDefaultConfig = function() { - YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this); - - // Add overlay config properties // - - /** - * The absolute x-coordinate position of the Overlay - * @config x - * @type Number - * @default null - */ - this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * The absolute y-coordinate position of the Overlay - * @config y - * @type Number - * @default null - */ - this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * An array with the absolute x and y positions of the Overlay - * @config xy - * @type Number[] - * @default null - */ - this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner. - * @config context - * @type Array - * @default null - */ - this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * True if the Overlay should be anchored to the center of the viewport. - * @config fixedcenter - * @type Boolean - * @default false - */ - this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } ); - - /** - * CSS width of the Overlay. - * @config width - * @type String - * @default null - */ - this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * CSS height of the Overlay. - * @config height - * @type String - * @default null - */ - this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * CSS z-index of the Overlay. - * @config zIndex - * @type Number - * @default null - */ - this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } ); - - /** - * True if the Overlay should be prevented from being positioned out of the viewport. - * @config constraintoviewport - * @type Boolean - * @default false - */ - this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } ); - - /** - * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below). - * @config iframe - * @type Boolean - * @default true for IE6 and below, false for all others - */ - this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } ); -}; - -/** -* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]); -* @method moveTo -* @param {Number} x The Overlay's new x position -* @param {Number} y The Overlay's new y position -*/ -YAHOO.widget.Overlay.prototype.moveTo = function(x, y) { - this.cfg.setProperty("xy",[x,y]); -}; - -/** -* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -* @method hideMacGeckoScrollbars -*/ -YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "show-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "hide-scrollbars"); -}; - -/** -* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -* @method showMacGeckoScrollbars -*/ -YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "show-scrollbars"); -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent. -* @method configVisible -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) { - var visible = args[0]; - var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility"); - - if (currentVis == "inherit") { - var e = this.element.parentNode; - while (e.nodeType != 9 && e.nodeType != 11) { - currentVis = YAHOO.util.Dom.getStyle(e, "visibility"); - if (currentVis != "inherit") { break; } - e = e.parentNode; - } - if (currentVis == "inherit") { - currentVis = "visible"; - } - } - - var effect = this.cfg.getProperty("effect"); - - var effectInstances = []; - if (effect) { - if (effect instanceof Array) { - for (var i=0;i<effect.length;i++) { - var eff = effect[i]; - effectInstances[effectInstances.length] = eff.effect(this, eff.duration); - } - } else { - effectInstances[effectInstances.length] = effect.effect(this, effect.duration); - } - } - - var isMacGecko = (this.platform == "mac" && this.browser == "gecko"); - - if (visible) { // Show - if (isMacGecko) { - this.showMacGeckoScrollbars(); - } - - if (effect) { // Animate in - if (visible) { // Animate in if not showing - if (currentVis != "visible" || currentVis === "") { - this.beforeShowEvent.fire(); - for (var j=0;j<effectInstances.length;j++) { - var ei = effectInstances[j]; - if (j === 0 && ! YAHOO.util.Config.alreadySubscribed(ei.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) { - ei.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete - } - ei.animateIn(); - } - } - } - } else { // Show - if (currentVis != "visible" || currentVis === "") { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "visibility", "visible"); - this.cfg.refireEvent("iframe"); - this.showEvent.fire(); - } - } - - } else { // Hide - if (isMacGecko) { - this.hideMacGeckoScrollbars(); - } - - if (effect) { // Animate out if showing - if (currentVis == "visible") { - this.beforeHideEvent.fire(); - for (var k=0;k<effectInstances.length;k++) { - var h = effectInstances[k]; - if (k === 0 && ! YAHOO.util.Config.alreadySubscribed(h.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) { - h.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete - } - h.animateOut(); - } - } else if (currentVis === "") { - YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden"); - } - } else { // Simple hide - if (currentVis == "visible" || currentVis === "") { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden"); - this.cfg.refireEvent("iframe"); - this.hideEvent.fire(); - } - } - } -}; - -/** -* Center event handler used for centering on scroll/resize, but only if the Overlay is visible -* @method doCenterOnDOMEvent -*/ -YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() { - if (this.cfg.getProperty("visible")) { - this.center(); - } -}; - -/** -* The default event handler fired when the "fixedcenter" property is changed. -* @method configFixedCenter -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) { - var val = args[0]; - - if (val) { - this.center(); - - if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) { - this.beforeShowEvent.subscribe(this.center, this, true); - } - - if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) { - YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true); - } - - if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) { - YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true); - } - } else { - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); - } -}; - -/** -* The default event handler fired when the "height" property is changed. -* @method configHeight -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) { - var height = args[0]; - var el = this.element; - YAHOO.util.Dom.setStyle(el, "height", height); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "width" property is changed. -* @method configWidth -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) { - var width = args[0]; - var el = this.element; - YAHOO.util.Dom.setStyle(el, "width", width); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "zIndex" property is changed. -* @method configzIndex -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) { - var zIndex = args[0]; - - var el = this.element; - - if (! zIndex) { - zIndex = YAHOO.util.Dom.getStyle(el, "zIndex"); - if (! zIndex || isNaN(zIndex)) { - zIndex = 0; - } - } - - if (this.iframe) { - if (zIndex <= 0) { - zIndex = 1; - } - YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1)); - } - - YAHOO.util.Dom.setStyle(el, "zIndex", zIndex); - this.cfg.setProperty("zIndex", zIndex, true); -}; - -/** -* The default event handler fired when the "xy" property is changed. -* @method configXY -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) { - var pos = args[0]; - var x = pos[0]; - var y = pos[1]; - - this.cfg.setProperty("x", x); - this.cfg.setProperty("y", y); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.log("xy: " + [x,y], "iframe"); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x,y]); -}; - -/** -* The default event handler fired when the "x" property is changed. -* @method configX -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) { - var x = args[0]; - var y = this.cfg.getProperty("y"); - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.util.Dom.setX(this.element, x, true); - - this.cfg.setProperty("xy", [x, y], true); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x, y]); -}; - -/** -* The default event handler fired when the "y" property is changed. -* @method configY -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) { - var x = this.cfg.getProperty("x"); - var y = args[0]; - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.util.Dom.setY(this.element, y, true); - - this.cfg.setProperty("xy", [x, y], true); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x, y]); -}; - -/** -* Shows the iframe shim, if it has been enabled -* @method showIframe -*/ -YAHOO.widget.Overlay.prototype.showIframe = function() { - if (this.iframe) { - this.iframe.style.display = "block"; - } -}; - -/** -* Hides the iframe shim, if it has been enabled -* @method hideIframe -*/ -YAHOO.widget.Overlay.prototype.hideIframe = function() { - if (this.iframe) { - this.iframe.style.display = "none"; - } -}; - -/** -* The default event handler fired when the "iframe" property is changed. -* @method configIframe -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) { - - var val = args[0]; - - if (val) { // IFRAME shim is enabled - - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, this.showIframe, this)) { - this.showEvent.subscribe(this.showIframe, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, this.hideIframe, this)) { - this.hideEvent.subscribe(this.hideIframe, this, true); - } - - var x = this.cfg.getProperty("x"); - var y = this.cfg.getProperty("y"); - - if (! x || ! y) { - this.syncPosition(); - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - } - - YAHOO.log("iframe positioning to: " + [x,y], "iframe"); - - if (! isNaN(x) && ! isNaN(y)) { - if (! this.iframe) { - this.iframe = document.createElement("iframe"); - if (this.isSecure) { - this.iframe.src = YAHOO.widget.Overlay.IFRAME_SRC; - } - - var parent = this.element.parentNode; - if (parent) { - parent.appendChild(this.iframe); - } else { - document.body.appendChild(this.iframe); - } - - YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute"); - YAHOO.util.Dom.setStyle(this.iframe, "border", "none"); - YAHOO.util.Dom.setStyle(this.iframe, "margin", "0"); - YAHOO.util.Dom.setStyle(this.iframe, "padding", "0"); - YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); - if (this.cfg.getProperty("visible")) { - this.showIframe(); - } else { - this.hideIframe(); - } - } - - var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display"); - - if (iframeDisplay == "none") { - this.iframe.style.display = "block"; - } - - YAHOO.util.Dom.setXY(this.iframe, [x,y]); - - var width = this.element.clientWidth; - var height = this.element.clientHeight; - - YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px"); - YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px"); - - if (iframeDisplay == "none") { - this.iframe.style.display = "none"; - } - } - } else { - if (this.iframe) { - this.iframe.style.display = "none"; - } - this.showEvent.unsubscribe(this.showIframe, this); - this.hideEvent.unsubscribe(this.hideIframe, this); - } -}; - - -/** -* The default event handler fired when the "constraintoviewport" property is changed. -* @method configConstrainToViewport -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) { - var val = args[0]; - if (val) { - if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) { - this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true); - } - } else { - this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this); - } -}; - -/** -* The default event handler fired when the "context" property is changed. -* @method configContext -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) { - var contextArgs = args[0]; - - if (contextArgs) { - var contextEl = contextArgs[0]; - var elementMagnetCorner = contextArgs[1]; - var contextMagnetCorner = contextArgs[2]; - - if (contextEl) { - if (typeof contextEl == "string") { - this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true); - } - - if (elementMagnetCorner && contextMagnetCorner) { - this.align(elementMagnetCorner, contextMagnetCorner); - } - } - } -}; - - -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT. -* @method align -* @param {String} elementAlign The String representing the corner of the Overlay that should be aligned to the context element -* @param {String} contextAlign The corner of the context element that the elementAlign corner should stick to. -*/ -YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) { - var contextArgs = this.cfg.getProperty("context"); - if (contextArgs) { - var context = contextArgs[0]; - - var element = this.element; - var me = this; - - if (! elementAlign) { - elementAlign = contextArgs[1]; - } - - if (! contextAlign) { - contextAlign = contextArgs[2]; - } - - if (element && context) { - var contextRegion = YAHOO.util.Dom.getRegion(context); - - var doAlign = function(v,h) { - switch (elementAlign) { - case YAHOO.widget.Overlay.TOP_LEFT: - me.moveTo(h,v); - break; - case YAHOO.widget.Overlay.TOP_RIGHT: - me.moveTo(h-element.offsetWidth,v); - break; - case YAHOO.widget.Overlay.BOTTOM_LEFT: - me.moveTo(h,v-element.offsetHeight); - break; - case YAHOO.widget.Overlay.BOTTOM_RIGHT: - me.moveTo(h-element.offsetWidth,v-element.offsetHeight); - break; - } - }; - - switch (contextAlign) { - case YAHOO.widget.Overlay.TOP_LEFT: - doAlign(contextRegion.top, contextRegion.left); - break; - case YAHOO.widget.Overlay.TOP_RIGHT: - doAlign(contextRegion.top, contextRegion.right); - break; - case YAHOO.widget.Overlay.BOTTOM_LEFT: - doAlign(contextRegion.bottom, contextRegion.left); - break; - case YAHOO.widget.Overlay.BOTTOM_RIGHT: - doAlign(contextRegion.bottom, contextRegion.right); - break; - } - } - } -}; - -/** -* The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true. -* @method enforceConstraints -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) { - var pos = args[0]; - - var x = pos[0]; - var y = pos[1]; - - var offsetHeight = this.element.offsetHeight; - var offsetWidth = this.element.offsetWidth; - - var viewPortWidth = YAHOO.util.Dom.getViewportWidth(); - var viewPortHeight = YAHOO.util.Dom.getViewportHeight(); - - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var topConstraint = scrollY + 10; - var leftConstraint = scrollX + 10; - var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10; - var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10; - - if (x < leftConstraint) { - x = leftConstraint; - } else if (x > rightConstraint) { - x = rightConstraint; - } - - if (y < topConstraint) { - y = topConstraint; - } else if (y > bottomConstraint) { - y = bottomConstraint; - } - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - this.cfg.setProperty("xy", [x,y], true); -}; - -/** -* Centers the container in the viewport. -* @method center -*/ -YAHOO.widget.Overlay.prototype.center = function() { - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var viewPortWidth = YAHOO.util.Dom.getClientWidth(); - var viewPortHeight = YAHOO.util.Dom.getClientHeight(); - - var elementWidth = this.element.offsetWidth; - var elementHeight = this.element.offsetHeight; - - var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX; - var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY; - - this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]); - - this.cfg.refireEvent("iframe"); -}; - -/** -* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop. -* @method syncPosition -*/ -YAHOO.widget.Overlay.prototype.syncPosition = function() { - var pos = YAHOO.util.Dom.getXY(this.element); - this.cfg.setProperty("x", pos[0], true); - this.cfg.setProperty("y", pos[1], true); - this.cfg.setProperty("xy", pos, true); -}; - -/** -* Event handler fired when the resize monitor element is resized. -* @method onDomResize -* @param {DOMEvent} e The resize DOM event -* @param {Object} obj The scope object -*/ -YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) { - YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj); - var me = this; - setTimeout(function() { - me.syncPosition(); - me.cfg.refireEvent("iframe"); - me.cfg.refireEvent("context"); - }, 0); -}; - -/** -* Removes the Overlay element from the DOM and sets all child elements to null. -* @method destroy -*/ -YAHOO.widget.Overlay.prototype.destroy = function() { - if (this.iframe) { - this.iframe.parentNode.removeChild(this.iframe); - } - - this.iframe = null; - - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); - - YAHOO.widget.Overlay.superclass.destroy.call(this); -}; - -/** -* Returns a String representation of the object. -* @method toString -* @return {String} The string representation of the Overlay. -*/ -YAHOO.widget.Overlay.prototype.toString = function() { - return "Overlay " + this.id; -}; - -/** -* A singleton CustomEvent used for reacting to the DOM event for window scroll -* @event YAHOO.widget.Overlay.windowScrollEvent -*/ -YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll"); - -/** -* A singleton CustomEvent used for reacting to the DOM event for window resize -* @event YAHOO.widget.Overlay.windowResizeEvent -*/ -YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize"); - -/** -* The DOM event handler used to fire the CustomEvent for window scroll -* @method YAHOO.widget.Overlay.windowScrollHandler -* @static -* @param {DOMEvent} e The DOM scroll event -*/ -YAHOO.widget.Overlay.windowScrollHandler = function(e) { - if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { - if (! window.scrollEnd) { - window.scrollEnd = -1; - } - clearTimeout(window.scrollEnd); - window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1); - } else { - YAHOO.widget.Overlay.windowScrollEvent.fire(); - } -}; - -/** -* The DOM event handler used to fire the CustomEvent for window resize -* @method YAHOO.widget.Overlay.windowResizeHandler -* @static -* @param {DOMEvent} e The DOM resize event -*/ -YAHOO.widget.Overlay.windowResizeHandler = function(e) { - if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { - if (! window.resizeEnd) { - window.resizeEnd = -1; - } - clearTimeout(window.resizeEnd); - window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100); - } else { - YAHOO.widget.Overlay.windowResizeEvent.fire(); - } -}; - -/** -* A boolean that indicated whether the window resize and scroll events have already been subscribed to. -* @property YAHOO.widget.Overlay._initialized -* @private -* @type Boolean -*/ -YAHOO.widget.Overlay._initialized = null; - -if (YAHOO.widget.Overlay._initialized === null) { - YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler); - YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler); - - YAHOO.widget.Overlay._initialized = true; -} - -/** -* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget -* @namespace YAHOO.widget -* @class OverlayManager -* @constructor -* @param {Array} overlays Optional. A collection of Overlays to register with the manager. -* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager -*/ -YAHOO.widget.OverlayManager = function(userConfig) { - this.init(userConfig); -}; - -/** -* The CSS class representing a focused Overlay -* @property YAHOO.widget.OverlayManager.CSS_FOCUSED -* @static -* @final -* @type String -*/ -YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused"; - -YAHOO.widget.OverlayManager.prototype = { - /** - * The class's constructor function - * @property contructor - * @type Function - */ - constructor : YAHOO.widget.OverlayManager, - - /** - * The array of Overlays that are currently registered - * @property overlays - * @type YAHOO.widget.Overlay[] - */ - overlays : null, - - /** - * Initializes the default configuration of the OverlayManager - * @method initDefaultConfig - */ - initDefaultConfig : function() { - /** - * The collection of registered Overlays in use by the OverlayManager - * @config overlays - * @type YAHOO.widget.Overlay[] - * @default null - */ - this.cfg.addProperty("overlays", { suppressEvent:true } ); - - /** - * The default DOM event that should be used to focus an Overlay - * @config focusevent - * @type String - * @default "mousedown" - */ - this.cfg.addProperty("focusevent", { value:"mousedown" } ); - }, - - /** - * Initializes the OverlayManager - * @method init - * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager. - * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager - */ - init : function(userConfig) { - /** - * The OverlayManager's Config object used for monitoring configuration properties. - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - this.initDefaultConfig(); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - this.cfg.fireQueue(); - - /** - * The currently activated Overlay - * @property activeOverlay - * @private - * @type YAHOO.widget.Overlay - */ - var activeOverlay = null; - - /** - * Returns the currently focused Overlay - * @method getActive - * @return {YAHOO.widget.Overlay} The currently focused Overlay - */ - this.getActive = function() { - return activeOverlay; - }; - - /** - * Focuses the specified Overlay - * @method focus - * @param {YAHOO.widget.Overlay} overlay The Overlay to focus - * @param {String} overlay The id of the Overlay to focus - */ - this.focus = function(overlay) { - var o = this.find(overlay); - if (o) { - this.blurAll(); - activeOverlay = o; - YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - this.overlays.sort(this.compareZIndexDesc); - var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex"); - if (! isNaN(topZIndex) && this.overlays[0] != overlay) { - activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2)); - } - this.overlays.sort(this.compareZIndexDesc); - } - }; - - /** - * Removes the specified Overlay from the manager - * @method remove - * @param {YAHOO.widget.Overlay} overlay The Overlay to remove - * @param {String} overlay The id of the Overlay to remove - */ - this.remove = function(overlay) { - var o = this.find(overlay); - if (o) { - var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex"); - o.cfg.setProperty("zIndex", -1000, true); - this.overlays.sort(this.compareZIndexDesc); - this.overlays = this.overlays.slice(0, this.overlays.length-1); - o.cfg.setProperty("zIndex", originalZ, true); - - o.cfg.setProperty("manager", null); - o.focusEvent = null; - o.blurEvent = null; - o.focus = null; - o.blur = null; - } - }; - - /** - * Removes focus from all registered Overlays in the manager - * @method blurAll - */ - this.blurAll = function() { - activeOverlay = null; - for (var o=0;o<this.overlays.length;o++) { - YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - } - }; - - var overlays = this.cfg.getProperty("overlays"); - - if (! this.overlays) { - this.overlays = []; - } - - if (overlays) { - this.register(overlays); - this.overlays.sort(this.compareZIndexDesc); - } - }, - - /** - * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each. - * @method register - * @param {YAHOO.widget.Overlay} overlay An Overlay to register with the manager. - * @param {YAHOO.widget.Overlay[]} overlay An array of Overlays to register with the manager. - * @return {Boolean} True if any Overlays are registered. - */ - register : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - overlay.cfg.addProperty("manager", { value:this } ); - - overlay.focusEvent = new YAHOO.util.CustomEvent("focus"); - overlay.blurEvent = new YAHOO.util.CustomEvent("blur"); - - var mgr=this; - - overlay.focus = function() { - mgr.focus(this); - this.focusEvent.fire(); - }; - - overlay.blur = function() { - mgr.blurAll(); - this.blurEvent.fire(); - }; - - var focusOnDomEvent = function(e,obj) { - overlay.focus(); - }; - - var focusevent = this.cfg.getProperty("focusevent"); - YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true); - - var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex"); - if (! isNaN(zIndex)) { - overlay.cfg.setProperty("zIndex", parseInt(zIndex, 10)); - } else { - overlay.cfg.setProperty("zIndex", 0); - } - - this.overlays.push(overlay); - return true; - } else if (overlay instanceof Array) { - var regcount = 0; - for (var i=0;i<overlay.length;i++) { - if (this.register(overlay[i])) { - regcount++; - } - } - if (regcount > 0) { - return true; - } - } else { - return false; - } - }, - - /** - * Attempts to locate an Overlay by instance or ID. - * @method find - * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager - * @param {String} overlay An Overlay id to locate within the manager - * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located. - */ - find : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - for (var o=0;o<this.overlays.length;o++) { - if (this.overlays[o] == overlay) { - return this.overlays[o]; - } - } - } else if (typeof overlay == "string") { - for (var p=0;p<this.overlays.length;p++) { - if (this.overlays[p].id == overlay) { - return this.overlays[p]; - } - } - } - return null; - }, - - /** - * Used for sorting the manager's Overlays by z-index. - * @method compareZIndexDesc - * @private - * @return {Number} 0, 1, or -1, depending on where the Overlay should fall in the stacking order. - */ - compareZIndexDesc : function(o1, o2) { - var zIndex1 = o1.cfg.getProperty("zIndex"); - var zIndex2 = o2.cfg.getProperty("zIndex"); - - if (zIndex1 > zIndex2) { - return -1; - } else if (zIndex1 < zIndex2) { - return 1; - } else { - return 0; - } - }, - - /** - * Shows all Overlays in the manager. - * @method showAll - */ - showAll : function() { - for (var o=0;o<this.overlays.length;o++) { - this.overlays[o].show(); - } - }, - - /** - * Hides all Overlays in the manager. - * @method hideAll - */ - hideAll : function() { - for (var o=0;o<this.overlays.length;o++) { - this.overlays[o].hide(); - } - }, - - /** - * Returns a string representation of the object. - * @method toString - * @return {String} The string representation of the OverlayManager - */ - toString : function() { - return "OverlayManager"; - } - -}; - -/** -* KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements. -* @namespace YAHOO.util -* @class KeyListener -* @constructor -* @param {HTMLElement} attachTo The element or element ID to which the key event should be attached -* @param {String} attachTo The element or element ID to which the key event should be attached -* @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). -* @param {Function} handler The CustomEvent handler to fire when the key event is detected -* @param {Object} handler An object literal representing the handler. -* @param {String} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown. -*/ -YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) { - if (! attachTo) { - YAHOO.log("No attachTo element specified", "error"); - } - if (! keyData) { - YAHOO.log("No keyData specified", "error"); - } - if (! handler) { - YAHOO.log("No handler specified", "error"); - } - - if (! event) { - event = YAHOO.util.KeyListener.KEYDOWN; - } - - /** - * The CustomEvent fired internally when a key is pressed - * @event keyEvent - * @private - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - var keyEvent = new YAHOO.util.CustomEvent("keyPressed"); - - /** - * The CustomEvent fired when the KeyListener is enabled via the enable() function - * @event enabledEvent - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - this.enabledEvent = new YAHOO.util.CustomEvent("enabled"); - - /** - * The CustomEvent fired when the KeyListener is disabled via the disable() function - * @event disabledEvent - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - this.disabledEvent = new YAHOO.util.CustomEvent("disabled"); - - if (typeof attachTo == 'string') { - attachTo = document.getElementById(attachTo); - } - - if (typeof handler == 'function') { - keyEvent.subscribe(handler); - } else { - keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope); - } - - /** - * Handles the key event when a key is pressed. - * @method handleKeyPress - * @param {DOMEvent} e The keypress DOM event - * @param {Object} obj The DOM event scope object - * @private - */ - function handleKeyPress(e, obj) { - if (! keyData.shift) { - keyData.shift = false; - } - if (! keyData.alt) { - keyData.alt = false; - } - if (! keyData.ctrl) { - keyData.ctrl = false; - } - - // check held down modifying keys first - if (e.shiftKey == keyData.shift && - e.altKey == keyData.alt && - e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match - - var dataItem; - var keyPressed; - - if (keyData.keys instanceof Array) { - for (var i=0;i<keyData.keys.length;i++) { - dataItem = keyData.keys[i]; - - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - break; - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - break; - } - } - } else { - dataItem = keyData.keys; - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - } - } - } - } - - /** - * Enables the KeyListener by attaching the DOM event listeners to the target DOM element - * @method enable - */ - this.enable = function() { - if (! this.enabled) { - YAHOO.util.Event.addListener(attachTo, event, handleKeyPress); - this.enabledEvent.fire(keyData); - } - /** - * Boolean indicating the enabled/disabled state of the Tooltip - * @property enabled - * @type Boolean - */ - this.enabled = true; - }; - - /** - * Disables the KeyListener by removing the DOM event listeners from the target DOM element - * @method disable - */ - this.disable = function() { - if (this.enabled) { - YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress); - this.disabledEvent.fire(keyData); - } - this.enabled = false; - }; - - /** - * Returns a String representation of the object. - * @method toString - * @return {String} The string representation of the KeyListener - */ - this.toString = function() { - return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : ""); - }; - -}; - -/** -* Constant representing the DOM "keydown" event. -* @property YAHOO.util.KeyListener.KEYDOWN -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYDOWN = "keydown"; - -/** -* Constant representing the DOM "keyup" event. -* @property YAHOO.util.KeyListener.KEYUP -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYUP = "keyup"; - -/** -* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden. -* @namespace YAHOO.widget -* @class ContainerEffect -* @constructor -* @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with -* @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element. -* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion. -*/ -YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) { - if (! animClass) { - animClass = YAHOO.util.Anim; - } - - /** - * The overlay to animate - * @property overlay - * @type YAHOO.widget.Overlay - */ - this.overlay = overlay; - /** - * The animation attributes to use when transitioning into view - * @property attrIn - * @type Object - */ - this.attrIn = attrIn; - /** - * The animation attributes to use when transitioning out of view - * @property attrOut - * @type Object - */ - this.attrOut = attrOut; - /** - * The target element to be animated - * @property targetElement - * @type HTMLElement - */ - this.targetElement = targetElement || overlay.element; - /** - * The animation class to use for animating the overlay - * @property animClass - * @type class - */ - this.animClass = animClass; -}; - -/** -* Initializes the animation classes and events. -* @method init -*/ -YAHOO.widget.ContainerEffect.prototype.init = function() { - this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn"); - this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut"); - - this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete"); - this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete"); - - this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method); - this.animIn.onStart.subscribe(this.handleStartAnimateIn, this); - this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this); - this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this); - - this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method); - this.animOut.onStart.subscribe(this.handleStartAnimateOut, this); - this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this); - this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this); -}; - -/** -* Triggers the in-animation. -* @method animateIn -*/ -YAHOO.widget.ContainerEffect.prototype.animateIn = function() { - this.beforeAnimateInEvent.fire(); - this.animIn.animate(); -}; - -/** -* Triggers the out-animation. -* @method animateOut -*/ -YAHOO.widget.ContainerEffect.prototype.animateOut = function() { - this.beforeAnimateOutEvent.fire(); - this.animOut.animate(); -}; - -/** -* The default onStart handler for the in-animation. -* @method handleStartAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { }; -/** -* The default onTween handler for the in-animation. -* @method handleTweenAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { }; -/** -* The default onComplete handler for the in-animation. -* @method handleCompleteAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { }; - -/** -* The default onStart handler for the out-animation. -* @method handleStartAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { }; -/** -* The default onTween handler for the out-animation. -* @method handleTweenAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { }; -/** -* The default onComplete handler for the out-animation. -* @method handleCompleteAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { }; - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the ContainerEffect -*/ -YAHOO.widget.ContainerEffect.prototype.toString = function() { - var output = "ContainerEffect"; - if (this.overlay) { - output += " [" + this.overlay.toString() + "]"; - } - return output; -}; - -/** -* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out. -* @method FADE -* @static -* @param {Overlay} overlay The Overlay object to animate -* @param {Number} dur The duration of the animation -* @return {ContainerEffect} The configured ContainerEffect object -*/ -YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) { - var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element ); - - fade.handleStartAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (! obj.overlay.underlay) { - obj.overlay.cfg.refireEvent("underlay"); - } - - if (obj.overlay.underlay) { - obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity"); - obj.overlay.underlay.style.filter = null; - } - - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0); - }; - - fade.handleCompleteAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - - if (obj.overlay.underlay) { - YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity); - } - - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - }; - - fade.handleStartAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.underlay) { - obj.overlay.underlay.style.filter = null; - } - }; - - fade.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1); - - obj.overlay.cfg.refireEvent("iframe"); - - obj.animateOutCompleteEvent.fire(); - }; - - fade.init(); - return fade; -}; - - -/** -* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out. -* @method SLIDE -* @static -* @param {Overlay} overlay The Overlay object to animate -* @param {Number} dur The duration of the animation -* @return {ContainerEffect} The configured ContainerEffect object -*/ -YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) { - var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element); - var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element); - - var clientWidth = YAHOO.util.Dom.getClientWidth(); - var offsetWidth = overlay.element.offsetWidth; - - var slide = new YAHOO.widget.ContainerEffect(overlay, { - attributes:{ points: { to:[x, y] } }, - duration:dur, - method:YAHOO.util.Easing.easeIn - }, - { - attributes:{ points: { to:[(clientWidth+25), y] } }, - duration:dur, - method:YAHOO.util.Easing.easeOut - }, - overlay.element, - YAHOO.util.Motion); - - - slide.handleStartAnimateIn = function(type,args,obj) { - obj.overlay.element.style.left = (-25-offsetWidth) + "px"; - obj.overlay.element.style.top = y + "px"; - }; - - slide.handleTweenAnimateIn = function(type, args, obj) { - - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var currentX = pos[0]; - var currentY = pos[1]; - - if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - } - - obj.overlay.cfg.setProperty("xy", [currentX,currentY], true); - obj.overlay.cfg.refireEvent("iframe"); - }; - - slide.handleCompleteAnimateIn = function(type, args, obj) { - obj.overlay.cfg.setProperty("xy", [x,y], true); - obj.startX = x; - obj.startY = y; - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - }; - - slide.handleStartAnimateOut = function(type, args, obj) { - var vw = YAHOO.util.Dom.getViewportWidth(); - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var yso = pos[1]; - - var currentTo = obj.animOut.attributes.points.to; - obj.animOut.attributes.points.to = [(vw+25), yso]; - }; - - slide.handleTweenAnimateOut = function(type, args, obj) { - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var xto = pos[0]; - var yto = pos[1]; - - obj.overlay.cfg.setProperty("xy", [xto,yto], true); - obj.overlay.cfg.refireEvent("iframe"); - }; - - slide.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - - obj.overlay.cfg.setProperty("xy", [x,y]); - obj.animateOutCompleteEvent.fire(); - }; - - slide.init(); - return slide; -}; - -YAHOO.register("container_core", YAHOO.widget.Module, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/container/container_core-min.js b/interface/web/js/yui/container/container_core-min.js deleted file mode 100644 index 7fa6fffc43..0000000000 --- a/interface/web/js/yui/container/container_core-min.js +++ /dev/null @@ -1,109 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var queueItemKey=queueItem[0];var queueItemValue=queueItem[1];if(queueItemKey.toLowerCase()==key){eventQueue[i]=null;eventQueue.push([key,(typeof value!='undefined'?value:queueItemValue)]);foundDuplicate=true;break;}}} -if(!foundDuplicate&&typeof value!='undefined'){eventQueue.push([key,value]);}} -if(property.supercedes){for(var s=0;s<property.supercedes.length;s++){var supercedesCheck=property.supercedes[s];for(var q=0;q<eventQueue.length;q++){var queueItemCheck=eventQueue[q];if(queueItemCheck){var queueItemCheckKey=queueItemCheck[0];var queueItemCheckValue=queueItemCheck[1];if(queueItemCheckKey.toLowerCase()==supercedesCheck.toLowerCase()){eventQueue.push([queueItemCheckKey,queueItemCheckValue]);eventQueue[q]=null;break;}}}}} -return true;}else{return false;}};this.refireEvent=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event&&typeof property.value!='undefined'){if(this.queueInProgress){this.queueProperty(key);}else{fireEvent(key,property.value);}}};this.applyConfig=function(userConfig,init){if(init){initialConfig=userConfig;} -for(var prop in userConfig){this.queueProperty(prop,userConfig[prop]);}};this.refresh=function(){for(var prop in config){this.refireEvent(prop);}};this.fireQueue=function(){this.queueInProgress=true;for(var i=0;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var key=queueItem[0];var value=queueItem[1];var property=config[key];property.value=value;fireEvent(key,value);}} -this.queueInProgress=false;eventQueue=[];};this.subscribeToConfigEvent=function(key,handler,obj,override){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(!YAHOO.util.Config.alreadySubscribed(property.event,handler,obj)){property.event.subscribe(handler,obj,override);} -return true;}else{return false;}};this.unsubscribeFromConfigEvent=function(key,handler,obj){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){return property.event.unsubscribe(handler,obj);}else{return false;}};this.toString=function(){var output="Config";if(this.owner){output+=" ["+this.owner.toString()+"]";} -return output;};this.outputEventQueue=function(){var output="";for(var q=0;q<eventQueue.length;q++){var queueItem=eventQueue[q];if(queueItem){output+=queueItem[0]+"="+queueItem[1]+", ";}} -return output;};};YAHOO.util.Config.alreadySubscribed=function(evt,fn,obj){for(var e=0;e<evt.subscribers.length;e++){var subsc=evt.subscribers[e];if(subsc&&subsc.obj==obj&&subsc.fn==fn){return true;}} -return false;};YAHOO.widget.Module=function(el,userConfig){if(el){this.init(el,userConfig);}else{}};YAHOO.widget.Module.IMG_ROOT=null;YAHOO.widget.Module.IMG_ROOT_SSL=null;YAHOO.widget.Module.CSS_MODULE="module";YAHOO.widget.Module.CSS_HEADER="hd";YAHOO.widget.Module.CSS_BODY="bd";YAHOO.widget.Module.CSS_FOOTER="ft";YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL="javascript:false;";YAHOO.widget.Module.textResizeEvent=new YAHOO.util.CustomEvent("textResize");YAHOO.widget.Module.prototype={constructor:YAHOO.widget.Module,element:null,header:null,body:null,footer:null,id:null,imageRoot:YAHOO.widget.Module.IMG_ROOT,initEvents:function(){this.beforeInitEvent=new YAHOO.util.CustomEvent("beforeInit");this.initEvent=new YAHOO.util.CustomEvent("init");this.appendEvent=new YAHOO.util.CustomEvent("append");this.beforeRenderEvent=new YAHOO.util.CustomEvent("beforeRender");this.renderEvent=new YAHOO.util.CustomEvent("render");this.changeHeaderEvent=new YAHOO.util.CustomEvent("changeHeader");this.changeBodyEvent=new YAHOO.util.CustomEvent("changeBody");this.changeFooterEvent=new YAHOO.util.CustomEvent("changeFooter");this.changeContentEvent=new YAHOO.util.CustomEvent("changeContent");this.destroyEvent=new YAHOO.util.CustomEvent("destroy");this.beforeShowEvent=new YAHOO.util.CustomEvent("beforeShow");this.showEvent=new YAHOO.util.CustomEvent("show");this.beforeHideEvent=new YAHOO.util.CustomEvent("beforeHide");this.hideEvent=new YAHOO.util.CustomEvent("hide");},platform:function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1){return"windows";}else if(ua.indexOf("macintosh")!=-1){return"mac";}else{return false;}}(),browser:function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('opera')!=-1){return'opera';}else if(ua.indexOf('msie 7')!=-1){return'ie7';}else if(ua.indexOf('msie')!=-1){return'ie';}else if(ua.indexOf('safari')!=-1){return'safari';}else if(ua.indexOf('gecko')!=-1){return'gecko';}else{return false;}}(),isSecure:function(){if(window.location.href.toLowerCase().indexOf("https")===0){return true;}else{return false;}}(),initDefaultConfig:function(){this.cfg.addProperty("visible",{value:true,handler:this.configVisible,validator:this.cfg.checkBoolean});this.cfg.addProperty("effect",{suppressEvent:true,supercedes:["visible"]});this.cfg.addProperty("monitorresize",{value:true,handler:this.configMonitorResize});},init:function(el,userConfig){this.initEvents();this.beforeInitEvent.fire(YAHOO.widget.Module);this.cfg=new YAHOO.util.Config(this);if(this.isSecure){this.imageRoot=YAHOO.widget.Module.IMG_ROOT_SSL;} -if(typeof el=="string"){var elId=el;el=document.getElementById(el);if(!el){el=document.createElement("div");el.id=elId;}} -this.element=el;if(el.id){this.id=el.id;} -var childNodes=this.element.childNodes;if(childNodes){for(var i=0;i<childNodes.length;i++){var child=childNodes[i];switch(child.className){case YAHOO.widget.Module.CSS_HEADER:this.header=child;break;case YAHOO.widget.Module.CSS_BODY:this.body=child;break;case YAHOO.widget.Module.CSS_FOOTER:this.footer=child;break;}}} -this.initDefaultConfig();YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Module.CSS_MODULE);if(userConfig){this.cfg.applyConfig(userConfig,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.renderEvent,this.cfg.fireQueue,this.cfg)){this.renderEvent.subscribe(this.cfg.fireQueue,this.cfg,true);} -this.initEvent.fire(YAHOO.widget.Module);},initResizeMonitor:function(){if(this.browser!="opera"){var resizeMonitor=document.getElementById("_yuiResizeMonitor");if(!resizeMonitor){resizeMonitor=document.createElement("iframe");var bIE=(this.browser.indexOf("ie")===0);if(this.isSecure&&YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL&&bIE){resizeMonitor.src=YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL;} -resizeMonitor.id="_yuiResizeMonitor";resizeMonitor.style.visibility="hidden";document.body.appendChild(resizeMonitor);resizeMonitor.style.width="10em";resizeMonitor.style.height="10em";resizeMonitor.style.position="absolute";var nLeft=-1*resizeMonitor.offsetWidth;var nTop=-1*resizeMonitor.offsetHeight;resizeMonitor.style.top=nTop+"px";resizeMonitor.style.left=nLeft+"px";resizeMonitor.style.borderStyle="none";resizeMonitor.style.borderWidth="0";YAHOO.util.Dom.setStyle(resizeMonitor,"opacity","0");resizeMonitor.style.visibility="visible";if(!bIE){var doc=resizeMonitor.contentWindow.document;doc.open();doc.close();}} -var fireTextResize=function(){YAHOO.widget.Module.textResizeEvent.fire();};if(resizeMonitor&&resizeMonitor.contentWindow){this.resizeMonitor=resizeMonitor;YAHOO.widget.Module.textResizeEvent.subscribe(this.onDomResize,this,true);if(!YAHOO.widget.Module.textResizeInitialized){if(!YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow,"resize",fireTextResize)){YAHOO.util.Event.addListener(this.resizeMonitor,"resize",fireTextResize);} -YAHOO.widget.Module.textResizeInitialized=true;}}}},onDomResize:function(e,obj){var nLeft=-1*this.resizeMonitor.offsetWidth,nTop=-1*this.resizeMonitor.offsetHeight;this.resizeMonitor.style.top=nTop+"px";this.resizeMonitor.style.left=nLeft+"px";},setHeader:function(headerContent){if(!this.header){this.header=document.createElement("div");this.header.className=YAHOO.widget.Module.CSS_HEADER;} -if(typeof headerContent=="string"){this.header.innerHTML=headerContent;}else{this.header.innerHTML="";this.header.appendChild(headerContent);} -this.changeHeaderEvent.fire(headerContent);this.changeContentEvent.fire();},appendToHeader:function(element){if(!this.header){this.header=document.createElement("div");this.header.className=YAHOO.widget.Module.CSS_HEADER;} -this.header.appendChild(element);this.changeHeaderEvent.fire(element);this.changeContentEvent.fire();},setBody:function(bodyContent){if(!this.body){this.body=document.createElement("div");this.body.className=YAHOO.widget.Module.CSS_BODY;} -if(typeof bodyContent=="string") -{this.body.innerHTML=bodyContent;}else{this.body.innerHTML="";this.body.appendChild(bodyContent);} -this.changeBodyEvent.fire(bodyContent);this.changeContentEvent.fire();},appendToBody:function(element){if(!this.body){this.body=document.createElement("div");this.body.className=YAHOO.widget.Module.CSS_BODY;} -this.body.appendChild(element);this.changeBodyEvent.fire(element);this.changeContentEvent.fire();},setFooter:function(footerContent){if(!this.footer){this.footer=document.createElement("div");this.footer.className=YAHOO.widget.Module.CSS_FOOTER;} -if(typeof footerContent=="string"){this.footer.innerHTML=footerContent;}else{this.footer.innerHTML="";this.footer.appendChild(footerContent);} -this.changeFooterEvent.fire(footerContent);this.changeContentEvent.fire();},appendToFooter:function(element){if(!this.footer){this.footer=document.createElement("div");this.footer.className=YAHOO.widget.Module.CSS_FOOTER;} -this.footer.appendChild(element);this.changeFooterEvent.fire(element);this.changeContentEvent.fire();},render:function(appendToNode,moduleElement){this.beforeRenderEvent.fire();if(!moduleElement){moduleElement=this.element;} -var me=this;var appendTo=function(element){if(typeof element=="string"){element=document.getElementById(element);} -if(element){element.appendChild(me.element);me.appendEvent.fire();}};if(appendToNode){appendTo(appendToNode);}else{if(!YAHOO.util.Dom.inDocument(this.element)){return false;}} -if(this.header&&!YAHOO.util.Dom.inDocument(this.header)){var firstChild=moduleElement.firstChild;if(firstChild){moduleElement.insertBefore(this.header,firstChild);}else{moduleElement.appendChild(this.header);}} -if(this.body&&!YAHOO.util.Dom.inDocument(this.body)){if(this.footer&&YAHOO.util.Dom.isAncestor(this.moduleElement,this.footer)){moduleElement.insertBefore(this.body,this.footer);}else{moduleElement.appendChild(this.body);}} -if(this.footer&&!YAHOO.util.Dom.inDocument(this.footer)){moduleElement.appendChild(this.footer);} -this.renderEvent.fire();return true;},destroy:function(){var parent;if(this.element){YAHOO.util.Event.purgeElement(this.element,true);parent=this.element.parentNode;} -if(parent){parent.removeChild(this.element);} -this.element=null;this.header=null;this.body=null;this.footer=null;for(var e in this){if(e instanceof YAHOO.util.CustomEvent){e.unsubscribeAll();}} -YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize,this);this.destroyEvent.fire();},show:function(){this.cfg.setProperty("visible",true);},hide:function(){this.cfg.setProperty("visible",false);},configVisible:function(type,args,obj){var visible=args[0];if(visible){this.beforeShowEvent.fire();YAHOO.util.Dom.setStyle(this.element,"display","block");this.showEvent.fire();}else{this.beforeHideEvent.fire();YAHOO.util.Dom.setStyle(this.element,"display","none");this.hideEvent.fire();}},configMonitorResize:function(type,args,obj){var monitor=args[0];if(monitor){this.initResizeMonitor();}else{YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize,this,true);this.resizeMonitor=null;}}};YAHOO.widget.Module.prototype.toString=function(){return"Module "+this.id;};YAHOO.widget.Overlay=function(el,userConfig){YAHOO.widget.Overlay.superclass.constructor.call(this,el,userConfig);};YAHOO.extend(YAHOO.widget.Overlay,YAHOO.widget.Module);YAHOO.widget.Overlay.IFRAME_SRC="javascript:false;";YAHOO.widget.Overlay.TOP_LEFT="tl";YAHOO.widget.Overlay.TOP_RIGHT="tr";YAHOO.widget.Overlay.BOTTOM_LEFT="bl";YAHOO.widget.Overlay.BOTTOM_RIGHT="br";YAHOO.widget.Overlay.CSS_OVERLAY="yui-overlay";YAHOO.widget.Overlay.prototype.init=function(el,userConfig){YAHOO.widget.Overlay.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Overlay);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Overlay.CSS_OVERLAY);if(userConfig){this.cfg.applyConfig(userConfig,true);} -if(this.platform=="mac"&&this.browser=="gecko"){if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)){this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)){this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);}} -this.initEvent.fire(YAHOO.widget.Overlay);};YAHOO.widget.Overlay.prototype.initEvents=function(){YAHOO.widget.Overlay.superclass.initEvents.call(this);this.beforeMoveEvent=new YAHOO.util.CustomEvent("beforeMove",this);this.moveEvent=new YAHOO.util.CustomEvent("move",this);};YAHOO.widget.Overlay.prototype.initDefaultConfig=function(){YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);this.cfg.addProperty("x",{handler:this.configX,validator:this.cfg.checkNumber,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("y",{handler:this.configY,validator:this.cfg.checkNumber,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("xy",{handler:this.configXY,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("context",{handler:this.configContext,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("fixedcenter",{value:false,handler:this.configFixedCenter,validator:this.cfg.checkBoolean,supercedes:["iframe","visible"]});this.cfg.addProperty("width",{handler:this.configWidth,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("height",{handler:this.configHeight,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("zIndex",{value:null,handler:this.configzIndex});this.cfg.addProperty("constraintoviewport",{value:false,handler:this.configConstrainToViewport,validator:this.cfg.checkBoolean,supercedes:["iframe","x","y","xy"]});this.cfg.addProperty("iframe",{value:(this.browser=="ie"?true:false),handler:this.configIframe,validator:this.cfg.checkBoolean,supercedes:["zIndex"]});};YAHOO.widget.Overlay.prototype.moveTo=function(x,y){this.cfg.setProperty("xy",[x,y]);};YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars=function(){YAHOO.util.Dom.removeClass(this.element,"show-scrollbars");YAHOO.util.Dom.addClass(this.element,"hide-scrollbars");};YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars=function(){YAHOO.util.Dom.removeClass(this.element,"hide-scrollbars");YAHOO.util.Dom.addClass(this.element,"show-scrollbars");};YAHOO.widget.Overlay.prototype.configVisible=function(type,args,obj){var visible=args[0];var currentVis=YAHOO.util.Dom.getStyle(this.element,"visibility");if(currentVis=="inherit"){var e=this.element.parentNode;while(e.nodeType!=9&&e.nodeType!=11){currentVis=YAHOO.util.Dom.getStyle(e,"visibility");if(currentVis!="inherit"){break;} -e=e.parentNode;} -if(currentVis=="inherit"){currentVis="visible";}} -var effect=this.cfg.getProperty("effect");var effectInstances=[];if(effect){if(effect instanceof Array){for(var i=0;i<effect.length;i++){var eff=effect[i];effectInstances[effectInstances.length]=eff.effect(this,eff.duration);}}else{effectInstances[effectInstances.length]=effect.effect(this,effect.duration);}} -var isMacGecko=(this.platform=="mac"&&this.browser=="gecko");if(visible){if(isMacGecko){this.showMacGeckoScrollbars();} -if(effect){if(visible){if(currentVis!="visible"||currentVis===""){this.beforeShowEvent.fire();for(var j=0;j<effectInstances.length;j++){var ei=effectInstances[j];if(j===0&&!YAHOO.util.Config.alreadySubscribed(ei.animateInCompleteEvent,this.showEvent.fire,this.showEvent)){ei.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true);} -ei.animateIn();}}}}else{if(currentVis!="visible"||currentVis===""){this.beforeShowEvent.fire();YAHOO.util.Dom.setStyle(this.element,"visibility","visible");this.cfg.refireEvent("iframe");this.showEvent.fire();}}}else{if(isMacGecko){this.hideMacGeckoScrollbars();} -if(effect){if(currentVis=="visible"){this.beforeHideEvent.fire();for(var k=0;k<effectInstances.length;k++){var h=effectInstances[k];if(k===0&&!YAHOO.util.Config.alreadySubscribed(h.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)){h.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true);} -h.animateOut();}}else if(currentVis===""){YAHOO.util.Dom.setStyle(this.element,"visibility","hidden");}}else{if(currentVis=="visible"||currentVis===""){this.beforeHideEvent.fire();YAHOO.util.Dom.setStyle(this.element,"visibility","hidden");this.cfg.refireEvent("iframe");this.hideEvent.fire();}}}};YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent=function(){if(this.cfg.getProperty("visible")){this.center();}};YAHOO.widget.Overlay.prototype.configFixedCenter=function(type,args,obj){var val=args[0];if(val){this.center();if(!YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent,this.center,this)){this.beforeShowEvent.subscribe(this.center,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent,this.doCenterOnDOMEvent,this)){YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent,this.doCenterOnDOMEvent,this)){YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.doCenterOnDOMEvent,this,true);}}else{YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);}};YAHOO.widget.Overlay.prototype.configHeight=function(type,args,obj){var height=args[0];var el=this.element;YAHOO.util.Dom.setStyle(el,"height",height);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.configWidth=function(type,args,obj){var width=args[0];var el=this.element;YAHOO.util.Dom.setStyle(el,"width",width);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.configzIndex=function(type,args,obj){var zIndex=args[0];var el=this.element;if(!zIndex){zIndex=YAHOO.util.Dom.getStyle(el,"zIndex");if(!zIndex||isNaN(zIndex)){zIndex=0;}} -if(this.iframe){if(zIndex<=0){zIndex=1;} -YAHOO.util.Dom.setStyle(this.iframe,"zIndex",(zIndex-1));} -YAHOO.util.Dom.setStyle(el,"zIndex",zIndex);this.cfg.setProperty("zIndex",zIndex,true);};YAHOO.widget.Overlay.prototype.configXY=function(type,args,obj){var pos=args[0];var x=pos[0];var y=pos[1];this.cfg.setProperty("x",x);this.cfg.setProperty("y",y);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);};YAHOO.widget.Overlay.prototype.configX=function(type,args,obj){var x=args[0];var y=this.cfg.getProperty("y");this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");YAHOO.util.Dom.setX(this.element,x,true);this.cfg.setProperty("xy",[x,y],true);this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);};YAHOO.widget.Overlay.prototype.configY=function(type,args,obj){var x=this.cfg.getProperty("x");var y=args[0];this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");YAHOO.util.Dom.setY(this.element,y,true);this.cfg.setProperty("xy",[x,y],true);this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);};YAHOO.widget.Overlay.prototype.showIframe=function(){if(this.iframe){this.iframe.style.display="block";}};YAHOO.widget.Overlay.prototype.hideIframe=function(){if(this.iframe){this.iframe.style.display="none";}};YAHOO.widget.Overlay.prototype.configIframe=function(type,args,obj){var val=args[0];if(val){if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showIframe,this)){this.showEvent.subscribe(this.showIframe,this,true);} -if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideIframe,this)){this.hideEvent.subscribe(this.hideIframe,this,true);} -var x=this.cfg.getProperty("x");var y=this.cfg.getProperty("y");if(!x||!y){this.syncPosition();x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");} -if(!isNaN(x)&&!isNaN(y)){if(!this.iframe){this.iframe=document.createElement("iframe");if(this.isSecure){this.iframe.src=YAHOO.widget.Overlay.IFRAME_SRC;} -var parent=this.element.parentNode;if(parent){parent.appendChild(this.iframe);}else{document.body.appendChild(this.iframe);} -YAHOO.util.Dom.setStyle(this.iframe,"position","absolute");YAHOO.util.Dom.setStyle(this.iframe,"border","none");YAHOO.util.Dom.setStyle(this.iframe,"margin","0");YAHOO.util.Dom.setStyle(this.iframe,"padding","0");YAHOO.util.Dom.setStyle(this.iframe,"opacity","0");if(this.cfg.getProperty("visible")){this.showIframe();}else{this.hideIframe();}} -var iframeDisplay=YAHOO.util.Dom.getStyle(this.iframe,"display");if(iframeDisplay=="none"){this.iframe.style.display="block";} -YAHOO.util.Dom.setXY(this.iframe,[x,y]);var width=this.element.clientWidth;var height=this.element.clientHeight;YAHOO.util.Dom.setStyle(this.iframe,"width",(width+2)+"px");YAHOO.util.Dom.setStyle(this.iframe,"height",(height+2)+"px");if(iframeDisplay=="none"){this.iframe.style.display="none";}}}else{if(this.iframe){this.iframe.style.display="none";} -this.showEvent.unsubscribe(this.showIframe,this);this.hideEvent.unsubscribe(this.hideIframe,this);}};YAHOO.widget.Overlay.prototype.configConstrainToViewport=function(type,args,obj){var val=args[0];if(val){if(!YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent,this.enforceConstraints,this)){this.beforeMoveEvent.subscribe(this.enforceConstraints,this,true);}}else{this.beforeMoveEvent.unsubscribe(this.enforceConstraints,this);}};YAHOO.widget.Overlay.prototype.configContext=function(type,args,obj){var contextArgs=args[0];if(contextArgs){var contextEl=contextArgs[0];var elementMagnetCorner=contextArgs[1];var contextMagnetCorner=contextArgs[2];if(contextEl){if(typeof contextEl=="string"){this.cfg.setProperty("context",[document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner],true);} -if(elementMagnetCorner&&contextMagnetCorner){this.align(elementMagnetCorner,contextMagnetCorner);}}}};YAHOO.widget.Overlay.prototype.align=function(elementAlign,contextAlign){var contextArgs=this.cfg.getProperty("context");if(contextArgs){var context=contextArgs[0];var element=this.element;var me=this;if(!elementAlign){elementAlign=contextArgs[1];} -if(!contextAlign){contextAlign=contextArgs[2];} -if(element&&context){var contextRegion=YAHOO.util.Dom.getRegion(context);var doAlign=function(v,h){switch(elementAlign){case YAHOO.widget.Overlay.TOP_LEFT:me.moveTo(h,v);break;case YAHOO.widget.Overlay.TOP_RIGHT:me.moveTo(h-element.offsetWidth,v);break;case YAHOO.widget.Overlay.BOTTOM_LEFT:me.moveTo(h,v-element.offsetHeight);break;case YAHOO.widget.Overlay.BOTTOM_RIGHT:me.moveTo(h-element.offsetWidth,v-element.offsetHeight);break;}};switch(contextAlign){case YAHOO.widget.Overlay.TOP_LEFT:doAlign(contextRegion.top,contextRegion.left);break;case YAHOO.widget.Overlay.TOP_RIGHT:doAlign(contextRegion.top,contextRegion.right);break;case YAHOO.widget.Overlay.BOTTOM_LEFT:doAlign(contextRegion.bottom,contextRegion.left);break;case YAHOO.widget.Overlay.BOTTOM_RIGHT:doAlign(contextRegion.bottom,contextRegion.right);break;}}}};YAHOO.widget.Overlay.prototype.enforceConstraints=function(type,args,obj){var pos=args[0];var x=pos[0];var y=pos[1];var offsetHeight=this.element.offsetHeight;var offsetWidth=this.element.offsetWidth;var viewPortWidth=YAHOO.util.Dom.getViewportWidth();var viewPortHeight=YAHOO.util.Dom.getViewportHeight();var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var topConstraint=scrollY+10;var leftConstraint=scrollX+10;var bottomConstraint=scrollY+viewPortHeight-offsetHeight-10;var rightConstraint=scrollX+viewPortWidth-offsetWidth-10;if(x<leftConstraint){x=leftConstraint;}else if(x>rightConstraint){x=rightConstraint;} -if(y<topConstraint){y=topConstraint;}else if(y>bottomConstraint){y=bottomConstraint;} -this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.cfg.setProperty("xy",[x,y],true);};YAHOO.widget.Overlay.prototype.center=function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var x=(viewPortWidth/2)-(elementWidth/2)+scrollX;var y=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.cfg.setProperty("xy",[parseInt(x,10),parseInt(y,10)]);this.cfg.refireEvent("iframe");};YAHOO.widget.Overlay.prototype.syncPosition=function(){var pos=YAHOO.util.Dom.getXY(this.element);this.cfg.setProperty("x",pos[0],true);this.cfg.setProperty("y",pos[1],true);this.cfg.setProperty("xy",pos,true);};YAHOO.widget.Overlay.prototype.onDomResize=function(e,obj){YAHOO.widget.Overlay.superclass.onDomResize.call(this,e,obj);var me=this;setTimeout(function(){me.syncPosition();me.cfg.refireEvent("iframe");me.cfg.refireEvent("context");},0);};YAHOO.widget.Overlay.prototype.destroy=function(){if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);} -this.iframe=null;YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.superclass.destroy.call(this);};YAHOO.widget.Overlay.prototype.toString=function(){return"Overlay "+this.id;};YAHOO.widget.Overlay.windowScrollEvent=new YAHOO.util.CustomEvent("windowScroll");YAHOO.widget.Overlay.windowResizeEvent=new YAHOO.util.CustomEvent("windowResize");YAHOO.widget.Overlay.windowScrollHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.scrollEnd){window.scrollEnd=-1;} -clearTimeout(window.scrollEnd);window.scrollEnd=setTimeout(function(){YAHOO.widget.Overlay.windowScrollEvent.fire();},1);}else{YAHOO.widget.Overlay.windowScrollEvent.fire();}};YAHOO.widget.Overlay.windowResizeHandler=function(e){if(YAHOO.widget.Module.prototype.browser=="ie"||YAHOO.widget.Module.prototype.browser=="ie7"){if(!window.resizeEnd){window.resizeEnd=-1;} -clearTimeout(window.resizeEnd);window.resizeEnd=setTimeout(function(){YAHOO.widget.Overlay.windowResizeEvent.fire();},100);}else{YAHOO.widget.Overlay.windowResizeEvent.fire();}};YAHOO.widget.Overlay._initialized=null;if(YAHOO.widget.Overlay._initialized===null){YAHOO.util.Event.addListener(window,"scroll",YAHOO.widget.Overlay.windowScrollHandler);YAHOO.util.Event.addListener(window,"resize",YAHOO.widget.Overlay.windowResizeHandler);YAHOO.widget.Overlay._initialized=true;} -YAHOO.widget.OverlayManager=function(userConfig){this.init(userConfig);};YAHOO.widget.OverlayManager.CSS_FOCUSED="focused";YAHOO.widget.OverlayManager.prototype={constructor:YAHOO.widget.OverlayManager,overlays:null,initDefaultConfig:function(){this.cfg.addProperty("overlays",{suppressEvent:true});this.cfg.addProperty("focusevent",{value:"mousedown"});},init:function(userConfig){this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();if(userConfig){this.cfg.applyConfig(userConfig,true);} -this.cfg.fireQueue();var activeOverlay=null;this.getActive=function(){return activeOverlay;};this.focus=function(overlay){var o=this.find(overlay);if(o){this.blurAll();activeOverlay=o;YAHOO.util.Dom.addClass(activeOverlay.element,YAHOO.widget.OverlayManager.CSS_FOCUSED);this.overlays.sort(this.compareZIndexDesc);var topZIndex=YAHOO.util.Dom.getStyle(this.overlays[0].element,"zIndex");if(!isNaN(topZIndex)&&this.overlays[0]!=overlay){activeOverlay.cfg.setProperty("zIndex",(parseInt(topZIndex,10)+2));} -this.overlays.sort(this.compareZIndexDesc);}};this.remove=function(overlay){var o=this.find(overlay);if(o){var originalZ=YAHOO.util.Dom.getStyle(o.element,"zIndex");o.cfg.setProperty("zIndex",-1000,true);this.overlays.sort(this.compareZIndexDesc);this.overlays=this.overlays.slice(0,this.overlays.length-1);o.cfg.setProperty("zIndex",originalZ,true);o.cfg.setProperty("manager",null);o.focusEvent=null;o.blurEvent=null;o.focus=null;o.blur=null;}};this.blurAll=function(){activeOverlay=null;for(var o=0;o<this.overlays.length;o++){YAHOO.util.Dom.removeClass(this.overlays[o].element,YAHOO.widget.OverlayManager.CSS_FOCUSED);}};var overlays=this.cfg.getProperty("overlays");if(!this.overlays){this.overlays=[];} -if(overlays){this.register(overlays);this.overlays.sort(this.compareZIndexDesc);}},register:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){overlay.cfg.addProperty("manager",{value:this});overlay.focusEvent=new YAHOO.util.CustomEvent("focus");overlay.blurEvent=new YAHOO.util.CustomEvent("blur");var mgr=this;overlay.focus=function(){mgr.focus(this);this.focusEvent.fire();};overlay.blur=function(){mgr.blurAll();this.blurEvent.fire();};var focusOnDomEvent=function(e,obj){overlay.focus();};var focusevent=this.cfg.getProperty("focusevent");YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);var zIndex=YAHOO.util.Dom.getStyle(overlay.element,"zIndex");if(!isNaN(zIndex)){overlay.cfg.setProperty("zIndex",parseInt(zIndex,10));}else{overlay.cfg.setProperty("zIndex",0);} -this.overlays.push(overlay);return true;}else if(overlay instanceof Array){var regcount=0;for(var i=0;i<overlay.length;i++){if(this.register(overlay[i])){regcount++;}} -if(regcount>0){return true;}}else{return false;}},find:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){for(var o=0;o<this.overlays.length;o++){if(this.overlays[o]==overlay){return this.overlays[o];}}}else if(typeof overlay=="string"){for(var p=0;p<this.overlays.length;p++){if(this.overlays[p].id==overlay){return this.overlays[p];}}} -return null;},compareZIndexDesc:function(o1,o2){var zIndex1=o1.cfg.getProperty("zIndex");var zIndex2=o2.cfg.getProperty("zIndex");if(zIndex1>zIndex2){return-1;}else if(zIndex1<zIndex2){return 1;}else{return 0;}},showAll:function(){for(var o=0;o<this.overlays.length;o++){this.overlays[o].show();}},hideAll:function(){for(var o=0;o<this.overlays.length;o++){this.overlays[o].hide();}},toString:function(){return"OverlayManager";}};YAHOO.util.KeyListener=function(attachTo,keyData,handler,event){if(!attachTo){} -if(!keyData){} -if(!handler){} -if(!event){event=YAHOO.util.KeyListener.KEYDOWN;} -var keyEvent=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof attachTo=='string'){attachTo=document.getElementById(attachTo);} -if(typeof handler=='function'){keyEvent.subscribe(handler);}else{keyEvent.subscribe(handler.fn,handler.scope,handler.correctScope);} -function handleKeyPress(e,obj){if(!keyData.shift){keyData.shift=false;} -if(!keyData.alt){keyData.alt=false;} -if(!keyData.ctrl){keyData.ctrl=false;} -if(e.shiftKey==keyData.shift&&e.altKey==keyData.alt&&e.ctrlKey==keyData.ctrl){var dataItem;var keyPressed;if(keyData.keys instanceof Array){for(var i=0;i<keyData.keys.length;i++){dataItem=keyData.keys[i];if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);break;}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);break;}}}else{dataItem=keyData.keys;if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);}}}} -this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(attachTo,event,handleKeyPress);this.enabledEvent.fire(keyData);} -this.enabled=true;};this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(attachTo,event,handleKeyPress);this.disabledEvent.fire(keyData);} -this.enabled=false;};this.toString=function(){return"KeyListener ["+keyData.keys+"] "+attachTo.tagName+(attachTo.id?"["+attachTo.id+"]":"");};};YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.widget.ContainerEffect=function(overlay,attrIn,attrOut,targetElement,animClass){if(!animClass){animClass=YAHOO.util.Anim;} -this.overlay=overlay;this.attrIn=attrIn;this.attrOut=attrOut;this.targetElement=targetElement||overlay.element;this.animClass=animClass;};YAHOO.widget.ContainerEffect.prototype.init=function(){this.beforeAnimateInEvent=new YAHOO.util.CustomEvent("beforeAnimateIn");this.beforeAnimateOutEvent=new YAHOO.util.CustomEvent("beforeAnimateOut");this.animateInCompleteEvent=new YAHOO.util.CustomEvent("animateInComplete");this.animateOutCompleteEvent=new YAHOO.util.CustomEvent("animateOutComplete");this.animIn=new this.animClass(this.targetElement,this.attrIn.attributes,this.attrIn.duration,this.attrIn.method);this.animIn.onStart.subscribe(this.handleStartAnimateIn,this);this.animIn.onTween.subscribe(this.handleTweenAnimateIn,this);this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn,this);this.animOut=new this.animClass(this.targetElement,this.attrOut.attributes,this.attrOut.duration,this.attrOut.method);this.animOut.onStart.subscribe(this.handleStartAnimateOut,this);this.animOut.onTween.subscribe(this.handleTweenAnimateOut,this);this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut,this);};YAHOO.widget.ContainerEffect.prototype.animateIn=function(){this.beforeAnimateInEvent.fire();this.animIn.animate();};YAHOO.widget.ContainerEffect.prototype.animateOut=function(){this.beforeAnimateOutEvent.fire();this.animOut.animate();};YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut=function(type,args,obj){};YAHOO.widget.ContainerEffect.prototype.toString=function(){var output="ContainerEffect";if(this.overlay){output+=" ["+this.overlay.toString()+"]";} -return output;};YAHOO.widget.ContainerEffect.FADE=function(overlay,dur){var fade=new YAHOO.widget.ContainerEffect(overlay,{attributes:{opacity:{from:0,to:1}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{opacity:{to:0}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element);fade.handleStartAnimateIn=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(!obj.overlay.underlay){obj.overlay.cfg.refireEvent("underlay");} -if(obj.overlay.underlay){obj.initialUnderlayOpacity=YAHOO.util.Dom.getStyle(obj.overlay.underlay,"opacity");obj.overlay.underlay.style.filter=null;} -YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","visible");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",0);};fade.handleCompleteAnimateIn=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;} -if(obj.overlay.underlay){YAHOO.util.Dom.setStyle(obj.overlay.underlay,"opacity",obj.initialUnderlayOpacity);} -obj.overlay.cfg.refireEvent("iframe");obj.animateInCompleteEvent.fire();};fade.handleStartAnimateOut=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(obj.overlay.underlay){obj.overlay.underlay.style.filter=null;}};fade.handleCompleteAnimateOut=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;} -YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","hidden");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",1);obj.overlay.cfg.refireEvent("iframe");obj.animateOutCompleteEvent.fire();};fade.init();return fade;};YAHOO.widget.ContainerEffect.SLIDE=function(overlay,dur){var x=overlay.cfg.getProperty("x")||YAHOO.util.Dom.getX(overlay.element);var y=overlay.cfg.getProperty("y")||YAHOO.util.Dom.getY(overlay.element);var clientWidth=YAHOO.util.Dom.getClientWidth();var offsetWidth=overlay.element.offsetWidth;var slide=new YAHOO.widget.ContainerEffect(overlay,{attributes:{points:{to:[x,y]}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{points:{to:[(clientWidth+25),y]}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element,YAHOO.util.Motion);slide.handleStartAnimateIn=function(type,args,obj){obj.overlay.element.style.left=(-25-offsetWidth)+"px";obj.overlay.element.style.top=y+"px";};slide.handleTweenAnimateIn=function(type,args,obj){var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var currentX=pos[0];var currentY=pos[1];if(YAHOO.util.Dom.getStyle(obj.overlay.element,"visibility")=="hidden"&¤tX<x){YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","visible");} -obj.overlay.cfg.setProperty("xy",[currentX,currentY],true);obj.overlay.cfg.refireEvent("iframe");};slide.handleCompleteAnimateIn=function(type,args,obj){obj.overlay.cfg.setProperty("xy",[x,y],true);obj.startX=x;obj.startY=y;obj.overlay.cfg.refireEvent("iframe");obj.animateInCompleteEvent.fire();};slide.handleStartAnimateOut=function(type,args,obj){var vw=YAHOO.util.Dom.getViewportWidth();var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var yso=pos[1];var currentTo=obj.animOut.attributes.points.to;obj.animOut.attributes.points.to=[(vw+25),yso];};slide.handleTweenAnimateOut=function(type,args,obj){var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var xto=pos[0];var yto=pos[1];obj.overlay.cfg.setProperty("xy",[xto,yto],true);obj.overlay.cfg.refireEvent("iframe");};slide.handleCompleteAnimateOut=function(type,args,obj){YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","hidden");obj.overlay.cfg.setProperty("xy",[x,y]);obj.animateOutCompleteEvent.fire();};slide.init();return slide;};YAHOO.register("container_core",YAHOO.widget.Module,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/container/container_core.js b/interface/web/js/yui/container/container_core.js deleted file mode 100644 index 814478a8c6..0000000000 --- a/interface/web/js/yui/container/container_core.js +++ /dev/null @@ -1,2919 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** -* 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<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - - if (queueItem) { - var queueItemKey = queueItem[0]; - var queueItemValue = queueItem[1]; - - if (queueItemKey.toLowerCase() == key) { - // found a dupe... push to end of queue, null current item, and break - eventQueue[i] = null; - eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]); - foundDuplicate = true; - break; - } - } - } - - if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue - eventQueue.push([key, value]); - } - } - - if (property.supercedes) { - for (var s=0;s<property.supercedes.length;s++) { - var supercedesCheck = property.supercedes[s]; - - for (var q=0;q<eventQueue.length;q++) { - var queueItemCheck = eventQueue[q]; - - if (queueItemCheck) { - var queueItemCheckKey = queueItemCheck[0]; - var queueItemCheckValue = queueItemCheck[1]; - - if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) { - eventQueue.push([queueItemCheckKey, queueItemCheckValue]); - eventQueue[q] = null; - break; - } - } - } - } - } - - return true; - } else { - return false; - } - }; - - /** - * Fires the event for a property using the property's current value. - * @method refireEvent - * @param {String} key The name of the property - */ - this.refireEvent = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') { - if (this.queueInProgress) { - this.queueProperty(key); - } else { - fireEvent(key, property.value); - } - } - }; - - /** - * Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their associated events to execute. - * @method applyConfig - * @param {Object} userConfig The configuration Object literal - * @param {Boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. - */ - this.applyConfig = function(userConfig, init) { - if (init) { - initialConfig = userConfig; - } - for (var prop in userConfig) { - this.queueProperty(prop, userConfig[prop]); - } - }; - - /** - * Refires the events for all configuration properties using their current values. - * @method refresh - */ - this.refresh = function() { - for (var prop in config) { - this.refireEvent(prop); - } - }; - - /** - * Fires the normalized list of queued property change events - * @method fireQueue - */ - this.fireQueue = function() { - this.queueInProgress = true; - for (var i=0;i<eventQueue.length;i++) { - var queueItem = eventQueue[i]; - if (queueItem) { - var key = queueItem[0]; - var value = queueItem[1]; - - var property = config[key]; - property.value = value; - - fireEvent(key,value); - } - } - - this.queueInProgress = false; - eventQueue = []; - }; - - /** - * Subscribes an external handler to the change event for any given property. - * @method subscribeToConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @param {Boolean} override Optional. If true, will override "this" within the handler to map to the scope Object passed into the method. - * @return {Boolean} True, if the subscription was successful, otherwise false. - */ - this.subscribeToConfigEvent = function(key, handler, obj, override) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) { - property.event.subscribe(handler, obj, override); - } - return true; - } else { - return false; - } - }; - - /** - * Unsubscribes an external handler from the change event for any given property. - * @method unsubscribeFromConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation) - * @return {Boolean} True, if the unsubscription was successful, otherwise false. - */ - this.unsubscribeFromConfigEvent = function(key, handler, obj) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.event.unsubscribe(handler, obj); - } else { - return false; - } - }; - - /** - * Returns a string representation of the Config object - * @method toString - * @return {String} The Config object in string format. - */ - this.toString = function() { - var output = "Config"; - if (this.owner) { - output += " [" + this.owner.toString() + "]"; - } - return output; - }; - - /** - * Returns a string representation of the Config object's current CustomEvent queue - * @method outputEventQueue - * @return {String} The string list of CustomEvents currently queued for execution - */ - this.outputEventQueue = function() { - var output = ""; - for (var q=0;q<eventQueue.length;q++) { - var queueItem = eventQueue[q]; - if (queueItem) { - output += queueItem[0] + "=" + queueItem[1] + ", "; - } - } - return output; - }; -}; - -/** -* Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent -* @method YAHOO.util.Config.alreadySubscribed -* @static -* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions -* @param {Function} fn The function to look for in the subscribers list -* @param {Object} obj The execution scope Object for the subscription -* @return {Boolean} true, if the function/Object pair is already subscribed to the CustomEvent passed in -*/ -YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) { - for (var e=0;e<evt.subscribers.length;e++) { - var subsc = evt.subscribers[e]; - if (subsc && subsc.obj == obj && subsc.fn == fn) { - return true; - } - } - return false; -}; - -/** -* The Container family of components is designed to enable developers to create different kinds of content-containing modules on the web. Module and Overlay are the most basic containers, and they can be used directly or extended to build custom containers. Also part of the Container family are four UI controls that extend Module and Overlay: Tooltip, Panel, Dialog, and SimpleDialog. -* @module container -* @title Container -* @requires yahoo,dom,event,dragdrop,animation -*/ - -/** -* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package. -* @namespace YAHOO.widget -* @class Module -* @constructor -* @param {String} el The element ID representing the Module <em>OR</em> -* @param {HTMLElement} el The element representing the Module -* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. -*/ -YAHOO.widget.Module = function(el, userConfig) { - if (el) { - this.init(el, userConfig); - } else { - } -}; - -/** -* Constant representing the prefix path to use for non-secure images -* @property YAHOO.widget.Module.IMG_ROOT -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.IMG_ROOT = null; - -/** -* Constant representing the prefix path to use for securely served images -* @property YAHOO.widget.Module.IMG_ROOT_SSL -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.IMG_ROOT_SSL = null; - -/** -* Constant for the default CSS class name that represents a Module -* @property YAHOO.widget.Module.CSS_MODULE -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_MODULE = "module"; - -/** -* Constant representing the module header -* @property YAHOO.widget.Module.CSS_HEADER -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_HEADER = "hd"; - -/** -* Constant representing the module body -* @property YAHOO.widget.Module.CSS_BODY -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_BODY = "bd"; - -/** -* Constant representing the module footer -* @property YAHOO.widget.Module.CSS_FOOTER -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.CSS_FOOTER = "ft"; - -/** -* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size -* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL -* @static -* @final -* @type String -*/ -YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;"; - -/** -* Singleton CustomEvent fired when the font size is changed in the browser. -* Opera's "zoom" functionality currently does not support text size detection. -* @event YAHOO.widget.Module.textResizeEvent -*/ -YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize"); - -YAHOO.widget.Module.prototype = { - /** - * The class's constructor function - * @property contructor - * @type Function - */ - constructor : YAHOO.widget.Module, - - /** - * The main module element that contains the header, body, and footer - * @property element - * @type HTMLElement - */ - element : null, - - /** - * The header element, denoted with CSS class "hd" - * @property header - * @type HTMLElement - */ - header : null, - - /** - * The body element, denoted with CSS class "bd" - * @property body - * @type HTMLElement - */ - body : null, - - /** - * The footer element, denoted with CSS class "ft" - * @property footer - * @type HTMLElement - */ - footer : null, - - /** - * The id of the element - * @property id - * @type String - */ - id : null, - - /** - * The String representing the image root - * @property imageRoot - * @type String - */ - imageRoot : YAHOO.widget.Module.IMG_ROOT, - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - * @method initEvents - */ - initEvents : function() { - - /** - * CustomEvent fired prior to class initalization. - * @event beforeInitEvent - * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - */ - this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); - - /** - * CustomEvent fired after class initalization. - * @event initEvent - * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - */ - this.initEvent = new YAHOO.util.CustomEvent("init"); - - /** - * CustomEvent fired when the Module is appended to the DOM - * @event appendEvent - */ - this.appendEvent = new YAHOO.util.CustomEvent("append"); - - /** - * CustomEvent fired before the Module is rendered - * @event beforeRenderEvent - */ - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - - /** - * CustomEvent fired after the Module is rendered - * @event renderEvent - */ - this.renderEvent = new YAHOO.util.CustomEvent("render"); - - /** - * CustomEvent fired when the header content of the Module is modified - * @event changeHeaderEvent - * @param {String/HTMLElement} content String/element representing the new header content - */ - this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); - - /** - * CustomEvent fired when the body content of the Module is modified - * @event changeBodyEvent - * @param {String/HTMLElement} content String/element representing the new body content - */ - this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); - - /** - * CustomEvent fired when the footer content of the Module is modified - * @event changeFooterEvent - * @param {String/HTMLElement} content String/element representing the new footer content - */ - this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); - - /** - * CustomEvent fired when the content of the Module is modified - * @event changeContentEvent - */ - this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); - - /** - * CustomEvent fired when the Module is destroyed - * @event destroyEvent - */ - this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); - - /** - * CustomEvent fired before the Module is shown - * @event beforeShowEvent - */ - this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); - - /** - * CustomEvent fired after the Module is shown - * @event showEvent - */ - this.showEvent = new YAHOO.util.CustomEvent("show"); - - /** - * CustomEvent fired before the Module is hidden - * @event beforeHideEvent - */ - this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); - - /** - * CustomEvent fired after the Module is hidden - * @event hideEvent - */ - this.hideEvent = new YAHOO.util.CustomEvent("hide"); - }, - - /** - * String representing the current user-agent platform - * @property platform - * @type String - */ - platform : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) { - return "windows"; - } else if (ua.indexOf("macintosh") != -1) { - return "mac"; - } else { - return false; - } - }(), - - /** - * String representing the current user-agent browser - * @property browser - * @type String - */ - browser : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) - return 'opera'; - } else if (ua.indexOf('msie 7')!=-1) { // IE7 - return 'ie7'; - } else if (ua.indexOf('msie') !=-1) { // IE - return 'ie'; - } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") - return 'safari'; - } else if (ua.indexOf('gecko') != -1) { // Gecko - return 'gecko'; - } else { - return false; - } - }(), - - /** - * Boolean representing whether or not the current browsing context is secure (https) - * @property isSecure - * @type Boolean - */ - isSecure : function() { - if (window.location.href.toLowerCase().indexOf("https") === 0) { - return true; - } else { - return false; - } - }(), - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - */ - initDefaultConfig : function() { - // Add properties // - - /** - * Specifies whether the Module is visible on the page. - * @config visible - * @type Boolean - * @default true - */ - this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } ); - - /** - * Object or array of objects representing the ContainerEffect classes that are active for animating the container. - * @config effect - * @type Object - * @default null - */ - this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } ); - - /** - * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document - * @config monitorresize - * @type Boolean - * @default true - */ - this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } ); - }, - - /** - * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. - * @method init - * @param {String} el The element ID representing the Module <em>OR</em> - * @param {HTMLElement} el The element representing the Module - * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. - */ - init : function(el, userConfig) { - - this.initEvents(); - - this.beforeInitEvent.fire(YAHOO.widget.Module); - - /** - * The Module's Config object used for monitoring configuration properties. - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - if (this.isSecure) { - this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL; - } - - if (typeof el == "string") { - var elId = el; - - el = document.getElementById(el); - if (! el) { - el = document.createElement("div"); - el.id = elId; - } - } - - this.element = el; - - if (el.id) { - this.id = el.id; - } - - var childNodes = this.element.childNodes; - - if (childNodes) { - for (var i=0;i<childNodes.length;i++) { - var child = childNodes[i]; - switch (child.className) { - case YAHOO.widget.Module.CSS_HEADER: - this.header = child; - break; - case YAHOO.widget.Module.CSS_BODY: - this.body = child; - break; - case YAHOO.widget.Module.CSS_FOOTER: - this.footer = child; - break; - } - } - } - - this.initDefaultConfig(); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - // Subscribe to the fireQueue() method of Config so that any queued configuration changes are - // excecuted upon render of the Module - if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) { - this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true); - } - - this.initEvent.fire(YAHOO.widget.Module); - }, - - /** - * Initialized an empty IFRAME that is placed out of the visible area that can be used to detect text resize. - * @method initResizeMonitor - */ - initResizeMonitor : function() { - - if(this.browser != "opera") { - - var resizeMonitor = document.getElementById("_yuiResizeMonitor"); - - if (! resizeMonitor) { - - resizeMonitor = document.createElement("iframe"); - - var bIE = (this.browser.indexOf("ie") === 0); - - if(this.isSecure && YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL && bIE) { - resizeMonitor.src = YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL; - } - - resizeMonitor.id = "_yuiResizeMonitor"; - resizeMonitor.style.visibility = "hidden"; - - document.body.appendChild(resizeMonitor); - - resizeMonitor.style.width = "10em"; - resizeMonitor.style.height = "10em"; - resizeMonitor.style.position = "absolute"; - - var nLeft = -1 * resizeMonitor.offsetWidth; - var nTop = -1 * resizeMonitor.offsetHeight; - - resizeMonitor.style.top = nTop + "px"; - resizeMonitor.style.left = nLeft + "px"; - resizeMonitor.style.borderStyle = "none"; - resizeMonitor.style.borderWidth = "0"; - YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0"); - - resizeMonitor.style.visibility = "visible"; - - if(!bIE) { - - var doc = resizeMonitor.contentWindow.document; - - doc.open(); - doc.close(); - - } - } - - var fireTextResize = function() { - YAHOO.widget.Module.textResizeEvent.fire(); - }; - - if(resizeMonitor && resizeMonitor.contentWindow) { - this.resizeMonitor = resizeMonitor; - - YAHOO.widget.Module.textResizeEvent.subscribe(this.onDomResize, this, true); - - if (! YAHOO.widget.Module.textResizeInitialized) { - if (! YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", fireTextResize)) { - // This will fail in IE if document.domain has changed, so we must change the listener to - // use the resizeMonitor element instead - YAHOO.util.Event.addListener(this.resizeMonitor, "resize", fireTextResize); - } - YAHOO.widget.Module.textResizeInitialized = true; - } - } - - } - - }, - - /** - * Event handler fired when the resize monitor element is resized. - * @method onDomResize - * @param {DOMEvent} e The DOM resize event - * @param {Object} obj The scope object passed to the handler - */ - onDomResize : function(e, obj) { - - var nLeft = -1 * this.resizeMonitor.offsetWidth, - nTop = -1 * this.resizeMonitor.offsetHeight; - - this.resizeMonitor.style.top = nTop + "px"; - this.resizeMonitor.style.left = nLeft + "px"; - - }, - - /** - * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created. - * @method setHeader - * @param {String} headerContent The HTML used to set the header <em>OR</em> - * @param {HTMLElement} headerContent The HTMLElement to append to the header - */ - setHeader : function(headerContent) { - if (! this.header) { - this.header = document.createElement("div"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - if (typeof headerContent == "string") { - this.header.innerHTML = headerContent; - } else { - this.header.innerHTML = ""; - this.header.appendChild(headerContent); - } - - this.changeHeaderEvent.fire(headerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the header. If no header is present, one will be automatically created. - * @method appendToHeader - * @param {HTMLElement} element The element to append to the header - */ - appendToHeader : function(element) { - if (! this.header) { - this.header = document.createElement("div"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - this.header.appendChild(element); - this.changeHeaderEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created. - * @method setBody - * @param {String} bodyContent The HTML used to set the body <em>OR</em> - * @param {HTMLElement} bodyContent The HTMLElement to append to the body - */ - setBody : function(bodyContent) { - if (! this.body) { - this.body = document.createElement("div"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - if (typeof bodyContent == "string") - { - this.body.innerHTML = bodyContent; - } else { - this.body.innerHTML = ""; - this.body.appendChild(bodyContent); - } - - this.changeBodyEvent.fire(bodyContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the body. If no body is present, one will be automatically created. - * @method appendToBody - * @param {HTMLElement} element The element to append to the body - */ - appendToBody : function(element) { - if (! this.body) { - this.body = document.createElement("div"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - this.body.appendChild(element); - this.changeBodyEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created. - * @method setFooter - * @param {String} footerContent The HTML used to set the footer <em>OR</em> - * @param {HTMLElement} footerContent The HTMLElement to append to the footer - */ - setFooter : function(footerContent) { - if (! this.footer) { - this.footer = document.createElement("div"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - if (typeof footerContent == "string") { - this.footer.innerHTML = footerContent; - } else { - this.footer.innerHTML = ""; - this.footer.appendChild(footerContent); - } - - this.changeFooterEvent.fire(footerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the footer. If no footer is present, one will be automatically created. - * @method appendToFooter - * @param {HTMLElement} element The element to append to the footer - */ - appendToFooter : function(element) { - if (! this.footer) { - this.footer = document.createElement("div"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - this.footer.appendChild(element); - this.changeFooterEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. - * @method render - * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em> - * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering - * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container. - * @return {Boolean} Success or failure of the render - */ - render : function(appendToNode, moduleElement) { - this.beforeRenderEvent.fire(); - - if (! moduleElement) { - moduleElement = this.element; - } - - var me = this; - var appendTo = function(element) { - if (typeof element == "string") { - element = document.getElementById(element); - } - - if (element) { - element.appendChild(me.element); - me.appendEvent.fire(); - } - }; - - if (appendToNode) { - appendTo(appendToNode); - } else { // No node was passed in. If the element is not pre-marked up, this fails - if (! YAHOO.util.Dom.inDocument(this.element)) { - return false; - } - } - - // Need to get everything into the DOM if it isn't already - - if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) { - // There is a header, but it's not in the DOM yet... need to add it - var firstChild = moduleElement.firstChild; - if (firstChild) { // Insert before first child if exists - moduleElement.insertBefore(this.header, firstChild); - } else { // Append to empty body because there are no children - moduleElement.appendChild(this.header); - } - } - - if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) { - // There is a body, but it's not in the DOM yet... need to add it - if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM - moduleElement.insertBefore(this.body, this.footer); - } else { // Append to element because there is no footer - moduleElement.appendChild(this.body); - } - } - - if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) { - // There is a footer, but it's not in the DOM yet... need to add it - moduleElement.appendChild(this.footer); - } - - this.renderEvent.fire(); - return true; - }, - - /** - * Removes the Module element from the DOM and sets all child elements to null. - * @method destroy - */ - destroy : function() { - var parent; - - if (this.element) { - YAHOO.util.Event.purgeElement(this.element, true); - parent = this.element.parentNode; - } - if (parent) { - parent.removeChild(this.element); - } - - this.element = null; - this.header = null; - this.body = null; - this.footer = null; - - for (var e in this) { - if (e instanceof YAHOO.util.CustomEvent) { - e.unsubscribeAll(); - } - } - - YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this); - - this.destroyEvent.fire(); - }, - - /** - * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after. - * @method show - */ - show : function() { - this.cfg.setProperty("visible", true); - }, - - /** - * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after. - * @method hide - */ - hide : function() { - this.cfg.setProperty("visible", false); - }, - - // BUILT-IN EVENT HANDLERS FOR MODULE // - - /** - * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none". - * This method is responsible for firing showEvent and hideEvent. - * @param {String} type The CustomEvent type (usually the property name) - * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. - * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. - * @method configVisible - */ - configVisible : function(type, args, obj) { - var visible = args[0]; - if (visible) { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "block"); - this.showEvent.fire(); - } else { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "none"); - this.hideEvent.fire(); - } - }, - - /** - * Default event handler for the "monitorresize" configuration property - * @param {String} type The CustomEvent type (usually the property name) - * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. - * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. - * @method configMonitorResize - */ - configMonitorResize : function(type, args, obj) { - var monitor = args[0]; - if (monitor) { - this.initResizeMonitor(); - } else { - YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true); - this.resizeMonitor = null; - } - } -}; - -/** -* Returns a String representation of the Object. -* @method toString -* @return {String} The string representation of the Module -*/ -YAHOO.widget.Module.prototype.toString = function() { - return "Module " + this.id; -}; - -/** -* Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements. -* @namespace YAHOO.widget -* @class Overlay -* @extends YAHOO.widget.Module -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Overlay = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig); -}; - -YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module); - -/** -* The URL that will be placed in the iframe -* @property YAHOO.widget.Overlay.IFRAME_SRC -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;"; - -/** -* Constant representing the top left corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.TOP_LEFT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.TOP_LEFT = "tl"; - -/** -* Constant representing the top right corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.TOP_RIGHT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.TOP_RIGHT = "tr"; - -/** -* Constant representing the top bottom left corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.BOTTOM_LEFT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.BOTTOM_LEFT = "bl"; - -/** -* Constant representing the bottom right corner of an element, used for configuring the context element alignment -* @property YAHOO.widget.Overlay.BOTTOM_RIGHT -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.BOTTOM_RIGHT = "br"; - -/** -* Constant representing the default CSS class used for an Overlay -* @property YAHOO.widget.Overlay.CSS_OVERLAY -* @static -* @final -* @type String -*/ -YAHOO.widget.Overlay.CSS_OVERLAY = "yui-overlay"; - -/** -* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @method init -* @param {String} el The element ID representing the Overlay <em>OR</em> -* @param {HTMLElement} el The element representing the Overlay -* @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Overlay.prototype.init = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Overlay); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - if (this.platform == "mac" && this.browser == "gecko") { - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) { - this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) { - this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true); - } - } - - this.initEvent.fire(YAHOO.widget.Overlay); - -}; - -/** -* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class. -* @method initEvents -*/ -YAHOO.widget.Overlay.prototype.initEvents = function() { - YAHOO.widget.Overlay.superclass.initEvents.call(this); - - /** - * CustomEvent fired before the Overlay is moved. - * @event beforeMoveEvent - * @param {Number} x x coordinate - * @param {Number} y y coordinate - */ - this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this); - - /** - * CustomEvent fired after the Overlay is moved. - * @event moveEvent - * @param {Number} x x coordinate - * @param {Number} y y coordinate - */ - this.moveEvent = new YAHOO.util.CustomEvent("move", this); -}; - -/** -* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). -* @method initDefaultConfig -*/ -YAHOO.widget.Overlay.prototype.initDefaultConfig = function() { - YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this); - - // Add overlay config properties // - - /** - * The absolute x-coordinate position of the Overlay - * @config x - * @type Number - * @default null - */ - this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * The absolute y-coordinate position of the Overlay - * @config y - * @type Number - * @default null - */ - this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * An array with the absolute x and y positions of the Overlay - * @config xy - * @type Number[] - * @default null - */ - this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner. - * @config context - * @type Array - * @default null - */ - this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * True if the Overlay should be anchored to the center of the viewport. - * @config fixedcenter - * @type Boolean - * @default false - */ - this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } ); - - /** - * CSS width of the Overlay. - * @config width - * @type String - * @default null - */ - this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * CSS height of the Overlay. - * @config height - * @type String - * @default null - */ - this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } ); - - /** - * CSS z-index of the Overlay. - * @config zIndex - * @type Number - * @default null - */ - this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } ); - - /** - * True if the Overlay should be prevented from being positioned out of the viewport. - * @config constraintoviewport - * @type Boolean - * @default false - */ - this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } ); - - /** - * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below). - * @config iframe - * @type Boolean - * @default true for IE6 and below, false for all others - */ - this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } ); -}; - -/** -* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]); -* @method moveTo -* @param {Number} x The Overlay's new x position -* @param {Number} y The Overlay's new y position -*/ -YAHOO.widget.Overlay.prototype.moveTo = function(x, y) { - this.cfg.setProperty("xy",[x,y]); -}; - -/** -* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -* @method hideMacGeckoScrollbars -*/ -YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "show-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "hide-scrollbars"); -}; - -/** -* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -* @method showMacGeckoScrollbars -*/ -YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "show-scrollbars"); -}; - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent. -* @method configVisible -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) { - var visible = args[0]; - var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility"); - - if (currentVis == "inherit") { - var e = this.element.parentNode; - while (e.nodeType != 9 && e.nodeType != 11) { - currentVis = YAHOO.util.Dom.getStyle(e, "visibility"); - if (currentVis != "inherit") { break; } - e = e.parentNode; - } - if (currentVis == "inherit") { - currentVis = "visible"; - } - } - - var effect = this.cfg.getProperty("effect"); - - var effectInstances = []; - if (effect) { - if (effect instanceof Array) { - for (var i=0;i<effect.length;i++) { - var eff = effect[i]; - effectInstances[effectInstances.length] = eff.effect(this, eff.duration); - } - } else { - effectInstances[effectInstances.length] = effect.effect(this, effect.duration); - } - } - - var isMacGecko = (this.platform == "mac" && this.browser == "gecko"); - - if (visible) { // Show - if (isMacGecko) { - this.showMacGeckoScrollbars(); - } - - if (effect) { // Animate in - if (visible) { // Animate in if not showing - if (currentVis != "visible" || currentVis === "") { - this.beforeShowEvent.fire(); - for (var j=0;j<effectInstances.length;j++) { - var ei = effectInstances[j]; - if (j === 0 && ! YAHOO.util.Config.alreadySubscribed(ei.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) { - ei.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete - } - ei.animateIn(); - } - } - } - } else { // Show - if (currentVis != "visible" || currentVis === "") { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "visibility", "visible"); - this.cfg.refireEvent("iframe"); - this.showEvent.fire(); - } - } - - } else { // Hide - if (isMacGecko) { - this.hideMacGeckoScrollbars(); - } - - if (effect) { // Animate out if showing - if (currentVis == "visible") { - this.beforeHideEvent.fire(); - for (var k=0;k<effectInstances.length;k++) { - var h = effectInstances[k]; - if (k === 0 && ! YAHOO.util.Config.alreadySubscribed(h.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) { - h.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete - } - h.animateOut(); - } - } else if (currentVis === "") { - YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden"); - } - } else { // Simple hide - if (currentVis == "visible" || currentVis === "") { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden"); - this.cfg.refireEvent("iframe"); - this.hideEvent.fire(); - } - } - } -}; - -/** -* Center event handler used for centering on scroll/resize, but only if the Overlay is visible -* @method doCenterOnDOMEvent -*/ -YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() { - if (this.cfg.getProperty("visible")) { - this.center(); - } -}; - -/** -* The default event handler fired when the "fixedcenter" property is changed. -* @method configFixedCenter -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) { - var val = args[0]; - - if (val) { - this.center(); - - if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) { - this.beforeShowEvent.subscribe(this.center, this, true); - } - - if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) { - YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true); - } - - if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) { - YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true); - } - } else { - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); - } -}; - -/** -* The default event handler fired when the "height" property is changed. -* @method configHeight -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) { - var height = args[0]; - var el = this.element; - YAHOO.util.Dom.setStyle(el, "height", height); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "width" property is changed. -* @method configWidth -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) { - var width = args[0]; - var el = this.element; - YAHOO.util.Dom.setStyle(el, "width", width); - this.cfg.refireEvent("iframe"); -}; - -/** -* The default event handler fired when the "zIndex" property is changed. -* @method configzIndex -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) { - var zIndex = args[0]; - - var el = this.element; - - if (! zIndex) { - zIndex = YAHOO.util.Dom.getStyle(el, "zIndex"); - if (! zIndex || isNaN(zIndex)) { - zIndex = 0; - } - } - - if (this.iframe) { - if (zIndex <= 0) { - zIndex = 1; - } - YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1)); - } - - YAHOO.util.Dom.setStyle(el, "zIndex", zIndex); - this.cfg.setProperty("zIndex", zIndex, true); -}; - -/** -* The default event handler fired when the "xy" property is changed. -* @method configXY -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) { - var pos = args[0]; - var x = pos[0]; - var y = pos[1]; - - this.cfg.setProperty("x", x); - this.cfg.setProperty("y", y); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x,y]); -}; - -/** -* The default event handler fired when the "x" property is changed. -* @method configX -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) { - var x = args[0]; - var y = this.cfg.getProperty("y"); - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.util.Dom.setX(this.element, x, true); - - this.cfg.setProperty("xy", [x, y], true); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x, y]); -}; - -/** -* The default event handler fired when the "y" property is changed. -* @method configY -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) { - var x = this.cfg.getProperty("x"); - var y = args[0]; - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - - this.beforeMoveEvent.fire([x,y]); - - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - - YAHOO.util.Dom.setY(this.element, y, true); - - this.cfg.setProperty("xy", [x, y], true); - - this.cfg.refireEvent("iframe"); - this.moveEvent.fire([x, y]); -}; - -/** -* Shows the iframe shim, if it has been enabled -* @method showIframe -*/ -YAHOO.widget.Overlay.prototype.showIframe = function() { - if (this.iframe) { - this.iframe.style.display = "block"; - } -}; - -/** -* Hides the iframe shim, if it has been enabled -* @method hideIframe -*/ -YAHOO.widget.Overlay.prototype.hideIframe = function() { - if (this.iframe) { - this.iframe.style.display = "none"; - } -}; - -/** -* The default event handler fired when the "iframe" property is changed. -* @method configIframe -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) { - - var val = args[0]; - - if (val) { // IFRAME shim is enabled - - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, this.showIframe, this)) { - this.showEvent.subscribe(this.showIframe, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, this.hideIframe, this)) { - this.hideEvent.subscribe(this.hideIframe, this, true); - } - - var x = this.cfg.getProperty("x"); - var y = this.cfg.getProperty("y"); - - if (! x || ! y) { - this.syncPosition(); - x = this.cfg.getProperty("x"); - y = this.cfg.getProperty("y"); - } - - - if (! isNaN(x) && ! isNaN(y)) { - if (! this.iframe) { - this.iframe = document.createElement("iframe"); - if (this.isSecure) { - this.iframe.src = YAHOO.widget.Overlay.IFRAME_SRC; - } - - var parent = this.element.parentNode; - if (parent) { - parent.appendChild(this.iframe); - } else { - document.body.appendChild(this.iframe); - } - - YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute"); - YAHOO.util.Dom.setStyle(this.iframe, "border", "none"); - YAHOO.util.Dom.setStyle(this.iframe, "margin", "0"); - YAHOO.util.Dom.setStyle(this.iframe, "padding", "0"); - YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0"); - if (this.cfg.getProperty("visible")) { - this.showIframe(); - } else { - this.hideIframe(); - } - } - - var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display"); - - if (iframeDisplay == "none") { - this.iframe.style.display = "block"; - } - - YAHOO.util.Dom.setXY(this.iframe, [x,y]); - - var width = this.element.clientWidth; - var height = this.element.clientHeight; - - YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px"); - YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px"); - - if (iframeDisplay == "none") { - this.iframe.style.display = "none"; - } - } - } else { - if (this.iframe) { - this.iframe.style.display = "none"; - } - this.showEvent.unsubscribe(this.showIframe, this); - this.hideEvent.unsubscribe(this.hideIframe, this); - } -}; - - -/** -* The default event handler fired when the "constraintoviewport" property is changed. -* @method configConstrainToViewport -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) { - var val = args[0]; - if (val) { - if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) { - this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true); - } - } else { - this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this); - } -}; - -/** -* The default event handler fired when the "context" property is changed. -* @method configContext -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) { - var contextArgs = args[0]; - - if (contextArgs) { - var contextEl = contextArgs[0]; - var elementMagnetCorner = contextArgs[1]; - var contextMagnetCorner = contextArgs[2]; - - if (contextEl) { - if (typeof contextEl == "string") { - this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true); - } - - if (elementMagnetCorner && contextMagnetCorner) { - this.align(elementMagnetCorner, contextMagnetCorner); - } - } - } -}; - - -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT. -* @method align -* @param {String} elementAlign The String representing the corner of the Overlay that should be aligned to the context element -* @param {String} contextAlign The corner of the context element that the elementAlign corner should stick to. -*/ -YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) { - var contextArgs = this.cfg.getProperty("context"); - if (contextArgs) { - var context = contextArgs[0]; - - var element = this.element; - var me = this; - - if (! elementAlign) { - elementAlign = contextArgs[1]; - } - - if (! contextAlign) { - contextAlign = contextArgs[2]; - } - - if (element && context) { - var contextRegion = YAHOO.util.Dom.getRegion(context); - - var doAlign = function(v,h) { - switch (elementAlign) { - case YAHOO.widget.Overlay.TOP_LEFT: - me.moveTo(h,v); - break; - case YAHOO.widget.Overlay.TOP_RIGHT: - me.moveTo(h-element.offsetWidth,v); - break; - case YAHOO.widget.Overlay.BOTTOM_LEFT: - me.moveTo(h,v-element.offsetHeight); - break; - case YAHOO.widget.Overlay.BOTTOM_RIGHT: - me.moveTo(h-element.offsetWidth,v-element.offsetHeight); - break; - } - }; - - switch (contextAlign) { - case YAHOO.widget.Overlay.TOP_LEFT: - doAlign(contextRegion.top, contextRegion.left); - break; - case YAHOO.widget.Overlay.TOP_RIGHT: - doAlign(contextRegion.top, contextRegion.right); - break; - case YAHOO.widget.Overlay.BOTTOM_LEFT: - doAlign(contextRegion.bottom, contextRegion.left); - break; - case YAHOO.widget.Overlay.BOTTOM_RIGHT: - doAlign(contextRegion.bottom, contextRegion.right); - break; - } - } - } -}; - -/** -* The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true. -* @method enforceConstraints -* @param {String} type The CustomEvent type (usually the property name) -* @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property. -* @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner. -*/ -YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) { - var pos = args[0]; - - var x = pos[0]; - var y = pos[1]; - - var offsetHeight = this.element.offsetHeight; - var offsetWidth = this.element.offsetWidth; - - var viewPortWidth = YAHOO.util.Dom.getViewportWidth(); - var viewPortHeight = YAHOO.util.Dom.getViewportHeight(); - - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var topConstraint = scrollY + 10; - var leftConstraint = scrollX + 10; - var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10; - var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10; - - if (x < leftConstraint) { - x = leftConstraint; - } else if (x > rightConstraint) { - x = rightConstraint; - } - - if (y < topConstraint) { - y = topConstraint; - } else if (y > bottomConstraint) { - y = bottomConstraint; - } - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - this.cfg.setProperty("xy", [x,y], true); -}; - -/** -* Centers the container in the viewport. -* @method center -*/ -YAHOO.widget.Overlay.prototype.center = function() { - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var viewPortWidth = YAHOO.util.Dom.getClientWidth(); - var viewPortHeight = YAHOO.util.Dom.getClientHeight(); - - var elementWidth = this.element.offsetWidth; - var elementHeight = this.element.offsetHeight; - - var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX; - var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY; - - this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]); - - this.cfg.refireEvent("iframe"); -}; - -/** -* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop. -* @method syncPosition -*/ -YAHOO.widget.Overlay.prototype.syncPosition = function() { - var pos = YAHOO.util.Dom.getXY(this.element); - this.cfg.setProperty("x", pos[0], true); - this.cfg.setProperty("y", pos[1], true); - this.cfg.setProperty("xy", pos, true); -}; - -/** -* Event handler fired when the resize monitor element is resized. -* @method onDomResize -* @param {DOMEvent} e The resize DOM event -* @param {Object} obj The scope object -*/ -YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) { - YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj); - var me = this; - setTimeout(function() { - me.syncPosition(); - me.cfg.refireEvent("iframe"); - me.cfg.refireEvent("context"); - }, 0); -}; - -/** -* Removes the Overlay element from the DOM and sets all child elements to null. -* @method destroy -*/ -YAHOO.widget.Overlay.prototype.destroy = function() { - if (this.iframe) { - this.iframe.parentNode.removeChild(this.iframe); - } - - this.iframe = null; - - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this); - - YAHOO.widget.Overlay.superclass.destroy.call(this); -}; - -/** -* Returns a String representation of the object. -* @method toString -* @return {String} The string representation of the Overlay. -*/ -YAHOO.widget.Overlay.prototype.toString = function() { - return "Overlay " + this.id; -}; - -/** -* A singleton CustomEvent used for reacting to the DOM event for window scroll -* @event YAHOO.widget.Overlay.windowScrollEvent -*/ -YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll"); - -/** -* A singleton CustomEvent used for reacting to the DOM event for window resize -* @event YAHOO.widget.Overlay.windowResizeEvent -*/ -YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize"); - -/** -* The DOM event handler used to fire the CustomEvent for window scroll -* @method YAHOO.widget.Overlay.windowScrollHandler -* @static -* @param {DOMEvent} e The DOM scroll event -*/ -YAHOO.widget.Overlay.windowScrollHandler = function(e) { - if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { - if (! window.scrollEnd) { - window.scrollEnd = -1; - } - clearTimeout(window.scrollEnd); - window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1); - } else { - YAHOO.widget.Overlay.windowScrollEvent.fire(); - } -}; - -/** -* The DOM event handler used to fire the CustomEvent for window resize -* @method YAHOO.widget.Overlay.windowResizeHandler -* @static -* @param {DOMEvent} e The DOM resize event -*/ -YAHOO.widget.Overlay.windowResizeHandler = function(e) { - if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") { - if (! window.resizeEnd) { - window.resizeEnd = -1; - } - clearTimeout(window.resizeEnd); - window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100); - } else { - YAHOO.widget.Overlay.windowResizeEvent.fire(); - } -}; - -/** -* A boolean that indicated whether the window resize and scroll events have already been subscribed to. -* @property YAHOO.widget.Overlay._initialized -* @private -* @type Boolean -*/ -YAHOO.widget.Overlay._initialized = null; - -if (YAHOO.widget.Overlay._initialized === null) { - YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler); - YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler); - - YAHOO.widget.Overlay._initialized = true; -} - -/** -* OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget -* @namespace YAHOO.widget -* @class OverlayManager -* @constructor -* @param {Array} overlays Optional. A collection of Overlays to register with the manager. -* @param {Object} userConfig The object literal representing the user configuration of the OverlayManager -*/ -YAHOO.widget.OverlayManager = function(userConfig) { - this.init(userConfig); -}; - -/** -* The CSS class representing a focused Overlay -* @property YAHOO.widget.OverlayManager.CSS_FOCUSED -* @static -* @final -* @type String -*/ -YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused"; - -YAHOO.widget.OverlayManager.prototype = { - /** - * The class's constructor function - * @property contructor - * @type Function - */ - constructor : YAHOO.widget.OverlayManager, - - /** - * The array of Overlays that are currently registered - * @property overlays - * @type YAHOO.widget.Overlay[] - */ - overlays : null, - - /** - * Initializes the default configuration of the OverlayManager - * @method initDefaultConfig - */ - initDefaultConfig : function() { - /** - * The collection of registered Overlays in use by the OverlayManager - * @config overlays - * @type YAHOO.widget.Overlay[] - * @default null - */ - this.cfg.addProperty("overlays", { suppressEvent:true } ); - - /** - * The default DOM event that should be used to focus an Overlay - * @config focusevent - * @type String - * @default "mousedown" - */ - this.cfg.addProperty("focusevent", { value:"mousedown" } ); - }, - - /** - * Initializes the OverlayManager - * @method init - * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager. - * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager - */ - init : function(userConfig) { - /** - * The OverlayManager's Config object used for monitoring configuration properties. - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - this.initDefaultConfig(); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - this.cfg.fireQueue(); - - /** - * The currently activated Overlay - * @property activeOverlay - * @private - * @type YAHOO.widget.Overlay - */ - var activeOverlay = null; - - /** - * Returns the currently focused Overlay - * @method getActive - * @return {YAHOO.widget.Overlay} The currently focused Overlay - */ - this.getActive = function() { - return activeOverlay; - }; - - /** - * Focuses the specified Overlay - * @method focus - * @param {YAHOO.widget.Overlay} overlay The Overlay to focus - * @param {String} overlay The id of the Overlay to focus - */ - this.focus = function(overlay) { - var o = this.find(overlay); - if (o) { - this.blurAll(); - activeOverlay = o; - YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - this.overlays.sort(this.compareZIndexDesc); - var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex"); - if (! isNaN(topZIndex) && this.overlays[0] != overlay) { - activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2)); - } - this.overlays.sort(this.compareZIndexDesc); - } - }; - - /** - * Removes the specified Overlay from the manager - * @method remove - * @param {YAHOO.widget.Overlay} overlay The Overlay to remove - * @param {String} overlay The id of the Overlay to remove - */ - this.remove = function(overlay) { - var o = this.find(overlay); - if (o) { - var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex"); - o.cfg.setProperty("zIndex", -1000, true); - this.overlays.sort(this.compareZIndexDesc); - this.overlays = this.overlays.slice(0, this.overlays.length-1); - o.cfg.setProperty("zIndex", originalZ, true); - - o.cfg.setProperty("manager", null); - o.focusEvent = null; - o.blurEvent = null; - o.focus = null; - o.blur = null; - } - }; - - /** - * Removes focus from all registered Overlays in the manager - * @method blurAll - */ - this.blurAll = function() { - activeOverlay = null; - for (var o=0;o<this.overlays.length;o++) { - YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - } - }; - - var overlays = this.cfg.getProperty("overlays"); - - if (! this.overlays) { - this.overlays = []; - } - - if (overlays) { - this.register(overlays); - this.overlays.sort(this.compareZIndexDesc); - } - }, - - /** - * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each. - * @method register - * @param {YAHOO.widget.Overlay} overlay An Overlay to register with the manager. - * @param {YAHOO.widget.Overlay[]} overlay An array of Overlays to register with the manager. - * @return {Boolean} True if any Overlays are registered. - */ - register : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - overlay.cfg.addProperty("manager", { value:this } ); - - overlay.focusEvent = new YAHOO.util.CustomEvent("focus"); - overlay.blurEvent = new YAHOO.util.CustomEvent("blur"); - - var mgr=this; - - overlay.focus = function() { - mgr.focus(this); - this.focusEvent.fire(); - }; - - overlay.blur = function() { - mgr.blurAll(); - this.blurEvent.fire(); - }; - - var focusOnDomEvent = function(e,obj) { - overlay.focus(); - }; - - var focusevent = this.cfg.getProperty("focusevent"); - YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true); - - var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex"); - if (! isNaN(zIndex)) { - overlay.cfg.setProperty("zIndex", parseInt(zIndex, 10)); - } else { - overlay.cfg.setProperty("zIndex", 0); - } - - this.overlays.push(overlay); - return true; - } else if (overlay instanceof Array) { - var regcount = 0; - for (var i=0;i<overlay.length;i++) { - if (this.register(overlay[i])) { - regcount++; - } - } - if (regcount > 0) { - return true; - } - } else { - return false; - } - }, - - /** - * Attempts to locate an Overlay by instance or ID. - * @method find - * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager - * @param {String} overlay An Overlay id to locate within the manager - * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located. - */ - find : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - for (var o=0;o<this.overlays.length;o++) { - if (this.overlays[o] == overlay) { - return this.overlays[o]; - } - } - } else if (typeof overlay == "string") { - for (var p=0;p<this.overlays.length;p++) { - if (this.overlays[p].id == overlay) { - return this.overlays[p]; - } - } - } - return null; - }, - - /** - * Used for sorting the manager's Overlays by z-index. - * @method compareZIndexDesc - * @private - * @return {Number} 0, 1, or -1, depending on where the Overlay should fall in the stacking order. - */ - compareZIndexDesc : function(o1, o2) { - var zIndex1 = o1.cfg.getProperty("zIndex"); - var zIndex2 = o2.cfg.getProperty("zIndex"); - - if (zIndex1 > zIndex2) { - return -1; - } else if (zIndex1 < zIndex2) { - return 1; - } else { - return 0; - } - }, - - /** - * Shows all Overlays in the manager. - * @method showAll - */ - showAll : function() { - for (var o=0;o<this.overlays.length;o++) { - this.overlays[o].show(); - } - }, - - /** - * Hides all Overlays in the manager. - * @method hideAll - */ - hideAll : function() { - for (var o=0;o<this.overlays.length;o++) { - this.overlays[o].hide(); - } - }, - - /** - * Returns a string representation of the object. - * @method toString - * @return {String} The string representation of the OverlayManager - */ - toString : function() { - return "OverlayManager"; - } - -}; - -/** -* KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements. -* @namespace YAHOO.util -* @class KeyListener -* @constructor -* @param {HTMLElement} attachTo The element or element ID to which the key event should be attached -* @param {String} attachTo The element or element ID to which the key event should be attached -* @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). -* @param {Function} handler The CustomEvent handler to fire when the key event is detected -* @param {Object} handler An object literal representing the handler. -* @param {String} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown. -*/ -YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) { - if (! attachTo) { - } - if (! keyData) { - } - if (! handler) { - } - - if (! event) { - event = YAHOO.util.KeyListener.KEYDOWN; - } - - /** - * The CustomEvent fired internally when a key is pressed - * @event keyEvent - * @private - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - var keyEvent = new YAHOO.util.CustomEvent("keyPressed"); - - /** - * The CustomEvent fired when the KeyListener is enabled via the enable() function - * @event enabledEvent - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - this.enabledEvent = new YAHOO.util.CustomEvent("enabled"); - - /** - * The CustomEvent fired when the KeyListener is disabled via the disable() function - * @event disabledEvent - * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes). - */ - this.disabledEvent = new YAHOO.util.CustomEvent("disabled"); - - if (typeof attachTo == 'string') { - attachTo = document.getElementById(attachTo); - } - - if (typeof handler == 'function') { - keyEvent.subscribe(handler); - } else { - keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope); - } - - /** - * Handles the key event when a key is pressed. - * @method handleKeyPress - * @param {DOMEvent} e The keypress DOM event - * @param {Object} obj The DOM event scope object - * @private - */ - function handleKeyPress(e, obj) { - if (! keyData.shift) { - keyData.shift = false; - } - if (! keyData.alt) { - keyData.alt = false; - } - if (! keyData.ctrl) { - keyData.ctrl = false; - } - - // check held down modifying keys first - if (e.shiftKey == keyData.shift && - e.altKey == keyData.alt && - e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match - - var dataItem; - var keyPressed; - - if (keyData.keys instanceof Array) { - for (var i=0;i<keyData.keys.length;i++) { - dataItem = keyData.keys[i]; - - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - break; - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - break; - } - } - } else { - dataItem = keyData.keys; - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - } - } - } - } - - /** - * Enables the KeyListener by attaching the DOM event listeners to the target DOM element - * @method enable - */ - this.enable = function() { - if (! this.enabled) { - YAHOO.util.Event.addListener(attachTo, event, handleKeyPress); - this.enabledEvent.fire(keyData); - } - /** - * Boolean indicating the enabled/disabled state of the Tooltip - * @property enabled - * @type Boolean - */ - this.enabled = true; - }; - - /** - * Disables the KeyListener by removing the DOM event listeners from the target DOM element - * @method disable - */ - this.disable = function() { - if (this.enabled) { - YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress); - this.disabledEvent.fire(keyData); - } - this.enabled = false; - }; - - /** - * Returns a String representation of the object. - * @method toString - * @return {String} The string representation of the KeyListener - */ - this.toString = function() { - return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : ""); - }; - -}; - -/** -* Constant representing the DOM "keydown" event. -* @property YAHOO.util.KeyListener.KEYDOWN -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYDOWN = "keydown"; - -/** -* Constant representing the DOM "keyup" event. -* @property YAHOO.util.KeyListener.KEYUP -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYUP = "keyup"; - -/** -* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden. -* @namespace YAHOO.widget -* @class ContainerEffect -* @constructor -* @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with -* @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element. -* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion. -*/ -YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) { - if (! animClass) { - animClass = YAHOO.util.Anim; - } - - /** - * The overlay to animate - * @property overlay - * @type YAHOO.widget.Overlay - */ - this.overlay = overlay; - /** - * The animation attributes to use when transitioning into view - * @property attrIn - * @type Object - */ - this.attrIn = attrIn; - /** - * The animation attributes to use when transitioning out of view - * @property attrOut - * @type Object - */ - this.attrOut = attrOut; - /** - * The target element to be animated - * @property targetElement - * @type HTMLElement - */ - this.targetElement = targetElement || overlay.element; - /** - * The animation class to use for animating the overlay - * @property animClass - * @type class - */ - this.animClass = animClass; -}; - -/** -* Initializes the animation classes and events. -* @method init -*/ -YAHOO.widget.ContainerEffect.prototype.init = function() { - this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn"); - this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut"); - - this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete"); - this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete"); - - this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method); - this.animIn.onStart.subscribe(this.handleStartAnimateIn, this); - this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this); - this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this); - - this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method); - this.animOut.onStart.subscribe(this.handleStartAnimateOut, this); - this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this); - this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this); -}; - -/** -* Triggers the in-animation. -* @method animateIn -*/ -YAHOO.widget.ContainerEffect.prototype.animateIn = function() { - this.beforeAnimateInEvent.fire(); - this.animIn.animate(); -}; - -/** -* Triggers the out-animation. -* @method animateOut -*/ -YAHOO.widget.ContainerEffect.prototype.animateOut = function() { - this.beforeAnimateOutEvent.fire(); - this.animOut.animate(); -}; - -/** -* The default onStart handler for the in-animation. -* @method handleStartAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { }; -/** -* The default onTween handler for the in-animation. -* @method handleTweenAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { }; -/** -* The default onComplete handler for the in-animation. -* @method handleCompleteAnimateIn -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { }; - -/** -* The default onStart handler for the out-animation. -* @method handleStartAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { }; -/** -* The default onTween handler for the out-animation. -* @method handleTweenAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { }; -/** -* The default onComplete handler for the out-animation. -* @method handleCompleteAnimateOut -* @param {String} type The CustomEvent type -* @param {Object[]} args The CustomEvent arguments -* @param {Object} obj The scope object -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { }; - -/** -* Returns a string representation of the object. -* @method toString -* @return {String} The string representation of the ContainerEffect -*/ -YAHOO.widget.ContainerEffect.prototype.toString = function() { - var output = "ContainerEffect"; - if (this.overlay) { - output += " [" + this.overlay.toString() + "]"; - } - return output; -}; - -/** -* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out. -* @method FADE -* @static -* @param {Overlay} overlay The Overlay object to animate -* @param {Number} dur The duration of the animation -* @return {ContainerEffect} The configured ContainerEffect object -*/ -YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) { - var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element ); - - fade.handleStartAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (! obj.overlay.underlay) { - obj.overlay.cfg.refireEvent("underlay"); - } - - if (obj.overlay.underlay) { - obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity"); - obj.overlay.underlay.style.filter = null; - } - - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0); - }; - - fade.handleCompleteAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - - if (obj.overlay.underlay) { - YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity); - } - - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - }; - - fade.handleStartAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.underlay) { - obj.overlay.underlay.style.filter = null; - } - }; - - fade.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1); - - obj.overlay.cfg.refireEvent("iframe"); - - obj.animateOutCompleteEvent.fire(); - }; - - fade.init(); - return fade; -}; - - -/** -* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out. -* @method SLIDE -* @static -* @param {Overlay} overlay The Overlay object to animate -* @param {Number} dur The duration of the animation -* @return {ContainerEffect} The configured ContainerEffect object -*/ -YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) { - var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element); - var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element); - - var clientWidth = YAHOO.util.Dom.getClientWidth(); - var offsetWidth = overlay.element.offsetWidth; - - var slide = new YAHOO.widget.ContainerEffect(overlay, { - attributes:{ points: { to:[x, y] } }, - duration:dur, - method:YAHOO.util.Easing.easeIn - }, - { - attributes:{ points: { to:[(clientWidth+25), y] } }, - duration:dur, - method:YAHOO.util.Easing.easeOut - }, - overlay.element, - YAHOO.util.Motion); - - - slide.handleStartAnimateIn = function(type,args,obj) { - obj.overlay.element.style.left = (-25-offsetWidth) + "px"; - obj.overlay.element.style.top = y + "px"; - }; - - slide.handleTweenAnimateIn = function(type, args, obj) { - - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var currentX = pos[0]; - var currentY = pos[1]; - - if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - } - - obj.overlay.cfg.setProperty("xy", [currentX,currentY], true); - obj.overlay.cfg.refireEvent("iframe"); - }; - - slide.handleCompleteAnimateIn = function(type, args, obj) { - obj.overlay.cfg.setProperty("xy", [x,y], true); - obj.startX = x; - obj.startY = y; - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - }; - - slide.handleStartAnimateOut = function(type, args, obj) { - var vw = YAHOO.util.Dom.getViewportWidth(); - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var yso = pos[1]; - - var currentTo = obj.animOut.attributes.points.to; - obj.animOut.attributes.points.to = [(vw+25), yso]; - }; - - slide.handleTweenAnimateOut = function(type, args, obj) { - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var xto = pos[0]; - var yto = pos[1]; - - obj.overlay.cfg.setProperty("xy", [xto,yto], true); - obj.overlay.cfg.refireEvent("iframe"); - }; - - slide.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - - obj.overlay.cfg.setProperty("xy", [x,y]); - obj.animateOutCompleteEvent.fire(); - }; - - slide.init(); - return slide; -}; - -YAHOO.register("container_core", YAHOO.widget.Module, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/datasource/README b/interface/web/js/yui/datasource/README deleted file mode 100644 index e5a18c41e4..0000000000 --- a/interface/web/js/yui/datasource/README +++ /dev/null @@ -1,5 +0,0 @@ -DataSource Release Notes - -*** version 2.2.0 *** - -* Beta release. diff --git a/interface/web/js/yui/datasource/datasource-beta-debug.js b/interface/web/js/yui/datasource/datasource-beta-debug.js deleted file mode 100644 index 54bbd9594a..0000000000 --- a/interface/web/js/yui/datasource/datasource-beta-debug.js +++ /dev/null @@ -1,912 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The DataSource utility provides a common configurable interface for widgets - * to access a variety of data, from JavaScript arrays to online servers over - * XHR. - * - * @module datasource - * @requires yahoo, event - * @optional xhr - * @title DataSource Utility - * @beta - */ - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The DataSource class defines and manages a live set of data for widgets to - * interact with. Examples of live databases include in-memory - * local data such as a JavaScript array, a JavaScript function, or JSON, or - * remote data such as data retrieved through an XHR connection. - * - * @class DataSource - * @uses YAHOO.util.EventProvider - * @constructor - * @param oLiveData {Object} Pointer to live database - * @param oConfigs {Object} (optional) Object literal of configuration values - */ -YAHOO.util.DataSource = function(oLiveData, oConfigs) { - // Set any config params passed in to override defaults - if(typeof oConfigs == "object") { - for(var sConfig in oConfigs) { - if (sConfig) { - this[sConfig] = oConfigs[sConfig]; - } - } - } - - if(!oLiveData) { - YAHOO.log("Could not instantiate DataSource due to invalid live database.","error",this.toString()); - return; - } - else { - switch(oLiveData.constructor) { - case Function: - this.dataType = YAHOO.util.DataSource.TYPE_JSFUNCTION; - break; - case Array: - this.dataType = YAHOO.util.DataSource.TYPE_JSARRAY; - break; - case String: - this.dataType = YAHOO.util.DataSource.TYPE_XHR; - break; - case Object: - this.dataType = YAHOO.util.DataSource.TYPE_JSON; - break; - default: - this.dataType = YAHOO.util.DataSource.TYPE_UNKNOWN; - break; - } - this.liveData = oLiveData; - } - - // 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 = []; - YAHOO.log("Cache initialized","info",this.toString()); - } - - this._sName = "instance" + YAHOO.util.DataSource._nIndex; - YAHOO.util.DataSource._nIndex++; - YAHOO.log("DataSource initialized", "info", this.toString()); - - - ///////////////////////////////////////////////////////////////////////////// - // - // Custom Events - // - ///////////////////////////////////////////////////////////////////////////// - - /** - * Fired when a request is made to the local cache. - * - * @event cacheRequestEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("cacheRequestEvent"); - - /** - * Fired when data is retrieved from the local cache. - * - * @event getCachedResponseEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.response {Object} The response object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("cacheResponseEvent"); - - /** - * Fired when a request is sent to the live data source. - * - * @event requestEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("requestEvent"); - - /** - * Fired when live data source sends response. - * - * @event parseResponseEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.response {Object} The raw response object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("responseEvent"); - - /** - * Fired when response is parsed. - * - * @event responseParseEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.response {Object} The parsed response object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("responseParseEvent"); - - /** - * Fired when response is cached. - * - * @event responseCacheEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.response {Object} The parsed response object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("responseCacheEvent"); - /** - * Fired when an error is encountered with the live data source. - * - * @event dataErrorEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - * @param oArgs.message {String} The error message. - */ - this.createEvent("dataErrorEvent"); - - /** - * Fired when the local cache is flushed. - * - * @event cacheFlushEvent - */ - this.createEvent("cacheFlushEvent"); -}; - -YAHOO.augment(YAHOO.util.DataSource, YAHOO.util.EventProvider); - -///////////////////////////////////////////////////////////////////////////// -// -// Public constants -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Type is unknown. - * - * @property TYPE_UNKNOWN - * @type Number - * @final - * @default -1 - */ -YAHOO.util.DataSource.TYPE_UNKNOWN = -1; - -/** - * Type is a JavaScript Array. - * - * @property TYPE_JSARRAY - * @type Number - * @final - * @default 0 - */ -YAHOO.util.DataSource.TYPE_JSARRAY = 0; - -/** - * Type is a JavaScript Function. - * - * @property TYPE_JSFUNCTIOn - * @type Number - * @final - * @default 1 - */ -YAHOO.util.DataSource.TYPE_JSFUNCTION = 1; - -/** - * Type is hosted on a server via an XHR connection. - * - * @property TYPE_XHR - * @type Number - * @final - * @default 2 - */ -YAHOO.util.DataSource.TYPE_XHR = 2; - -/** - * Type is JSON. - * - * @property TYPE_JSON - * @type Number - * @final - * @default 3 - */ -YAHOO.util.DataSource.TYPE_JSON = 3; - -/** - * Type is XML. - * - * @property TYPE_XML - * @type Number - * @final - * @default 4 - */ -YAHOO.util.DataSource.TYPE_XML = 4; - -/** - * Type is plain text. - * - * @property TYPE_TEXT - * @type Number - * @final - * @default 5 - */ -YAHOO.util.DataSource.TYPE_TEXT = 5; -/** - * Error message for invalid data responses. - * - * @property ERROR_DATAINVALID - * @type String - * @final - * @default "Invalid data" - */ -YAHOO.util.DataSource.ERROR_DATAINVALID = "Invalid data"; - -/** - * Error message for null data responses. - * - * @property ERROR_DATANULL - * @type String - * @final - * @default "Null data" - */ -YAHOO.util.DataSource.ERROR_DATANULL = "Null data"; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple DataSource instances. - * - * @property _nIndex - * @type Number - * @private - */ -YAHOO.util.DataSource._nIndex = 0; - -/** - * Name of DataSource instance. - * - * @property _sName - * @type String - * @private - */ -YAHOO.util.DataSource.prototype._sName = null; - -/** - * Local cache of data result objects indexed chronologically. - * - * @property _aCache - * @type Object[] - * @private - */ -YAHOO.util.DataSource.prototype._aCache = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - - - -///////////////////////////////////////////////////////////////////////////// -// -// 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 0 - */ -YAHOO.util.DataSource.prototype.maxCacheEntries = 0; - - /** - * Pointer to live database. - * - * @property liveData - * @type Object - */ -YAHOO.util.DataSource.prototype.liveData = null; - - /** - * If data is accessed over XHR via Connection Manager, the connection timeout is - * configurable in 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.util.DataSource.prototype.connTimeout = null; - - /** - * 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.util.DataSource.prototype.connMgr = YAHOO.util.Connect || null; - -/** - * Where the live data is held. - * - * @property dataType - * @type Number - * @default YAHOO.util.DataSource.TYPE_UNKNOWN - * - */ -YAHOO.util.DataSource.prototype.dataType = YAHOO.util.DataSource.TYPE_UNKNOWN; - -/** - * Format of response. - * - * @property responseType - * @type Number - * @default YAHOO.util.DataSource.TYPE_UNKNOWN - */ -YAHOO.util.DataSource.prototype.responseType = YAHOO.util.DataSource.TYPE_UNKNOWN; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor to the unique name of the DataSource instance. - * - * @method toString - * @return {String} Unique name of the DataSource instance. - */ -YAHOO.util.DataSource.prototype.toString = function() { - return "DataSource " + this._sName; -}; - -/** - * Overridable method passes request to cache and returns cached response if any, - * refreshing the hit in the cache as the newest item. Returns null if there is - * no cache hit. - * - * @method getCachedResponse - * @param oRequest {Object} Request object. - * @param oCallback {Function} Handler function to receive the response - * @param oCaller {Object} The Calling object that is making the request - * @return {Object} Cached response object or null. - */ -YAHOO.util.DataSource.prototype.getCachedResponse = function(oRequest, oCallback, oCaller) { - var aCache = this._aCache; - var nCacheLength = (aCache) ? aCache.length : 0; - var oResponse = null; - - // If cache is enabled... - if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) { - this.fireEvent("cacheRequestEvent", {request:oRequest,callback:oCallback,caller:oCaller}); - - // Loop through each cached element - for(var i = nCacheLength-1; i >= 0; i--) { - var oCacheElem = aCache[i]; - - // Defer cache hit logic to a public overridable method - if(this.isCacheHit(oRequest,oCacheElem.request)) { - // Grab the cached response - oResponse = oCacheElem.response; - // The cache returned a hit! - // Remove element from its original location - aCache.splice(i,1); - // Add as newest - this.addToCache(oRequest, oResponse); - this.fireEvent("cacheResponseEvent", {request:oRequest,response:oResponse,callback:oCallback,caller:oCaller}); - break; - } - } - } - return oResponse; -}; - -/** - * Default overridable method matches given request to given cached request. - * Returns true if is a hit, returns false otherwise. Implementers should - * override this method to customize the cache-matching algorithm. - * - * @method isCacheHit - * @param oRequest {Object} Request object. - * @param oCachedRequest {Object} Cached request object. - * @return {Boolean} True if given request matches cached request, false otherwise. - */ -YAHOO.util.DataSource.prototype.isCacheHit = function(oRequest, oCachedRequest) { - return (oRequest === oCachedRequest); -}; - -/** - * Adds a new item to the cache. If cache is full, evicts the stalest item - * before adding the new item. - * - * @method addToCache - * @param oRequest {Object} Request object. - * @param oResponse {Object} Response object to cache. - */ -YAHOO.util.DataSource.prototype.addToCache = function(oRequest, oResponse) { - //TODO: check for duplicate entries - var aCache = this._aCache; - // Don't add if anything important is missing. - if(!aCache || !oRequest || !oResponse) { - return; - } - - // If the cache is full, make room by removing stalest element (index=0) - while(aCache.length >= this.maxCacheEntries) { - aCache.shift(); - } - - // Add to cache in the newest position, at the end of the array - var oCacheElem = {request:oRequest,response:oResponse}; - aCache.push(oCacheElem); - this.fireEvent("responseCacheEvent",{request:oRequest,response:oResponse}); - -}; - -/** - * Flushes cache. - * - * @method flushCache - */ -YAHOO.util.DataSource.prototype.flushCache = function() { - if(this._aCache) { - this._aCache = []; - } - this.fireEvent("cacheFlushEvent"); -}; - -/** - * First looks for cached response, then sends request to live data. - * - * @method sendRequest - * @param oRequest {Object} Request object - * @param oCallback {Function} Handler function to receive the response - * @param oCaller {Object} The Calling object that is making the request - */ -YAHOO.util.DataSource.prototype.sendRequest = function(oRequest, oCallback, oCaller) { - // First look in cache - var oCachedResponse = this.getCachedResponse(oRequest, oCallback, oCaller); - if(oCachedResponse) { - oCallback.call(oCaller, oRequest, oCachedResponse); - return; - } - - // Not in cache, so forward request to live data - this.makeConnection(oRequest, oCallback, oCaller); -}; - -/** - * Overridable method provides default functionality to make a connection to - * live data in order to send request. The response coming back is then - * forwarded to the handleResponse function. This method should be customized - * for more complex implementations. - * - * @method makeConnection - * @param oRequest {Object} Request object. - * @param oCallback {Function} Handler function to receive the response - * @param oCaller {Object} The Calling object that is making the request - */ -YAHOO.util.DataSource.prototype.makeConnection = function(oRequest, oCallback, oCaller) { - this.fireEvent("requestEvent", {request:oRequest,callback:oCallback,caller:oCaller}); - var oRawResponse = null; - - // How to make the connection depends on the type of data - switch(this.dataType) { - - // If the live data is a JavaScript Array - // simply forward the entire array to the handler - case YAHOO.util.DataSource.TYPE_JSARRAY: - case YAHOO.util.DataSource.TYPE_JSON: - oRawResponse = this.liveData; - this.handleResponse(oRequest, oRawResponse, oCallback, oCaller); - break; - - // If the live data is a JavaScript Function - // pass the request in as a parameter and - // forward the return value to the handler - case YAHOO.util.DataSource.TYPE_JSFUNCTION: - oRawResponse = this.liveData(oRequest); - this.handleResponse(oRequest, oRawResponse, oCallback, oCaller); - break; - - // If the live data is over Connection Manager - // set up the callback object and - // pass the request in as a URL query and - // forward the response to the handler - case YAHOO.util.DataSource.TYPE_XHR: - /** - * Connection Manager success handler - * - * @method _xhrSuccess - * @param oResponse {Object} HTTPXMLRequest object - * @private - */ - var _xhrSuccess = function(oResponse) { - // Error if no response - if(!oResponse) { - this.fireEvent("dataErrorEvent", {request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATANULL}); - YAHOO.log(YAHOO.util.DataSource.ERROR_DATANULL, "error", this.toString()); - return null; - } - // Error if response ID does not match last made request ID. - else if(!this._oConn || (oResponse.tId != this._oConn.tId)) { - this.fireEvent("dataErrorEvent", {request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATAINVALID}); - YAHOO.log(YAHOO.util.DataSource.ERROR_DATAINVALID, "error", this.toString()); - return null; - } - // Forward to handler - else { - this.handleResponse(oRequest, oResponse, oCallback, oCaller); - } - }; - - /** - * Connection Manager failure handler - * - * @method _xhrFailure - * @param oResponse {Object} HTTPXMLRequest object - * @private - */ - var _xhrFailure = function(oResponse) { - this.fireEvent("dataErrorEvent", {request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATAXHR}); - YAHOO.log(this.ERROR_DATAXHR + ": " + oResp.statusText, "error", this.toString()); - return null; - }; - - /** - * Connection Manager callback object - * - * @property _xhrCallback - * @param oResponse {Object} HTTPXMLRequest object - * @private - */ - var _xhrCallback = { - success:_xhrSuccess, - failure:_xhrFailure, - scope: this - }; - - //TODO: connTimeout config - if(this.connTimeout && !isNaN(this.connTimeout) && this.connTimeout > 0) { - _xhrCallback.timeout = this.connTimeout; - } - - //TODO: oConn config - if(this._oConn && this.connMgr) { - this.connMgr.abort(this._oConn); - } - - var sUri = this.liveData+"?"+oRequest; - if(this.connMgr) { - this._oConn = this.connMgr.asyncRequest("GET", sUri, _xhrCallback, null); - } - else { - YAHOO.log("Could not find a valid Connection Manager","error",this.toString()); - } - - break; - default: - //TODO: any default? - break; - } -}; - -/** - * Handles raw data response from live data source. - * - * @method handleResponse - * @param oRequest {Object} Request object - * @param oRawResponse {Object} The raw response from the live database - * @param oCallback {Function} Handler function to receive the response - * @param oCaller {Object} The calling object that is making the request - */ -YAHOO.util.DataSource.prototype.handleResponse = function(oRequest, oRawResponse, oCallback, oCaller) { - this.fireEvent("responseEvent", {request:oRequest,response:oRawResponse,callback:oCallback,caller:oCaller}); - var xhr = (this.dataType == YAHOO.util.DataSource.TYPE_XHR) ? true : false; - var oParsedResponse = null; - //TODO: break out into overridable methods - switch(this.responseType) { - case YAHOO.util.DataSource.TYPE_JSARRAY: - if(xhr && oRawResponse.responseText) { - oRawResponse = oRawResponse.responseText; - } - oParsedResponse = this.parseArrayData(oRequest, oRawResponse); - break; - case YAHOO.util.DataSource.TYPE_JSON: - if(xhr && oRawResponse.responseText) { - oRawResponse = oRawResponse.responseText; - } - oParsedResponse = this.parseJSONData(oRequest, oRawResponse); - break; - case YAHOO.util.DataSource.TYPE_XML: - if(xhr && oRawResponse.responseXML) { - oRawResponse = oRawResponse.responseXML; - } - oParsedResponse = this.parseXMLData(oRequest, oRawResponse); - break; - case YAHOO.util.DataSource.TYPE_TEXT: - if(xhr && oRawResponse.responseText) { - oRawResponse = oRawResponse.responseText; - } - oParsedResponse = this.parseTextData(oRequest, oRawResponse); - break; - default: - //TODO: pass off to custom function - //var contentType = oRawResponse.getResponseHeader["Content-Type"]; - YAHOO.log("Unknown response type","warn",this.toStrin()); - break; - } - - if(oParsedResponse) { - this.fireEvent("responseParseEvent", {request:oRequest,response:oParsedResponse,callback:oCallback,caller:oCaller}); - // Cache the response - this.addToCache(oRequest, oParsedResponse); - } - else { - this.fireEvent("dataErrorEvent", {request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATANULL}); - YAHOO.log(YAHOO.util.DataSource.ERROR_DATANULL, "error", this.toString()); - } - - // Send the response back to the caller - oCallback.call(oCaller, oRequest, oParsedResponse); -}; - -/** - * Overridable method parses raw array data into a response object. - * - * @method parseArrayData - * @param oRequest {Object} Request object. - * @param oRawResponse {Object} The raw response from the live database - * @return {Object} Parsed response object - */ -YAHOO.util.DataSource.prototype.parseArrayData = function(oRequest, oRawResponse) { - var oParsedResponse = []; - var fields = this.responseSchema.fields; - for(var i=oRawResponse.length-1; i>-1; i--) { - var oResult = {}; - for(var j=fields.length; j>-1; j--) { - oResult[fields[j]] = oRawResponse[i][j] || oRawResponse[i][fields[j]]; - } - oParsedResponse.unshift(oResult); - } - return oParsedResponse; -}; - -/** - * Overridable method parses raw plain text data into a response object. - * - * @method parseTextData - * @param oRequest {Object} Request object - * @param oRawResponse {Object} The raw response from the live database - * @return {Object} Parsed response object - */ -YAHOO.util.DataSource.prototype.parseTextData = function(oRequest, oRawResponse) { - var oParsedResponse = []; - var recDelim = this.responseSchema.recordDelim; - var fieldDelim = this.responseSchema.fieldDelim; - var aSchema = this.responseSchema.fields; - if(oRawResponse.length > 0) { - // Delete the last line delimiter at the end of the data if it exists - var newLength = oRawResponse.length-recDelim.length; - if(oRawResponse.substr(newLength) == recDelim) { - oRawResponse = oRawResponse.substr(0, newLength); - } - // Split along record delimiter to get an array of strings - var recordsarray = oRawResponse.split(recDelim); - // Cycle through each record, except the first which contains header info - for(var i = recordsarray.length-1; i >= 1; i--) { - var dataobject = {}; - for(var j=aSchema.length-1; j >= 0; j--) { - // Split along field delimter to get each data value - var fielddataarray = recordsarray[i].split(fieldDelim); - - // Remove quotation marks from edges, if applicable - var string = fielddataarray[j]; - if(string.charAt(0) == "\"") { - string = string.substr(1); - } - if(string.charAt(string.length-1) == "\"") { - string = string.substr(0,string.length-1); - } - dataobject[aSchema[j]] = string; - } - oParsedResponse.push(dataobject); - } - } - return oParsedResponse; -}; - -/** - * Overridable method parses raw XML data into a response object. - * - * @method parseXMLData - * @param oRequest {Object} Request object - * @param oRawResponse {Object} The raw response from the live database - * @return {Object} Parsed response object - */ -YAHOO.util.DataSource.prototype.parseXMLData = function(oRequest, oRawResponse) { - var bError = false; - var oParsedResponse = []; - var xmlList = oRawResponse.getElementsByTagName(this.responseSchema.resultNode); - if(!xmlList) { - bError = true; - } - // Loop through each result - else { - for(var k = xmlList.length-1; k >= 0 ; k--) { - var result = xmlList.item(k); - var oResult = {}; - // Loop through each data field in each result using the schema - for(var m = this.responseSchema.fields.length-1; m >= 0 ; m--) { - var field = this.responseSchema.fields[m]; - var sValue = null; - // Values may be held in an attribute... - var xmlAttr = result.attributes.getNamedItem(field); - if(xmlAttr) { - sValue = xmlAttr.value; - } - // ...or in a node - else { - var xmlNode = result.getElementsByTagName(field); - 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 - oResult[field] = sValue; - } - // Capture each array of values into an array of results - oParsedResponse.unshift(oResult); - } - } - if(bError) { - return null; - } - return oParsedResponse; -}; - -/** - * Overridable method parses raw JSON data into a response object. - * - * @method parseJSONData - * @param oRequest {Object} Request object - * @param oRawResponse {Object} The raw response from the live database - * @return {Object} Parsed response object - */ -YAHOO.util.DataSource.prototype.parseJSONData = function(oRequest, oRawResponse) { - //TODO: validate oRawResponse - var bError = false; - var oParsedResponse = []; - var aSchema = this.responseSchema.fields; - - var jsonObj,jsonList; - if(oRawResponse) { - // Parse JSON object out if it's a string - if(oRawResponse.constructor == String) { - // Check for latest JSON lib but divert KHTML clients - if(oRawResponse.parseJSON && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) { - // Use the new JSON utility if available - jsonObj = oRawResponse.parseJSON(); - if(!jsonObj) { - bError = true; - } - } - // Check for older JSON lib but divert KHTML clients - else if(window.JSON && JSON.parse && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) { - // Use the JSON utility if available - jsonObj = JSON.parse(oRawResponse); - if(!jsonObj) { - bError = true; - } - } - // No JSON lib found so parse the string - else { - try { - // Trim leading spaces - while (oRawResponse.length > 0 && - (oRawResponse.charAt(0) != "{") && - (oRawResponse.charAt(0) != "[")) { - oRawResponse = oRawResponse.substring(1, oResponse.length); - } - - if(oRawResponse.length > 0) { - // Strip extraneous stuff at the end - var objEnd = Math.max(oRawResponse.lastIndexOf("]"),oRawResponse.lastIndexOf("}")); - oRawResponse = oRawResponse.substring(0,objEnd+1); - - // Turn the string into an object literal... - // ...eval is necessary here - jsonObj = eval("(" + oRawResponse + ")"); - if(!jsonObj) { - bError = true; - } - - } - } - catch(e) { - bError = true; - } - } - } - // Response must already be a JSON object - else if(oRawResponse.constructor == Object) { - jsonObj = oRawResponse; - } - // Now that we have a JSON object, parse a jsonList out of it - if(jsonObj && jsonObj.constructor == Object) { - try { - // eval is necessary here since schema can be of unknown depth - jsonList = eval("jsonObj." + this.responseSchema.resultsList); - } - catch(e) { - bError = true; - } - } - } - if(bError || !jsonList) { - // Something went wrong - return null; - } - - if(jsonList.constructor != Array) { - jsonList = [jsonList]; - } - - // Loop through the array of all responses... - for(var i = jsonList.length-1; i >= 0 ; i--) { - var oResult = {}; - var jsonResult = jsonList[i]; - // ...and loop through each data field value of each response - for(var j = aSchema.length-1; j >= 0 ; 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()); - oResult[aSchema[j]] = dataFieldValue; - } - // Capture the array of data field values in an array of results - oParsedResponse.unshift(oResult); - } - return oParsedResponse; -}; - -YAHOO.register("datasource", YAHOO.util.DataSource, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/datasource/datasource-beta-min.js b/interface/web/js/yui/datasource/datasource-beta-min.js deleted file mode 100644 index 253bfd7fa9..0000000000 --- a/interface/web/js/yui/datasource/datasource-beta-min.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -YAHOO.util.DataSource=function(oLiveData,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}} -if(!oLiveData){return;} -else{switch(oLiveData.constructor){case Function:this.dataType=YAHOO.util.DataSource.TYPE_JSFUNCTION;break;case Array:this.dataType=YAHOO.util.DataSource.TYPE_JSARRAY;break;case String:this.dataType=YAHOO.util.DataSource.TYPE_XHR;break;case Object:this.dataType=YAHOO.util.DataSource.TYPE_JSON;break;default:this.dataType=YAHOO.util.DataSource.TYPE_UNKNOWN;break;} -this.liveData=oLiveData;} -var maxCacheEntries=this.maxCacheEntries;if(isNaN(maxCacheEntries)||(maxCacheEntries<0)){maxCacheEntries=0;} -if(maxCacheEntries>0&&!this._aCache){this._aCache=[];} -this._sName="instance"+YAHOO.util.DataSource._nIndex;YAHOO.util.DataSource._nIndex++;this.createEvent("cacheRequestEvent");this.createEvent("cacheResponseEvent");this.createEvent("requestEvent");this.createEvent("responseEvent");this.createEvent("responseParseEvent");this.createEvent("responseCacheEvent");this.createEvent("dataErrorEvent");this.createEvent("cacheFlushEvent");};YAHOO.augment(YAHOO.util.DataSource,YAHOO.util.EventProvider);YAHOO.util.DataSource.TYPE_UNKNOWN=-1;YAHOO.util.DataSource.TYPE_JSARRAY=0;YAHOO.util.DataSource.TYPE_JSFUNCTION=1;YAHOO.util.DataSource.TYPE_XHR=2;YAHOO.util.DataSource.TYPE_JSON=3;YAHOO.util.DataSource.TYPE_XML=4;YAHOO.util.DataSource.TYPE_TEXT=5;YAHOO.util.DataSource.ERROR_DATAINVALID="Invalid data";YAHOO.util.DataSource.ERROR_DATANULL="Null data";YAHOO.util.DataSource._nIndex=0;YAHOO.util.DataSource.prototype._sName=null;YAHOO.util.DataSource.prototype._aCache=null;YAHOO.util.DataSource.prototype.maxCacheEntries=0;YAHOO.util.DataSource.prototype.liveData=null;YAHOO.util.DataSource.prototype.connTimeout=null;YAHOO.util.DataSource.prototype.connMgr=YAHOO.util.Connect||null;YAHOO.util.DataSource.prototype.dataType=YAHOO.util.DataSource.TYPE_UNKNOWN;YAHOO.util.DataSource.prototype.responseType=YAHOO.util.DataSource.TYPE_UNKNOWN;YAHOO.util.DataSource.prototype.toString=function(){return"DataSource "+this._sName;};YAHOO.util.DataSource.prototype.getCachedResponse=function(oRequest,oCallback,oCaller){var aCache=this._aCache;var nCacheLength=(aCache)?aCache.length:0;var oResponse=null;if((this.maxCacheEntries>0)&&aCache&&(nCacheLength>0)){this.fireEvent("cacheRequestEvent",{request:oRequest,callback:oCallback,caller:oCaller});for(var i=nCacheLength-1;i>=0;i--){var oCacheElem=aCache[i];if(this.isCacheHit(oRequest,oCacheElem.request)){oResponse=oCacheElem.response;aCache.splice(i,1);this.addToCache(oRequest,oResponse);this.fireEvent("cacheResponseEvent",{request:oRequest,response:oResponse,callback:oCallback,caller:oCaller});break;}}} -return oResponse;};YAHOO.util.DataSource.prototype.isCacheHit=function(oRequest,oCachedRequest){return(oRequest===oCachedRequest);};YAHOO.util.DataSource.prototype.addToCache=function(oRequest,oResponse){var aCache=this._aCache;if(!aCache||!oRequest||!oResponse){return;} -while(aCache.length>=this.maxCacheEntries){aCache.shift();} -var oCacheElem={request:oRequest,response:oResponse};aCache.push(oCacheElem);this.fireEvent("responseCacheEvent",{request:oRequest,response:oResponse});};YAHOO.util.DataSource.prototype.flushCache=function(){if(this._aCache){this._aCache=[];} -this.fireEvent("cacheFlushEvent");};YAHOO.util.DataSource.prototype.sendRequest=function(oRequest,oCallback,oCaller){var oCachedResponse=this.getCachedResponse(oRequest,oCallback,oCaller);if(oCachedResponse){oCallback.call(oCaller,oRequest,oCachedResponse);return;} -this.makeConnection(oRequest,oCallback,oCaller);};YAHOO.util.DataSource.prototype.makeConnection=function(oRequest,oCallback,oCaller){this.fireEvent("requestEvent",{request:oRequest,callback:oCallback,caller:oCaller});var oRawResponse=null;switch(this.dataType){case YAHOO.util.DataSource.TYPE_JSARRAY:case YAHOO.util.DataSource.TYPE_JSON:oRawResponse=this.liveData;this.handleResponse(oRequest,oRawResponse,oCallback,oCaller);break;case YAHOO.util.DataSource.TYPE_JSFUNCTION:oRawResponse=this.liveData(oRequest);this.handleResponse(oRequest,oRawResponse,oCallback,oCaller);break;case YAHOO.util.DataSource.TYPE_XHR:var _xhrSuccess=function(oResponse){if(!oResponse){this.fireEvent("dataErrorEvent",{request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATANULL});return null;} -else if(!this._oConn||(oResponse.tId!=this._oConn.tId)){this.fireEvent("dataErrorEvent",{request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATAINVALID});return null;} -else{this.handleResponse(oRequest,oResponse,oCallback,oCaller);}};var _xhrFailure=function(oResponse){this.fireEvent("dataErrorEvent",{request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATAXHR});return null;};var _xhrCallback={success:_xhrSuccess,failure:_xhrFailure,scope:this};if(this.connTimeout&&!isNaN(this.connTimeout)&&this.connTimeout>0){_xhrCallback.timeout=this.connTimeout;} -if(this._oConn&&this.connMgr){this.connMgr.abort(this._oConn);} -var sUri=this.liveData+"?"+oRequest;if(this.connMgr){this._oConn=this.connMgr.asyncRequest("GET",sUri,_xhrCallback,null);} -else{} -break;default:break;}};YAHOO.util.DataSource.prototype.handleResponse=function(oRequest,oRawResponse,oCallback,oCaller){this.fireEvent("responseEvent",{request:oRequest,response:oRawResponse,callback:oCallback,caller:oCaller});var xhr=(this.dataType==YAHOO.util.DataSource.TYPE_XHR)?true:false;var oParsedResponse=null;switch(this.responseType){case YAHOO.util.DataSource.TYPE_JSARRAY:if(xhr&&oRawResponse.responseText){oRawResponse=oRawResponse.responseText;} -oParsedResponse=this.parseArrayData(oRequest,oRawResponse);break;case YAHOO.util.DataSource.TYPE_JSON:if(xhr&&oRawResponse.responseText){oRawResponse=oRawResponse.responseText;} -oParsedResponse=this.parseJSONData(oRequest,oRawResponse);break;case YAHOO.util.DataSource.TYPE_XML:if(xhr&&oRawResponse.responseXML){oRawResponse=oRawResponse.responseXML;} -oParsedResponse=this.parseXMLData(oRequest,oRawResponse);break;case YAHOO.util.DataSource.TYPE_TEXT:if(xhr&&oRawResponse.responseText){oRawResponse=oRawResponse.responseText;} -oParsedResponse=this.parseTextData(oRequest,oRawResponse);break;default:break;} -if(oParsedResponse){this.fireEvent("responseParseEvent",{request:oRequest,response:oParsedResponse,callback:oCallback,caller:oCaller});this.addToCache(oRequest,oParsedResponse);} -else{this.fireEvent("dataErrorEvent",{request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATANULL});} -oCallback.call(oCaller,oRequest,oParsedResponse);};YAHOO.util.DataSource.prototype.parseArrayData=function(oRequest,oRawResponse){var oParsedResponse=[];var fields=this.responseSchema.fields;for(var i=oRawResponse.length-1;i>-1;i--){var oResult={};for(var j=fields.length;j>-1;j--){oResult[fields[j]]=oRawResponse[i][j]||oRawResponse[i][fields[j]];} -oParsedResponse.unshift(oResult);} -return oParsedResponse;};YAHOO.util.DataSource.prototype.parseTextData=function(oRequest,oRawResponse){var oParsedResponse=[];var recDelim=this.responseSchema.recordDelim;var fieldDelim=this.responseSchema.fieldDelim;var aSchema=this.responseSchema.fields;if(oRawResponse.length>0){var newLength=oRawResponse.length-recDelim.length;if(oRawResponse.substr(newLength)==recDelim){oRawResponse=oRawResponse.substr(0,newLength);} -var recordsarray=oRawResponse.split(recDelim);for(var i=recordsarray.length-1;i>=1;i--){var dataobject={};for(var j=aSchema.length-1;j>=0;j--){var fielddataarray=recordsarray[i].split(fieldDelim);var string=fielddataarray[j];if(string.charAt(0)=="\""){string=string.substr(1);} -if(string.charAt(string.length-1)=="\""){string=string.substr(0,string.length-1);} -dataobject[aSchema[j]]=string;} -oParsedResponse.push(dataobject);}} -return oParsedResponse;};YAHOO.util.DataSource.prototype.parseXMLData=function(oRequest,oRawResponse){var bError=false;var oParsedResponse=[];var xmlList=oRawResponse.getElementsByTagName(this.responseSchema.resultNode);if(!xmlList){bError=true;} -else{for(var k=xmlList.length-1;k>=0;k--){var result=xmlList.item(k);var oResult={};for(var m=this.responseSchema.fields.length-1;m>=0;m--){var field=this.responseSchema.fields[m];var sValue=null;var xmlAttr=result.attributes.getNamedItem(field);if(xmlAttr){sValue=xmlAttr.value;} -else{var xmlNode=result.getElementsByTagName(field);if(xmlNode&&xmlNode.item(0)&&xmlNode.item(0).firstChild){sValue=xmlNode.item(0).firstChild.nodeValue;} -else{sValue="";}} -oResult[field]=sValue;} -oParsedResponse.unshift(oResult);}} -if(bError){return null;} -return oParsedResponse;};YAHOO.util.DataSource.prototype.parseJSONData=function(oRequest,oRawResponse){var bError=false;var oParsedResponse=[];var aSchema=this.responseSchema.fields;var jsonObj,jsonList;if(oRawResponse){if(oRawResponse.constructor==String){if(oRawResponse.parseJSON&&(navigator.userAgent.toLowerCase().indexOf('khtml')==-1)){jsonObj=oRawResponse.parseJSON();if(!jsonObj){bError=true;}} -else if(window.JSON&&JSON.parse&&(navigator.userAgent.toLowerCase().indexOf('khtml')==-1)){jsonObj=JSON.parse(oRawResponse);if(!jsonObj){bError=true;}} -else{try{while(oRawResponse.length>0&&(oRawResponse.charAt(0)!="{")&&(oRawResponse.charAt(0)!="[")){oRawResponse=oRawResponse.substring(1,oResponse.length);} -if(oRawResponse.length>0){var objEnd=Math.max(oRawResponse.lastIndexOf("]"),oRawResponse.lastIndexOf("}"));oRawResponse=oRawResponse.substring(0,objEnd+1);jsonObj=eval("("+oRawResponse+")");if(!jsonObj){bError=true;}}} -catch(e){bError=true;}}} -else if(oRawResponse.constructor==Object){jsonObj=oRawResponse;} -if(jsonObj&&jsonObj.constructor==Object){try{jsonList=eval("jsonObj."+this.responseSchema.resultsList);} -catch(e){bError=true;}}} -if(bError||!jsonList){return null;} -if(jsonList.constructor!=Array){jsonList=[jsonList];} -for(var i=jsonList.length-1;i>=0;i--){var oResult={};var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=0;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";} -oResult[aSchema[j]]=dataFieldValue;} -oParsedResponse.unshift(oResult);} -return oParsedResponse;};YAHOO.register("datasource",YAHOO.util.DataSource,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/datasource/datasource-beta.js b/interface/web/js/yui/datasource/datasource-beta.js deleted file mode 100644 index 893f287ef9..0000000000 --- a/interface/web/js/yui/datasource/datasource-beta.js +++ /dev/null @@ -1,902 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The DataSource utility provides a common configurable interface for widgets - * to access a variety of data, from JavaScript arrays to online servers over - * XHR. - * - * @module datasource - * @requires yahoo, event - * @optional xhr - * @title DataSource Utility - * @beta - */ - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The DataSource class defines and manages a live set of data for widgets to - * interact with. Examples of live databases include in-memory - * local data such as a JavaScript array, a JavaScript function, or JSON, or - * remote data such as data retrieved through an XHR connection. - * - * @class DataSource - * @uses YAHOO.util.EventProvider - * @constructor - * @param oLiveData {Object} Pointer to live database - * @param oConfigs {Object} (optional) Object literal of configuration values - */ -YAHOO.util.DataSource = function(oLiveData, oConfigs) { - // Set any config params passed in to override defaults - if(typeof oConfigs == "object") { - for(var sConfig in oConfigs) { - if (sConfig) { - this[sConfig] = oConfigs[sConfig]; - } - } - } - - if(!oLiveData) { - return; - } - else { - switch(oLiveData.constructor) { - case Function: - this.dataType = YAHOO.util.DataSource.TYPE_JSFUNCTION; - break; - case Array: - this.dataType = YAHOO.util.DataSource.TYPE_JSARRAY; - break; - case String: - this.dataType = YAHOO.util.DataSource.TYPE_XHR; - break; - case Object: - this.dataType = YAHOO.util.DataSource.TYPE_JSON; - break; - default: - this.dataType = YAHOO.util.DataSource.TYPE_UNKNOWN; - break; - } - this.liveData = oLiveData; - } - - // 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.util.DataSource._nIndex; - YAHOO.util.DataSource._nIndex++; - - - ///////////////////////////////////////////////////////////////////////////// - // - // Custom Events - // - ///////////////////////////////////////////////////////////////////////////// - - /** - * Fired when a request is made to the local cache. - * - * @event cacheRequestEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("cacheRequestEvent"); - - /** - * Fired when data is retrieved from the local cache. - * - * @event getCachedResponseEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.response {Object} The response object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("cacheResponseEvent"); - - /** - * Fired when a request is sent to the live data source. - * - * @event requestEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("requestEvent"); - - /** - * Fired when live data source sends response. - * - * @event parseResponseEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.response {Object} The raw response object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("responseEvent"); - - /** - * Fired when response is parsed. - * - * @event responseParseEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.response {Object} The parsed response object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("responseParseEvent"); - - /** - * Fired when response is cached. - * - * @event responseCacheEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.response {Object} The parsed response object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - */ - this.createEvent("responseCacheEvent"); - /** - * Fired when an error is encountered with the live data source. - * - * @event dataErrorEvent - * @param oArgs.request {Object} The request object. - * @param oArgs.callback {Function} The callback function. - * @param oArgs.caller {Object} The parent object of the callback function. - * @param oArgs.message {String} The error message. - */ - this.createEvent("dataErrorEvent"); - - /** - * Fired when the local cache is flushed. - * - * @event cacheFlushEvent - */ - this.createEvent("cacheFlushEvent"); -}; - -YAHOO.augment(YAHOO.util.DataSource, YAHOO.util.EventProvider); - -///////////////////////////////////////////////////////////////////////////// -// -// Public constants -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Type is unknown. - * - * @property TYPE_UNKNOWN - * @type Number - * @final - * @default -1 - */ -YAHOO.util.DataSource.TYPE_UNKNOWN = -1; - -/** - * Type is a JavaScript Array. - * - * @property TYPE_JSARRAY - * @type Number - * @final - * @default 0 - */ -YAHOO.util.DataSource.TYPE_JSARRAY = 0; - -/** - * Type is a JavaScript Function. - * - * @property TYPE_JSFUNCTIOn - * @type Number - * @final - * @default 1 - */ -YAHOO.util.DataSource.TYPE_JSFUNCTION = 1; - -/** - * Type is hosted on a server via an XHR connection. - * - * @property TYPE_XHR - * @type Number - * @final - * @default 2 - */ -YAHOO.util.DataSource.TYPE_XHR = 2; - -/** - * Type is JSON. - * - * @property TYPE_JSON - * @type Number - * @final - * @default 3 - */ -YAHOO.util.DataSource.TYPE_JSON = 3; - -/** - * Type is XML. - * - * @property TYPE_XML - * @type Number - * @final - * @default 4 - */ -YAHOO.util.DataSource.TYPE_XML = 4; - -/** - * Type is plain text. - * - * @property TYPE_TEXT - * @type Number - * @final - * @default 5 - */ -YAHOO.util.DataSource.TYPE_TEXT = 5; -/** - * Error message for invalid data responses. - * - * @property ERROR_DATAINVALID - * @type String - * @final - * @default "Invalid data" - */ -YAHOO.util.DataSource.ERROR_DATAINVALID = "Invalid data"; - -/** - * Error message for null data responses. - * - * @property ERROR_DATANULL - * @type String - * @final - * @default "Null data" - */ -YAHOO.util.DataSource.ERROR_DATANULL = "Null data"; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple DataSource instances. - * - * @property _nIndex - * @type Number - * @private - */ -YAHOO.util.DataSource._nIndex = 0; - -/** - * Name of DataSource instance. - * - * @property _sName - * @type String - * @private - */ -YAHOO.util.DataSource.prototype._sName = null; - -/** - * Local cache of data result objects indexed chronologically. - * - * @property _aCache - * @type Object[] - * @private - */ -YAHOO.util.DataSource.prototype._aCache = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - - - -///////////////////////////////////////////////////////////////////////////// -// -// 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 0 - */ -YAHOO.util.DataSource.prototype.maxCacheEntries = 0; - - /** - * Pointer to live database. - * - * @property liveData - * @type Object - */ -YAHOO.util.DataSource.prototype.liveData = null; - - /** - * If data is accessed over XHR via Connection Manager, the connection timeout is - * configurable in 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.util.DataSource.prototype.connTimeout = null; - - /** - * 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.util.DataSource.prototype.connMgr = YAHOO.util.Connect || null; - -/** - * Where the live data is held. - * - * @property dataType - * @type Number - * @default YAHOO.util.DataSource.TYPE_UNKNOWN - * - */ -YAHOO.util.DataSource.prototype.dataType = YAHOO.util.DataSource.TYPE_UNKNOWN; - -/** - * Format of response. - * - * @property responseType - * @type Number - * @default YAHOO.util.DataSource.TYPE_UNKNOWN - */ -YAHOO.util.DataSource.prototype.responseType = YAHOO.util.DataSource.TYPE_UNKNOWN; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor to the unique name of the DataSource instance. - * - * @method toString - * @return {String} Unique name of the DataSource instance. - */ -YAHOO.util.DataSource.prototype.toString = function() { - return "DataSource " + this._sName; -}; - -/** - * Overridable method passes request to cache and returns cached response if any, - * refreshing the hit in the cache as the newest item. Returns null if there is - * no cache hit. - * - * @method getCachedResponse - * @param oRequest {Object} Request object. - * @param oCallback {Function} Handler function to receive the response - * @param oCaller {Object} The Calling object that is making the request - * @return {Object} Cached response object or null. - */ -YAHOO.util.DataSource.prototype.getCachedResponse = function(oRequest, oCallback, oCaller) { - var aCache = this._aCache; - var nCacheLength = (aCache) ? aCache.length : 0; - var oResponse = null; - - // If cache is enabled... - if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) { - this.fireEvent("cacheRequestEvent", {request:oRequest,callback:oCallback,caller:oCaller}); - - // Loop through each cached element - for(var i = nCacheLength-1; i >= 0; i--) { - var oCacheElem = aCache[i]; - - // Defer cache hit logic to a public overridable method - if(this.isCacheHit(oRequest,oCacheElem.request)) { - // Grab the cached response - oResponse = oCacheElem.response; - // The cache returned a hit! - // Remove element from its original location - aCache.splice(i,1); - // Add as newest - this.addToCache(oRequest, oResponse); - this.fireEvent("cacheResponseEvent", {request:oRequest,response:oResponse,callback:oCallback,caller:oCaller}); - break; - } - } - } - return oResponse; -}; - -/** - * Default overridable method matches given request to given cached request. - * Returns true if is a hit, returns false otherwise. Implementers should - * override this method to customize the cache-matching algorithm. - * - * @method isCacheHit - * @param oRequest {Object} Request object. - * @param oCachedRequest {Object} Cached request object. - * @return {Boolean} True if given request matches cached request, false otherwise. - */ -YAHOO.util.DataSource.prototype.isCacheHit = function(oRequest, oCachedRequest) { - return (oRequest === oCachedRequest); -}; - -/** - * Adds a new item to the cache. If cache is full, evicts the stalest item - * before adding the new item. - * - * @method addToCache - * @param oRequest {Object} Request object. - * @param oResponse {Object} Response object to cache. - */ -YAHOO.util.DataSource.prototype.addToCache = function(oRequest, oResponse) { - //TODO: check for duplicate entries - var aCache = this._aCache; - // Don't add if anything important is missing. - if(!aCache || !oRequest || !oResponse) { - return; - } - - // If the cache is full, make room by removing stalest element (index=0) - while(aCache.length >= this.maxCacheEntries) { - aCache.shift(); - } - - // Add to cache in the newest position, at the end of the array - var oCacheElem = {request:oRequest,response:oResponse}; - aCache.push(oCacheElem); - this.fireEvent("responseCacheEvent",{request:oRequest,response:oResponse}); - -}; - -/** - * Flushes cache. - * - * @method flushCache - */ -YAHOO.util.DataSource.prototype.flushCache = function() { - if(this._aCache) { - this._aCache = []; - } - this.fireEvent("cacheFlushEvent"); -}; - -/** - * First looks for cached response, then sends request to live data. - * - * @method sendRequest - * @param oRequest {Object} Request object - * @param oCallback {Function} Handler function to receive the response - * @param oCaller {Object} The Calling object that is making the request - */ -YAHOO.util.DataSource.prototype.sendRequest = function(oRequest, oCallback, oCaller) { - // First look in cache - var oCachedResponse = this.getCachedResponse(oRequest, oCallback, oCaller); - if(oCachedResponse) { - oCallback.call(oCaller, oRequest, oCachedResponse); - return; - } - - // Not in cache, so forward request to live data - this.makeConnection(oRequest, oCallback, oCaller); -}; - -/** - * Overridable method provides default functionality to make a connection to - * live data in order to send request. The response coming back is then - * forwarded to the handleResponse function. This method should be customized - * for more complex implementations. - * - * @method makeConnection - * @param oRequest {Object} Request object. - * @param oCallback {Function} Handler function to receive the response - * @param oCaller {Object} The Calling object that is making the request - */ -YAHOO.util.DataSource.prototype.makeConnection = function(oRequest, oCallback, oCaller) { - this.fireEvent("requestEvent", {request:oRequest,callback:oCallback,caller:oCaller}); - var oRawResponse = null; - - // How to make the connection depends on the type of data - switch(this.dataType) { - - // If the live data is a JavaScript Array - // simply forward the entire array to the handler - case YAHOO.util.DataSource.TYPE_JSARRAY: - case YAHOO.util.DataSource.TYPE_JSON: - oRawResponse = this.liveData; - this.handleResponse(oRequest, oRawResponse, oCallback, oCaller); - break; - - // If the live data is a JavaScript Function - // pass the request in as a parameter and - // forward the return value to the handler - case YAHOO.util.DataSource.TYPE_JSFUNCTION: - oRawResponse = this.liveData(oRequest); - this.handleResponse(oRequest, oRawResponse, oCallback, oCaller); - break; - - // If the live data is over Connection Manager - // set up the callback object and - // pass the request in as a URL query and - // forward the response to the handler - case YAHOO.util.DataSource.TYPE_XHR: - /** - * Connection Manager success handler - * - * @method _xhrSuccess - * @param oResponse {Object} HTTPXMLRequest object - * @private - */ - var _xhrSuccess = function(oResponse) { - // Error if no response - if(!oResponse) { - this.fireEvent("dataErrorEvent", {request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATANULL}); - return null; - } - // Error if response ID does not match last made request ID. - else if(!this._oConn || (oResponse.tId != this._oConn.tId)) { - this.fireEvent("dataErrorEvent", {request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATAINVALID}); - return null; - } - // Forward to handler - else { - this.handleResponse(oRequest, oResponse, oCallback, oCaller); - } - }; - - /** - * Connection Manager failure handler - * - * @method _xhrFailure - * @param oResponse {Object} HTTPXMLRequest object - * @private - */ - var _xhrFailure = function(oResponse) { - this.fireEvent("dataErrorEvent", {request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATAXHR}); - return null; - }; - - /** - * Connection Manager callback object - * - * @property _xhrCallback - * @param oResponse {Object} HTTPXMLRequest object - * @private - */ - var _xhrCallback = { - success:_xhrSuccess, - failure:_xhrFailure, - scope: this - }; - - //TODO: connTimeout config - if(this.connTimeout && !isNaN(this.connTimeout) && this.connTimeout > 0) { - _xhrCallback.timeout = this.connTimeout; - } - - //TODO: oConn config - if(this._oConn && this.connMgr) { - this.connMgr.abort(this._oConn); - } - - var sUri = this.liveData+"?"+oRequest; - if(this.connMgr) { - this._oConn = this.connMgr.asyncRequest("GET", sUri, _xhrCallback, null); - } - else { - } - - break; - default: - //TODO: any default? - break; - } -}; - -/** - * Handles raw data response from live data source. - * - * @method handleResponse - * @param oRequest {Object} Request object - * @param oRawResponse {Object} The raw response from the live database - * @param oCallback {Function} Handler function to receive the response - * @param oCaller {Object} The calling object that is making the request - */ -YAHOO.util.DataSource.prototype.handleResponse = function(oRequest, oRawResponse, oCallback, oCaller) { - this.fireEvent("responseEvent", {request:oRequest,response:oRawResponse,callback:oCallback,caller:oCaller}); - var xhr = (this.dataType == YAHOO.util.DataSource.TYPE_XHR) ? true : false; - var oParsedResponse = null; - //TODO: break out into overridable methods - switch(this.responseType) { - case YAHOO.util.DataSource.TYPE_JSARRAY: - if(xhr && oRawResponse.responseText) { - oRawResponse = oRawResponse.responseText; - } - oParsedResponse = this.parseArrayData(oRequest, oRawResponse); - break; - case YAHOO.util.DataSource.TYPE_JSON: - if(xhr && oRawResponse.responseText) { - oRawResponse = oRawResponse.responseText; - } - oParsedResponse = this.parseJSONData(oRequest, oRawResponse); - break; - case YAHOO.util.DataSource.TYPE_XML: - if(xhr && oRawResponse.responseXML) { - oRawResponse = oRawResponse.responseXML; - } - oParsedResponse = this.parseXMLData(oRequest, oRawResponse); - break; - case YAHOO.util.DataSource.TYPE_TEXT: - if(xhr && oRawResponse.responseText) { - oRawResponse = oRawResponse.responseText; - } - oParsedResponse = this.parseTextData(oRequest, oRawResponse); - break; - default: - //TODO: pass off to custom function - //var contentType = oRawResponse.getResponseHeader["Content-Type"]; - break; - } - - if(oParsedResponse) { - this.fireEvent("responseParseEvent", {request:oRequest,response:oParsedResponse,callback:oCallback,caller:oCaller}); - // Cache the response - this.addToCache(oRequest, oParsedResponse); - } - else { - this.fireEvent("dataErrorEvent", {request:oRequest,callback:oCallback,caller:oCaller,message:YAHOO.util.DataSource.ERROR_DATANULL}); - } - - // Send the response back to the caller - oCallback.call(oCaller, oRequest, oParsedResponse); -}; - -/** - * Overridable method parses raw array data into a response object. - * - * @method parseArrayData - * @param oRequest {Object} Request object. - * @param oRawResponse {Object} The raw response from the live database - * @return {Object} Parsed response object - */ -YAHOO.util.DataSource.prototype.parseArrayData = function(oRequest, oRawResponse) { - var oParsedResponse = []; - var fields = this.responseSchema.fields; - for(var i=oRawResponse.length-1; i>-1; i--) { - var oResult = {}; - for(var j=fields.length; j>-1; j--) { - oResult[fields[j]] = oRawResponse[i][j] || oRawResponse[i][fields[j]]; - } - oParsedResponse.unshift(oResult); - } - return oParsedResponse; -}; - -/** - * Overridable method parses raw plain text data into a response object. - * - * @method parseTextData - * @param oRequest {Object} Request object - * @param oRawResponse {Object} The raw response from the live database - * @return {Object} Parsed response object - */ -YAHOO.util.DataSource.prototype.parseTextData = function(oRequest, oRawResponse) { - var oParsedResponse = []; - var recDelim = this.responseSchema.recordDelim; - var fieldDelim = this.responseSchema.fieldDelim; - var aSchema = this.responseSchema.fields; - if(oRawResponse.length > 0) { - // Delete the last line delimiter at the end of the data if it exists - var newLength = oRawResponse.length-recDelim.length; - if(oRawResponse.substr(newLength) == recDelim) { - oRawResponse = oRawResponse.substr(0, newLength); - } - // Split along record delimiter to get an array of strings - var recordsarray = oRawResponse.split(recDelim); - // Cycle through each record, except the first which contains header info - for(var i = recordsarray.length-1; i >= 1; i--) { - var dataobject = {}; - for(var j=aSchema.length-1; j >= 0; j--) { - // Split along field delimter to get each data value - var fielddataarray = recordsarray[i].split(fieldDelim); - - // Remove quotation marks from edges, if applicable - var string = fielddataarray[j]; - if(string.charAt(0) == "\"") { - string = string.substr(1); - } - if(string.charAt(string.length-1) == "\"") { - string = string.substr(0,string.length-1); - } - dataobject[aSchema[j]] = string; - } - oParsedResponse.push(dataobject); - } - } - return oParsedResponse; -}; - -/** - * Overridable method parses raw XML data into a response object. - * - * @method parseXMLData - * @param oRequest {Object} Request object - * @param oRawResponse {Object} The raw response from the live database - * @return {Object} Parsed response object - */ -YAHOO.util.DataSource.prototype.parseXMLData = function(oRequest, oRawResponse) { - var bError = false; - var oParsedResponse = []; - var xmlList = oRawResponse.getElementsByTagName(this.responseSchema.resultNode); - if(!xmlList) { - bError = true; - } - // Loop through each result - else { - for(var k = xmlList.length-1; k >= 0 ; k--) { - var result = xmlList.item(k); - var oResult = {}; - // Loop through each data field in each result using the schema - for(var m = this.responseSchema.fields.length-1; m >= 0 ; m--) { - var field = this.responseSchema.fields[m]; - var sValue = null; - // Values may be held in an attribute... - var xmlAttr = result.attributes.getNamedItem(field); - if(xmlAttr) { - sValue = xmlAttr.value; - } - // ...or in a node - else { - var xmlNode = result.getElementsByTagName(field); - 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 - oResult[field] = sValue; - } - // Capture each array of values into an array of results - oParsedResponse.unshift(oResult); - } - } - if(bError) { - return null; - } - return oParsedResponse; -}; - -/** - * Overridable method parses raw JSON data into a response object. - * - * @method parseJSONData - * @param oRequest {Object} Request object - * @param oRawResponse {Object} The raw response from the live database - * @return {Object} Parsed response object - */ -YAHOO.util.DataSource.prototype.parseJSONData = function(oRequest, oRawResponse) { - //TODO: validate oRawResponse - var bError = false; - var oParsedResponse = []; - var aSchema = this.responseSchema.fields; - - var jsonObj,jsonList; - if(oRawResponse) { - // Parse JSON object out if it's a string - if(oRawResponse.constructor == String) { - // Check for latest JSON lib but divert KHTML clients - if(oRawResponse.parseJSON && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) { - // Use the new JSON utility if available - jsonObj = oRawResponse.parseJSON(); - if(!jsonObj) { - bError = true; - } - } - // Check for older JSON lib but divert KHTML clients - else if(window.JSON && JSON.parse && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) { - // Use the JSON utility if available - jsonObj = JSON.parse(oRawResponse); - if(!jsonObj) { - bError = true; - } - } - // No JSON lib found so parse the string - else { - try { - // Trim leading spaces - while (oRawResponse.length > 0 && - (oRawResponse.charAt(0) != "{") && - (oRawResponse.charAt(0) != "[")) { - oRawResponse = oRawResponse.substring(1, oResponse.length); - } - - if(oRawResponse.length > 0) { - // Strip extraneous stuff at the end - var objEnd = Math.max(oRawResponse.lastIndexOf("]"),oRawResponse.lastIndexOf("}")); - oRawResponse = oRawResponse.substring(0,objEnd+1); - - // Turn the string into an object literal... - // ...eval is necessary here - jsonObj = eval("(" + oRawResponse + ")"); - if(!jsonObj) { - bError = true; - } - - } - } - catch(e) { - bError = true; - } - } - } - // Response must already be a JSON object - else if(oRawResponse.constructor == Object) { - jsonObj = oRawResponse; - } - // Now that we have a JSON object, parse a jsonList out of it - if(jsonObj && jsonObj.constructor == Object) { - try { - // eval is necessary here since schema can be of unknown depth - jsonList = eval("jsonObj." + this.responseSchema.resultsList); - } - catch(e) { - bError = true; - } - } - } - if(bError || !jsonList) { - // Something went wrong - return null; - } - - if(jsonList.constructor != Array) { - jsonList = [jsonList]; - } - - // Loop through the array of all responses... - for(var i = jsonList.length-1; i >= 0 ; i--) { - var oResult = {}; - var jsonResult = jsonList[i]; - // ...and loop through each data field value of each response - for(var j = aSchema.length-1; j >= 0 ; j--) { - // ...and capture data into an array mapped according to the schema... - var dataFieldValue = jsonResult[aSchema[j]]; - if(!dataFieldValue) { - dataFieldValue = ""; - } - oResult[aSchema[j]] = dataFieldValue; - } - // Capture the array of data field values in an array of results - oParsedResponse.unshift(oResult); - } - return oParsedResponse; -}; - -YAHOO.register("datasource", YAHOO.util.DataSource, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/datatable/README b/interface/web/js/yui/datatable/README deleted file mode 100644 index be684ecb79..0000000000 --- a/interface/web/js/yui/datatable/README +++ /dev/null @@ -1,9 +0,0 @@ -DataTable Release Notes - -*** version 2.2.0 *** - -* Beta release. - -* Caption is not supported when scrolling is enabled. - -* Resizeability is not supported for fixed-width DataTables. diff --git a/interface/web/js/yui/datatable/assets/datatable.css b/interface/web/js/yui/datatable/assets/datatable.css deleted file mode 100644 index 4885ff7386..0000000000 --- a/interface/web/js/yui/datatable/assets/datatable.css +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/*debug css -.example span, .example .yui-dt-columntext {border:1px solid red;}*/ - -/*foundational css*/ -td { - overflow:hidden; -} - -.yui-dt-headcontainer { - position:relative; - -} - -.yui-dt-headtext { - position:relative; - border-right:10px; -} - -.yui-dt-headresizer { - position:absolute; - margin-right:-6px; - right:0; - bottom:0; - width:6px; - height:100%; - cursor:w-resize; - cursor:col-resize; -} - -.yui-dt-firstlink,.yui-dt-prevlink,.yui-dt-nextlink,.yui-dt-lastlink,.yui-dt-pagelink { - cursor:hand; - cursor:pointer; - text-decoration:underline; -} - -.yui-dt-scrollable { - width:20em; - margin-bottom:3em; -} - - -.yui-dt-scrollable thead { - background:#696969; /* IE needs a bgcolor to hide tbody as it scrolls */ - border:1px solid #000; - display:block; /* enables tbody scrolling for safari and opera */ -} - -.yui-dt-scrollable thead th { - width:10em; /* any value seems to here, just need something */ -} - -tbody.yui-dt-scrollable { - display:block; /* enables tbody scrolling for safari and opera */ - height:10em; - overflow:auto; /* for scrolling other than IE */ -} - -/* IE specific */ -.yui-dt-scrollable { - height:10em; - *overflow-y:auto; -} - -.yui-dt-scrollable tbody { - *height:auto; /* override the non IE height */ -} - -.yui-dt-scrollable thead tr { - position:relative; /* IE cant scroll tbody, so trick it into fixing thead */ -} - -.yui-dt-scrollable tbody td { - width:10em; -} - - diff --git a/interface/web/js/yui/datatable/datatable-beta-debug.js b/interface/web/js/yui/datatable/datatable-beta-debug.js deleted file mode 100644 index f99ec5f738..0000000000 --- a/interface/web/js/yui/datatable/datatable-beta-debug.js +++ /dev/null @@ -1,4956 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The DataTable widget provides a progressively enhanced DHTML control for - * displaying tabular data across A-grade browsers. - * - * @module datatable - * @requires yahoo, dom, event, datasource - * @optional dragdrop - * @title DataTable Widget - * @beta - */ - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * DataTable class for the YUI DataTable widget. - * - * @class DataTable - * @uses YAHOO.util.EventProvider - * @constructor - * @param elContainer {HTMLElement} Container element for the TABLE. - * @param oColumnSet {YAHOO.widget.ColumnSet} ColumnSet instance. - * @param oDataSource {YAHOO.util.DataSource} DataSource instance. - * @param oConfigs {object} (optional) Object literal of configuration values. - */ -YAHOO.widget.DataTable = function(elContainer,oColumnSet,oDataSource,oConfigs) { - // Internal vars - var i; - this._nIndex = YAHOO.widget.DataTable._nCount; - this._sName = "instance" + this._nIndex; - this.id = "yui-dt"+this._nIndex; - - // Validate configs - if(typeof oConfigs == "object") { - for(var sConfig in oConfigs) { - this[sConfig] = oConfigs[sConfig]; - } - } - - // Validate DataSource - if(oDataSource) { - if(oDataSource instanceof YAHOO.util.DataSource) { - this.dataSource = oDataSource; - } - else { - YAHOO.log("Invalid DataSource", "warn", this.toString()); - } - } - - // Validate ColumnSet - if(oColumnSet && (oColumnSet instanceof YAHOO.widget.ColumnSet)) { - this._oColumnSet = oColumnSet; - } - else { - YAHOO.log("Could not instantiate DataTable due to an invalid ColumnSet", "error", this.toString()); - return; - } - - // Create RecordSet - this._oRecordSet = new YAHOO.widget.RecordSet(); - - // Validate HTML Element - elContainer = YAHOO.util.Dom.get(elContainer); - if(elContainer && elContainer.tagName && (elContainer.tagName.toLowerCase() == "div")) { - this._elContainer = elContainer; - // Peek in container child nodes to see if TABLE already exists - var elTable = null; - if(elContainer.hasChildNodes()) { - var children = elContainer.childNodes; - for(i=0; i<children.length; i++) { - if(children[i].tagName && children[i].tagName.toLowerCase() == "table") { - elTable = children[i]; - break; - } - } - } - - // Progressively enhance an existing table from markup... - // while using the markup as the source of data - if(elTable && !this.dataSource) { - // Fill RecordSet with data parsed out of table - var aRecords = []; - - // Iterate through each TBODY - for(i=0; i<elTable.tBodies.length; i++) { - var elBody = elTable.tBodies[i]; - - // Iterate through each TR - for(var j=0; j<elBody.rows.length; j++) { - var elRow = elBody.rows[j]; - var oRecord = {}; - - // Iterate through each TD - for(var k=0; k<elRow.cells.length; k++) { - - //var elCell = elRow.cells[l]; - //elCell.id = this.id+"-bdrow"+k+"-cell"+l; - //TODO: can we parse a column with null key? - oRecord[oColumnSet.keys[k].key] = oColumnSet.keys[k].parse(elRow.cells[k].innerHTML); - } - aRecords.push(oRecord); - } - } - - this._initTable(); - - var ok = this.doBeforeLoadData(aRecords); - if(ok) { - this._oRecordSet.addRecords(aRecords); - this.paginateRows(); - } - } - // Create markup from scratch using the provided DataSource - else if(this.dataSource) { - this._initTable(); - // Send out for data in an asynchronous request - oDataSource.sendRequest(this.initialRequest, this.onDataReturnPaginateRows, this); - } - // Else there is no data - else { - this._initTable(); - this.showEmptyMessage(); - } - } - // Container element not found in document - else { - YAHOO.log("Could not instantiate DataTable due to an invalid container element", "error", this.toString()); - return; - } - - // Set up sort - this.subscribe("headCellClickEvent",this.onEventSortColumn); - - // Set up context menu - //TODO: does trigger have to exist? can trigger be TBODY rather than rows? - if(this.contextMenu && this.contextMenuOptions) { - this.contextMenu = new YAHOO.widget.ContextMenu(this.id+"-cm", { trigger: this._elBody.rows } ); - this.contextMenu.addItem("delete item"); - this.contextMenu.render(document.body); - } - - // Set up event model - elTable = this._elTable; - ///////////////////////////////////////////////////////////////////////////// - // - // DOM Events - // - ///////////////////////////////////////////////////////////////////////////// - //YAHOO.util.Event.addListener(this._elContainer, "focus", this._onFocus, this); - YAHOO.util.Event.addListener(elTable, "click", this._onClick, this); - YAHOO.util.Event.addListener(elTable, "dblclick", this._onDoubleclick, this); - YAHOO.util.Event.addListener(elTable, "mouseout", this._onMouseout, this); - YAHOO.util.Event.addListener(elTable, "mouseover", this._onMouseover, this); - YAHOO.util.Event.addListener(elTable, "mousedown", this._onMousedown, this); - //YAHOO.util.Event.addListener(elTable, "mouseup", this._onMouseup, this); - //YAHOO.util.Event.addListener(elTable, "mousemove", this._onMousemove, this); - YAHOO.util.Event.addListener(elTable, "keydown", this._onKeydown, this); - YAHOO.util.Event.addListener(elTable, "keypress", this._onKeypress, this); - YAHOO.util.Event.addListener(document, "keyup", this._onDocumentKeyup, this); - YAHOO.util.Event.addListener(elTable, "keyup", this._onKeyup, this); - //YAHOO.util.Event.addListener(elTable, "focus", this._onFocus, this); - YAHOO.util.Event.addListener(elTable, "blur", this._onBlur, this); - - ///////////////////////////////////////////////////////////////////////////// - // - // Custom Events - // - ///////////////////////////////////////////////////////////////////////////// - - /** - * Fired when a mouseover occurs on a TD element. - * - * @event cellMouseoverEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellMouseoverEvent"); - - /** - * Fired when a mouseout occurs on a TD element. - * - * @event cellMouseoutEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellMouseoutEvent"); - - /** - * Fired when a TH cell element is mouseover. - * - * @event headCellMouseoverEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - * - */ - this.createEvent("headCellMouseoverEvent"); - - /** - * Fired when a TH cell element is mouseout. - * - * @event headCellMouseoutEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - * - */ - this.createEvent("headCellMouseoutEvent"); - - /** - * Fired when a TABLE element is mouseover. - * - * @event tableMouseoverEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableMouseoverEvent"); - - /** - * Fired when a TABLE element is mouseout. - * - * @event tableMouseoutEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableMouseoutEvent"); - - /** - * Fired when a mousedown occurs on a TD element. - * - * @event cellMousedownEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellMousedownEvent"); - - /** - * Fired when a TH cell element is mousedown. - * - * @event headCellMousedownEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - */ - this.createEvent("headCellMousedownEvent"); - - /** - * Fired when a TABLE element is mousedown. - * - * @event tableMousedownEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableMousedownEvent"); - - /** - * Fired when a CHECKBOX element is clicked. - * - * @event checkboxClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The CHECKBOX element. - */ - this.checkboxClickEvent = this.createEvent("checkboxClickEvent"); - //this.checkboxClickEvent.subscribeEvent.subscribe(this._registerEvent,{type:"checkboxClickEvent"},this); - - /** - * Fired when a RADIO element is clicked. - * - * @event radioClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The RADIO element. - */ - this.createEvent("radioClickEvent"); - - /** - * Fired when a TD element is clicked. - * - * @event cellClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellClickEvent"); - - /** - * Fired when a TH cell element is clicked. - * - * @event headCellClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - */ - this.createEvent("headCellClickEvent"); - - /** - * Fired when a TABLE element is clicked. - * - * @event tableClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableClickEvent"); - - /** - * Fired when a TD element is doubleclicked. - * - * @event cellDoubleclickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellDoubleclickEvent"); - - /** - * Fired when a TH cell element is doubleclicked. - * - * @event headCellDoubleclickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - */ - this.createEvent("headCellDoubleclickEvent"); - - /** - * Fired when a TABLE element is doubleclicked. - * - * @event tableDoubleclickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableDoubleclickEvent"); - - /** - * Fired when a column is sorted. - * - * @event columnSortEvent - * @param oArgs.column {YAHOO.widget.Column} The Column instance. - * @param oArgs.dir {String} Sort direction "asc" or "desc". - */ - this.createEvent("columnSortEvent"); - - /** - * Fired when an editor is activated. - * - * @event editorShowEvent - * @param oArgs.target {HTMLElement} The TD element. - * @param oArgs.column {YAHOO.widget.Column} The Column instance. - */ - this.createEvent("editorShowEvent"); - - - /** - * Fired when a cell is edited. - * - * @event cellEditEvent - * @param oArgs.target {HTMLElement} The TD element. - * @param oArgs.newData {Object} New data value. - * @param oArgs.oldData {Object} Old data value. - */ - this.createEvent("cellEditEvent"); - - /** - * Fired when a column is resized. - * - * @event columnResizeEvent - * @param oArgs.target {HTMLElement} The TH element. - */ - this.createEvent("columnResizeEvent"); - - /** - * Fired when DataTable instance is first initialized. - * - * @event tableInitEvent - */ - this.createEvent("tableInitEvent"); - - /** - * Fired when DataTable instance is focused. - * - * @event tableFocusEvent - */ - this.createEvent("tableFocusEvent"); - - /** - * Fired when data is returned from DataSource. - * - * @event dataReturnEvent - * @param oArgs.request {String} Original request. - * @param oArgs.response {Object} Response object. - */ - this.createEvent("dataReturnEvent"); - - /** - * Fired when DataTable is paginated. - * - * @event paginateEvent - */ - this.createEvent("paginateEvent"); - - /** - * Fired when a TD element is formatted. - * - * @event cellFormatEvent - * @param oArgs.el {HTMLElement} Reference to the TD element. - */ - this.createEvent("cellFormatEvent"); - - /** - * Fired when an element is selected. - * - * @event selectEvent - * @param oArgs.els {Array} An array of the selected element(s). - */ - this.createEvent("selectEvent"); - - /** - * Fired when an element is unselected. - * - * @event unselectEvent - * @param oArgs.els {Array} An array of the unselected element(s). - */ - this.createEvent("unselectEvent"); - - /** - * Fired when an element is highlighted. - * - * @event highlightEvent - * @param oArgs.els {Array} An array of the highlighted element(s). - */ - this.createEvent("highlightEvent"); - - /** - * Fired when an element is unhighlighted. - * - * @event unhighlightEvent - * @param oArgs.els {Array} An array of the unhighlighted element(s). - */ - this.createEvent("unhighlightEvent"); - - /** - * Fired when one or more TR elements are deleted. - * - * @event rowDeleteEvent - * @param oArgs.rowIndexes {Array} The indexes of the deleted rows. - */ - this.createEvent("rowDeleteEvent"); - this.subscribe("rowDeleteEvent", this._onRowDelete); - - /** - * Fired when one or more TR elements are appended. - * - * @event rowAppendEvent - * @param oArgs.rowIds {Array} The IDs of the appended rows. - */ - this.createEvent("rowAppendEvent"); - - /** - * Fired when a Record is updated in the RecordSet. - * - * @event recordSetUpdateEvent - * @param oArgs.record {YAHOO.widget.Record} The Record instance. - * @param oArgs.key {String} The Record key. - * @param oArgs.newData {Object} New data. - * @param oArgs.oldData {Object} New data. - */ - this.createEvent("recordSetUpdateEvent"); - this._oRecordSet.subscribe("recordUpdateEvent", this._onRecordUpdate, this, true); - - - YAHOO.widget.DataTable._nCount++; - YAHOO.log("DataTable initialized", "info", this.toString()); - this.fireEvent("tableInitEvent"); -}; - -if(YAHOO.util.EventProvider) { - YAHOO.augment(YAHOO.widget.DataTable, YAHOO.util.EventProvider); -} -else { - YAHOO.log("Missing dependency: YAHOO.util.EventProvider","error",this.toString()); -} - -///////////////////////////////////////////////////////////////////////////// -// -// Public constants -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Class name assigned to TBODY element that holds data rows. - * - * @property CLASS_BODY - * @type String - * @static - * @final - * @default "yui-dt-body" - */ -YAHOO.widget.DataTable.CLASS_BODY = "yui-dt-body"; - -/** - * Class name assigned to container element within THEAD. - * - * @property CLASS_HEADCONTAINER - * @type String - * @static - * @final - */ -YAHOO.widget.DataTable.CLASS_HEADCONTAINER = "yui-dt-headcontainer"; - -/** - * Class name assigned to resizer handle element within THEAD. - * - * @property CLASS_HEADRESIZER - * @type String - * @static - * @final - * @default "yui-dt-headresizer" - */ -YAHOO.widget.DataTable.CLASS_HEADRESIZER = "yui-dt-headresizer"; - -/** - * Class name assigned to text displayed within THEAD. - * - * @property CLASS_HEADTEXT - * @type String - * @static - * @final - * @default "yui-dt-headtext" - */ -YAHOO.widget.DataTable.CLASS_HEADTEXT = "yui-dt-headtext"; - -/** - * Class name assigned to even TR elements. - * - * @property CLASS_EVEN - * @type String - * @static - * @final - * @default "yui-dt-even - */ -YAHOO.widget.DataTable.CLASS_EVEN = "yui-dt-even"; - -/** - * Class name assigned to odd TR elements. - * - * @property CLASS_ODD - * @type String - * @static - * @final - * @default "yui-dt-odd" - */ -YAHOO.widget.DataTable.CLASS_ODD = "yui-dt-odd"; - -/** - * Class name assigned to empty elements. - * - * @property CLASS_EMPTY - * @type String - * @static - * @final - * @default "yui-dt-empty" - */ -YAHOO.widget.DataTable.CLASS_EMPTY = "yui-dt-empty"; - -/** - * Class name assigned to loading message. - * - * @property CLASS_LOADING - * @type String - * @static - * @final - * @default "yui-dt-loading" - */ -YAHOO.widget.DataTable.CLASS_LOADING = "yui-dt-loading"; - -/** - * Class name assigned to selected elements. - * - * @property CLASS_SELECTED - * @type String - * @static - * @final - * @default "yui-dt-selected" - */ -YAHOO.widget.DataTable.CLASS_SELECTED = "yui-dt-selected"; - -/** - * Class name assigned to highlighted element. - * - * @property CLASS_HIGHLIGHT - * @type String - * @static - * @final - * @default "yui-dt-highlight" - */ -YAHOO.widget.DataTable.CLASS_HIGHLIGHT = "yui-dt-highlight"; - -/** - * Class name assigned to certain elements of a scrollable DataTable. - * - * @property CLASS_SCROLLABLE - * @type String - * @static - * @final - * @default "yui-dt-scrollable" - */ -YAHOO.widget.DataTable.CLASS_SCROLLABLE = "yui-dt-scrollable"; - -/** - * Class name assigned to column headers of sortable Columns. - * - * @property CLASS_SORTABLE - * @type String - * @static - * @final - * @default "yui-dt-sortable" - */ -YAHOO.widget.DataTable.CLASS_SORTABLE = "yui-dt-sortable"; - -/** - * Class name assigned to column headers when sorted in ascending order. - * - * @property CLASS_SORTEDBYASC - * @type String - * @static - * @final - * @default "yui-dt-sortedbyasc" - */ -YAHOO.widget.DataTable.CLASS_SORTEDBYASC = "yui-dt-sortedbyasc"; - -/** - * Class name assigned to column headers when sorted in descending order. - * - * @property CLASS_SORTEDBYDESC - * @type String - * @static - * @final - * @default "yui-dt-sortedbydesc" - */ -YAHOO.widget.DataTable.CLASS_SORTEDBYDESC = "yui-dt-sortedbydesc"; - -/** - * Class name assigned to the pagination link "<<". - * - * @property CLASS_FIRSTLINK - * @type String - * @static - * @final - * @default "yui-dt-firstlink" - */ -YAHOO.widget.DataTable.CLASS_FIRSTLINK = "yui-dt-firstlink"; - -/** - * Class name assigned to the pagination link "<<" when it is disabled. - * - * @property CLASS_FIRSTPAGE - * @type String - * @static - * @final - * @default "yui-dt-firstpage" - */ -YAHOO.widget.DataTable.CLASS_FIRSTPAGE = "yui-dt-firstpage"; - -/** - * Class name assigned to the pagination link ">>". - * - * @property CLASS_LASTLINK - * @type String - * @static - * @final - * @default "yui-dt-lastlink" - */ -YAHOO.widget.DataTable.CLASS_LASTLINK = "yui-dt-lastlink"; - -/** - * Class name assigned to the pagination link ">>" when it is disabled. - * - * @property CLASS_LASTPAGE - * @type String - * @static - * @final - * @default "yui-dt-lastpage" - */ -YAHOO.widget.DataTable.CLASS_LASTPAGE = "yui-dt-lastpage"; - -/** - * Class name assigned to the pagination link "<". - * - * @property CLASS_PREVLINK - * @type String - * @static - * @final - * @default "yui-dt-prevlink" - */ -YAHOO.widget.DataTable.CLASS_PREVLINK = "yui-dt-prevlink"; - -/** - * Class name assigned to the pagination link "<" when it is disabled. - * - * @property CLASS_PREVPAGE - * @type String - * @static - * @final - * @default "yui-dt-prevpage" - */ -YAHOO.widget.DataTable.CLASS_PREVPAGE = "yui-dt-prevpage"; - -/** - * Class name assigned to the pagination link ">". - * - * @property CLASS_NEXTLINK - * @type String - * @static - * @final - * @default "yui-dt-nextlink" - */ -YAHOO.widget.DataTable.CLASS_NEXTLINK = "yui-dt-nextlink"; - -/** - * Class name assigned to the pagination link ">" when it is disabled. - * - * @property CLASS_NEXTPAGE - * @type String - * @static - * @final - * @default "yui-dt-nextpage" - */ -YAHOO.widget.DataTable.CLASS_NEXTPAGE = "yui-dt-nextpage"; - - -/** - * Class name assigned to pagination links to specific page numbers. - * - * @property CLASS_PAGELINK - * @type String - * @static - * @final - * @default "yui-dt-pagelink" - */ -YAHOO.widget.DataTable.CLASS_PAGELINK = "yui-dt-pagelink"; - -/** - * Class name assigned to pagination links for specific page numbers that are disabled. - * - * @property CLASS_CURRENTPAGE - * @type String - * @static - * @final - * @default "yui-dt-currentpage" - */ -YAHOO.widget.DataTable.CLASS_CURRENTPAGE = "yui-dt-currentpage"; - -/** - * Class name assigned to the pagination SELECT element. - * - * @property CLASS_PAGESELECT - * @type String - * @static - * @final - * @default "yui-dt-pageselect" - */ -YAHOO.widget.DataTable.CLASS_PAGESELECT = "yui-dt-pageselect"; - -/** - * Class name assigned to the pagination links container element. - * - * @property CLASS_PAGELINKS - * @type String - * @static - * @final - * @default "yui-dt-pagelinks" - */ -YAHOO.widget.DataTable.CLASS_PAGELINKS = "yui-dt-pagelinks"; - -/** - * Class name assigned to editable TD elements. - * - * @property CLASS_EDITABLE - * @type String - * @static - * @final - * @default "yui-dt-editable" - */ -YAHOO.widget.DataTable.CLASS_EDITABLE = "yui-dt-editable"; - -/** - * Class name assigned to TD elements of type "checkbox". - * - * @property CLASS_CHECKBOX - * @type String - * @static - * @final - * @default "yui-dt-checkbox" - */ -YAHOO.widget.DataTable.CLASS_CHECKBOX = "yui-dt-checkbox"; - -/** - * Class name assigned to TD elements of type "currency". - * - * @property CLASS_CURRENCY - * @type String - * @static - * @final - * @default "yui-dt-currency" - */ -YAHOO.widget.DataTable.CLASS_CURRENCY = "yui-dt-currency"; - -/** - * Class name assigned to TD elements of type "date". - * - * @property CLASS_DATE - * @type String - * @static - * @final - * @default "yui-dt-date" - */ -YAHOO.widget.DataTable.CLASS_DATE = "yui-dt-date"; - -/** - * Class name assigned to TD elements of type "email". - * - * @property CLASS_EMAIL - * @type String - * @static - * @final - * @default "yui-dt-email" - */ -YAHOO.widget.DataTable.CLASS_EMAIL = "yui-dt-email"; - -/** - * Class name assigned to TD elements of type "link". - * - * @property CLASS_LINK - * @type String - * @static - * @final - * @default "yui-dt-link" - */ -YAHOO.widget.DataTable.CLASS_LINK = "yui-dt-link"; - -/** - * Class name assigned to TD elements of type "number". - * - * @property CLASS_NUMBER - * @type String - * @static - * @final - * @default "yui-dt-number" - */ -YAHOO.widget.DataTable.CLASS_NUMBER = "yui-dt-number"; - -/** - * Class name assigned to TD elements of type "string". - * - * @property CLASS_STRING - * @type String - * @static - * @final - * @default "yui-dt-string" - */ -YAHOO.widget.DataTable.CLASS_STRING = "yui-dt-string"; - -/** - * Message to display if DataTable has no data. - * - * @property MSG_EMPTY - * @type String - * @static - * @final - * @default "No records found." - */ -YAHOO.widget.DataTable.MSG_EMPTY = "No records found."; - -/** - * Message to display while DataTable is loading data. - * - * @property MSG_LOADING - * @type String - * @static - * @final - * @default "Loading data..." - */ -YAHOO.widget.DataTable.MSG_LOADING = "Loading data..."; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple DataTable instances. - * - * @property _nCount - * @type Number - * @private - * @static - */ -YAHOO.widget.DataTable._nCount = 0; - -/** - * Instance index. - * - * @property _nIndex - * @type Number - * @private - */ -YAHOO.widget.DataTable.prototype._nIndex = null; - -/** - * Unique instance name. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.DataTable.prototype._sName = null; - -//TODO: convert these to public members - -/** - * Container element reference. Is null unless the TABLE is built from scratch into the - * provided container. - * - * @property _elContainer - * @type HTMLElement - * @private - */ -YAHOO.widget.DataTable.prototype._elContainer = null; - -/** - * TABLE element reference. - * - * @property _elTable - * @type HTMLElement - * @private - */ -YAHOO.widget.DataTable.prototype._elTable = null; - -/** - * TBODY element reference. - * - * @property _elBody - * @type HTMLElement - * @private - */ -YAHOO.widget.DataTable.prototype._elBody = null; - -/** - * ColumnSet instance. - * - * @property _oColumnSet - * @type YAHOO.widget.ColumnSet - * @private - */ -YAHOO.widget.DataTable.prototype._oColumnSet = null; - -/** - * RecordSet instance. - * - * @property _oRecordSet - * @type YAHOO.widget.RecordSet - * @private - */ -YAHOO.widget.DataTable.prototype._oRecordSet = null; - -/** - * Array of Records that are in the selected state. - * - * @property _aSelectedRecords - * @type YAHOO.widget.Record[] - * @private - */ -YAHOO.widget.DataTable.prototype._aSelectedRecords = null; - -/** - * Internal variable to track whether widget has focus. - * - * @property _bFocused - * @type Boolean - * @private - */ -YAHOO.widget.DataTable.prototype._bFocused = false; - -/** - * Total number of pages, calculated on the fly. - * - * @property _totalPages - * @type Number - * @private - */ -YAHOO.widget.DataTable.prototype._totalPages = null; - - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Creates HTML markup for TABLE, THEAD, TBODY. - * - * @method _initTable - * @private - */ -YAHOO.widget.DataTable.prototype._initTable = function() { - // Clear the container - this._elContainer.innerHTML = ""; - - // Set up scrolling - if(this.scrollable) { - //TODO: conf height - YAHOO.util.Dom.addClass(this._elContainer,YAHOO.widget.DataTable.CLASS_SCROLLABLE); - } - - // Create TABLE - this._elTable = this._elContainer.appendChild(document.createElement("table")); - var elTable = this._elTable; - elTable.tabIndex = 0; - - // Create SUMMARY, if applicable - if(this.summary) { - elTable.summary = this.summary; - } - - // Create CAPTION, if applicable - if(this.caption) { - this._elCaption = elTable.appendChild(document.createElement("caption")); - this._elCaption.innerHTML = this.caption; - } - - // Create THEAD - this._initHead(elTable, this._oColumnSet); - - - // Create TBODY for messages - var elMsgBody = document.createElement("tbody"); - elMsgBody.tabIndex = -1; - this._elMsgRow = elMsgBody.appendChild(document.createElement("tr")); - var elMsgRow = this._elMsgRow; - var elMsgCell = elMsgRow.appendChild(document.createElement("td")); - elMsgCell.colSpan = this._oColumnSet.keys.length; - this._elMsgCell = elMsgCell; - this._elMsgBody = elTable.appendChild(elMsgBody); - this.showLoadingMessage(); - - // Create TBODY for data - this._elBody = elTable.appendChild(document.createElement("tbody")); - this._elBody.tabIndex = -1; - YAHOO.util.Dom.addClass(this._elBody,YAHOO.widget.DataTable.CLASS_BODY); - if(this.scrollable) { - YAHOO.util.Dom.addClass(this._elBody,YAHOO.widget.DataTable.CLASS_SCROLLABLE); - } -}; - -/** - * Populates THEAD element with TH cells as defined by ColumnSet. - * - * @method _initHead - * @private - */ -YAHOO.widget.DataTable.prototype._initHead = function() { - var i,oColumn; - - // Create THEAD - var elHead = document.createElement("thead"); - elHead.tabIndex = -1; - - // Iterate through each row of Column headers... - var colTree = this._oColumnSet.tree; - for(i=0; i<colTree.length; i++) { - var elHeadRow = elHead.appendChild(document.createElement("tr")); - elHeadRow.id = this.id+"-hdrow"+i; - - // ...and create THEAD cells - for(var j=0; j<colTree[i].length; j++) { - oColumn = colTree[i][j]; - var elHeadCell = elHeadRow.appendChild(document.createElement("th")); - elHeadCell.id = oColumn.getId(); - this._initHeadCell(elHeadCell,oColumn,i,j); - } - } - - this._elHead = this._elTable.appendChild(elHead); - - // Add Resizer only after DOM has been updated... - // ...and skip the last column - for(i=0; i<this._oColumnSet.keys.length-1; i++) { - oColumn = this._oColumnSet.keys[i]; - if(oColumn.resizeable && YAHOO.util.DD) { - //TODO: deal with fixed width tables - //TODO: no more oColumn.isLast - if(!this.fixedWidth || (this.fixedwidth && !oColumn.isLast)) { - // TODO: better way to get elHeadContainer - var elHeadContainer = (YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_HEADCONTAINER,"div",YAHOO.util.Dom.get(oColumn.getId())))[0]; - var elHeadResizer = elHeadContainer.appendChild(document.createElement("span")); - elHeadResizer.id = oColumn.getId() + "-resizer"; - YAHOO.util.Dom.addClass(elHeadResizer,YAHOO.widget.DataTable.CLASS_HEADRESIZER); - oColumn.ddResizer = new YAHOO.util.WidthResizer( - this, oColumn.getId(), elHeadResizer.id, elHeadResizer.id); - var cancelClick = function(e) { - YAHOO.util.Event.stopPropagation(e); - }; - YAHOO.util.Event.addListener(elHeadResizer,"click",cancelClick); - } - if(this.fixedWidth) { - elHeadContainer.style.overflow = "hidden"; - elHeadContent.style.overflow = "hidden"; - } - } - } - - YAHOO.log("THEAD with " + this._oColumnSet.keys.length + " columns created","info",this.toString()); -}; - -/** - * Populates TH cell as defined by Column. - * - * @method _initHeadCell - * @param elHeadCell {HTMLElement} TH cell element reference. - * @param oColumn {YAHOO.widget.Column} Column object. - * @param row {number} Row index. - * @param col {number} Column index. - * @private - */ -YAHOO.widget.DataTable.prototype._initHeadCell = function(elHeadCell,oColumn,row,col) { - // Clear out the cell of prior content - // TODO: purgeListeners and other validation-related things - var index = this._nIndex; - elHeadCell.columnIndex = col; - if(oColumn.abbr) { - elHeadCell.abbr = oColumn.abbr; - } - if(oColumn.width) { - elHeadCell.style.width = oColumn.width; - } - if(oColumn.className) { - YAHOO.util.Dom.addClass(elHeadCell,oColumn.className); - } - // Apply CSS for sorted tables - if(this.sortedBy && this.sortedBy.colKey) { - if(this.sortedBy.colKey == oColumn.key) { - var sortClass = (this.sortedBy.dir && (this.sortedBy.dir != "asc")) ? - YAHOO.widget.DataTable.CLASS_SORTEDBYDESC : - YAHOO.widget.DataTable.CLASS_SORTEDBYASC; - YAHOO.util.Dom.addClass(elHeadCell,sortClass); - this.sortedBy._id = elHeadCell.id; - } - } - - elHeadCell.innerHTML = ""; - - var elHeadContainer = elHeadCell.appendChild(document.createElement("div")); - elHeadContainer.id = this.id+"-hdrow"+row+"-container"+col; - YAHOO.util.Dom.addClass(elHeadContainer,YAHOO.widget.DataTable.CLASS_HEADCONTAINER); - var elHeadContent = elHeadContainer.appendChild(document.createElement("span")); - elHeadContent.id = this.id+"-hdrow"+row+"-text"+col; - YAHOO.util.Dom.addClass(elHeadContent,YAHOO.widget.DataTable.CLASS_HEADTEXT); - - elHeadCell.rowSpan = oColumn.getRowSpan(); - elHeadCell.colSpan = oColumn.getColSpan(); - - var contentText = oColumn.text || oColumn.key || ""; - if(oColumn.sortable) { - YAHOO.util.Dom.addClass(elHeadContent,YAHOO.widget.DataTable.CLASS_SORTABLE); - //TODO: Make hash configurable to be a server link - //TODO: Make title configurable - //TODO: Separate contentText from an accessibility link that says - // Click to sort ascending and push it offscreen - elHeadContent.innerHTML = "<a href=\"#\" title=\"Click to sort\">" + contentText + "</a>"; - //elHeadContent.innerHTML = contentText; - - } - else { - elHeadContent.innerHTML = contentText; - } -}; - -/** - * Add a new row to table body at position i if given, or to the bottom - * otherwise. Does not fire any events. - * - * @method _addRow - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param index {Number} Position at which to add row. - * @return {String} ID of the added TR element. - * @private - */ -YAHOO.widget.DataTable.prototype._addRow = function(oRecord, index) { - this.hideTableMessages(); - - // Is this an insert or an append? - var insert = (isNaN(index)) ? false : true; - if(!insert) { - index = this._elBody.rows.length; - } - - var oColumnSet = this._oColumnSet; - var oRecordSet = this._oRecordSet; - - var elRow = (insert && this._elBody.rows[index]) ? - this._elBody.insertBefore(document.createElement("tr"),this._elBody.rows[index]) : - this._elBody.appendChild(document.createElement("tr")); - var recId = oRecord.id; - elRow.id = this.id+"-bdrow"+index; - elRow.recordId = recId; - - // Create TBODY cells - for(var j=0; j<oColumnSet.keys.length; j++) { - var oColumn = oColumnSet.keys[j]; - var elCell = elRow.appendChild(document.createElement("td")); - elCell.id = this.id+"-bdrow"+index+"-cell"+j; - elCell.headers = oColumn.id; - elCell.columnIndex = j; - elCell.headers = oColumnSet.headers[j]; - - oColumn.format(elCell, oRecord); - /*p.abx {word-wrap:break-word;} -ought to solve the problem for Safari (the long words will wrap in your -tds, instead of overflowing to the next td. -(this is supported by IE win as well, so hide it if needed). - -One thing, though: it doesn't work in combination with -'white-space:nowrap'.*/ - -// need a div wrapper for safari? - if(this.fixedWidth) { - elCell.style.overflow = "hidden"; - //elCell.style.width = "20px"; - } - } - - if(this.isEmpty && (this._elBody.rows.length > 0)) { - //TODO: hideMessages() - //this._initRows() - //this.isEmpty = false; - } - - // Striping - if(!insert) { - if(index%2) { - YAHOO.util.Dom.addClass(elRow, YAHOO.widget.DataTable.CLASS_ODD); - } - else { - YAHOO.util.Dom.addClass(elRow, YAHOO.widget.DataTable.CLASS_EVEN); - } - } - else { - //TODO: pass in a subset for better performance - this._restripeRows(); - } - - return elRow.id; -}; - -/** - * Restripes rows by applying class YAHOO.widget.DataTable.CLASS_EVEN or - * YAHOO.widget.DataTable.CLASS_ODD. - * - * @method _restripeRows - * @param range {Number} (optional) Range defines a subset of rows to restripe. - * @private - */ -YAHOO.widget.DataTable.prototype._restripeRows = function(range) { - if(!range) { - var rows = this._elBody.rows; - for(var i=0; i<rows.length; i++) { - if(i%2) { - YAHOO.util.Dom.removeClass(rows[i], YAHOO.widget.DataTable.CLASS_EVEN); - YAHOO.util.Dom.addClass(rows[i], YAHOO.widget.DataTable.CLASS_ODD); - } - else { - YAHOO.util.Dom.removeClass(rows[i], YAHOO.widget.DataTable.CLASS_ODD); - YAHOO.util.Dom.addClass(rows[i], YAHOO.widget.DataTable.CLASS_EVEN); - } - } - } - else { - //TODO: allow restriping of a subset of rows for performance - } -}; - -/** - * Updates existing row at position i with data from the given Record. Does not - * fire any events. - * - * @method _updateRow - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param index {Number} Position at which to update row. - * @return {String} ID of the updated TR element. - * @private - */ -YAHOO.widget.DataTable.prototype._updateRow = function(oRecord, index) { - this.hideTableMessages(); - - var elRow = this._elBody.rows[index]; - elRow.recordId = oRecord.id; - - var columns = this._oColumnSet.keys; - // ...Update TBODY cells with new data - for(var j=0; j<columns.length; j++) { - columns[j].format(elRow.cells[j], oRecord); - } - return elRow.id; -}; - -/** - * Sets elements to selected state. Does not fire any events. Does not affect - * internal tracker. - * - * @method _select - * @param els {HTMLElement[] | String[]} Array of HTML elements by reference or ID string. - * @private - */ -YAHOO.widget.DataTable.prototype._select = function(els) { -//TODO: put els in an array if it is just one element? - for(var i=0; i<els.length; i++) { - // Set the style - YAHOO.util.Dom.addClass(YAHOO.util.Dom.get(els[i]),YAHOO.widget.DataTable.CLASS_SELECTED); - } - this._lastSelected = els[els.length-1]; -}; - -/** - * Sets elements to the unselected state. Does not fire any events. Does not - * affect internal tracker. - * - * @method _unselect - * @param els {HTMLElement[] | String[]} Array of HTML elements by reference or ID string. - * @private - */ -YAHOO.widget.DataTable.prototype._unselect = function(els) { - for(var i=0; i<els.length; i++) { - // Remove the style - YAHOO.util.Dom.removeClass(YAHOO.util.Dom.get(els[i]),YAHOO.widget.DataTable.CLASS_SELECTED); - } -}; - -/** - * Unselects all selected rows. Does not fire any events. Does not affect internal - * tracker. - * - * @method _unselectAllRows - * @private - */ -YAHOO.widget.DataTable.prototype._unselectAllRows = function() { - var selectedRows = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody); - this._unselect(selectedRows); -}; - -/** - * Unselects all selected cells. - * - * @method _unselectAllCells - * @private - */ -YAHOO.widget.DataTable.prototype._unselectAllCells = function() { - var selectedCells = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody); - this._unselect(selectedCells); -}; - -/** - * Deletes a given row element as well its corresponding Record in the RecordSet. - * Does not fire any events. - * - * @method _deleteRow - * @param elRow {element} HTML table row element reference. - * @private - */ -YAHOO.widget.DataTable.prototype._deleteRow = function(elRow) { -//TODO: sniff elRow.rowIndex - var allRows = this._elBody.rows; - var id = elRow.id; - var recordId = elRow.recordId; - for(var i=0; i< allRows.length; i++) { - if(id == allRows[i].id) { - this._elBody.deleteRow(i); - - // Update the RecordSet - this._oRecordSet.deleteRecord(i); - break; - } - } - if(this._elBody.rows.length === 0) { - this.showEmptyMessage(); - } -}; -///////////////////////////////////////////////////////////////////////////// -// -// Private DOM Event Handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Handles blur events on the TABLE element. - * - * @method _onBlur - * @param e {HTMLEvent} The blur event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onBlur = function(e, oSelf) { - this._bFocused = false; -}; - -/** - * Handles mouseover events on the TABLE element. - * - * @method _onMouseover - * @param e {HTMLEvent} The mouseover event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onMouseover = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "td": - oSelf.fireEvent("cellMouseoverEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - oSelf.fireEvent("headCellMouseoverEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - if(elTarget) { - elTag = elTarget.tagName.toLowerCase(); - } - else { - break; - } - } - } - oSelf.fireEvent("tableMouseoverEvent",{target:elTarget,event:e}); -}; - -/** - * Handles mouseout events on the TABLE element. - * - * @method _onMouseout - * @param e {HTMLEvent} The mouseout event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onMouseout = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "td": - oSelf.fireEvent("cellMouseoutEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - oSelf.fireEvent("headCellMouseoutEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - if(elTarget) { - elTag = elTarget.tagName.toLowerCase(); - } - else { - break; - } - } - } - oSelf.fireEvent("tableMouseoutEvent",{target:elTarget,event:e}); -}; - -/** - * Handles mousedown events on the TABLE element. - * - * @method _onMousedown - * @param e {HTMLEvent} The mousedown event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onMousedown = function(e, oSelf) { - //YAHOO.util.Event.stopEvent(e); - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "td": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("cellMousedownEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("headCellMousedownEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - if(elTarget) { - elTag = elTarget.tagName.toLowerCase(); - } - else { - break; - } - } - } - oSelf.fireEvent("tableMousedownEvent",{target:elTarget,event:e}); -}; - -/** - * Handles click events on the TABLE element. - * - * @method _onClick - * @param e {HTMLEvent} The click event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onClick = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; // True if event should stop propagating - - if(oSelf.activeEditor) { //&& (oSelf.activeEditor.column != column) - oSelf.activeEditor.hide(); - oSelf.activeEditor = null; - - // Editor causes widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "input": - if(elTarget.type.toLowerCase() == "checkbox") { - oSelf.fireEvent("checkboxClickEvent",{target:elTarget,event:e}); - } - else if(elTarget.type.toLowerCase() == "radio") { - oSelf.fireEvent("radioClickEvent",{target:elTarget,event:e}); - } - knownTag = true; - break; - case "td": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("cellClickEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("headCellClickEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - elTag = elTarget.tagName.toLowerCase(); - } - } - oSelf.focusTable(); - oSelf.fireEvent("tableClickEvent",{target:elTarget,event:e}); -}; - -/** - * Handles doubleclick events on the TABLE element. - * - * @method _onDoubleclick - * @param e {HTMLEvent} The doubleclick event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onDoubleclick = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; - - if(oSelf.activeEditor) { //&& (oSelf.activeEditor.column != column) - oSelf.activeEditor.hide(); - oSelf.activeEditor = null; - - // Editor causes widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "td": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("cellDoubleclickEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("headCellDoubleclickEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - elTag = elTarget.tagName.toLowerCase(); - } - } - oSelf.fireEvent("tableDoubleclickEvent",{target:elTarget,event:e}); -}; - -/** - * Handles keypress events on the TABLE. Mainly to support stopEvent on Mac. - * - * @method _onKeypress - * @param e {HTMLEvent} The key event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onKeypress = function(e, oSelf) { - var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1); - if(isMac) { - // arrow down - if(e.keyCode == 40) { - YAHOO.util.Event.stopEvent(e); - } - // arrow up - else if(e.keyCode == 38) { - YAHOO.util.Event.stopEvent(e); - } - } -}; - -/** - * Handles keydown events on the TABLE. Executes arrow selection. - * - * @method _onKeydown - * @param e {HTMLEvent} The key event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onKeydown = function(e, oSelf) { - var oldSelected = oSelf._lastSelected; - // Only move selection if one is already selected - // TODO: config to allow selection even if one is NOT already selected - // TODO: if something isn't selected already, arrow key should select first or last one - if(oldSelected && oSelf.isSelected(oldSelected)) { - var newSelected; - // arrow down - if(e.keyCode == 40) { - YAHOO.util.Event.stopEvent(e); - // row mode - if(oldSelected.tagName.toLowerCase() == "tr") { - // We have room to move down - if(oldSelected.sectionRowIndex+1 < oSelf._elBody.rows.length) { - if(!e.shiftKey) { - oSelf.unselectAllRows(); - } - newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex+1]; - oSelf.select(newSelected); - - } - } - // cell mode - else if(oldSelected.tagName.toLowerCase() == "td") { - /*// We have room to move down - if(oldSelected.sectionRowIndex+1 < oSelf._elBody.rows.length) { - if(!e.shiftKey) { - oSelf.unselectAllRows(); - } - newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex+1]; - oSelf.select(newSelected); - }*/ - } - // Arrows can cause widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - // arrow up - else if(e.keyCode == 38) { - YAHOO.util.Event.stopEvent(e); - // row mode - if(oldSelected.tagName.toLowerCase() == "tr") { - // We have room to move up - if((oldSelected.sectionRowIndex > 0)) { - if(!e.shiftKey) { - oSelf.unselectAllRows(); - } - newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex-1]; - oSelf.select(newSelected); - } - } - // cell mode - else if(oldSelected.tagName.toLowerCase() == "td") { - // We have room to move up - if((oldSelected.sectionRowIndex > 0)) { - if(!e.shiftKey) { - oSelf.unselectAllRows(); - } - newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex-1]; - oSelf.select(newSelected); - } - } - // Arrows can cause widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - } -}; - -/** - * Handles keyup events on the TABLE. Executes deletion - * - * @method _onKeyup - * @param e {HTMLEvent} The key event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onKeyup = function(e, oSelf) { - var key = YAHOO.util.Event.getCharCode(e); - // delete - if(key == 46) {//TODO: && this.isFocused - //TODO: delete row - } -}; - -/** - * Handles keyup events on the DOCUMENT. Executes interaction with editor. - * - * @method _onDocumentKeyup - * @param e {HTMLEvent} The key event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onDocumentKeyup = function(e, oSelf) { - // esc Clears active editor - if((e.keyCode == 27) && (oSelf.activeEditor)) { - oSelf.activeEditor.hide(); - oSelf.activeEditor = null; - - // Editor causes widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - // enter Saves active editor data - if((e.keyCode == 13) && (oSelf.activeEditor)) { - var elCell = oSelf.activeEditor.cell; - var oColumn = oSelf.activeEditor.column; - var oRecord = oSelf.activeEditor.record; - var oldValue = oRecord[oColumn.key]; - var newValue = oSelf.activeEditor.getValue(); - - //Update Record - //TODO: Column.key may be null! - oSelf._oRecordSet.updateRecord(oRecord,oColumn.key,newValue); - - //Update cell - oSelf.formatCell(elCell); - - // Hide editor - oSelf.activeEditor.hide(); - oSelf.activeEditor = null; - - // Editor causes widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - oSelf.fireEvent("cellEditEvent",{target:elCell,oldData:oldValue,newData:newValue}); - } -}; - -/** - * Handles click events on paginator links. - * - * @method _onPagerClick - * @param e {HTMLEvent} The click event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onPagerClick = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; // True if event should stop propagating - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "a": - YAHOO.util.Event.stopEvent(e); - switch(elTarget.className) { - case YAHOO.widget.DataTable.CLASS_PAGELINK: - oSelf.showPage(parseInt(elTarget.innerHTML,10)); - break; - case YAHOO.widget.DataTable.CLASS_FIRSTLINK: - oSelf.showPage(1); - break; - case YAHOO.widget.DataTable.CLASS_LASTLINK: - oSelf.showPage(oSelf._totalPages); - break; - case YAHOO.widget.DataTable.CLASS_PREVLINK: - oSelf.showPage(oSelf.pageCurrent-1); - break; - case YAHOO.widget.DataTable.CLASS_NEXTLINK: - oSelf.showPage(oSelf.pageCurrent+1); - break; - } - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - if(elTarget) { - elTag = elTarget.tagName.toLowerCase(); - } - else { - break; - } - } - } -}; - -/** - * Handles change events on paginator SELECT. - * - * @method _onPagerSelect - * @param e {HTMLEvent} The change event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onPagerSelect = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - - // How many rows per page - var oldRowsPerPage = oSelf.rowsPerPage; - var rowsPerPage = parseInt(elTarget[elTarget.selectedIndex].text,10); - if(rowsPerPage && (rowsPerPage != oSelf.rowsPerPage)) { - if(rowsPerPage > oldRowsPerPage) { - oSelf.pageCurrent = 1; - } - oSelf.rowsPerPage = rowsPerPage; - oSelf.paginateRows(); - } -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private Custom Event Handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Handles row delete events. - * - * @method _onRowDelete - * @param oArgs.rowIndexes {Number[]} The indexes of the deleted rows. - * @private - */ -YAHOO.widget.DataTable.prototype._onRowDelete = function(oArgs) { - this._restripeRows(); -}; - -/** - * Passes along recordSetUpdate Event when recordUpdateEvent is caught from RecordSet. - * - * @event _onRecordUpdate - * @param oArgs.record {YAHOO.widget.Record} The Record instance. - * @param oArgs.key {String} The Record key. - * @param oArgs.newData {Object} New data. - * @param oArgs.oldData {Object} New data. - * @private - */ -YAHOO.widget.DataTable.prototype._onRecordUpdate = function(oArgs) { - this.fireEvent("recordSetUpdateEvent",oArgs); -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * DataSource instance. - * - * @property dataSource - * @type YAHOO.util.DataSource - */ -YAHOO.widget.DataTable.prototype.dataSource = null; - -/** - * Initial request to send to DataSource. - * - * @property initialRequest - * @type String - * @default "" - */ -YAHOO.widget.DataTable.prototype.initialRequest = ""; - -/** - * Defines value of CAPTION attribute. - * - * @property caption - * @type String - */ -YAHOO.widget.DataTable.prototype.caption = null; - -/** - * Defines value of SUMMARY attribute. - * - * @property summary - * @type String - */ -YAHOO.widget.DataTable.prototype.summary = null; - -/** - * True if DataTable's width is a fixed size. - * - * @property fixedWidth - * @type Boolean - * @default false - */ -YAHOO.widget.DataTable.prototype.fixedWidth = false; - -/** - * True if TBODY should scroll while THEAD remains fixed. - * - * @property scrollable - * @type Boolean - * @default false - */ -YAHOO.widget.DataTable.prototype.scrollable = false; - -/** - * True if only one row may be selected at a time. - * - * @property rowSingleSelect - * @type Boolean - * @default false - */ -YAHOO.widget.DataTable.prototype.rowSingleSelect = false; - -/** - * ContextMenu instance. - * - * @property contextMenu - * @type YAHOO.widget.ContextMenu - */ -YAHOO.widget.DataTable.prototype.contextMenu = null; - -/** - * Current page number. - * - * @property pageCurrent - * @type Number - * @default 1 - */ -YAHOO.widget.DataTable.prototype.pageCurrent = 1; - -/** - * Rows per page. - * - * @property rowsPerPage - * @type Number - * @default 500 - */ -YAHOO.widget.DataTable.prototype.rowsPerPage = 500; - -/** - * Record index of first row of current page. - * - * @property startRecordIndex - * @type Number - * @default 1 - */ -YAHOO.widget.DataTable.prototype.startRecordIndex = 1; - -/** - * Maximum number of pagination page links to show. Any page links beyond this number are - * available through the "<" and ">" links. A negative value will display all page links. - * - * @property pageLinksLength - * @type Number - * @default -1 - */ -YAHOO.widget.DataTable.prototype.pageLinksLength = -1; - -/** - * Options to show in the rows-per-page pagination dropdown, should be an array - * of numbers. Null or an empty array causes no dropdown to be displayed. - * - * @property rowsPerPageDropdown - * @type Number[] - */ -YAHOO.widget.DataTable.prototype.rowsPerPageDropdown = null; - -/** - * First pagination page link. - * - * @property pageLinksStart - * @type Number - * @default 1 - */ -YAHOO.widget.DataTable.prototype.pageLinksStart = 1; - -/** - * An array of DIV elements into which pagination elements can go. - * - * @property pagers - * @type HTMLElement[] - */ -YAHOO.widget.DataTable.prototype.pagers = null; - -/** - * True if the DataTable is empty of data. False if DataTable is populated with - * data from RecordSet. - * - * @property isEmpty - * @type Boolean - */ -YAHOO.widget.DataTable.prototype.isEmpty = false; - -/** - * Object literal holds sort metadata: - * sortedBy.colKey - * sortedBy.dir - * - * - * @property sortedBy - * @type Object - */ -YAHOO.widget.DataTable.prototype.sortedBy = null; - - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor to the unique name of the DataSource instance. - * - * @method toString - * @return {String} Unique name of the DataSource instance. - */ - -YAHOO.widget.DataTable.prototype.toString = function() { - return "DataTable " + this._sName; -}; - -/** - * Returns element reference to TABLE. - * - * @method getTable - * @return {HTMLElement} Reference to TABLE element. - */ -YAHOO.widget.DataTable.prototype.getTable = function() { - return(this._elTable); -}; - -/** - * Returns element reference to THEAD. - * - * @method getHead - * @return {HTMLElement} Reference to THEAD element. - */ -YAHOO.widget.DataTable.prototype.getHead = function() { - return(this._elHead); -}; - -/** - * Returns element reference to TBODY. - * - * @method getBody - * @return {HTMLElement} Reference to TBODY element. - */ -YAHOO.widget.DataTable.prototype.getBody = function() { - return(this._elBody); -}; - -/** - * Returns element reference to given TR cell. - * - * @method getRow - * @param index {Number} Row number. - * @return {HTMLElement} Reference to TR element. - */ -YAHOO.widget.DataTable.prototype.getRow = function(index) { - return(this._elBody.rows[index]); -}; - -/** - * Returns element reference to given TD cell. - * - * @method getCell - * @param row {Number} Row number. - * @param col {Number} Column number. - * @return {HTMLElement} Reference to TD element. - */ -YAHOO.widget.DataTable.prototype.getCell = function(row, col) { - return(this._elBody.rows[row].cells[col]); -}; - -/** - * Placeholder row to indicate table data is empty. - * - * @method showEmptyMessage - */ -YAHOO.widget.DataTable.prototype.showEmptyMessage = function() { - if(this.isEmpty) { - return; - } - if(this.isLoading) { - this.hideTableMessages(); - } - - this._elMsgBody.style.display = ""; - var elCell = this._elMsgCell; - elCell.className = YAHOO.widget.DataTable.CLASS_EMPTY; - elCell.innerHTML = YAHOO.widget.DataTable.MSG_EMPTY; - this.isEmpty = true; -}; - -/** - * Placeholder row to indicate table data is loading. - * - * @method showLoadingMessage - */ -YAHOO.widget.DataTable.prototype.showLoadingMessage = function() { - if(this.isLoading) { - return; - } - if(this.isEmpty) { - this.hideTableMessages(); - } - - this._elMsgBody.style.display = ""; - var elCell = this._elMsgCell; - elCell.className = YAHOO.widget.DataTable.CLASS_LOADING; - elCell.innerHTML = YAHOO.widget.DataTable.MSG_LOADING; - this.isLoading = true; -}; - -/** - * Hide any placeholder message row. - * - * @method hideTableMessages - */ -YAHOO.widget.DataTable.prototype.hideTableMessages = function() { - if(!this.isEmpty && !this.isLoading) { - return; - } - - this._elMsgBody.style.display = "none"; - - this.isEmpty = false; - this.isLoading = false; -}; - -/** - * Sets focus on the TABLE element. - * - * @method focusTable - */ -YAHOO.widget.DataTable.prototype.focusTable = function() { - var elTable = this._elTable; - if(!this._bFocused) { - // http://developer.mozilla.org/en/docs/index.php?title=Key-navigable_custom_DHTML_widgets - // The timeout is necessary in both IE and Firefox 1.5, to prevent scripts from doing - // strange unexpected things as the user clicks on buttons and other controls. - setTimeout(function() { elTable.focus(); },0); - this._bFocused = true; - this.fireEvent("tableFocusEvent"); - } -}; - -/** - * Overridable method gives implementers a hook to access data before - * it gets added to RecordSet and rendered to the TBODY. - * - * @method doBeforeLoadData - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - * @return {Boolean} Return true to continue loading data into RecordSet and - * updating DataTable with new Records, false to cancel. - */ -YAHOO.widget.DataTable.prototype.doBeforeLoadData = function(sRequest, oResponse) { - return true; -}; - -/** - * Add rows to bottom of table body. - * - * @method appendRow - * @param aRecords {YAHOO.widget.Record[]} Array of Records. - */ -YAHOO.widget.DataTable.prototype.appendRows = function(aRecords) { - if(aRecords && aRecords.length > 0) { - this.hideTableMessages(); - - var rowIds = []; - for(var i=0; i<aRecords.length; i++) { - var rowId = this._addRow(aRecords[i]); - rowIds.push(rowId); - } - - this.fireEvent("rowAppendEvent", {rowIds:rowIds}); - } -}; - -/** - * Add rows to top of table body. - * - * @method insertRows - * @param aRecords {YAHOO.widget.Record[]} Array of Records. - */ -YAHOO.widget.DataTable.prototype.insertRows = function(aRecords) { - if(aRecords && aRecords.length > 0) { - this.hideTableMessages(); - - var rowIds = []; - for(var i=0; i<aRecords.length; i++) { - var rowId = this._addRow(aRecords[i],0); - rowIds.push(rowId); - } - - this.fireEvent("rowInsertEvent", {rowIds:rowIds}); - } -}; - -/** - * Replaces existing rows of table body with new Records. - * - * @method replaceRows - * @param aRecords {YAHOO.widget.Record[]} Array of Records. - */ -YAHOO.widget.DataTable.prototype.replaceRows = function(aRecords) { - var i; - - if(aRecords && aRecords.length > 0) { - this.hideTableMessages(); - - var elBody = this._elBody; - var elRows = this._elBody.rows; - - // Remove extra rows - while(elBody.hasChildNodes() && (elRows.length > aRecords.length)) { - elBody.deleteRow(0); - } - - // Unselect rows in the UI but keep tracking selected rows - var selectedRecords = this.getSelectedRecordIds(); - if(selectedRecords.length > 0) { - this._unselectAllRows(); - } - - var rowIds = []; - // Format in-place existing rows - for(i=0; i<elRows.length; i++) { - if(aRecords[i]) { - var oRecord = aRecords[i]; - rowIds.push(this._updateRow(oRecord,i)); - } - } - - // Add rows as necessary - for(i=elRows.length; i<aRecords.length; i++) { - rowIds.push(this._addRow(aRecords[i])); - } - - // Select any rows as necessary - for(i=0; i<selectedRecords.length; i++) { - var allRows = elBody.rows; - for(var j=0; j<allRows.length; j++) { - if(selectedRecords[i] == allRows[j].recordId) { - this._select([allRows[j]]); - } - } - } - - this.fireEvent("rowReplaceEvent", {rowIds:rowIds}); - } -}; - -/** - * Convenience method to add a new row to table body at position index if given, - * or to the bottom otherwise. - * - * @method addRow - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param index {Number} Position at which to add row. - */ -YAHOO.widget.DataTable.prototype.addRow = function(oRecord, index) { - if(oRecord) { - var rowId = this._addRow(oRecord, index); - if(index !== undefined) { - this.fireEvent("rowInsertEvent", {rowIds:[rowId]}); - } - else { - this.fireEvent("rowAppendEvent", {rowIds:[rowId]}); - } - } -}; - -/** - * Updates existing row at position index with data from the given Record. - * - * @method updateRow - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param index {Number} Position at which to update row. - */ -YAHOO.widget.DataTable.prototype.updateRow = function(oRecord, index) { - if(oRecord) { - var rowId = this._updateRow(oRecord, index); - this.fireEvent("rowUpdateEvent", {rowIds:[rowId]}); - } -}; - -/** - * Calls delete on selected rows. - * - * @method deleteSelectedRows - */ -YAHOO.widget.DataTable.prototype.deleteRows = function(rows) { - var rowIndexes = []; - for(var i=0; i<rows.length; i++) { - var rowIndex = (rows[i].sectionRowIndex !== undefined) ? rows[i].sectionRowIndex : null; - rowIndexes.push(rowIndex); - this._deleteRow(rows[i]); - this.fireEvent("rowDeleteEvent", {rowIndexes:rowIndexes}); - } -}; - -/** - * Deletes a given row element as well its corresponding Record in the RecordSet. - * - * @method deleteRow - * @param elRow {element} HTML table row element reference. - */ -YAHOO.widget.DataTable.prototype.deleteRow = function(elRow) { - if(elRow) { - var rowIndex = (elRow.sectionRowIndex !== undefined) ? elRow.sectionRowIndex : null; - this._deleteRow(elRow); - this.fireEvent("rowDeleteEvent", {rowIndexes:[rowIndex]}); - } -}; - -/** - * Sets one or more elements to the highlighted state. - * - * @method highlight - * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element - * reference, TR String ID, array of HTML TR element, or array of TR element IDs. - */ -YAHOO.widget.DataTable.prototype.highlight = function(els) { - if(els.constructor != Array) { - els = [els]; - } - YAHOO.util.Dom.addClass(els,YAHOO.widget.DataTable.CLASS_HIGHLIGHT); - this.fireEvent("highlightEvent",{els:els}); -}; - -/** - * Sets one or more elements to the unhighlighted state. - * - * @method unhighlight - * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element - * reference, TR String ID, array of HTML TR element, or array of TR element IDs. - */ -YAHOO.widget.DataTable.prototype.unhighlight = function(els) { - if(els.constructor != Array) { - els = [els]; - } - YAHOO.util.Dom.removeClass(els,YAHOO.widget.DataTable.CLASS_HIGHLIGHT); - this.fireEvent("unhighlightEvent",{els:els}); -}; - - -/** - * Sets one or more elements to the selected state. - * - * @method select - * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element - * reference, TR String ID, array of HTML TR element, or array of TR element IDs. - */ -YAHOO.widget.DataTable.prototype.select = function(els) { - if(els) { - if(els.constructor != Array) { - els = [els]; - } - this._select(els); - - // Add Record ID to internal tracker - var tracker = this._aSelectedRecords || []; - for(var i=0; i<els.length; i++) { - var id = els[i].recordId; - // Remove if already there - // Use Array.indexOf if available... - if(tracker.indexOf && (tracker.indexOf(id) > -1)) { - tracker.splice(tracker.indexOf(id),1); - } - // ...or do it the old-fashioned way - else { - for(var j=0; j<tracker.length; j++) { - if(tracker[j] === id){ - tracker.splice(j,1); - } - } - } - // Add to the end - tracker.push(id); - } - this._aSelectedRecords = tracker; - this.fireEvent("selectEvent",{els:els}); - } -}; - -/** - * Sets one or more elements to the unselected state. - * - * @method unselect - * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML element - * reference, element ID, array of HTML elements, or array of element IDs - */ -YAHOO.widget.DataTable.prototype.unselect = function(els) { - if(els) { - if(els.constructor != Array) { - els = [els]; - } - this._unselect(els); - // Remove Record ID from internal tracker - var tracker = this._aSelectedRecords || []; - for(var i=0; i<els.length; i++) { - var id = els[i].recordId; - - // Use Array.indexOf if available... - if(tracker.indexOf && (tracker.indexOf(id) > -1)) { - tracker.splice(tracker.indexOf(id),1); - } - // ...or do it the old-fashioned way - else { - for(var j=0; j<tracker.length; j++) { - if(tracker[j] === id){ - tracker.splice(j,1); - } - } - } - } - this._aSelectedRecords = tracker; - this.fireEvent("unselectEvent",{els:els}); - } -}; - -/** - * Unselects all selected rows. - * - * @method unselectAllRows - */ -YAHOO.widget.DataTable.prototype.unselectAllRows = function() { - var selectedRows = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody); - this.unselect(selectedRows); - this.fireEvent("unselectEvent", {els:selectedRows}); -}; - -/** - * Unselects all selected cells. - * - * @method unselectAllCells - */ -YAHOO.widget.DataTable.prototype.unselectAllCells = function() { - var selectedCells = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody); - this.unselect(selectedCells); - this.fireEvent("unselectEvent", {els:selectedCells}); -}; - - -/** - * Returns true if given element is select, false otherwise. - * - * @method isSelected - * @param el {element} HTML element reference. - * @return {boolean} True if element is selected. - */ -YAHOO.widget.DataTable.prototype.isSelected = function(el) { - return YAHOO.util.Dom.hasClass(el,YAHOO.widget.DataTable.CLASS_SELECTED); -}; - -/** - * Returns array of selected Record IDs. - * - * @method getSelectedRecordIds - * @return {HTMLElement[]} Array of selected TR elements. - */ -YAHOO.widget.DataTable.prototype.getSelectedRecordIds = function() { - return this._aSelectedRecords || []; -}; - -/** - * Returns array of selected rows. - * - * @method getSelectedRows - * @return {HTMLElement[]} Array of selected TR elements. - */ -YAHOO.widget.DataTable.prototype.getSelectedRows = function() { - //TODO: keep internal array if this is non performant - return YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody); -}; - -/** - * Returns array of selected TD cells. - * - * @method getSelectedCells - * @return {HTMLElement[]} Array of selected TD elements. - */ -YAHOO.widget.DataTable.prototype.getSelectedCells = function() { - //TODO: keep internal array - return YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody); -}; - -/** - * Returns pointer to the DataTable instance's ColumnSet instance. - * - * @method getColumnSet - * @return {YAHOO.widget.ColumnSet} ColumnSet instance. - */ -YAHOO.widget.DataTable.prototype.getColumnSet = function() { - return this._oColumnSet; -}; - -/** - * Returns pointer to the DataTable instance's RecordSet instance. - * - * @method getRecordSet - * @return {YAHOO.widget.RecordSet} RecordSet instance. - */ -YAHOO.widget.DataTable.prototype.getRecordSet = function() { - return this._oRecordSet; -}; - -/** - * Displays a specific page of a paginated DataTable. - * - * @method showPage - * @param nPage {Number} Which page. - */ -YAHOO.widget.DataTable.prototype.showPage = function(nPage) { - // Validate input - if(!nPage || isNaN(nPage) || (nPage < 1) || (nPage > this._totalPages)) { - nPage = 1; - } - this.pageCurrent = nPage; - this.paginateRows(); -}; - -/** - * If pagination is enabled, paginates all data in RecordSet and renders - * paginator UI, others renders normal TBODY without any paginator UI. - * - * @method paginateRows - */ -YAHOO.widget.DataTable.prototype.paginateRows = function() { - var i; - - // How many total Records - var recordsLength = this._oRecordSet.getLength(); - - // How many rows this page - var maxRows = (this.rowsPerPage < recordsLength) ? - this.rowsPerPage : recordsLength; - - // How many total pages - this._totalPages = Math.ceil(recordsLength / maxRows); - - // First row of this page - this.startRecordIndex = (this.pageCurrent-1) * this.rowsPerPage; - - // How many page links to display - var pageLinksLength = - ((this.pageLinksLength > 0) && (this.pageLinksLength < this._totalPages)) ? - this.pageLinksLength : this._totalPages; - - // First link of this page - this.pageLinksStart = (Math.ceil(this.pageCurrent/pageLinksLength-1) * pageLinksLength) + 1; - - // Show Records for this page - var pageRecords = this._oRecordSet.getRecords(this.startRecordIndex, this.rowsPerPage); - this.replaceRows(pageRecords); - - if(this.rowsPerPage < recordsLength) { - // Markup for page links - var isFirstPage = (this.pageCurrent == 1) ? true : false; - var isLastPage = (this.pageCurrent == this._totalPages) ? true : false; - var firstPageLink = (isFirstPage) ? - " <span class=\"" + YAHOO.widget.DataTable.CLASS_FIRSTPAGE + "\"><<</span> " : - " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_FIRSTLINK + "\"><<</a> "; - var prevPageLink = (isFirstPage) ? - " <span class=\"" + YAHOO.widget.DataTable.CLASS_PREVPAGE + "\"><</span> " : - " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_PREVLINK + "\"><</a> " ; - var nextPageLink = (isLastPage) ? - " <span class=\"" + YAHOO.widget.DataTable.CLASS_NEXTPAGE + "\">></span> " : - " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_NEXTLINK + "\">></a> " ; - var lastPageLink = (isLastPage) ? - " <span class=\"" + YAHOO.widget.DataTable.CLASS_LASTPAGE + "\">>></span> " : - " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_LASTLINK + "\">>></a> "; - var markup = firstPageLink + prevPageLink; - var maxLinks = (this.pageLinksStart+pageLinksLength < this._totalPages) ? - this.pageLinksStart+pageLinksLength-1 : this._totalPages; - for(i=this.pageLinksStart; i<=maxLinks; i++) { - if(i != this.pageCurrent) { - markup += " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_PAGELINK + "\">" + i + "</a> "; - } - else { - markup += " <span class=\"" + YAHOO.widget.DataTable.CLASS_CURRENTPAGE + "\">" + i + "</span>"; - } - } - markup += nextPageLink + lastPageLink; - - // Markup for rows-per-page dropdowns - var dropdown = this.rowsPerPageDropdown; - var select1, select2; - if(dropdown && (dropdown.constructor == Array) && (dropdown.length > 0)) { - select1 = document.createElement("select"); - select1.className = YAHOO.widget.DataTable.CLASS_PAGESELECT; - select2 = document.createElement("select"); - select2.className = YAHOO.widget.DataTable.CLASS_PAGESELECT; - - for(i=0; i<dropdown.length; i++) { - var option1 = document.createElement("option"); - var option2 = document.createElement("option"); - option1.value = dropdown[i]; - option2.value = dropdown[i]; - option1.innerHTML = dropdown[i]; - option2.innerHTML = dropdown[i]; - - if(this.rowsPerPage === dropdown[i]) { - option1.selected = true; - option2.selected = true; - } - option1 = select1.appendChild(option1); - option2 = select2.appendChild(option2); - } - } - - // Populate each pager container with markup - if(!this.pagers || (this.pagers.length === 0)) { - var pager1 = document.createElement("span"); - pager1.className = YAHOO.widget.DataTable.CLASS_PAGELINKS; - - var pager2 = document.createElement("span"); - pager2.className = YAHOO.widget.DataTable.CLASS_PAGELINKS; - - pager1 = this._elContainer.insertBefore(pager1, this._elTable); - select1 = (select1 === undefined) ? null : - this._elContainer.insertBefore(select1, this._elTable); - select2 = (select2 === undefined) ? null : - this._elContainer.insertBefore(select2, this._elTable.nextSibling); - pager2 = this._elContainer.insertBefore(pager2, this._elTable.nextSibling); - this.pagers = [ - {links:pager1,select:select1}, - {links:pager2,select:select2} - ]; - } - for(i=0; i<this.pagers.length; i++) { - this.pagers[i].links.innerHTML = markup; - YAHOO.util.Event.purgeElement(this.pagers[i].links); - if(this.pagers[i].select) { - YAHOO.util.Event.purgeElement(this.pagers[i].select); - } - this.pagers[i].innerHTML = markup; - YAHOO.util.Event.addListener(this.pagers[i].links,"click",this._onPagerClick,this); - if(this.pagers[i].select) { - YAHOO.util.Event.addListener(this.pagers[i].select,"change",this._onPagerSelect,this); - } - } - } - this.fireEvent("paginateEvent"); -}; - -/** - * Sort given column. - * - * @method sortColumn - * @param oColumn {YAHOO.widget.Column} Column to sort. TODO: accept the TH or TH.key - */ -YAHOO.widget.DataTable.prototype.sortColumn = function(oColumn) { - if(!oColumn) { - return; - } - if(!oColumn instanceof YAHOO.widget.Column) { - //TODO: Figure out the column based on TH ref or TH.key - return; - } - if(oColumn.sortable) { - // What is the default sort direction? - var sortDir = (oColumn.sortOptions && oColumn.sortOptions.defaultOrder) ? oColumn.sortOptions.defaultOrder : "asc"; - - //TODO: what if column doesn't have key? - // Is this column sorted already? - if(oColumn.key && this.sortedBy && (this.sortedBy.colKey == oColumn.key)) { - if(this.sortedBy.dir) { - sortDir = (this.sortedBy.dir == "asc") ? "desc" : "asc"; - } - else { - sortDir = (sortDir == "asc") ? "desc" : "asc"; - } - } - else if(!this.sortedBy) { - this.sortedBy = {}; - } - - // Define the sort handler function based on the direction - var sortFnc = null; - if((sortDir == "desc") && oColumn.sortOptions && oColumn.sortOptions.descFunction) { - sortFnc = oColumn.sortOptions.descFunction; - } - else if((sortDir == "asc") && oColumn.sortOptions && oColumn.sortOptions.ascFunction) { - sortFnc = oColumn.sortOptions.ascFunction; - } - - // Custom function was not provided so use the built-in sorter - // ONLY IF column key is defined - // TODO: use diff default functions based on column data type - // TODO: nested/cumulative/hierarchical sorting - if(!sortFnc && oColumn.key) { - var sorted; - sortFnc = function(a, b) { - if(sortDir == "desc") { - sorted = YAHOO.util.Sort.compareDesc(a[oColumn.key],b[oColumn.key]); - if(sorted === 0) { - return YAHOO.util.Sort.compareDesc(a.id,b.id); - } - else { - return sorted; - } - } - else { - sorted = YAHOO.util.Sort.compareAsc(a[oColumn.key],b[oColumn.key]); - if(sorted === 0) { - return YAHOO.util.Sort.compareAsc(a.id,b.id); - } - else { - return sorted; - } - } - }; - } - - if(sortFnc) { - // Do the actual sort - this._oRecordSet.sort(sortFnc); - - // Update the UI - this.paginateRows(); - - // Update classes - YAHOO.util.Dom.removeClass(this.sortedBy._id,YAHOO.widget.DataTable.CLASS_SORTEDBYASC); - YAHOO.util.Dom.removeClass(this.sortedBy._id,YAHOO.widget.DataTable.CLASS_SORTEDBYDESC); - var newClass = (sortDir == "asc") ? YAHOO.widget.DataTable.CLASS_SORTEDBYASC : YAHOO.widget.DataTable.CLASS_SORTEDBYDESC; - YAHOO.util.Dom.addClass(oColumn.getId(), newClass); - - // Keep track of currently sorted column - this.sortedBy.colKey = oColumn.key; - this.sortedBy.dir = sortDir; - this.sortedBy._id = oColumn.getId(); - - this.fireEvent("columnSortEvent",{column:oColumn,dir:sortDir}); - } - } - else { - //TODO - YAHOO.log("Column is not sortable", "info", this.toString()); - } -}; - -/** - * Shows editor for given cell. - * - * @method editCell - */ -YAHOO.widget.DataTable.prototype.editCell = function(elCell) { - if(elCell && !isNaN(elCell.columnIndex)) { - var column = this._oColumnSet.keys[elCell.columnIndex]; - if(column && column.editor) { - this.activeEditor = column.getEditor(elCell,this._oRecordSet.getRecord(elCell.parentNode.recordId)); - } - this._bFocused = true; - this.fireEvent("editorShowEvent",{target:elCell,column:column}); - } -}; - -/** - * Formats given cell. - * - * @method formatCell - */ -YAHOO.widget.DataTable.prototype.formatCell = function(elCell) { - if(elCell && !isNaN(elCell.columnIndex)) { - var column = this._oColumnSet.keys[elCell.columnIndex]; - column.format(elCell,this._oRecordSet.getRecord(elCell.parentNode.recordId)); - this.fireEvent("cellFormatEvent", {el:elCell}); - } -}; - - -///////////////////////////////////////////////////////////////////////////// -// -// Public Custom Event Handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Overridable custom event handler to sort column. - * - * @method onEventSortColumn - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventSortColumn = function(oArgs) { - var evt = oArgs.event; - var target = oArgs.target; - YAHOO.util.Event.stopEvent(evt); - - //TODO: traverse DOM to find a columnIndex, incl safety net if none exists - var columnIndex = target.columnIndex; - if(!isNaN(columnIndex)) { - this.sortColumn(this._oColumnSet.keys[columnIndex]); - } -}; - -/** - * Overridable custom event handler to select row. - * - * @method onEventSelectRow - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventSelectRow = function(oArgs) { - var i; - var evt = oArgs.event; - var target = oArgs.target; - - //TODO: add a safety net in case TR is never reached - // Walk up the DOM until we get to the TR - while(target.tagName.toLowerCase() != "tr") { - target = target.parentNode; - } - - if(this.isSelected(target)) { - this.unselect(target); - } - else { - if(this.rowSingleSelect && !evt.ctrlKey && !evt.shiftKey) { - this.unselectAllRows(); - } - if(evt.shiftKey) { - var startRow = this._lastSelected; - if(startRow && this.isSelected(startRow)) { - this.unselectAllRows(); - if(startRow.sectionRowIndex < target.sectionRowIndex) { - for(i=startRow.sectionRowIndex; i<=target.sectionRowIndex; i++) { - this.select(this._elBody.rows[i]); - } - } - else { - for(i=target.sectionRowIndex; i<=startRow.sectionRowIndex; i++) { - this.select(this._elBody.rows[i]); - } - } - } - else { - this.select(target); - } - } - else { - this.select(target); - } - } -}; - -/** - * Overridable custom event handler to select cell. - * - * @method onEventSelectCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventSelectCell = function(oArgs) { - var evt = oArgs.event; - var target = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(target.tagName.toLowerCase() != "td") { - target = target.parentNode; - } - - if(this.isSelected(target)) { - this.unselect(target); - } - else { - if(this.rowSingleSelect && !evt.ctrlKey) { - this.unselectAllCells(); - } - this.select(target); - } -}; - -/** - * Overridable custom event handler to format cell. - * - * @method onEventFormatCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventFormatCell = function(oArgs) { - var evt = oArgs.event; - var element = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(element.tagName.toLowerCase() != "td") { - element = element.parentNode; - } - - this.formatCell(element); -}; - -/** - * Overridable custom event handler to highlight cell. - * - * @method onEventHighlightCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventHighlightCell = function(oArgs) { - var evt = oArgs.event; - var element = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(element.tagName.toLowerCase() != "td") { - element = element.parentNode; - } - this.highlight(element); -}; - -/** - * Overridable custom event handler to unhighlight cell. - * - * @method onEventUnhighlightCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventUnhighlightCell = function(oArgs) { - var evt = oArgs.event; - var element = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(element.tagName.toLowerCase() != "td") { - element = element.parentNode; - } - - this.unhighlight(element); -}; -/** - * Overridable custom event handler to edit cell. - * - * @method onEventEditCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventEditCell = function(oArgs) { - var evt = oArgs.event; - var element = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(element.tagName.toLowerCase() != "td") { - element = element.parentNode; - } - - this.editCell(element); -}; - -/** - * Handles data return for adding new rows to table, including updating pagination. - * - * @method onDataReturnPaginateRows - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - */ -YAHOO.widget.DataTable.prototype.onDataReturnPaginateRows = function(sRequest, oResponse) { - this.fireEvent("dataReturnEvent", {request:sRequest,response:oResponse}); - - var ok = this.doBeforeLoadData(sRequest, oResponse); - if(ok) { - // Update the RecordSet from the response - var newRecords = this._oRecordSet.append(oResponse); - if(newRecords) { - // Update markup - this.paginateRows(); - YAHOO.log("Data returned for " + newRecords.length + " rows","info",this.toString()); - } - } -}; - -/** - * Handles data return for adding new rows to bottom of table. - * - * @method onDataReturnAppendRows - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - */ -YAHOO.widget.DataTable.prototype.onDataReturnAppendRows = function(sRequest, oResponse) { - this.fireEvent("dataReturnEvent", {request:sRequest,response:oResponse}); - - var ok = this.doBeforeLoadData(sRequest, oResponse); - if(ok) { - // Update the RecordSet from the response - var newRecords = this._oRecordSet.append(oResponse); - if(newRecords) { - // Update markup - this.appendRows(newRecords); - YAHOO.log("Data returned for " + newRecords.length + " rows","info",this.toString()); - } - } -}; - -/** - * Handles data return for inserting new rows to top of table. - * - * @method onDataReturnInsertRows - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - */ -YAHOO.widget.DataTable.prototype.onDataReturnInsertRows = function(sRequest, oResponse) { - this.fireEvent("dataReturnEvent", {request:sRequest,response:oResponse}); - - var ok = this.doBeforeLoadData(sRequest, oResponse); - if(ok) { - // Update the RecordSet from the response - var newRecords = this._oRecordSet.insert(oResponse); - if(newRecords) { - // Update markup - this.insertRows(newRecords); - YAHOO.log("Data returned for " + newRecords.length + " rows","info",this.toString()); - } - } -}; - -/** - * Handles data return for replacing all existing of table with new rows. - * - * @method onDataReturnReplaceRows - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - */ -YAHOO.widget.DataTable.prototype.onDataReturnReplaceRows = function(sRequest, oResponse) { - this.fireEvent("dataReturnEvent", {request:sRequest,response:oResponse}); - - var ok = this.doBeforeLoadData(sRequest, oResponse); - if(ok) { - // Update the RecordSet from the response - var newRecords = this._oRecordSet.replace(oResponse); - if(newRecords) { - this.replaceRows(newRecords); - YAHOO.log("Data returned for " + newRecords.length + " rows","info",this.toString()); - } - } -}; - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The ColumnSet class defines and manages a DataTable's Columns, - * including nested hierarchies and access to individual Column instances. - * - * @class ColumnSet - * @uses YAHOO.util.EventProvider - * @constructor - * @param aHeaders {Object[]} Array of object literals that define header cells. - */ -YAHOO.widget.ColumnSet = function(aHeaders) { -//TODO: break out nested functions into private methods - this._sName = "instance" + YAHOO.widget.ColumnSet._nCount; - - // Top-down tree representation of all Columns - var tree = []; - // Flat representation of all Columns - var flat = []; - // Flat representation of only Columns that display data - var keys = []; - // ID index of nested parent heirarchies for HEADERS attribute - var headers = []; - - var nodelevel = -1; - - // Internal recursive function to parse Columns out of object literal defs - var parseColumns = function(nodeList, parent) { - nodelevel++; - // A node level is an array of Columns - if(!tree[nodelevel]) { - tree[nodelevel] = []; - } - - // Determine depth of descendants at this level for node's rowspan - var nodeLevelMaxChildren = 0; - var recurseChildren = function(nodeList) { - var tmpMax = 0; - for(var i=0; i<nodeList.length; i++) { - if(nodeList[i].children) { - tmpMax++; - recurseChildren(nodeList[i].children); - } - if(tmpMax > nodeLevelMaxChildren) { - nodeLevelMaxChildren = tmpMax; - } - } - }; - recurseChildren(nodeList); - - // Parse each node for attributes and any children - for(var j=0; j<nodeList.length; j++) { - // Instantiate a Column for each node - var oColumn = new YAHOO.widget.Column(nodeList[j]); - flat.push(oColumn); - - // Assign parent, if applicable - if(parent) { - oColumn._parent = parent; - } - - // Start with default values - oColumn._rowspan = 1; - oColumn._colspan = 1; - - // Column may have children - if(nodeList[j].children) { - var children = nodeList[j].children; - var length = children.length; - - // Cascade certain properties to children if not defined on their own - for(var k=0; k<length; k++) { - var child = children[k]; - if(oColumn.className && (child.className === undefined)) { - child.className = oColumn.className; - } - if(oColumn.editor && (child.editor === undefined)) { - child.editor = oColumn.editor; - } - if(oColumn.formatter && (child.formatter === undefined)) { - child.formatter = oColumn.formatter; - } - if(oColumn.parser && (child.parser === undefined)) { - child.parser = oColumn.parser; - } - if(oColumn.resizeable && (child.resizeable === undefined)) { - child.resizeable = oColumn.resizeable; - } - if(oColumn.type && (child.type === undefined)) { - child.type = oColumn.type; - } - if(oColumn.width && (child.width === undefined)) { - child.width = oColumn.width; - } - } - - // Children increase colspan of the Column - oColumn._colspan = length; - - // Children increase colspan of the Column's parent - if (parent && parent._colspan) { - parent._colspan += length-1; - parent._children = []; - parent._children.push(oColumn); - } - - // Children must also be parsed - if(!tree[nodelevel+1]) { - tree[nodelevel+1] = []; - } - parseColumns(children, oColumn); - } - - // This Column does not have children, - // but other Columns at this level do - else if(nodeLevelMaxChildren > 0) { - // Children of siblings increase the rowspan of the Column - oColumn._rowspan += nodeLevelMaxChildren; - //if(oColumn.key) { - oColumn._index = keys.length; - keys.push(oColumn); - //} - } - // This entire node level does not have any children - else { - //if(oColumn.key) { - oColumn._index = keys.length; - keys.push(oColumn); - //} - } - - // Add the Column to the top-down tree - tree[nodelevel].push(oColumn); - } - nodelevel--; - }; - - // Do the parsing - if(aHeaders.length > 0) { - parseColumns(aHeaders); - } - - // Store header nesting in an array - var recurseAncestors = function(i, oColumn) { - headers[i].push(oColumn._id); - if(oColumn._parent) { - recurseAncestors(i, oColumn._parent); - } - }; - for(var i=0; i<keys.length; i++) { - headers[i] = []; - recurseAncestors(i, keys[i]); - headers[i] = headers[i].reverse(); - headers[i] = headers[i].join(" "); - } - - this.tree = tree; - this.flat = flat; - this.keys = keys; - this.headers = headers; - - YAHOO.widget.ColumnSet._nCount++; - YAHOO.log("ColumnSet initialized", "info", this.toString()); -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple data table instances. - * - * @property _nCount - * @type number - * @private - * @static - */ -YAHOO.widget.ColumnSet._nCount = 0; - -/** - * Unique instance name. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.ColumnSet.prototype._sName = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Top-down tree representation of Column hierarchy. - * - * @property tree - * @type YAHOO.widget.Column[] - */ -YAHOO.widget.ColumnSet.prototype.tree = null; - -/** - * Flattened representation of all Columns. - * - * @property flat - * @type YAHOO.widget.Column[] - * @default [] - */ -YAHOO.widget.ColumnSet.prototype.flat = null; - -/** - * Array of Columns that map one-to-one to a table column. - * - * @property keys - * @type YAHOO.widget.Column[] - * @default [] - */ -YAHOO.widget.ColumnSet.prototype.keys = null; - -/** - * ID index of nested parent heirarchies for HEADERS accessibility attribute. - * - * @property headers - * @type String[] - * @default [] - */ -YAHOO.widget.ColumnSet.prototype.headers = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor to the unique name of the ColumnSet instance. - * - * @method toString - * @return {String} Unique name of the ColumnSet instance. - */ - -YAHOO.widget.ColumnSet.prototype.toString = function() { - return "ColumnSet " + this._sName; -}; - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The Column class defines and manages attributes of DataTable Columns - * - * - * @class Column - * @constructor - * @param oConfigs {Object} Object literal of configuration values. - */ -YAHOO.widget.Column = function(oConfigs) { - // Internal variables - this._id = "yui-dtcol"+YAHOO.widget.Column._nCount; - - // Object literal defines Column attributes - if(typeof oConfigs == "object") { - for(var sConfig in oConfigs) { - if(sConfig) { - this[sConfig] = oConfigs[sConfig]; - } - } - } - - YAHOO.widget.Column._nCount++; -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal instance counter. - * - * @property _nCount - * @type Number - * @static - * @default 0 - */ -YAHOO.widget.Column._nCount = 0; - - -/** - * Unique ID, also assigned as DOM ID. - * - * @property _id - * @type String - * @private - */ -YAHOO.widget.Column.prototype._id = null; - -/** - * Reference to Column's index within its ColumnSet's key array, or null if not applicable. - * - * @property _index - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._index = null; - -/** - * Number of table cells the Column spans. - * - * @property _colspan - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._colspan = 1; - -/** - * Number of table rows the Column spans. - * - * @property _rowspan - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._rowspan = 1; - -/** - * Column's parent, or null. - * - * @property _parent - * @type YAHOO.widget.Column - * @private - */ -YAHOO.widget.Column.prototype._parent = null; - -/** - * Array of Column's chilren, or null. - * - * @property _children - * @type YAHOO.widget.Column[] - * @private - */ -YAHOO.widget.Column.prototype._children = null; - -//TODO: clean these up - -/** - * Current offsetWidth of the Column (in pixels). - * - * @property _width - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._width = null; - -/** - * Minimum width the Column can support (in pixels). Value is populated only if table - * is fixedwidth, null otherwise. - * - * @property _minWidth - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._minWidth = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Associated database field, or null. - * - * @property key - * @type String - */ -YAHOO.widget.Column.prototype.key = null; - -/** - * Text or HTML for display in Column's assocated TH element. - * - * @property text - * @type String - */ -YAHOO.widget.Column.prototype.text = null; - -/** - * Data types: "string", "number", "date", "currency", "checkbox", "select", - * "email", "link". - * - * @property type - * @type String - * @default "string" - */ -YAHOO.widget.Column.prototype.type = "string"; - -/** - * Column head cell ABBR for accessibility. - * - * @property abbr - * @type String - */ -YAHOO.widget.Column.prototype.abbr = null; - -/** - * Array of object literals that define children (nested headers) of a Column. - * - * @property children - * @type Object[] - */ -YAHOO.widget.Column.prototype.children = null; - -/** - * Column width. - * - * @property width - * @type String - */ -YAHOO.widget.Column.prototype.width = null; - -/** - * Custom CSS class to be applied to every cell in the Column. - * - * @property className - * @type String - */ -YAHOO.widget.Column.prototype.className = null; - -/** - * Defines a custom format function for Column, otherwise default is used, - * according to Column type. - * - * @property formatter - * @type HTMLFunction - */ -YAHOO.widget.Column.prototype.formatter = null; - -/** - * Defines a custom parse function for Column, otherwise default is used, - * according to Column type. - * - * @property parser - * @type HTMLFunction - */ -YAHOO.widget.Column.prototype.parser = null; - -/** - * Defines the type of editor for Column, otherwise Column is not editable. - * - * @property editor - * @type String - */ -YAHOO.widget.Column.prototype.editor = null; - -/** - * True if Column is resizeable, false otherwise. - * - * @property resizeable - * @type Boolean - * @default false - */ -YAHOO.widget.Column.prototype.resizeable = false; - -/** - * True if Column is sortable, false otherwise. - * - * @property sortable - * @type Boolean - * @default false - */ -YAHOO.widget.Column.prototype.sortable = false; - -/** - * Custom sort handler to arrange Column in descending order. - * - * @property sortOptions.descFunction - * @type Function - * @default null - */ -YAHOO.widget.Column.prototype.descFunction = null; - -/** - * Custom sort handler to arrange Column in ascending order. - * - * @property sortOptions.ascFunction - * @type Function - * @default null - */ -YAHOO.widget.Column.prototype.ascFunction = null; - - - - - - - - - - - - - - - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor returns Column's ID string. - * - * @method getId - * @return {String} Column's ID string. - */ -YAHOO.widget.Column.prototype.getId = function() { - return this._id; -}; - -/** - * Public accessor returns Column's colspan number. - * - * @method getColSpan - * @return {Number} Column's colspan number. - */ -YAHOO.widget.Column.prototype.getColSpan = function() { - return this._colspan; -}; - -/** - * Public accessor returns Column's rowspan number. - * - * @method getRowSpan - * @return {Number} Column's rowspan number. - */ -YAHOO.widget.Column.prototype.getRowSpan = function() { - return this._rowspan; -}; - - -/** - * Outputs markup into the given TD based on given Record. - * - * @method format - * @param elCell {HTMLElement} TD to format for display. - * @param oRecord {YAHOO.widget.Record} Record that holds data for the row. - * @return {HTML} Markup. - */ -YAHOO.widget.Column.prototype.format = function(elCell,oRecord) { - var oData = (this.key) ? oRecord[this.key] : null; - if(this.formatter) { - this.formatter(elCell, oRecord, this, oData); - } - else { - var type = this.type; - var markup = ""; - var classname = ""; - switch(type) { - case "checkbox": - YAHOO.widget.Column.formatCheckbox(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_CHECKBOX; - break; - case "currency": - YAHOO.widget.Column.formatCurrency(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_CURRENCY; - break; - case "date": - YAHOO.widget.Column.formatDate(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_DATE; - break; - case "email": - YAHOO.widget.Column.formatEmail(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_EMAIL; - break; - case "link": - YAHOO.widget.Column.formatLink(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_LINK; - break; - case "number": - YAHOO.widget.Column.formatNumber(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_NUMBER; - break; - case "select": - YAHOO.widget.Column.formatSelect(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_SELECT; - break; - default: - elCell.innerHTML = (oData) ? oData.toString() : ""; - //elCell.innerHTML = (oData) ? "<a href=\"#\">"+oData.toString()+"</a>" : ""; - classname = YAHOO.widget.DataTable.CLASS_STRING; - break; - } - - YAHOO.util.Dom.addClass(elCell, classname); - if(this.className) { - YAHOO.util.Dom.addClass(elCell, this.className); - } - } - - if(this.editor) { - YAHOO.util.Dom.addClass(elCell,YAHOO.widget.DataTable.CLASS_EDITABLE); - } -}; - - -/** - * Formats cells in Columns of type "checkbox". - * - * @method formatCheckbox - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatCheckbox = function(elCell, oRecord, oColumn, oData) { - var bChecked = oData; - bChecked = (bChecked) ? " checked" : ""; - elCell.innerHTML = "<input type=\"checkbox\"" + bChecked + - " class=\"" + YAHOO.widget.DataTable.CLASS_CHECKBOX + "\">"; -}; - -/** - * Formats cells in Columns of type "currency". Can be overridden for custom formatting. - * - * @method formatCurrency - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatCurrency = function(elCell, oRecord, oColumn, oData) { - // Make it dollars - var nAmount = oData; - var markup; - if(nAmount) { - markup = "$"+nAmount; - - // Normalize to the penny - var dotIndex = markup.indexOf("."); - if(dotIndex < 0) { - markup += ".00"; - } - else { - while(dotIndex != markup.length-3) { - markup += "0"; - } - } - } - else { - markup = ""; - } - elCell.innerHTML = markup; -}; - -/** - * Formats cells in Columns of type "date". - * - * @method formatDate - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatDate = function(elCell, oRecord, oColumn, oData) { - var oDate = oData; - if(oDate) { - elCell.innerHTML = oDate.getMonth() + "/" + oDate.getDate() + "/" + oDate.getFullYear(); - } - else { - elCell.innerHTML = ""; - } -}; - -/** - * Formats cells in Columns of type "email". - * - * @method formatEmail - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatEmail = function(elCell, oRecord, oColumn, oData) { - var sEmail = oData; - if(sEmail) { - elCell.innerHTML = "<a href=\"mailto:" + sEmail + "\">" + sEmail + "</a>"; - } - else { - elCell.innerHTML = ""; - } -}; - -/** - * Formats cells in Columns of type "link". - * - * @method formatLink - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatLink = function(elCell, oRecord, oColumn, oData) { - var sLink = oData; - if(sLink) { - elCell.innerHTML = "<a href=\"" + sLink + "\">" + sLink + "</a>"; - } - else { - elCell.innerHTML = ""; - } -}; - -/** - * Formats cells in Columns of type "number". - * - * @method formatNumber - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatNumber = function(elCell, oRecord, oColumn, oData) { - var nNumber = oData; - if(nNumber) { - elCell.innerHTML = nNumber.toString(); - } - else { - elCell.innerHTML = ""; - } -}; - -/** - * Formats cells in Columns of type "select". - * - * @method formatSelect - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatSelect = function(elCell, oRecord, oColumn, oData) { - var selectedValue = oData; - var options = oColumn.selectOptions; - - var markup = "<select>"; - if(options) { - for(var i=0; i<options.length; i++) { - var option = options[i]; - markup += "<option value=\"" + option + "\""; - if(selectedValue === option) { - markup += " selected"; - } - markup += ">" + option + "</option>"; - } - } - else { - if(selectedValue) { - markup += "<option value=\"" + selectedValue + "\" selected>" + selectedValue + "</option>"; - } - } - markup += "</select>"; - elCell.innerHTML = markup; -}; - -/** - * Takes innerHTML from TD and parses out data for storage in RecordSet. - * - * @method parse - * @param sMarkup {String} The TD's innerHTML value. - * @return {Object} Data. - */ -YAHOO.widget.Column.prototype.parse = function(sMarkup) { - if(this.parser) { - return this.parser(sMarkup); - } - else { - var data = null; - switch(this.type) { - case "checkbox": - data = YAHOO.widget.Column.parseCheckbox(sMarkup); - break; - case "currency": - data = YAHOO.widget.Column.parseCurrency(sMarkup); - break; - case "date": - data = YAHOO.widget.Column.parseDate(sMarkup); - break; - case "number": - data = YAHOO.widget.Column.parseNumber(sMarkup); - break; - case "select": - data = YAHOO.widget.Column.parseSelect(sMarkup); - break; - default: - if(sMarkup) { - data = sMarkup; - } - break; - } - return data; - } -}; - -/** - * Default parse function for Columns of type "checkbox" takes markup and - * extracts data. Can be overridden for custom parsing. - * - * @method parseCheckbox - * @param sMarkup - * @return {bChecked} True if checkbox is checked. - */ -YAHOO.widget.Column.parseCheckbox = function(sMarkup) { - return (sMarkup.indexOf("checked") < 0) ? false : true; -}; - -/** - * Default parse function for Columns of type "currency" takes markup and - * extracts data. Can be overridden for custom parsing. - * - * @method parseCurrency - * @param sMarkup - * @return {nAmount} Floating point amount. - */ -YAHOO.widget.Column.parseCurrency = function(sMarkup) { - return parseFloat(sMarkup.substring(1)); -}; - -/** - * Default parse function for Columns of type "date" takes markup and extracts - * data. Can be overridden for custom parsing. - * - * @method parseDate - * @param sMarkup - * @return {oDate} Date instance. - */ -YAHOO.widget.Column.parseDate = function(sMarkup) { - var mm = sMarkup.substring(0,sMarkup.indexOf("/")); - sMarkup = sMarkup.substring(sMarkup.indexOf("/")+1); - var dd = sMarkup.substring(0,sMarkup.indexOf("/")); - var yy = sMarkup.substring(sMarkup.indexOf("/")+1); - return new Date(yy, mm, dd); -}; - -/** - * Default parse function for Columns of type "number" takes markup and extracts - * data. Can be overridden for custom parsing. - * - * @method parseNumber - * @param sMarkup - * @return {nNumber} Number. - */ -YAHOO.widget.Column.parseNumber = function(sMarkup) { - return parseFloat(sMarkup); -}; - -/** - * Default parse function for Columns of type "select" takes markup and extracts - * data. Can be overridden for custom parsing. - * - * @method parseSelect - * @param sMarkup - * @return {sValue} Value of selected option. - */ -YAHOO.widget.Column.parseSelect = function(sMarkup) { - //return (sMarkup.indexOf("checked") < 0) ? false : true; -}; - -/** - * Outputs editor markup into the given TD based on given Record. - * - * @method showEditor - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @return YAHOO.widget.ColumnEditor - */ -YAHOO.widget.Column.prototype.getEditor = function(elCell, oRecord) { -//Sync up the arg signature for ColumnEditor constructor and show() - var oEditor = this.editor; - if(oEditor.constructor == String) { - oEditor = new YAHOO.widget.ColumnEditor(this.editor); - oEditor.show(elCell, oRecord, this); - this.editor = oEditor; - } - else if(oEditor instanceof YAHOO.widget.ColumnEditor) { - oEditor.show(elCell, oRecord, this); - } - return oEditor; -}; - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The ColumnEditor defines and manages inline editing functionality for a - * DataTable Column. - * - * @class ColumnEditor - * @constructor - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @param oColumn {YAHOO.widget.Column} The DataTable Column of the cell. - * @parem sType {String} Type identifier - */ -YAHOO.widget.ColumnEditor = function(sType) { - this.type = sType; - - //TODO: make sure ColumnEditors get destroyed if widget gets destroyed - // Works better to attach ColumnEditor to document.body - // rather than the DataTable container - // elTable comes in as a cell. Traverse up DOM to find the table. - // TODO: safety net in case table is never found. - //while(elCell.nodeName.toLowerCase() != "table") { - // elCell = elCell.parentNode; - //} - //this.tableContainer = elCell.parentNode; - - var container = document.body.appendChild(document.createElement("div"));//this.tableContainer.appendChild(document.createElement("div")); - container.style.position = "absolute"; - container.style.zIndex = 9000; - container.id = "yui-dt-coled" + YAHOO.widget.ColumnEditor._nCount; - this.container = container; - - switch(this.type) { - case "textbox": - this.createTextboxEditor(); - break; - case "textarea": - this.createTextareaEditor(); - break; - default: - break; - } - - YAHOO.widget.ColumnEditor._nCount++; -}; - - - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal instance counter. - * - * @property _nCount - * @type Number - * @static - * @default 0 - */ -YAHOO.widget.ColumnEditor._nCount =0; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Reference to the container DOM element for the ColumnEditor. - * - * @property container - * @type HTMLElement - */ -YAHOO.widget.ColumnEditor.prototype.container = null; - -/** - * Reference to the ColumnEditor's Column instance. - * - * @property column - * @type YAHOO.widget.Column - */ -YAHOO.widget.ColumnEditor.prototype.column = null; - -/** - * Type of editor: "textbox", etc. - * - * @property type - * @type String - */ -YAHOO.widget.ColumnEditor.prototype.type = null; - - - -/** - * Reference to form element(s) of the ColumnEditor. - * - * @property input - * @type HTMLElement || HTMLElement[] - */ -YAHOO.widget.ColumnEditor.prototype.input = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Shows ColumnEditor. - * - * @method show - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @param oColumn {YAHOO.widget.Column} The DataTable Column of the cell. - */ -YAHOO.widget.ColumnEditor.prototype.show = function(elCell, oRecord, oColumn) { - this.cell = elCell; - this.record = oRecord; - this.column = oColumn; - switch(this.type) { - case "textbox": - this.showTextboxEditor(elCell, oRecord, oColumn); - break; - case "textarea": - this.showTextareaEditor(elCell, oRecord, oColumn); - break; - default: - break; - } -}; - -/** - * Returns ColumnEditor data value. - * - * @method getValue - * @return Object - */ -YAHOO.widget.ColumnEditor.prototype.getValue = function() { - var value; - switch(this.type) { - case "textbox": - value = this.getTextboxEditorValue(); - break; - case "textarea": - value = this.getTextareaEditorValue(); - break; - default: - break; - } - return value; -}; - -/** - * Creates a textbox editor in the DOM. - * - * @method createTextboxEditor - * @return {HTML} ??? - */ -YAHOO.widget.ColumnEditor.prototype.createTextboxEditor = function() { - var elTextbox = this.container.appendChild(document.createElement("input")); - // For FF bug 236791 - elTextbox.setAttribute("autocomplete","off"); - this.input = elTextbox; -}; - -/** - * Creates a textarea editor in the DOM. - * - * @method createTextareaEditor - * @return {HTML} ??? - */ -YAHOO.widget.ColumnEditor.prototype.createTextareaEditor = function() { - var elTextarea = this.container.appendChild(document.createElement("textarea")); - this.input = elTextarea; -}; - -/** - * Shows ColumnEditor - * - * @method showTextboxEditor - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @param oColumn {YAHOO.widget.Column} The DataTable Column of the cell. - */ -YAHOO.widget.ColumnEditor.prototype.showTextboxEditor = function(elCell, oRecord, oColumn) { - // Size and value - this.input.style.width = (parseInt(elCell.offsetWidth,10)-7) + "px"; - this.input.style.height = (parseInt(elCell.offsetHeight,10)-7) + "px"; - this.input.value = elCell.innerHTML; - - // Position and show - var x,y; - - // Don't use getXY for Opera - if(navigator.userAgent.toLowerCase().indexOf("opera") != -1) { - x = elCell.offsetLeft; - y = elCell.offsetTop; - while(elCell.offsetParent) { - x += elCell.offsetParent.offsetLeft; - y += elCell.offsetParent.offsetTop; - elCell = elCell.offsetParent; - } - } - else { - var xy = YAHOO.util.Dom.getXY(elCell); - x = parseInt(YAHOO.util.Dom.getX(elCell),10);//xy[0] + 1; - y = parseInt(YAHOO.util.Dom.getY(elCell),10);//xy[1] + 1; - } - this.container.style.left = x + "px"; - this.container.style.top = y + "px"; - this.container.style.display = "block"; - - this.input.tabIndex = 0; - this.input.focus(); - this.input.select(); -}; - -/** - * Shows ColumnEditor - * - * @method showTextareaEditor - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @param oColumn {YAHOO.widget.Column} The DataTable Column of the cell. - */ -YAHOO.widget.ColumnEditor.prototype.showTextareaEditor = function(elCell, oRecord, oColumn) { - // Size and value - this.input.style.width = (parseInt(elCell.offsetWidth,10)-7) + "px"; - this.input.style.height = 4*(parseInt(elCell.offsetHeight,10)-7) + "px"; - this.input.value = elCell.innerHTML; - - // Position and show - var x,y; - - // Don't use getXY for Opera - if(navigator.userAgent.toLowerCase().indexOf("opera") != -1) { - x = elCell.offsetLeft; - y = elCell.offsetTop; - while(elCell.offsetParent) { - x += elCell.offsetParent.offsetLeft; - y += elCell.offsetParent.offsetTop; - elCell = elCell.offsetParent; - } - } - else { - var xy = YAHOO.util.Dom.getXY(elCell); - x = parseInt(YAHOO.util.Dom.getX(elCell),10);//xy[0] + 1; - y = parseInt(YAHOO.util.Dom.getY(elCell),10);//xy[1] + 1; - } - this.container.style.left = x + "px"; - this.container.style.top = y + "px"; - this.container.style.display = "block"; - - this.input.tabIndex = 0; - this.input.focus(); - this.input.select(); -}; - -/** - * Hides ColumnEditor - * - * @method hide - */ -YAHOO.widget.ColumnEditor.prototype.hide = function() { - this.input.tabIndex = -1; - this.container.style.display = "none"; -}; - -/** - * Returns ColumnEditor value - * - * @method getTextboxEditorValue - * @return String - */ -YAHOO.widget.ColumnEditor.prototype.getTextboxEditorValue = function() { - return this.input.value; -}; - -/** - * Returns ColumnEditor value - * - * @method getTextareaEditorValue - * @return String - */ -YAHOO.widget.ColumnEditor.prototype.getTextareaEditorValue = function() { - return this.input.value; -}; - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * Sort static utility to support Column sorting. - * - * @class Sort - * @static - */ -YAHOO.util.Sort = { - ///////////////////////////////////////////////////////////////////////////// - // - // Public methods - // - ///////////////////////////////////////////////////////////////////////////// - - /** - * Comparator function for sort in ascending order. String sorting is case insensitive. - * - * @method compareAsc - * @param a {object} First sort argument. - * @param b {object} Second sort argument. - */ - compareAsc: function(a, b) { - //TODO: is typeof better or is constructor property better? - if(a.constructor == String) { - a = a.toLowerCase(); - } - if(b.constructor == String) { - b = b.toLowerCase(); - } - if(a < b) { - return -1; - } - else if (a > b) { - return 1; - } - else { - return 0; - } - }, - - /** - * Comparator function for sort in descending order. String sorting is case insensitive. - * - * @method compareDesc - * @param a {object} First sort argument. - * @param b {object} Second sort argument. - */ - compareDesc: function(a, b) { - //TODO: is typeof better or is constructor property better? - if(a.constructor == String) { - a = a.toLowerCase(); - } - if(b.constructor == String) { - b = b.toLowerCase(); - } - if(a < b) { - return 1; - } - else if (a > b) { - return -1; - } - else { - return 0; - } - } -}; - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * WidthResizer subclasses DragDrop to support resizeable Columns. - * - * @class WidthResizer - * @extends YAHOO.util.DragDrop - * @constructor - * @param colElId {string} ID of the Column's TH element being resized - * @param handleElId {string} ID of the handle element that causes the resize - * @param sGroup {string} Group name of related DragDrop items - */ -YAHOO.util.WidthResizer = function(oDataTable, colId, handleId, sGroup, config) { - if (colId) { - this.cell = YAHOO.util.Dom.get(colId); - this.init(handleId, sGroup, config); - //this.initFrame(); - this.datatable = oDataTable; - this.setYConstraint(0,0); - } - else { - YAHOO.log("Column resizer could not be created due to invalid colElId","warn"); - } -}; - -if(YAHOO.util.DD) { - YAHOO.extend(YAHOO.util.WidthResizer, YAHOO.util.DD); -} - -///////////////////////////////////////////////////////////////////////////// -// -// Public DOM event handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Handles mousedown events on the Column resizer. - * - * @method onMouseDown - * @param e {string} The mousedown event - */ -YAHOO.util.WidthResizer.prototype.onMouseDown = function(e) { - this.startWidth = this.cell.offsetWidth; - this.startPos = YAHOO.util.Dom.getX(this.getDragEl()); - - if(this.datatable.fixedwidth) { - var cellText = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_COLUMNTEXT,"span",this.cell)[0]; - this.minWidth = cellText.offsetWidth + 6; - var sib = this.cell.nextSibling; - var sibCellText = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_COLUMNTEXT,"span",sib)[0]; - this.sibMinWidth = sibCellText.offsetWidth + 6; -//!! - var left = ((this.startWidth - this.minWidth) < 0) ? 0 : (this.startWidth - this.minWidth); - var right = ((sib.offsetWidth - this.sibMinWidth) < 0) ? 0 : (sib.offsetWidth - this.sibMinWidth); - this.setXConstraint(left, right); - YAHOO.log("cellstartwidth:" + this.startWidth,"time"); - YAHOO.log("cellminwidth:" + this.minWidth,"time"); - YAHOO.log("sibstartwidth:" + sib.offsetWidth,"time"); - YAHOO.log("sibminwidth:" + this.sibMinWidth,"time"); - YAHOO.log("l:" + left + " AND r:" + right,"time"); - } - -}; - -/** - * Handles mouseup events on the Column resizer. - * - * @method onMouseUp - * @param e {string} The mouseup event - */ -YAHOO.util.WidthResizer.prototype.onMouseUp = function(e) { - //TODO: replace the resizer where it belongs: - var resizeStyle = YAHOO.util.Dom.get(this.handleElId).style; - resizeStyle.left = "auto"; - resizeStyle.right = 0; - resizeStyle.marginRight = "-6px"; - resizeStyle.width = "6px"; - //.yui-dt-headresizer {position:absolute;margin-right:-6px;right:0;bottom:0;width:6px;height:100%;cursor:w-resize;cursor:col-resize;} - - - //var cells = this.datatable._elTable.tHead.rows[this.datatable._elTable.tHead.rows.length-1].cells; - //for(var i=0; i<cells.length; i++) { - //cells[i].style.width = "5px"; - //} - - //TODO: set new ColumnSet width values - this.datatable.fireEvent("columnResizeEvent",{datatable:this.datatable,target:YAHOO.util.Dom.get(this.id)}); -}; - -/** - * Handles drag events on the Column resizer. - * - * @method onDrag - * @param e {string} The drag event - */ -YAHOO.util.WidthResizer.prototype.onDrag = function(e) { - var newPos = YAHOO.util.Dom.getX(this.getDragEl());//YAHOO.log("newpos:"+newPos,"warn");//YAHOO.util.Event.getPageX(e); - var offsetX = newPos - this.startPos;//YAHOO.log("offset:"+offsetX,"warn"); - //YAHOO.log("startwidth:"+this.startWidth + " and offset:"+offsetX,"warn"); - var newWidth = this.startWidth + offsetX;//YAHOO.log("newwidth:"+newWidth,"warn"); - - if(newWidth < this.minWidth) { - newWidth = this.minWidth; - } - - // Resize the Column - var oDataTable = this.datatable; - var elCell = this.cell; - - //YAHOO.log("newwidth" + newWidth,"warn"); - //YAHOO.log(newWidth + " AND "+ elColumn.offsetWidth + " AND " + elColumn.id,"warn"); - - // Resize the other Columns - if(oDataTable.fixedwidth) { - // Moving right or left? - var sib = elCell.nextSibling; - //var sibIndex = elCell.index + 1; - var sibnewwidth = sib.offsetWidth - offsetX; - if(sibnewwidth < this.sibMinWidth) { - sibnewwidth = this.sibMinWidth; - } - - //TODO: how else to cycle through all the Columns without having to use an index property? - for(var i=0; i<oDataTable._oColumnSet.length; i++) { - if((i != elCell.index) && (i!=sibIndex)) { - YAHOO.util.Dom.get(oDataTable._oColumnSet.keys[i].id).style.width = oDataTable._oColumnSet.keys[i].width + "px"; - } - } - sib.style.width = sibnewwidth; - elCell.style.width = newWidth + "px"; - //oDataTable._oColumnSet.flat[sibIndex].width = sibnewwidth; - //oDataTable._oColumnSet.flat[elCell.index].width = newWidth; - - } - else { - elCell.style.width = newWidth + "px"; - } -}; - - - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * A RecordSet defines and manages a set of Records. - * - * @class RecordSet - * @param data {Object || Object[]} An object literal or an array of data. - * @constructor - */ -YAHOO.widget.RecordSet = function(data) { - // Internal variables - this._nIndex = YAHOO.widget.RecordSet._nCount; - this._records = []; - - if(data) { - if(data.constructor == Array) { - this.addRecords(data); - } - else if(data.constructor == Object) { - this.addRecord(data); - } - } - - /** - * Fired when a Record is updated with new data. - * - * @event recordUpdateEvent - * @param oArgs.record {YAHOO.widget.Record} The Record instance. - * @param oArgs.key {String} The Record key. - * @param oArgs.newData {Object} New data. - * @param oArgs.oldData {Object} Old data. - * - */ - this.createEvent("recordUpdateEvent"); - - - YAHOO.widget.RecordSet._nCount++; - YAHOO.log("RecordSet initialized", "info", this.toString()); -}; - -if(YAHOO.util.EventProvider) { - YAHOO.augment(YAHOO.widget.RecordSet, YAHOO.util.EventProvider); -} -else { - YAHOO.log("Missing dependency: YAHOO.util.EventProvider","error",this.toString()); -} - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// -/** - * Internal class variable to index multiple data table instances. - * - * @property _nCount - * @type number - * @private - * @static - */ -YAHOO.widget.RecordSet._nCount = 0; - -/** - * Instance index. - * - * @property _nIndex - * @type number - * @private - */ -YAHOO.widget.RecordSet.prototype._nIndex = null; - -/** - * Internal counter of how many records are in the RecordSet - * - * @property _length - * @private - */ -YAHOO.widget.RecordSet.prototype._length = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor to the unique name of the RecordSet instance. - * - * @method toString - * @return {string} Unique name of the RecordSet instance - */ -YAHOO.widget.RecordSet.prototype.toString = function() { - return "RecordSet instance " + this._nIndex; -}; - -/** - * Returns the number of non-null records in the sparse RecordSet - * - * @method getLength - * @return {Number} Number records in the RecordSet - */ -YAHOO.widget.RecordSet.prototype.getLength = function() { - return this._length; -}; - -/** - * Returns record with given name, at the given index, or null. - * - * @method getRecord - * @param identifier {String || Number} Record ID or record index - * @return {Object} Record object - */ -YAHOO.widget.RecordSet.prototype.getRecord = function(identifier) { - if(identifier) { - if(identifier.constructor == String) { - for(var i=0; i<this._records.length; i++) { - if(this._records[i].id == identifier) { - return this._records[i]; - } - } - return null; - } - else { - return this._records[identifier]; - } - } - return null; -}; - -/** - * Returns an array of Records from the RecordSet. - * - * @method getRecords - * @param i {number} Index of which record to start at - * @param range {number} (optional) Number of records to get - * @return {Array} Array of records starting at given index and lenth equal to - * given range. If range is null, entire RecordSet array is returned. - */ -YAHOO.widget.RecordSet.prototype.getRecords = function(i, range) { - if(i === undefined) { - return this._records; - } - i = parseInt(i,10); - if(isNaN(i)) { - return null; - } - if(range === undefined) { - return this._records.slice(i); - } - range = parseInt(range,10); - if(isNaN(range)) { - return null; - } - return this._records.slice(i, i+range); -}; - -/** - * Returns index for the given record. - * - * @method getRecordIndex - * @param oRecord {object} Record object - * @return {number} index - */ - -/*YAHOO.widget.RecordSet.prototype.getRecordIndex = function(oRecord) { - //TODO: return i; -};*/ - -/** - * Returns the record(2) with the given value at the given key. - * - * @method getRecordBy - * @param sKey {String} Key to search. - * @param oValue {Object} to match against. - * @return {YAHOO.widget.Record || YAHOO.widget.Record[]} Record or array of - * Records with the given value at the given key, or null. - */ -/*YAHOO.widget.RecordSet.prototype.getRecordBy = function(sKey, oValue) { - TODO: redo to match new algorithm - var record = null; - var length = this._records.length; - for(var i=length-1; i>0; i--) { - record = this._records[i]; - if(record && (record.extid == extId)) { - return record; - } - } - return null; - -};*/ - -/** - * Updates given Record at given key with given data. - * - * @method updateRecord - * @param oRecord {YAHOO.widget.Record} A Record instance. - * @param sKey {String} Key. - * @param oData {Object) New data. - */ -YAHOO.widget.RecordSet.prototype.updateRecord = function(oRecord, sKey, oData) { - var oldData = oRecord[sKey]; - oRecord[sKey] = oData; - this.fireEvent("recordUpdateEvent",{record:oRecord,key:sKey,newData:oData,oldData:oldData}); -}; - -/** - * Adds one Record to the RecordSet at the given index. If index is null, - * then adds the Record to the end of the RecordSet. - * - * @method addRecord - * @param oObjectLiteral {Object} An object literal of data. - * @param index {Number} (optional) Position index. - * @return {YAHOO.widget.Record} A Record instance. - */ -YAHOO.widget.RecordSet.prototype.addRecord = function(oObjectLiteral, index) { - if(oObjectLiteral) { - var oRecord = new YAHOO.widget.Record(oObjectLiteral); - if(!isNaN(index) && (index > -1)) { - this._records.splice(index,0,oRecord); - } - else { - this._records.push(oRecord); - } - this._length++; - return oRecord; - } - else { - return null; - } -}; - -/** - * Adds multiple Records to the RecordSet at the given index. If index is null, - * then adds the Records to the end of the RecordSet. - * - * @method addRecords - * @param data {Object[]} An array of object literal data. - * @param index {Number} (optional) Position index. - * @return {YAHOO.widget.Record} An array of Record instances. - */ -YAHOO.widget.RecordSet.prototype.addRecords = function(data, index) { - if(data) { - if(data.constructor == Array) { - var newRecords = []; - // Can't go backwards bc we need to preserve order - for(var i=0; i<data.length; i++) { - var record = this.addRecord(data[i], index); - newRecords.push(record); - } - return newRecords; - } - else if(data.constructor == Object) { - return this.addRecord(data); - } - } - else { - return null; - } -}; - -/** - * Convenience method to append the given data to the end of the RecordSet. - * - * @method append - * @param data {Object || Object[]} An object literal or array of data. - * @return {YAHOO.widget.Record || YAHOO.widget.Record[]} A Record or array of Records. - */ -YAHOO.widget.RecordSet.prototype.append = function(data) { - if(data) { - if(data.constructor == Array) { - var newRecords = []; - // Cant't go backwards bc we need to preserve order - for(var i=0; i<data.length; i++) { - var record = this.addRecord(data[i]); - newRecords.push(record); - } - return newRecords; - } - else if(data.constructor == Object) { - return this.addRecord(data); - } - } - else { - return null; - } - -}; - -/** - * Convenience method to insert the given data into the beginning of the RecordSet. - * - * @method insert - * @param data {Object || Object[]} An object literal or array of data. - * @return {YAHOO.widget.Record || YAHOO.widget.Record[]} A Record or array of Records. - */ -YAHOO.widget.RecordSet.prototype.insert = function(data) { - if(data) { - if(data.constructor == Array) { - var newRecords = []; - // Can't go backwards bc we need to preserve order - for(var i=data.length-1; i>-1; i--) { - var record = this.addRecord(data[i], 0); - newRecords.push(record); - } - return newRecords; - } - else if(data.constructor == Object) { - return this.addRecord(data, 0); - } - } - else { - return null; - } -}; - -/** - * Replaces all Records in RecordSet with new data. - * - * @method replace - * @param data {Object || Object[]} An object literal or array or data. - * @return {YAHOO.widget.Record || YAHOO.widget.Record[]} A Record or array of Records. - */ -YAHOO.widget.RecordSet.prototype.replace = function(data) { - if(data) { - this.reset(); - return this.append(data); - } - else { - return null; - } -}; - -/** - * Sorts RecordSet by given function. - * - * @method sort - * @param fnSort {Function} Reference to a sort function. - * @return {Array} Sorted array of Records - */ -YAHOO.widget.RecordSet.prototype.sort = function(fnSort) { - return this._records.sort(fnSort); -}; - - -/** - * Removes the record at the given index from the RecordSet. If a range is - * given, starts at the given index and removes all records in the range. - * - * @method deleteRecord - * @param i {Number} Record index - * @param range {Number} (optional) Range of records to remove, or null. - */ -YAHOO.widget.RecordSet.prototype.deleteRecord = function(i, range) { - if(!range || isNaN(range)) { - range = 1; - } - if(i && !isNaN(i)) { - this._records.splice(i, range); - this._length = this._length - range; - } -}; - -/** - * Removes all Records from the RecordSet. - * - * @method reset - */ -YAHOO.widget.RecordSet.prototype.reset = function() { - this._records = []; - this._length = 0; -}; - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The Record class defines a DataTable record. - * - * @class Record - * @constructor - * @param oConfigs {Object} (optional) Object literal of key/value pairs. - */ -YAHOO.widget.Record = function(oLiteral) { - if(typeof oLiteral == "object") { - for(var sKey in oLiteral) { - if(sKey) { - this[sKey] = oLiteral[sKey]; - } - } - } - this.id = "yui-dtrec"+YAHOO.widget.Record._nCount; - YAHOO.widget.Record._nCount++; -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple data table instances. - * - * @property _nCount - * @type number - * @private - * @static - */ -YAHOO.widget.Record._nCount = 0; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Unique name assigned at instantation, indicates original order. - * - * @property id - * @type string - */ -YAHOO.widget.Record.prototype.id = null; - -YAHOO.register("datatable", YAHOO.widget.DataTable, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/datatable/datatable-beta-min.js b/interface/web/js/yui/datatable/datatable-beta-min.js deleted file mode 100644 index f63a73244e..0000000000 --- a/interface/web/js/yui/datatable/datatable-beta-min.js +++ /dev/null @@ -1,214 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -YAHOO.widget.DataTable=function(elContainer,oColumnSet,oDataSource,oConfigs){var i;this._nIndex=YAHOO.widget.DataTable._nCount;this._sName="instance"+this._nIndex;this.id="yui-dt"+this._nIndex;if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}} -if(oDataSource){if(oDataSource instanceof YAHOO.util.DataSource){this.dataSource=oDataSource;} -else{}} -if(oColumnSet&&(oColumnSet instanceof YAHOO.widget.ColumnSet)){this._oColumnSet=oColumnSet;} -else{return;} -this._oRecordSet=new YAHOO.widget.RecordSet();elContainer=YAHOO.util.Dom.get(elContainer);if(elContainer&&elContainer.tagName&&(elContainer.tagName.toLowerCase()=="div")){this._elContainer=elContainer;var elTable=null;if(elContainer.hasChildNodes()){var children=elContainer.childNodes;for(i=0;i<children.length;i++){if(children[i].tagName&&children[i].tagName.toLowerCase()=="table"){elTable=children[i];break;}}} -if(elTable&&!this.dataSource){var aRecords=[];for(i=0;i<elTable.tBodies.length;i++){var elBody=elTable.tBodies[i];for(var j=0;j<elBody.rows.length;j++){var elRow=elBody.rows[j];var oRecord={};for(var k=0;k<elRow.cells.length;k++){oRecord[oColumnSet.keys[k].key]=oColumnSet.keys[k].parse(elRow.cells[k].innerHTML);} -aRecords.push(oRecord);}} -this._initTable();var ok=this.doBeforeLoadData(aRecords);if(ok){this._oRecordSet.addRecords(aRecords);this.paginateRows();}} -else if(this.dataSource){this._initTable();oDataSource.sendRequest(this.initialRequest,this.onDataReturnPaginateRows,this);} -else{this._initTable();this.showEmptyMessage();}} -else{return;} -this.subscribe("headCellClickEvent",this.onEventSortColumn);if(this.contextMenu&&this.contextMenuOptions){this.contextMenu=new YAHOO.widget.ContextMenu(this.id+"-cm",{trigger:this._elBody.rows});this.contextMenu.addItem("delete item");this.contextMenu.render(document.body);} -elTable=this._elTable;YAHOO.util.Event.addListener(elTable,"click",this._onClick,this);YAHOO.util.Event.addListener(elTable,"dblclick",this._onDoubleclick,this);YAHOO.util.Event.addListener(elTable,"mouseout",this._onMouseout,this);YAHOO.util.Event.addListener(elTable,"mouseover",this._onMouseover,this);YAHOO.util.Event.addListener(elTable,"mousedown",this._onMousedown,this);YAHOO.util.Event.addListener(elTable,"keydown",this._onKeydown,this);YAHOO.util.Event.addListener(elTable,"keypress",this._onKeypress,this);YAHOO.util.Event.addListener(document,"keyup",this._onDocumentKeyup,this);YAHOO.util.Event.addListener(elTable,"keyup",this._onKeyup,this);YAHOO.util.Event.addListener(elTable,"blur",this._onBlur,this);this.createEvent("cellMouseoverEvent");this.createEvent("cellMouseoutEvent");this.createEvent("headCellMouseoverEvent");this.createEvent("headCellMouseoutEvent");this.createEvent("tableMouseoverEvent");this.createEvent("tableMouseoutEvent");this.createEvent("cellMousedownEvent");this.createEvent("headCellMousedownEvent");this.createEvent("tableMousedownEvent");this.checkboxClickEvent=this.createEvent("checkboxClickEvent");this.createEvent("radioClickEvent");this.createEvent("cellClickEvent");this.createEvent("headCellClickEvent");this.createEvent("tableClickEvent");this.createEvent("cellDoubleclickEvent");this.createEvent("headCellDoubleclickEvent");this.createEvent("tableDoubleclickEvent");this.createEvent("columnSortEvent");this.createEvent("editorShowEvent");this.createEvent("cellEditEvent");this.createEvent("columnResizeEvent");this.createEvent("tableInitEvent");this.createEvent("tableFocusEvent");this.createEvent("dataReturnEvent");this.createEvent("paginateEvent");this.createEvent("cellFormatEvent");this.createEvent("selectEvent");this.createEvent("unselectEvent");this.createEvent("highlightEvent");this.createEvent("unhighlightEvent");this.createEvent("rowDeleteEvent");this.subscribe("rowDeleteEvent",this._onRowDelete);this.createEvent("rowAppendEvent");this.createEvent("recordSetUpdateEvent");this._oRecordSet.subscribe("recordUpdateEvent",this._onRecordUpdate,this,true);YAHOO.widget.DataTable._nCount++;this.fireEvent("tableInitEvent");};if(YAHOO.util.EventProvider){YAHOO.augment(YAHOO.widget.DataTable,YAHOO.util.EventProvider);} -else{} -YAHOO.widget.DataTable.CLASS_BODY="yui-dt-body";YAHOO.widget.DataTable.CLASS_HEADCONTAINER="yui-dt-headcontainer";YAHOO.widget.DataTable.CLASS_HEADRESIZER="yui-dt-headresizer";YAHOO.widget.DataTable.CLASS_HEADTEXT="yui-dt-headtext";YAHOO.widget.DataTable.CLASS_EVEN="yui-dt-even";YAHOO.widget.DataTable.CLASS_ODD="yui-dt-odd";YAHOO.widget.DataTable.CLASS_EMPTY="yui-dt-empty";YAHOO.widget.DataTable.CLASS_LOADING="yui-dt-loading";YAHOO.widget.DataTable.CLASS_SELECTED="yui-dt-selected";YAHOO.widget.DataTable.CLASS_HIGHLIGHT="yui-dt-highlight";YAHOO.widget.DataTable.CLASS_SCROLLABLE="yui-dt-scrollable";YAHOO.widget.DataTable.CLASS_SORTABLE="yui-dt-sortable";YAHOO.widget.DataTable.CLASS_SORTEDBYASC="yui-dt-sortedbyasc";YAHOO.widget.DataTable.CLASS_SORTEDBYDESC="yui-dt-sortedbydesc";YAHOO.widget.DataTable.CLASS_FIRSTLINK="yui-dt-firstlink";YAHOO.widget.DataTable.CLASS_FIRSTPAGE="yui-dt-firstpage";YAHOO.widget.DataTable.CLASS_LASTLINK="yui-dt-lastlink";YAHOO.widget.DataTable.CLASS_LASTPAGE="yui-dt-lastpage";YAHOO.widget.DataTable.CLASS_PREVLINK="yui-dt-prevlink";YAHOO.widget.DataTable.CLASS_PREVPAGE="yui-dt-prevpage";YAHOO.widget.DataTable.CLASS_NEXTLINK="yui-dt-nextlink";YAHOO.widget.DataTable.CLASS_NEXTPAGE="yui-dt-nextpage";YAHOO.widget.DataTable.CLASS_PAGELINK="yui-dt-pagelink";YAHOO.widget.DataTable.CLASS_CURRENTPAGE="yui-dt-currentpage";YAHOO.widget.DataTable.CLASS_PAGESELECT="yui-dt-pageselect";YAHOO.widget.DataTable.CLASS_PAGELINKS="yui-dt-pagelinks";YAHOO.widget.DataTable.CLASS_EDITABLE="yui-dt-editable";YAHOO.widget.DataTable.CLASS_CHECKBOX="yui-dt-checkbox";YAHOO.widget.DataTable.CLASS_CURRENCY="yui-dt-currency";YAHOO.widget.DataTable.CLASS_DATE="yui-dt-date";YAHOO.widget.DataTable.CLASS_EMAIL="yui-dt-email";YAHOO.widget.DataTable.CLASS_LINK="yui-dt-link";YAHOO.widget.DataTable.CLASS_NUMBER="yui-dt-number";YAHOO.widget.DataTable.CLASS_STRING="yui-dt-string";YAHOO.widget.DataTable.MSG_EMPTY="No records found.";YAHOO.widget.DataTable.MSG_LOADING="Loading data...";YAHOO.widget.DataTable._nCount=0;YAHOO.widget.DataTable.prototype._nIndex=null;YAHOO.widget.DataTable.prototype._sName=null;YAHOO.widget.DataTable.prototype._elContainer=null;YAHOO.widget.DataTable.prototype._elTable=null;YAHOO.widget.DataTable.prototype._elBody=null;YAHOO.widget.DataTable.prototype._oColumnSet=null;YAHOO.widget.DataTable.prototype._oRecordSet=null;YAHOO.widget.DataTable.prototype._aSelectedRecords=null;YAHOO.widget.DataTable.prototype._bFocused=false;YAHOO.widget.DataTable.prototype._totalPages=null;YAHOO.widget.DataTable.prototype._initTable=function(){this._elContainer.innerHTML="";if(this.scrollable){YAHOO.util.Dom.addClass(this._elContainer,YAHOO.widget.DataTable.CLASS_SCROLLABLE);} -this._elTable=this._elContainer.appendChild(document.createElement("table"));var elTable=this._elTable;elTable.tabIndex=0;if(this.summary){elTable.summary=this.summary;} -if(this.caption){this._elCaption=elTable.appendChild(document.createElement("caption"));this._elCaption.innerHTML=this.caption;} -this._initHead(elTable,this._oColumnSet);var elMsgBody=document.createElement("tbody");elMsgBody.tabIndex=-1;this._elMsgRow=elMsgBody.appendChild(document.createElement("tr"));var elMsgRow=this._elMsgRow;var elMsgCell=elMsgRow.appendChild(document.createElement("td"));elMsgCell.colSpan=this._oColumnSet.keys.length;this._elMsgCell=elMsgCell;this._elMsgBody=elTable.appendChild(elMsgBody);this.showLoadingMessage();this._elBody=elTable.appendChild(document.createElement("tbody"));this._elBody.tabIndex=-1;YAHOO.util.Dom.addClass(this._elBody,YAHOO.widget.DataTable.CLASS_BODY);if(this.scrollable){YAHOO.util.Dom.addClass(this._elBody,YAHOO.widget.DataTable.CLASS_SCROLLABLE);}};YAHOO.widget.DataTable.prototype._initHead=function(){var i,oColumn;var elHead=document.createElement("thead");elHead.tabIndex=-1;var colTree=this._oColumnSet.tree;for(i=0;i<colTree.length;i++){var elHeadRow=elHead.appendChild(document.createElement("tr"));elHeadRow.id=this.id+"-hdrow"+i;for(var j=0;j<colTree[i].length;j++){oColumn=colTree[i][j];var elHeadCell=elHeadRow.appendChild(document.createElement("th"));elHeadCell.id=oColumn.getId();this._initHeadCell(elHeadCell,oColumn,i,j);}} -this._elHead=this._elTable.appendChild(elHead);for(i=0;i<this._oColumnSet.keys.length-1;i++){oColumn=this._oColumnSet.keys[i];if(oColumn.resizeable&&YAHOO.util.DD){if(!this.fixedWidth||(this.fixedwidth&&!oColumn.isLast)){var elHeadContainer=(YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_HEADCONTAINER,"div",YAHOO.util.Dom.get(oColumn.getId())))[0];var elHeadResizer=elHeadContainer.appendChild(document.createElement("span"));elHeadResizer.id=oColumn.getId()+"-resizer";YAHOO.util.Dom.addClass(elHeadResizer,YAHOO.widget.DataTable.CLASS_HEADRESIZER);oColumn.ddResizer=new YAHOO.util.WidthResizer(this,oColumn.getId(),elHeadResizer.id,elHeadResizer.id);var cancelClick=function(e){YAHOO.util.Event.stopPropagation(e);};YAHOO.util.Event.addListener(elHeadResizer,"click",cancelClick);} -if(this.fixedWidth){elHeadContainer.style.overflow="hidden";elHeadContent.style.overflow="hidden";}}}};YAHOO.widget.DataTable.prototype._initHeadCell=function(elHeadCell,oColumn,row,col){var index=this._nIndex;elHeadCell.columnIndex=col;if(oColumn.abbr){elHeadCell.abbr=oColumn.abbr;} -if(oColumn.width){elHeadCell.style.width=oColumn.width;} -if(oColumn.className){YAHOO.util.Dom.addClass(elHeadCell,oColumn.className);} -if(this.sortedBy&&this.sortedBy.colKey){if(this.sortedBy.colKey==oColumn.key){var sortClass=(this.sortedBy.dir&&(this.sortedBy.dir!="asc"))?YAHOO.widget.DataTable.CLASS_SORTEDBYDESC:YAHOO.widget.DataTable.CLASS_SORTEDBYASC;YAHOO.util.Dom.addClass(elHeadCell,sortClass);this.sortedBy._id=elHeadCell.id;}} -elHeadCell.innerHTML="";var elHeadContainer=elHeadCell.appendChild(document.createElement("div"));elHeadContainer.id=this.id+"-hdrow"+row+"-container"+col;YAHOO.util.Dom.addClass(elHeadContainer,YAHOO.widget.DataTable.CLASS_HEADCONTAINER);var elHeadContent=elHeadContainer.appendChild(document.createElement("span"));elHeadContent.id=this.id+"-hdrow"+row+"-text"+col;YAHOO.util.Dom.addClass(elHeadContent,YAHOO.widget.DataTable.CLASS_HEADTEXT);elHeadCell.rowSpan=oColumn.getRowSpan();elHeadCell.colSpan=oColumn.getColSpan();var contentText=oColumn.text||oColumn.key||"";if(oColumn.sortable){YAHOO.util.Dom.addClass(elHeadContent,YAHOO.widget.DataTable.CLASS_SORTABLE);elHeadContent.innerHTML="<a href=\"#\" title=\"Click to sort\">"+contentText+"</a>";} -else{elHeadContent.innerHTML=contentText;}};YAHOO.widget.DataTable.prototype._addRow=function(oRecord,index){this.hideTableMessages();var insert=(isNaN(index))?false:true;if(!insert){index=this._elBody.rows.length;} -var oColumnSet=this._oColumnSet;var oRecordSet=this._oRecordSet;var elRow=(insert&&this._elBody.rows[index])?this._elBody.insertBefore(document.createElement("tr"),this._elBody.rows[index]):this._elBody.appendChild(document.createElement("tr"));var recId=oRecord.id;elRow.id=this.id+"-bdrow"+index;elRow.recordId=recId;for(var j=0;j<oColumnSet.keys.length;j++){var oColumn=oColumnSet.keys[j];var elCell=elRow.appendChild(document.createElement("td"));elCell.id=this.id+"-bdrow"+index+"-cell"+j;elCell.headers=oColumn.id;elCell.columnIndex=j;elCell.headers=oColumnSet.headers[j];oColumn.format(elCell,oRecord);if(this.fixedWidth){elCell.style.overflow="hidden";}} -if(this.isEmpty&&(this._elBody.rows.length>0)){} -if(!insert){if(index%2){YAHOO.util.Dom.addClass(elRow,YAHOO.widget.DataTable.CLASS_ODD);} -else{YAHOO.util.Dom.addClass(elRow,YAHOO.widget.DataTable.CLASS_EVEN);}} -else{this._restripeRows();} -return elRow.id;};YAHOO.widget.DataTable.prototype._restripeRows=function(range){if(!range){var rows=this._elBody.rows;for(var i=0;i<rows.length;i++){if(i%2){YAHOO.util.Dom.removeClass(rows[i],YAHOO.widget.DataTable.CLASS_EVEN);YAHOO.util.Dom.addClass(rows[i],YAHOO.widget.DataTable.CLASS_ODD);} -else{YAHOO.util.Dom.removeClass(rows[i],YAHOO.widget.DataTable.CLASS_ODD);YAHOO.util.Dom.addClass(rows[i],YAHOO.widget.DataTable.CLASS_EVEN);}}} -else{}};YAHOO.widget.DataTable.prototype._updateRow=function(oRecord,index){this.hideTableMessages();var elRow=this._elBody.rows[index];elRow.recordId=oRecord.id;var columns=this._oColumnSet.keys;for(var j=0;j<columns.length;j++){columns[j].format(elRow.cells[j],oRecord);} -return elRow.id;};YAHOO.widget.DataTable.prototype._select=function(els){for(var i=0;i<els.length;i++){YAHOO.util.Dom.addClass(YAHOO.util.Dom.get(els[i]),YAHOO.widget.DataTable.CLASS_SELECTED);} -this._lastSelected=els[els.length-1];};YAHOO.widget.DataTable.prototype._unselect=function(els){for(var i=0;i<els.length;i++){YAHOO.util.Dom.removeClass(YAHOO.util.Dom.get(els[i]),YAHOO.widget.DataTable.CLASS_SELECTED);}};YAHOO.widget.DataTable.prototype._unselectAllRows=function(){var selectedRows=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody);this._unselect(selectedRows);};YAHOO.widget.DataTable.prototype._unselectAllCells=function(){var selectedCells=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody);this._unselect(selectedCells);};YAHOO.widget.DataTable.prototype._deleteRow=function(elRow){var allRows=this._elBody.rows;var id=elRow.id;var recordId=elRow.recordId;for(var i=0;i<allRows.length;i++){if(id==allRows[i].id){this._elBody.deleteRow(i);this._oRecordSet.deleteRecord(i);break;}} -if(this._elBody.rows.length===0){this.showEmptyMessage();}};YAHOO.widget.DataTable.prototype._onBlur=function(e,oSelf){this._bFocused=false;};YAHOO.widget.DataTable.prototype._onMouseover=function(e,oSelf){var elTarget=YAHOO.util.Event.getTarget(e);var elTag=elTarget.tagName.toLowerCase();var knownTag=false;if(elTag!="table"){while(!knownTag){switch(elTag){case"body":knownTag=true;break;case"td":oSelf.fireEvent("cellMouseoverEvent",{target:elTarget,event:e});knownTag=true;break;case"th":oSelf.fireEvent("headCellMouseoverEvent",{target:elTarget,event:e});knownTag=true;break;default:break;} -elTarget=elTarget.parentNode;if(elTarget){elTag=elTarget.tagName.toLowerCase();} -else{break;}}} -oSelf.fireEvent("tableMouseoverEvent",{target:elTarget,event:e});};YAHOO.widget.DataTable.prototype._onMouseout=function(e,oSelf){var elTarget=YAHOO.util.Event.getTarget(e);var elTag=elTarget.tagName.toLowerCase();var knownTag=false;if(elTag!="table"){while(!knownTag){switch(elTag){case"body":knownTag=true;break;case"td":oSelf.fireEvent("cellMouseoutEvent",{target:elTarget,event:e});knownTag=true;break;case"th":oSelf.fireEvent("headCellMouseoutEvent",{target:elTarget,event:e});knownTag=true;break;default:break;} -elTarget=elTarget.parentNode;if(elTarget){elTag=elTarget.tagName.toLowerCase();} -else{break;}}} -oSelf.fireEvent("tableMouseoutEvent",{target:elTarget,event:e});};YAHOO.widget.DataTable.prototype._onMousedown=function(e,oSelf){var elTarget=YAHOO.util.Event.getTarget(e);var elTag=elTarget.tagName.toLowerCase();var knownTag=false;if(elTag!="table"){while(!knownTag){switch(elTag){case"body":knownTag=true;break;case"td":YAHOO.util.Event.stopEvent(e);oSelf.fireEvent("cellMousedownEvent",{target:elTarget,event:e});knownTag=true;break;case"th":YAHOO.util.Event.stopEvent(e);oSelf.fireEvent("headCellMousedownEvent",{target:elTarget,event:e});knownTag=true;break;default:break;} -elTarget=elTarget.parentNode;if(elTarget){elTag=elTarget.tagName.toLowerCase();} -else{break;}}} -oSelf.fireEvent("tableMousedownEvent",{target:elTarget,event:e});};YAHOO.widget.DataTable.prototype._onClick=function(e,oSelf){var elTarget=YAHOO.util.Event.getTarget(e);var elTag=elTarget.tagName.toLowerCase();var knownTag=false;if(oSelf.activeEditor){oSelf.activeEditor.hide();oSelf.activeEditor=null;oSelf._bFocused=false;oSelf.focusTable();} -if(elTag!="table"){while(!knownTag){switch(elTag){case"body":knownTag=true;break;case"input":if(elTarget.type.toLowerCase()=="checkbox"){oSelf.fireEvent("checkboxClickEvent",{target:elTarget,event:e});} -else if(elTarget.type.toLowerCase()=="radio"){oSelf.fireEvent("radioClickEvent",{target:elTarget,event:e});} -knownTag=true;break;case"td":YAHOO.util.Event.stopEvent(e);oSelf.fireEvent("cellClickEvent",{target:elTarget,event:e});knownTag=true;break;case"th":YAHOO.util.Event.stopEvent(e);oSelf.fireEvent("headCellClickEvent",{target:elTarget,event:e});knownTag=true;break;default:break;} -elTarget=elTarget.parentNode;elTag=elTarget.tagName.toLowerCase();}} -oSelf.focusTable();oSelf.fireEvent("tableClickEvent",{target:elTarget,event:e});};YAHOO.widget.DataTable.prototype._onDoubleclick=function(e,oSelf){var elTarget=YAHOO.util.Event.getTarget(e);var elTag=elTarget.tagName.toLowerCase();var knownTag=false;if(oSelf.activeEditor){oSelf.activeEditor.hide();oSelf.activeEditor=null;oSelf._bFocused=false;oSelf.focusTable();} -if(elTag!="table"){while(!knownTag){switch(elTag){case"body":knownTag=true;break;case"td":YAHOO.util.Event.stopEvent(e);oSelf.fireEvent("cellDoubleclickEvent",{target:elTarget,event:e});knownTag=true;break;case"th":YAHOO.util.Event.stopEvent(e);oSelf.fireEvent("headCellDoubleclickEvent",{target:elTarget,event:e});knownTag=true;break;default:break;} -elTarget=elTarget.parentNode;elTag=elTarget.tagName.toLowerCase();}} -oSelf.fireEvent("tableDoubleclickEvent",{target:elTarget,event:e});};YAHOO.widget.DataTable.prototype._onKeypress=function(e,oSelf){var isMac=(navigator.userAgent.toLowerCase().indexOf("mac")!=-1);if(isMac){if(e.keyCode==40){YAHOO.util.Event.stopEvent(e);} -else if(e.keyCode==38){YAHOO.util.Event.stopEvent(e);}}};YAHOO.widget.DataTable.prototype._onKeydown=function(e,oSelf){var oldSelected=oSelf._lastSelected;if(oldSelected&&oSelf.isSelected(oldSelected)){var newSelected;if(e.keyCode==40){YAHOO.util.Event.stopEvent(e);if(oldSelected.tagName.toLowerCase()=="tr"){if(oldSelected.sectionRowIndex+1<oSelf._elBody.rows.length){if(!e.shiftKey){oSelf.unselectAllRows();} -newSelected=oSelf._elBody.rows[oldSelected.sectionRowIndex+1];oSelf.select(newSelected);}} -else if(oldSelected.tagName.toLowerCase()=="td"){} -oSelf._bFocused=false;oSelf.focusTable();} -else if(e.keyCode==38){YAHOO.util.Event.stopEvent(e);if(oldSelected.tagName.toLowerCase()=="tr"){if((oldSelected.sectionRowIndex>0)){if(!e.shiftKey){oSelf.unselectAllRows();} -newSelected=oSelf._elBody.rows[oldSelected.sectionRowIndex-1];oSelf.select(newSelected);}} -else if(oldSelected.tagName.toLowerCase()=="td"){if((oldSelected.sectionRowIndex>0)){if(!e.shiftKey){oSelf.unselectAllRows();} -newSelected=oSelf._elBody.rows[oldSelected.sectionRowIndex-1];oSelf.select(newSelected);}} -oSelf._bFocused=false;oSelf.focusTable();}}};YAHOO.widget.DataTable.prototype._onKeyup=function(e,oSelf){var key=YAHOO.util.Event.getCharCode(e);if(key==46){}};YAHOO.widget.DataTable.prototype._onDocumentKeyup=function(e,oSelf){if((e.keyCode==27)&&(oSelf.activeEditor)){oSelf.activeEditor.hide();oSelf.activeEditor=null;oSelf._bFocused=false;oSelf.focusTable();} -if((e.keyCode==13)&&(oSelf.activeEditor)){var elCell=oSelf.activeEditor.cell;var oColumn=oSelf.activeEditor.column;var oRecord=oSelf.activeEditor.record;var oldValue=oRecord[oColumn.key];var newValue=oSelf.activeEditor.getValue();oSelf._oRecordSet.updateRecord(oRecord,oColumn.key,newValue);oSelf.formatCell(elCell);oSelf.activeEditor.hide();oSelf.activeEditor=null;oSelf._bFocused=false;oSelf.focusTable();oSelf.fireEvent("cellEditEvent",{target:elCell,oldData:oldValue,newData:newValue});}};YAHOO.widget.DataTable.prototype._onPagerClick=function(e,oSelf){var elTarget=YAHOO.util.Event.getTarget(e);var elTag=elTarget.tagName.toLowerCase();var knownTag=false;if(elTag!="table"){while(!knownTag){switch(elTag){case"body":knownTag=true;break;case"a":YAHOO.util.Event.stopEvent(e);switch(elTarget.className){case YAHOO.widget.DataTable.CLASS_PAGELINK:oSelf.showPage(parseInt(elTarget.innerHTML,10));break;case YAHOO.widget.DataTable.CLASS_FIRSTLINK:oSelf.showPage(1);break;case YAHOO.widget.DataTable.CLASS_LASTLINK:oSelf.showPage(oSelf._totalPages);break;case YAHOO.widget.DataTable.CLASS_PREVLINK:oSelf.showPage(oSelf.pageCurrent-1);break;case YAHOO.widget.DataTable.CLASS_NEXTLINK:oSelf.showPage(oSelf.pageCurrent+1);break;} -knownTag=true;break;default:break;} -elTarget=elTarget.parentNode;if(elTarget){elTag=elTarget.tagName.toLowerCase();} -else{break;}}}};YAHOO.widget.DataTable.prototype._onPagerSelect=function(e,oSelf){var elTarget=YAHOO.util.Event.getTarget(e);var elTag=elTarget.tagName.toLowerCase();var oldRowsPerPage=oSelf.rowsPerPage;var rowsPerPage=parseInt(elTarget[elTarget.selectedIndex].text,10);if(rowsPerPage&&(rowsPerPage!=oSelf.rowsPerPage)){if(rowsPerPage>oldRowsPerPage){oSelf.pageCurrent=1;} -oSelf.rowsPerPage=rowsPerPage;oSelf.paginateRows();}};YAHOO.widget.DataTable.prototype._onRowDelete=function(oArgs){this._restripeRows();};YAHOO.widget.DataTable.prototype._onRecordUpdate=function(oArgs){this.fireEvent("recordSetUpdateEvent",oArgs);};YAHOO.widget.DataTable.prototype.dataSource=null;YAHOO.widget.DataTable.prototype.initialRequest="";YAHOO.widget.DataTable.prototype.caption=null;YAHOO.widget.DataTable.prototype.summary=null;YAHOO.widget.DataTable.prototype.fixedWidth=false;YAHOO.widget.DataTable.prototype.scrollable=false;YAHOO.widget.DataTable.prototype.rowSingleSelect=false;YAHOO.widget.DataTable.prototype.contextMenu=null;YAHOO.widget.DataTable.prototype.pageCurrent=1;YAHOO.widget.DataTable.prototype.rowsPerPage=500;YAHOO.widget.DataTable.prototype.startRecordIndex=1;YAHOO.widget.DataTable.prototype.pageLinksLength=-1;YAHOO.widget.DataTable.prototype.rowsPerPageDropdown=null;YAHOO.widget.DataTable.prototype.pageLinksStart=1;YAHOO.widget.DataTable.prototype.pagers=null;YAHOO.widget.DataTable.prototype.isEmpty=false;YAHOO.widget.DataTable.prototype.sortedBy=null;YAHOO.widget.DataTable.prototype.toString=function(){return"DataTable "+this._sName;};YAHOO.widget.DataTable.prototype.getTable=function(){return(this._elTable);};YAHOO.widget.DataTable.prototype.getHead=function(){return(this._elHead);};YAHOO.widget.DataTable.prototype.getBody=function(){return(this._elBody);};YAHOO.widget.DataTable.prototype.getRow=function(index){return(this._elBody.rows[index]);};YAHOO.widget.DataTable.prototype.getCell=function(row,col){return(this._elBody.rows[row].cells[col]);};YAHOO.widget.DataTable.prototype.showEmptyMessage=function(){if(this.isEmpty){return;} -if(this.isLoading){this.hideTableMessages();} -this._elMsgBody.style.display="";var elCell=this._elMsgCell;elCell.className=YAHOO.widget.DataTable.CLASS_EMPTY;elCell.innerHTML=YAHOO.widget.DataTable.MSG_EMPTY;this.isEmpty=true;};YAHOO.widget.DataTable.prototype.showLoadingMessage=function(){if(this.isLoading){return;} -if(this.isEmpty){this.hideTableMessages();} -this._elMsgBody.style.display="";var elCell=this._elMsgCell;elCell.className=YAHOO.widget.DataTable.CLASS_LOADING;elCell.innerHTML=YAHOO.widget.DataTable.MSG_LOADING;this.isLoading=true;};YAHOO.widget.DataTable.prototype.hideTableMessages=function(){if(!this.isEmpty&&!this.isLoading){return;} -this._elMsgBody.style.display="none";this.isEmpty=false;this.isLoading=false;};YAHOO.widget.DataTable.prototype.focusTable=function(){var elTable=this._elTable;if(!this._bFocused){setTimeout(function(){elTable.focus();},0);this._bFocused=true;this.fireEvent("tableFocusEvent");}};YAHOO.widget.DataTable.prototype.doBeforeLoadData=function(sRequest,oResponse){return true;};YAHOO.widget.DataTable.prototype.appendRows=function(aRecords){if(aRecords&&aRecords.length>0){this.hideTableMessages();var rowIds=[];for(var i=0;i<aRecords.length;i++){var rowId=this._addRow(aRecords[i]);rowIds.push(rowId);} -this.fireEvent("rowAppendEvent",{rowIds:rowIds});}};YAHOO.widget.DataTable.prototype.insertRows=function(aRecords){if(aRecords&&aRecords.length>0){this.hideTableMessages();var rowIds=[];for(var i=0;i<aRecords.length;i++){var rowId=this._addRow(aRecords[i],0);rowIds.push(rowId);} -this.fireEvent("rowInsertEvent",{rowIds:rowIds});}};YAHOO.widget.DataTable.prototype.replaceRows=function(aRecords){var i;if(aRecords&&aRecords.length>0){this.hideTableMessages();var elBody=this._elBody;var elRows=this._elBody.rows;while(elBody.hasChildNodes()&&(elRows.length>aRecords.length)){elBody.deleteRow(0);} -var selectedRecords=this.getSelectedRecordIds();if(selectedRecords.length>0){this._unselectAllRows();} -var rowIds=[];for(i=0;i<elRows.length;i++){if(aRecords[i]){var oRecord=aRecords[i];rowIds.push(this._updateRow(oRecord,i));}} -for(i=elRows.length;i<aRecords.length;i++){rowIds.push(this._addRow(aRecords[i]));} -for(i=0;i<selectedRecords.length;i++){var allRows=elBody.rows;for(var j=0;j<allRows.length;j++){if(selectedRecords[i]==allRows[j].recordId){this._select([allRows[j]]);}}} -this.fireEvent("rowReplaceEvent",{rowIds:rowIds});}};YAHOO.widget.DataTable.prototype.addRow=function(oRecord,index){if(oRecord){var rowId=this._addRow(oRecord,index);if(index!==undefined){this.fireEvent("rowInsertEvent",{rowIds:[rowId]});} -else{this.fireEvent("rowAppendEvent",{rowIds:[rowId]});}}};YAHOO.widget.DataTable.prototype.updateRow=function(oRecord,index){if(oRecord){var rowId=this._updateRow(oRecord,index);this.fireEvent("rowUpdateEvent",{rowIds:[rowId]});}};YAHOO.widget.DataTable.prototype.deleteRows=function(rows){var rowIndexes=[];for(var i=0;i<rows.length;i++){var rowIndex=(rows[i].sectionRowIndex!==undefined)?rows[i].sectionRowIndex:null;rowIndexes.push(rowIndex);this._deleteRow(rows[i]);this.fireEvent("rowDeleteEvent",{rowIndexes:rowIndexes});}};YAHOO.widget.DataTable.prototype.deleteRow=function(elRow){if(elRow){var rowIndex=(elRow.sectionRowIndex!==undefined)?elRow.sectionRowIndex:null;this._deleteRow(elRow);this.fireEvent("rowDeleteEvent",{rowIndexes:[rowIndex]});}};YAHOO.widget.DataTable.prototype.highlight=function(els){if(els.constructor!=Array){els=[els];} -YAHOO.util.Dom.addClass(els,YAHOO.widget.DataTable.CLASS_HIGHLIGHT);this.fireEvent("highlightEvent",{els:els});};YAHOO.widget.DataTable.prototype.unhighlight=function(els){if(els.constructor!=Array){els=[els];} -YAHOO.util.Dom.removeClass(els,YAHOO.widget.DataTable.CLASS_HIGHLIGHT);this.fireEvent("unhighlightEvent",{els:els});};YAHOO.widget.DataTable.prototype.select=function(els){if(els){if(els.constructor!=Array){els=[els];} -this._select(els);var tracker=this._aSelectedRecords||[];for(var i=0;i<els.length;i++){var id=els[i].recordId;if(tracker.indexOf&&(tracker.indexOf(id)>-1)){tracker.splice(tracker.indexOf(id),1);} -else{for(var j=0;j<tracker.length;j++){if(tracker[j]===id){tracker.splice(j,1);}}} -tracker.push(id);} -this._aSelectedRecords=tracker;this.fireEvent("selectEvent",{els:els});}};YAHOO.widget.DataTable.prototype.unselect=function(els){if(els){if(els.constructor!=Array){els=[els];} -this._unselect(els);var tracker=this._aSelectedRecords||[];for(var i=0;i<els.length;i++){var id=els[i].recordId;if(tracker.indexOf&&(tracker.indexOf(id)>-1)){tracker.splice(tracker.indexOf(id),1);} -else{for(var j=0;j<tracker.length;j++){if(tracker[j]===id){tracker.splice(j,1);}}}} -this._aSelectedRecords=tracker;this.fireEvent("unselectEvent",{els:els});}};YAHOO.widget.DataTable.prototype.unselectAllRows=function(){var selectedRows=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody);this.unselect(selectedRows);this.fireEvent("unselectEvent",{els:selectedRows});};YAHOO.widget.DataTable.prototype.unselectAllCells=function(){var selectedCells=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody);this.unselect(selectedCells);this.fireEvent("unselectEvent",{els:selectedCells});};YAHOO.widget.DataTable.prototype.isSelected=function(el){return YAHOO.util.Dom.hasClass(el,YAHOO.widget.DataTable.CLASS_SELECTED);};YAHOO.widget.DataTable.prototype.getSelectedRecordIds=function(){return this._aSelectedRecords||[];};YAHOO.widget.DataTable.prototype.getSelectedRows=function(){return YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody);};YAHOO.widget.DataTable.prototype.getSelectedCells=function(){return YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody);};YAHOO.widget.DataTable.prototype.getColumnSet=function(){return this._oColumnSet;};YAHOO.widget.DataTable.prototype.getRecordSet=function(){return this._oRecordSet;};YAHOO.widget.DataTable.prototype.showPage=function(nPage){if(!nPage||isNaN(nPage)||(nPage<1)||(nPage>this._totalPages)){nPage=1;} -this.pageCurrent=nPage;this.paginateRows();};YAHOO.widget.DataTable.prototype.paginateRows=function(){var i;var recordsLength=this._oRecordSet.getLength();var maxRows=(this.rowsPerPage<recordsLength)?this.rowsPerPage:recordsLength;this._totalPages=Math.ceil(recordsLength/maxRows);this.startRecordIndex=(this.pageCurrent-1)*this.rowsPerPage;var pageLinksLength=((this.pageLinksLength>0)&&(this.pageLinksLength<this._totalPages))?this.pageLinksLength:this._totalPages;this.pageLinksStart=(Math.ceil(this.pageCurrent/pageLinksLength-1)*pageLinksLength)+1;var pageRecords=this._oRecordSet.getRecords(this.startRecordIndex,this.rowsPerPage);this.replaceRows(pageRecords);if(this.rowsPerPage<recordsLength){var isFirstPage=(this.pageCurrent==1)?true:false;var isLastPage=(this.pageCurrent==this._totalPages)?true:false;var firstPageLink=(isFirstPage)?" <span class=\""+YAHOO.widget.DataTable.CLASS_FIRSTPAGE+"\"><<</span> ":" <a href=\"#\" class=\""+YAHOO.widget.DataTable.CLASS_FIRSTLINK+"\"><<</a> ";var prevPageLink=(isFirstPage)?" <span class=\""+YAHOO.widget.DataTable.CLASS_PREVPAGE+"\"><</span> ":" <a href=\"#\" class=\""+YAHOO.widget.DataTable.CLASS_PREVLINK+"\"><</a> ";var nextPageLink=(isLastPage)?" <span class=\""+YAHOO.widget.DataTable.CLASS_NEXTPAGE+"\">></span> ":" <a href=\"#\" class=\""+YAHOO.widget.DataTable.CLASS_NEXTLINK+"\">></a> ";var lastPageLink=(isLastPage)?" <span class=\""+YAHOO.widget.DataTable.CLASS_LASTPAGE+"\">>></span> ":" <a href=\"#\" class=\""+YAHOO.widget.DataTable.CLASS_LASTLINK+"\">>></a> ";var markup=firstPageLink+prevPageLink;var maxLinks=(this.pageLinksStart+pageLinksLength<this._totalPages)?this.pageLinksStart+pageLinksLength-1:this._totalPages;for(i=this.pageLinksStart;i<=maxLinks;i++){if(i!=this.pageCurrent){markup+=" <a href=\"#\" class=\""+YAHOO.widget.DataTable.CLASS_PAGELINK+"\">"+i+"</a> ";} -else{markup+=" <span class=\""+YAHOO.widget.DataTable.CLASS_CURRENTPAGE+"\">"+i+"</span>";}} -markup+=nextPageLink+lastPageLink;var dropdown=this.rowsPerPageDropdown;var select1,select2;if(dropdown&&(dropdown.constructor==Array)&&(dropdown.length>0)){select1=document.createElement("select");select1.className=YAHOO.widget.DataTable.CLASS_PAGESELECT;select2=document.createElement("select");select2.className=YAHOO.widget.DataTable.CLASS_PAGESELECT;for(i=0;i<dropdown.length;i++){var option1=document.createElement("option");var option2=document.createElement("option");option1.value=dropdown[i];option2.value=dropdown[i];option1.innerHTML=dropdown[i];option2.innerHTML=dropdown[i];if(this.rowsPerPage===dropdown[i]){option1.selected=true;option2.selected=true;} -option1=select1.appendChild(option1);option2=select2.appendChild(option2);}} -if(!this.pagers||(this.pagers.length===0)){var pager1=document.createElement("span");pager1.className=YAHOO.widget.DataTable.CLASS_PAGELINKS;var pager2=document.createElement("span");pager2.className=YAHOO.widget.DataTable.CLASS_PAGELINKS;pager1=this._elContainer.insertBefore(pager1,this._elTable);select1=(select1===undefined)?null:this._elContainer.insertBefore(select1,this._elTable);select2=(select2===undefined)?null:this._elContainer.insertBefore(select2,this._elTable.nextSibling);pager2=this._elContainer.insertBefore(pager2,this._elTable.nextSibling);this.pagers=[{links:pager1,select:select1},{links:pager2,select:select2}];} -for(i=0;i<this.pagers.length;i++){this.pagers[i].links.innerHTML=markup;YAHOO.util.Event.purgeElement(this.pagers[i].links);if(this.pagers[i].select){YAHOO.util.Event.purgeElement(this.pagers[i].select);} -this.pagers[i].innerHTML=markup;YAHOO.util.Event.addListener(this.pagers[i].links,"click",this._onPagerClick,this);if(this.pagers[i].select){YAHOO.util.Event.addListener(this.pagers[i].select,"change",this._onPagerSelect,this);}}} -this.fireEvent("paginateEvent");};YAHOO.widget.DataTable.prototype.sortColumn=function(oColumn){if(!oColumn){return;} -if(!oColumn instanceof YAHOO.widget.Column){return;} -if(oColumn.sortable){var sortDir=(oColumn.sortOptions&&oColumn.sortOptions.defaultOrder)?oColumn.sortOptions.defaultOrder:"asc";if(oColumn.key&&this.sortedBy&&(this.sortedBy.colKey==oColumn.key)){if(this.sortedBy.dir){sortDir=(this.sortedBy.dir=="asc")?"desc":"asc";} -else{sortDir=(sortDir=="asc")?"desc":"asc";}} -else if(!this.sortedBy){this.sortedBy={};} -var sortFnc=null;if((sortDir=="desc")&&oColumn.sortOptions&&oColumn.sortOptions.descFunction){sortFnc=oColumn.sortOptions.descFunction;} -else if((sortDir=="asc")&&oColumn.sortOptions&&oColumn.sortOptions.ascFunction){sortFnc=oColumn.sortOptions.ascFunction;} -if(!sortFnc&&oColumn.key){var sorted;sortFnc=function(a,b){if(sortDir=="desc"){sorted=YAHOO.util.Sort.compareDesc(a[oColumn.key],b[oColumn.key]);if(sorted===0){return YAHOO.util.Sort.compareDesc(a.id,b.id);} -else{return sorted;}} -else{sorted=YAHOO.util.Sort.compareAsc(a[oColumn.key],b[oColumn.key]);if(sorted===0){return YAHOO.util.Sort.compareAsc(a.id,b.id);} -else{return sorted;}}};} -if(sortFnc){this._oRecordSet.sort(sortFnc);this.paginateRows();YAHOO.util.Dom.removeClass(this.sortedBy._id,YAHOO.widget.DataTable.CLASS_SORTEDBYASC);YAHOO.util.Dom.removeClass(this.sortedBy._id,YAHOO.widget.DataTable.CLASS_SORTEDBYDESC);var newClass=(sortDir=="asc")?YAHOO.widget.DataTable.CLASS_SORTEDBYASC:YAHOO.widget.DataTable.CLASS_SORTEDBYDESC;YAHOO.util.Dom.addClass(oColumn.getId(),newClass);this.sortedBy.colKey=oColumn.key;this.sortedBy.dir=sortDir;this.sortedBy._id=oColumn.getId();this.fireEvent("columnSortEvent",{column:oColumn,dir:sortDir});}} -else{}};YAHOO.widget.DataTable.prototype.editCell=function(elCell){if(elCell&&!isNaN(elCell.columnIndex)){var column=this._oColumnSet.keys[elCell.columnIndex];if(column&&column.editor){this.activeEditor=column.getEditor(elCell,this._oRecordSet.getRecord(elCell.parentNode.recordId));} -this._bFocused=true;this.fireEvent("editorShowEvent",{target:elCell,column:column});}};YAHOO.widget.DataTable.prototype.formatCell=function(elCell){if(elCell&&!isNaN(elCell.columnIndex)){var column=this._oColumnSet.keys[elCell.columnIndex];column.format(elCell,this._oRecordSet.getRecord(elCell.parentNode.recordId));this.fireEvent("cellFormatEvent",{el:elCell});}};YAHOO.widget.DataTable.prototype.onEventSortColumn=function(oArgs){var evt=oArgs.event;var target=oArgs.target;YAHOO.util.Event.stopEvent(evt);var columnIndex=target.columnIndex;if(!isNaN(columnIndex)){this.sortColumn(this._oColumnSet.keys[columnIndex]);}};YAHOO.widget.DataTable.prototype.onEventSelectRow=function(oArgs){var i;var evt=oArgs.event;var target=oArgs.target;while(target.tagName.toLowerCase()!="tr"){target=target.parentNode;} -if(this.isSelected(target)){this.unselect(target);} -else{if(this.rowSingleSelect&&!evt.ctrlKey&&!evt.shiftKey){this.unselectAllRows();} -if(evt.shiftKey){var startRow=this._lastSelected;if(startRow&&this.isSelected(startRow)){this.unselectAllRows();if(startRow.sectionRowIndex<target.sectionRowIndex){for(i=startRow.sectionRowIndex;i<=target.sectionRowIndex;i++){this.select(this._elBody.rows[i]);}} -else{for(i=target.sectionRowIndex;i<=startRow.sectionRowIndex;i++){this.select(this._elBody.rows[i]);}}} -else{this.select(target);}} -else{this.select(target);}}};YAHOO.widget.DataTable.prototype.onEventSelectCell=function(oArgs){var evt=oArgs.event;var target=oArgs.target;while(target.tagName.toLowerCase()!="td"){target=target.parentNode;} -if(this.isSelected(target)){this.unselect(target);} -else{if(this.rowSingleSelect&&!evt.ctrlKey){this.unselectAllCells();} -this.select(target);}};YAHOO.widget.DataTable.prototype.onEventFormatCell=function(oArgs){var evt=oArgs.event;var element=oArgs.target;while(element.tagName.toLowerCase()!="td"){element=element.parentNode;} -this.formatCell(element);};YAHOO.widget.DataTable.prototype.onEventHighlightCell=function(oArgs){var evt=oArgs.event;var element=oArgs.target;while(element.tagName.toLowerCase()!="td"){element=element.parentNode;} -this.highlight(element);};YAHOO.widget.DataTable.prototype.onEventUnhighlightCell=function(oArgs){var evt=oArgs.event;var element=oArgs.target;while(element.tagName.toLowerCase()!="td"){element=element.parentNode;} -this.unhighlight(element);};YAHOO.widget.DataTable.prototype.onEventEditCell=function(oArgs){var evt=oArgs.event;var element=oArgs.target;while(element.tagName.toLowerCase()!="td"){element=element.parentNode;} -this.editCell(element);};YAHOO.widget.DataTable.prototype.onDataReturnPaginateRows=function(sRequest,oResponse){this.fireEvent("dataReturnEvent",{request:sRequest,response:oResponse});var ok=this.doBeforeLoadData(sRequest,oResponse);if(ok){var newRecords=this._oRecordSet.append(oResponse);if(newRecords){this.paginateRows();}}};YAHOO.widget.DataTable.prototype.onDataReturnAppendRows=function(sRequest,oResponse){this.fireEvent("dataReturnEvent",{request:sRequest,response:oResponse});var ok=this.doBeforeLoadData(sRequest,oResponse);if(ok){var newRecords=this._oRecordSet.append(oResponse);if(newRecords){this.appendRows(newRecords);}}};YAHOO.widget.DataTable.prototype.onDataReturnInsertRows=function(sRequest,oResponse){this.fireEvent("dataReturnEvent",{request:sRequest,response:oResponse});var ok=this.doBeforeLoadData(sRequest,oResponse);if(ok){var newRecords=this._oRecordSet.insert(oResponse);if(newRecords){this.insertRows(newRecords);}}};YAHOO.widget.DataTable.prototype.onDataReturnReplaceRows=function(sRequest,oResponse){this.fireEvent("dataReturnEvent",{request:sRequest,response:oResponse});var ok=this.doBeforeLoadData(sRequest,oResponse);if(ok){var newRecords=this._oRecordSet.replace(oResponse);if(newRecords){this.replaceRows(newRecords);}}};YAHOO.widget.ColumnSet=function(aHeaders){this._sName="instance"+YAHOO.widget.ColumnSet._nCount;var tree=[];var flat=[];var keys=[];var headers=[];var nodelevel=-1;var parseColumns=function(nodeList,parent){nodelevel++;if(!tree[nodelevel]){tree[nodelevel]=[];} -var nodeLevelMaxChildren=0;var recurseChildren=function(nodeList){var tmpMax=0;for(var i=0;i<nodeList.length;i++){if(nodeList[i].children){tmpMax++;recurseChildren(nodeList[i].children);} -if(tmpMax>nodeLevelMaxChildren){nodeLevelMaxChildren=tmpMax;}}};recurseChildren(nodeList);for(var j=0;j<nodeList.length;j++){var oColumn=new YAHOO.widget.Column(nodeList[j]);flat.push(oColumn);if(parent){oColumn._parent=parent;} -oColumn._rowspan=1;oColumn._colspan=1;if(nodeList[j].children){var children=nodeList[j].children;var length=children.length;for(var k=0;k<length;k++){var child=children[k];if(oColumn.className&&(child.className===undefined)){child.className=oColumn.className;} -if(oColumn.editor&&(child.editor===undefined)){child.editor=oColumn.editor;} -if(oColumn.formatter&&(child.formatter===undefined)){child.formatter=oColumn.formatter;} -if(oColumn.parser&&(child.parser===undefined)){child.parser=oColumn.parser;} -if(oColumn.resizeable&&(child.resizeable===undefined)){child.resizeable=oColumn.resizeable;} -if(oColumn.type&&(child.type===undefined)){child.type=oColumn.type;} -if(oColumn.width&&(child.width===undefined)){child.width=oColumn.width;}} -oColumn._colspan=length;if(parent&&parent._colspan){parent._colspan+=length-1;parent._children=[];parent._children.push(oColumn);} -if(!tree[nodelevel+1]){tree[nodelevel+1]=[];} -parseColumns(children,oColumn);} -else if(nodeLevelMaxChildren>0){oColumn._rowspan+=nodeLevelMaxChildren;oColumn._index=keys.length;keys.push(oColumn);} -else{oColumn._index=keys.length;keys.push(oColumn);} -tree[nodelevel].push(oColumn);} -nodelevel--;};if(aHeaders.length>0){parseColumns(aHeaders);} -var recurseAncestors=function(i,oColumn){headers[i].push(oColumn._id);if(oColumn._parent){recurseAncestors(i,oColumn._parent);}};for(var i=0;i<keys.length;i++){headers[i]=[];recurseAncestors(i,keys[i]);headers[i]=headers[i].reverse();headers[i]=headers[i].join(" ");} -this.tree=tree;this.flat=flat;this.keys=keys;this.headers=headers;YAHOO.widget.ColumnSet._nCount++;};YAHOO.widget.ColumnSet._nCount=0;YAHOO.widget.ColumnSet.prototype._sName=null;YAHOO.widget.ColumnSet.prototype.tree=null;YAHOO.widget.ColumnSet.prototype.flat=null;YAHOO.widget.ColumnSet.prototype.keys=null;YAHOO.widget.ColumnSet.prototype.headers=null;YAHOO.widget.ColumnSet.prototype.toString=function(){return"ColumnSet "+this._sName;};YAHOO.widget.Column=function(oConfigs){this._id="yui-dtcol"+YAHOO.widget.Column._nCount;if(typeof oConfigs=="object"){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}} -YAHOO.widget.Column._nCount++;};YAHOO.widget.Column._nCount=0;YAHOO.widget.Column.prototype._id=null;YAHOO.widget.Column.prototype._index=null;YAHOO.widget.Column.prototype._colspan=1;YAHOO.widget.Column.prototype._rowspan=1;YAHOO.widget.Column.prototype._parent=null;YAHOO.widget.Column.prototype._children=null;YAHOO.widget.Column.prototype._width=null;YAHOO.widget.Column.prototype._minWidth=null;YAHOO.widget.Column.prototype.key=null;YAHOO.widget.Column.prototype.text=null;YAHOO.widget.Column.prototype.type="string";YAHOO.widget.Column.prototype.abbr=null;YAHOO.widget.Column.prototype.children=null;YAHOO.widget.Column.prototype.width=null;YAHOO.widget.Column.prototype.className=null;YAHOO.widget.Column.prototype.formatter=null;YAHOO.widget.Column.prototype.parser=null;YAHOO.widget.Column.prototype.editor=null;YAHOO.widget.Column.prototype.resizeable=false;YAHOO.widget.Column.prototype.sortable=false;YAHOO.widget.Column.prototype.descFunction=null;YAHOO.widget.Column.prototype.ascFunction=null;YAHOO.widget.Column.prototype.getId=function(){return this._id;};YAHOO.widget.Column.prototype.getColSpan=function(){return this._colspan;};YAHOO.widget.Column.prototype.getRowSpan=function(){return this._rowspan;};YAHOO.widget.Column.prototype.format=function(elCell,oRecord){var oData=(this.key)?oRecord[this.key]:null;if(this.formatter){this.formatter(elCell,oRecord,this,oData);} -else{var type=this.type;var markup="";var classname="";switch(type){case"checkbox":YAHOO.widget.Column.formatCheckbox(elCell,oRecord,this,oData);classname=YAHOO.widget.DataTable.CLASS_CHECKBOX;break;case"currency":YAHOO.widget.Column.formatCurrency(elCell,oRecord,this,oData);classname=YAHOO.widget.DataTable.CLASS_CURRENCY;break;case"date":YAHOO.widget.Column.formatDate(elCell,oRecord,this,oData);classname=YAHOO.widget.DataTable.CLASS_DATE;break;case"email":YAHOO.widget.Column.formatEmail(elCell,oRecord,this,oData);classname=YAHOO.widget.DataTable.CLASS_EMAIL;break;case"link":YAHOO.widget.Column.formatLink(elCell,oRecord,this,oData);classname=YAHOO.widget.DataTable.CLASS_LINK;break;case"number":YAHOO.widget.Column.formatNumber(elCell,oRecord,this,oData);classname=YAHOO.widget.DataTable.CLASS_NUMBER;break;case"select":YAHOO.widget.Column.formatSelect(elCell,oRecord,this,oData);classname=YAHOO.widget.DataTable.CLASS_SELECT;break;default:elCell.innerHTML=(oData)?oData.toString():"";classname=YAHOO.widget.DataTable.CLASS_STRING;break;} -YAHOO.util.Dom.addClass(elCell,classname);if(this.className){YAHOO.util.Dom.addClass(elCell,this.className);}} -if(this.editor){YAHOO.util.Dom.addClass(elCell,YAHOO.widget.DataTable.CLASS_EDITABLE);}};YAHOO.widget.Column.formatCheckbox=function(elCell,oRecord,oColumn,oData){var bChecked=oData;bChecked=(bChecked)?" checked":"";elCell.innerHTML="<input type=\"checkbox\""+bChecked+" class=\""+YAHOO.widget.DataTable.CLASS_CHECKBOX+"\">";};YAHOO.widget.Column.formatCurrency=function(elCell,oRecord,oColumn,oData){var nAmount=oData;var markup;if(nAmount){markup="$"+nAmount;var dotIndex=markup.indexOf(".");if(dotIndex<0){markup+=".00";} -else{while(dotIndex!=markup.length-3){markup+="0";}}} -else{markup="";} -elCell.innerHTML=markup;};YAHOO.widget.Column.formatDate=function(elCell,oRecord,oColumn,oData){var oDate=oData;if(oDate){elCell.innerHTML=oDate.getMonth()+"/"+oDate.getDate()+"/"+oDate.getFullYear();} -else{elCell.innerHTML="";}};YAHOO.widget.Column.formatEmail=function(elCell,oRecord,oColumn,oData){var sEmail=oData;if(sEmail){elCell.innerHTML="<a href=\"mailto:"+sEmail+"\">"+sEmail+"</a>";} -else{elCell.innerHTML="";}};YAHOO.widget.Column.formatLink=function(elCell,oRecord,oColumn,oData){var sLink=oData;if(sLink){elCell.innerHTML="<a href=\""+sLink+"\">"+sLink+"</a>";} -else{elCell.innerHTML="";}};YAHOO.widget.Column.formatNumber=function(elCell,oRecord,oColumn,oData){var nNumber=oData;if(nNumber){elCell.innerHTML=nNumber.toString();} -else{elCell.innerHTML="";}};YAHOO.widget.Column.formatSelect=function(elCell,oRecord,oColumn,oData){var selectedValue=oData;var options=oColumn.selectOptions;var markup="<select>";if(options){for(var i=0;i<options.length;i++){var option=options[i];markup+="<option value=\""+option+"\"";if(selectedValue===option){markup+=" selected";} -markup+=">"+option+"</option>";}} -else{if(selectedValue){markup+="<option value=\""+selectedValue+"\" selected>"+selectedValue+"</option>";}} -markup+="</select>";elCell.innerHTML=markup;};YAHOO.widget.Column.prototype.parse=function(sMarkup){if(this.parser){return this.parser(sMarkup);} -else{var data=null;switch(this.type){case"checkbox":data=YAHOO.widget.Column.parseCheckbox(sMarkup);break;case"currency":data=YAHOO.widget.Column.parseCurrency(sMarkup);break;case"date":data=YAHOO.widget.Column.parseDate(sMarkup);break;case"number":data=YAHOO.widget.Column.parseNumber(sMarkup);break;case"select":data=YAHOO.widget.Column.parseSelect(sMarkup);break;default:if(sMarkup){data=sMarkup;} -break;} -return data;}};YAHOO.widget.Column.parseCheckbox=function(sMarkup){return(sMarkup.indexOf("checked")<0)?false:true;};YAHOO.widget.Column.parseCurrency=function(sMarkup){return parseFloat(sMarkup.substring(1));};YAHOO.widget.Column.parseDate=function(sMarkup){var mm=sMarkup.substring(0,sMarkup.indexOf("/"));sMarkup=sMarkup.substring(sMarkup.indexOf("/")+1);var dd=sMarkup.substring(0,sMarkup.indexOf("/"));var yy=sMarkup.substring(sMarkup.indexOf("/")+1);return new Date(yy,mm,dd);};YAHOO.widget.Column.parseNumber=function(sMarkup){return parseFloat(sMarkup);};YAHOO.widget.Column.parseSelect=function(sMarkup){};YAHOO.widget.Column.prototype.getEditor=function(elCell,oRecord){var oEditor=this.editor;if(oEditor.constructor==String){oEditor=new YAHOO.widget.ColumnEditor(this.editor);oEditor.show(elCell,oRecord,this);this.editor=oEditor;} -else if(oEditor instanceof YAHOO.widget.ColumnEditor){oEditor.show(elCell,oRecord,this);} -return oEditor;};YAHOO.widget.ColumnEditor=function(sType){this.type=sType;var container=document.body.appendChild(document.createElement("div"));container.style.position="absolute";container.style.zIndex=9000;container.id="yui-dt-coled"+YAHOO.widget.ColumnEditor._nCount;this.container=container;switch(this.type){case"textbox":this.createTextboxEditor();break;case"textarea":this.createTextareaEditor();break;default:break;} -YAHOO.widget.ColumnEditor._nCount++;};YAHOO.widget.ColumnEditor._nCount=0;YAHOO.widget.ColumnEditor.prototype.container=null;YAHOO.widget.ColumnEditor.prototype.column=null;YAHOO.widget.ColumnEditor.prototype.type=null;YAHOO.widget.ColumnEditor.prototype.input=null;YAHOO.widget.ColumnEditor.prototype.show=function(elCell,oRecord,oColumn){this.cell=elCell;this.record=oRecord;this.column=oColumn;switch(this.type){case"textbox":this.showTextboxEditor(elCell,oRecord,oColumn);break;case"textarea":this.showTextareaEditor(elCell,oRecord,oColumn);break;default:break;}};YAHOO.widget.ColumnEditor.prototype.getValue=function(){var value;switch(this.type){case"textbox":value=this.getTextboxEditorValue();break;case"textarea":value=this.getTextareaEditorValue();break;default:break;} -return value;};YAHOO.widget.ColumnEditor.prototype.createTextboxEditor=function(){var elTextbox=this.container.appendChild(document.createElement("input"));elTextbox.setAttribute("autocomplete","off");this.input=elTextbox;};YAHOO.widget.ColumnEditor.prototype.createTextareaEditor=function(){var elTextarea=this.container.appendChild(document.createElement("textarea"));this.input=elTextarea;};YAHOO.widget.ColumnEditor.prototype.showTextboxEditor=function(elCell,oRecord,oColumn){this.input.style.width=(parseInt(elCell.offsetWidth,10)-7)+"px";this.input.style.height=(parseInt(elCell.offsetHeight,10)-7)+"px";this.input.value=elCell.innerHTML;var x,y;if(navigator.userAgent.toLowerCase().indexOf("opera")!=-1){x=elCell.offsetLeft;y=elCell.offsetTop;while(elCell.offsetParent){x+=elCell.offsetParent.offsetLeft;y+=elCell.offsetParent.offsetTop;elCell=elCell.offsetParent;}} -else{var xy=YAHOO.util.Dom.getXY(elCell);x=parseInt(YAHOO.util.Dom.getX(elCell),10);y=parseInt(YAHOO.util.Dom.getY(elCell),10);} -this.container.style.left=x+"px";this.container.style.top=y+"px";this.container.style.display="block";this.input.tabIndex=0;this.input.focus();this.input.select();};YAHOO.widget.ColumnEditor.prototype.showTextareaEditor=function(elCell,oRecord,oColumn){this.input.style.width=(parseInt(elCell.offsetWidth,10)-7)+"px";this.input.style.height=4*(parseInt(elCell.offsetHeight,10)-7)+"px";this.input.value=elCell.innerHTML;var x,y;if(navigator.userAgent.toLowerCase().indexOf("opera")!=-1){x=elCell.offsetLeft;y=elCell.offsetTop;while(elCell.offsetParent){x+=elCell.offsetParent.offsetLeft;y+=elCell.offsetParent.offsetTop;elCell=elCell.offsetParent;}} -else{var xy=YAHOO.util.Dom.getXY(elCell);x=parseInt(YAHOO.util.Dom.getX(elCell),10);y=parseInt(YAHOO.util.Dom.getY(elCell),10);} -this.container.style.left=x+"px";this.container.style.top=y+"px";this.container.style.display="block";this.input.tabIndex=0;this.input.focus();this.input.select();};YAHOO.widget.ColumnEditor.prototype.hide=function(){this.input.tabIndex=-1;this.container.style.display="none";};YAHOO.widget.ColumnEditor.prototype.getTextboxEditorValue=function(){return this.input.value;};YAHOO.widget.ColumnEditor.prototype.getTextareaEditorValue=function(){return this.input.value;};YAHOO.util.Sort={compareAsc:function(a,b){if(a.constructor==String){a=a.toLowerCase();} -if(b.constructor==String){b=b.toLowerCase();} -if(a<b){return-1;} -else if(a>b){return 1;} -else{return 0;}},compareDesc:function(a,b){if(a.constructor==String){a=a.toLowerCase();} -if(b.constructor==String){b=b.toLowerCase();} -if(a<b){return 1;} -else if(a>b){return-1;} -else{return 0;}}};YAHOO.util.WidthResizer=function(oDataTable,colId,handleId,sGroup,config){if(colId){this.cell=YAHOO.util.Dom.get(colId);this.init(handleId,sGroup,config);this.datatable=oDataTable;this.setYConstraint(0,0);} -else{}};if(YAHOO.util.DD){YAHOO.extend(YAHOO.util.WidthResizer,YAHOO.util.DD);} -YAHOO.util.WidthResizer.prototype.onMouseDown=function(e){this.startWidth=this.cell.offsetWidth;this.startPos=YAHOO.util.Dom.getX(this.getDragEl());if(this.datatable.fixedwidth){var cellText=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_COLUMNTEXT,"span",this.cell)[0];this.minWidth=cellText.offsetWidth+6;var sib=this.cell.nextSibling;var sibCellText=YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_COLUMNTEXT,"span",sib)[0];this.sibMinWidth=sibCellText.offsetWidth+6;var left=((this.startWidth-this.minWidth)<0)?0:(this.startWidth-this.minWidth);var right=((sib.offsetWidth-this.sibMinWidth)<0)?0:(sib.offsetWidth-this.sibMinWidth);this.setXConstraint(left,right);}};YAHOO.util.WidthResizer.prototype.onMouseUp=function(e){var resizeStyle=YAHOO.util.Dom.get(this.handleElId).style;resizeStyle.left="auto";resizeStyle.right=0;resizeStyle.marginRight="-6px";resizeStyle.width="6px";this.datatable.fireEvent("columnResizeEvent",{datatable:this.datatable,target:YAHOO.util.Dom.get(this.id)});};YAHOO.util.WidthResizer.prototype.onDrag=function(e){if(newWidth<this.minWidth){newWidth=this.minWidth;} -var oDataTable=this.datatable;var elCell=this.cell;if(oDataTable.fixedwidth){var sib=elCell.nextSibling;var sibnewwidth=sib.offsetWidth-offsetX;if(sibnewwidth<this.sibMinWidth){sibnewwidth=this.sibMinWidth;} -for(var i=0;i<oDataTable._oColumnSet.length;i++){if((i!=elCell.index)&&(i!=sibIndex)){YAHOO.util.Dom.get(oDataTable._oColumnSet.keys[i].id).style.width=oDataTable._oColumnSet.keys[i].width+"px";}} -sib.style.width=sibnewwidth;elCell.style.width=newWidth+"px";} -else{elCell.style.width=newWidth+"px";}};YAHOO.widget.RecordSet=function(data){this._nIndex=YAHOO.widget.RecordSet._nCount;this._records=[];if(data){if(data.constructor==Array){this.addRecords(data);} -else if(data.constructor==Object){this.addRecord(data);}} -this.createEvent("recordUpdateEvent");YAHOO.widget.RecordSet._nCount++;};if(YAHOO.util.EventProvider){YAHOO.augment(YAHOO.widget.RecordSet,YAHOO.util.EventProvider);} -else{} -YAHOO.widget.RecordSet._nCount=0;YAHOO.widget.RecordSet.prototype._nIndex=null;YAHOO.widget.RecordSet.prototype._length=null;YAHOO.widget.RecordSet.prototype.toString=function(){return"RecordSet instance "+this._nIndex;};YAHOO.widget.RecordSet.prototype.getLength=function(){return this._length;};YAHOO.widget.RecordSet.prototype.getRecord=function(identifier){if(identifier){if(identifier.constructor==String){for(var i=0;i<this._records.length;i++){if(this._records[i].id==identifier){return this._records[i];}} -return null;} -else{return this._records[identifier];}} -return null;};YAHOO.widget.RecordSet.prototype.getRecords=function(i,range){if(i===undefined){return this._records;} -i=parseInt(i,10);if(isNaN(i)){return null;} -if(range===undefined){return this._records.slice(i);} -range=parseInt(range,10);if(isNaN(range)){return null;} -return this._records.slice(i,i+range);};YAHOO.widget.RecordSet.prototype.updateRecord=function(oRecord,sKey,oData){var oldData=oRecord[sKey];oRecord[sKey]=oData;this.fireEvent("recordUpdateEvent",{record:oRecord,key:sKey,newData:oData,oldData:oldData});};YAHOO.widget.RecordSet.prototype.addRecord=function(oObjectLiteral,index){if(oObjectLiteral){var oRecord=new YAHOO.widget.Record(oObjectLiteral);if(!isNaN(index)&&(index>-1)){this._records.splice(index,0,oRecord);} -else{this._records.push(oRecord);} -this._length++;return oRecord;} -else{return null;}};YAHOO.widget.RecordSet.prototype.addRecords=function(data,index){if(data){if(data.constructor==Array){var newRecords=[];for(var i=0;i<data.length;i++){var record=this.addRecord(data[i],index);newRecords.push(record);} -return newRecords;} -else if(data.constructor==Object){return this.addRecord(data);}} -else{return null;}};YAHOO.widget.RecordSet.prototype.append=function(data){if(data){if(data.constructor==Array){var newRecords=[];for(var i=0;i<data.length;i++){var record=this.addRecord(data[i]);newRecords.push(record);} -return newRecords;} -else if(data.constructor==Object){return this.addRecord(data);}} -else{return null;}};YAHOO.widget.RecordSet.prototype.insert=function(data){if(data){if(data.constructor==Array){var newRecords=[];for(var i=data.length-1;i>-1;i--){var record=this.addRecord(data[i],0);newRecords.push(record);} -return newRecords;} -else if(data.constructor==Object){return this.addRecord(data,0);}} -else{return null;}};YAHOO.widget.RecordSet.prototype.replace=function(data){if(data){this.reset();return this.append(data);} -else{return null;}};YAHOO.widget.RecordSet.prototype.sort=function(fnSort){return this._records.sort(fnSort);};YAHOO.widget.RecordSet.prototype.deleteRecord=function(i,range){if(!range||isNaN(range)){range=1;} -if(i&&!isNaN(i)){this._records.splice(i,range);this._length=this._length-range;}};YAHOO.widget.RecordSet.prototype.reset=function(){this._records=[];this._length=0;};YAHOO.widget.Record=function(oLiteral){if(typeof oLiteral=="object"){for(var sKey in oLiteral){if(sKey){this[sKey]=oLiteral[sKey];}}} -this.id="yui-dtrec"+YAHOO.widget.Record._nCount;YAHOO.widget.Record._nCount++;};YAHOO.widget.Record._nCount=0;YAHOO.widget.Record.prototype.id=null;YAHOO.register("datatable",YAHOO.widget.DataTable,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/datatable/datatable-beta.js b/interface/web/js/yui/datatable/datatable-beta.js deleted file mode 100644 index 2630b0f3fa..0000000000 --- a/interface/web/js/yui/datatable/datatable-beta.js +++ /dev/null @@ -1,4930 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The DataTable widget provides a progressively enhanced DHTML control for - * displaying tabular data across A-grade browsers. - * - * @module datatable - * @requires yahoo, dom, event, datasource - * @optional dragdrop - * @title DataTable Widget - * @beta - */ - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * DataTable class for the YUI DataTable widget. - * - * @class DataTable - * @uses YAHOO.util.EventProvider - * @constructor - * @param elContainer {HTMLElement} Container element for the TABLE. - * @param oColumnSet {YAHOO.widget.ColumnSet} ColumnSet instance. - * @param oDataSource {YAHOO.util.DataSource} DataSource instance. - * @param oConfigs {object} (optional) Object literal of configuration values. - */ -YAHOO.widget.DataTable = function(elContainer,oColumnSet,oDataSource,oConfigs) { - // Internal vars - var i; - this._nIndex = YAHOO.widget.DataTable._nCount; - this._sName = "instance" + this._nIndex; - this.id = "yui-dt"+this._nIndex; - - // Validate configs - if(typeof oConfigs == "object") { - for(var sConfig in oConfigs) { - this[sConfig] = oConfigs[sConfig]; - } - } - - // Validate DataSource - if(oDataSource) { - if(oDataSource instanceof YAHOO.util.DataSource) { - this.dataSource = oDataSource; - } - else { - } - } - - // Validate ColumnSet - if(oColumnSet && (oColumnSet instanceof YAHOO.widget.ColumnSet)) { - this._oColumnSet = oColumnSet; - } - else { - return; - } - - // Create RecordSet - this._oRecordSet = new YAHOO.widget.RecordSet(); - - // Validate HTML Element - elContainer = YAHOO.util.Dom.get(elContainer); - if(elContainer && elContainer.tagName && (elContainer.tagName.toLowerCase() == "div")) { - this._elContainer = elContainer; - // Peek in container child nodes to see if TABLE already exists - var elTable = null; - if(elContainer.hasChildNodes()) { - var children = elContainer.childNodes; - for(i=0; i<children.length; i++) { - if(children[i].tagName && children[i].tagName.toLowerCase() == "table") { - elTable = children[i]; - break; - } - } - } - - // Progressively enhance an existing table from markup... - // while using the markup as the source of data - if(elTable && !this.dataSource) { - // Fill RecordSet with data parsed out of table - var aRecords = []; - - // Iterate through each TBODY - for(i=0; i<elTable.tBodies.length; i++) { - var elBody = elTable.tBodies[i]; - - // Iterate through each TR - for(var j=0; j<elBody.rows.length; j++) { - var elRow = elBody.rows[j]; - var oRecord = {}; - - // Iterate through each TD - for(var k=0; k<elRow.cells.length; k++) { - - //var elCell = elRow.cells[l]; - //elCell.id = this.id+"-bdrow"+k+"-cell"+l; - //TODO: can we parse a column with null key? - oRecord[oColumnSet.keys[k].key] = oColumnSet.keys[k].parse(elRow.cells[k].innerHTML); - } - aRecords.push(oRecord); - } - } - - this._initTable(); - - var ok = this.doBeforeLoadData(aRecords); - if(ok) { - this._oRecordSet.addRecords(aRecords); - this.paginateRows(); - } - } - // Create markup from scratch using the provided DataSource - else if(this.dataSource) { - this._initTable(); - // Send out for data in an asynchronous request - oDataSource.sendRequest(this.initialRequest, this.onDataReturnPaginateRows, this); - } - // Else there is no data - else { - this._initTable(); - this.showEmptyMessage(); - } - } - // Container element not found in document - else { - return; - } - - // Set up sort - this.subscribe("headCellClickEvent",this.onEventSortColumn); - - // Set up context menu - //TODO: does trigger have to exist? can trigger be TBODY rather than rows? - if(this.contextMenu && this.contextMenuOptions) { - this.contextMenu = new YAHOO.widget.ContextMenu(this.id+"-cm", { trigger: this._elBody.rows } ); - this.contextMenu.addItem("delete item"); - this.contextMenu.render(document.body); - } - - // Set up event model - elTable = this._elTable; - ///////////////////////////////////////////////////////////////////////////// - // - // DOM Events - // - ///////////////////////////////////////////////////////////////////////////// - //YAHOO.util.Event.addListener(this._elContainer, "focus", this._onFocus, this); - YAHOO.util.Event.addListener(elTable, "click", this._onClick, this); - YAHOO.util.Event.addListener(elTable, "dblclick", this._onDoubleclick, this); - YAHOO.util.Event.addListener(elTable, "mouseout", this._onMouseout, this); - YAHOO.util.Event.addListener(elTable, "mouseover", this._onMouseover, this); - YAHOO.util.Event.addListener(elTable, "mousedown", this._onMousedown, this); - //YAHOO.util.Event.addListener(elTable, "mouseup", this._onMouseup, this); - //YAHOO.util.Event.addListener(elTable, "mousemove", this._onMousemove, this); - YAHOO.util.Event.addListener(elTable, "keydown", this._onKeydown, this); - YAHOO.util.Event.addListener(elTable, "keypress", this._onKeypress, this); - YAHOO.util.Event.addListener(document, "keyup", this._onDocumentKeyup, this); - YAHOO.util.Event.addListener(elTable, "keyup", this._onKeyup, this); - //YAHOO.util.Event.addListener(elTable, "focus", this._onFocus, this); - YAHOO.util.Event.addListener(elTable, "blur", this._onBlur, this); - - ///////////////////////////////////////////////////////////////////////////// - // - // Custom Events - // - ///////////////////////////////////////////////////////////////////////////// - - /** - * Fired when a mouseover occurs on a TD element. - * - * @event cellMouseoverEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellMouseoverEvent"); - - /** - * Fired when a mouseout occurs on a TD element. - * - * @event cellMouseoutEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellMouseoutEvent"); - - /** - * Fired when a TH cell element is mouseover. - * - * @event headCellMouseoverEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - * - */ - this.createEvent("headCellMouseoverEvent"); - - /** - * Fired when a TH cell element is mouseout. - * - * @event headCellMouseoutEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - * - */ - this.createEvent("headCellMouseoutEvent"); - - /** - * Fired when a TABLE element is mouseover. - * - * @event tableMouseoverEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableMouseoverEvent"); - - /** - * Fired when a TABLE element is mouseout. - * - * @event tableMouseoutEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableMouseoutEvent"); - - /** - * Fired when a mousedown occurs on a TD element. - * - * @event cellMousedownEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellMousedownEvent"); - - /** - * Fired when a TH cell element is mousedown. - * - * @event headCellMousedownEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - */ - this.createEvent("headCellMousedownEvent"); - - /** - * Fired when a TABLE element is mousedown. - * - * @event tableMousedownEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableMousedownEvent"); - - /** - * Fired when a CHECKBOX element is clicked. - * - * @event checkboxClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The CHECKBOX element. - */ - this.checkboxClickEvent = this.createEvent("checkboxClickEvent"); - //this.checkboxClickEvent.subscribeEvent.subscribe(this._registerEvent,{type:"checkboxClickEvent"},this); - - /** - * Fired when a RADIO element is clicked. - * - * @event radioClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The RADIO element. - */ - this.createEvent("radioClickEvent"); - - /** - * Fired when a TD element is clicked. - * - * @event cellClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellClickEvent"); - - /** - * Fired when a TH cell element is clicked. - * - * @event headCellClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - */ - this.createEvent("headCellClickEvent"); - - /** - * Fired when a TABLE element is clicked. - * - * @event tableClickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableClickEvent"); - - /** - * Fired when a TD element is doubleclicked. - * - * @event cellDoubleclickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TD element. - */ - this.createEvent("cellDoubleclickEvent"); - - /** - * Fired when a TH cell element is doubleclicked. - * - * @event headCellDoubleclickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TH element. - */ - this.createEvent("headCellDoubleclickEvent"); - - /** - * Fired when a TABLE element is doubleclicked. - * - * @event tableDoubleclickEvent - * @param oArgs.event {HTMLEvent} The event object. - * @param oArgs.target {HTMLElement} The TABLE element. - * - */ - this.createEvent("tableDoubleclickEvent"); - - /** - * Fired when a column is sorted. - * - * @event columnSortEvent - * @param oArgs.column {YAHOO.widget.Column} The Column instance. - * @param oArgs.dir {String} Sort direction "asc" or "desc". - */ - this.createEvent("columnSortEvent"); - - /** - * Fired when an editor is activated. - * - * @event editorShowEvent - * @param oArgs.target {HTMLElement} The TD element. - * @param oArgs.column {YAHOO.widget.Column} The Column instance. - */ - this.createEvent("editorShowEvent"); - - - /** - * Fired when a cell is edited. - * - * @event cellEditEvent - * @param oArgs.target {HTMLElement} The TD element. - * @param oArgs.newData {Object} New data value. - * @param oArgs.oldData {Object} Old data value. - */ - this.createEvent("cellEditEvent"); - - /** - * Fired when a column is resized. - * - * @event columnResizeEvent - * @param oArgs.target {HTMLElement} The TH element. - */ - this.createEvent("columnResizeEvent"); - - /** - * Fired when DataTable instance is first initialized. - * - * @event tableInitEvent - */ - this.createEvent("tableInitEvent"); - - /** - * Fired when DataTable instance is focused. - * - * @event tableFocusEvent - */ - this.createEvent("tableFocusEvent"); - - /** - * Fired when data is returned from DataSource. - * - * @event dataReturnEvent - * @param oArgs.request {String} Original request. - * @param oArgs.response {Object} Response object. - */ - this.createEvent("dataReturnEvent"); - - /** - * Fired when DataTable is paginated. - * - * @event paginateEvent - */ - this.createEvent("paginateEvent"); - - /** - * Fired when a TD element is formatted. - * - * @event cellFormatEvent - * @param oArgs.el {HTMLElement} Reference to the TD element. - */ - this.createEvent("cellFormatEvent"); - - /** - * Fired when an element is selected. - * - * @event selectEvent - * @param oArgs.els {Array} An array of the selected element(s). - */ - this.createEvent("selectEvent"); - - /** - * Fired when an element is unselected. - * - * @event unselectEvent - * @param oArgs.els {Array} An array of the unselected element(s). - */ - this.createEvent("unselectEvent"); - - /** - * Fired when an element is highlighted. - * - * @event highlightEvent - * @param oArgs.els {Array} An array of the highlighted element(s). - */ - this.createEvent("highlightEvent"); - - /** - * Fired when an element is unhighlighted. - * - * @event unhighlightEvent - * @param oArgs.els {Array} An array of the unhighlighted element(s). - */ - this.createEvent("unhighlightEvent"); - - /** - * Fired when one or more TR elements are deleted. - * - * @event rowDeleteEvent - * @param oArgs.rowIndexes {Array} The indexes of the deleted rows. - */ - this.createEvent("rowDeleteEvent"); - this.subscribe("rowDeleteEvent", this._onRowDelete); - - /** - * Fired when one or more TR elements are appended. - * - * @event rowAppendEvent - * @param oArgs.rowIds {Array} The IDs of the appended rows. - */ - this.createEvent("rowAppendEvent"); - - /** - * Fired when a Record is updated in the RecordSet. - * - * @event recordSetUpdateEvent - * @param oArgs.record {YAHOO.widget.Record} The Record instance. - * @param oArgs.key {String} The Record key. - * @param oArgs.newData {Object} New data. - * @param oArgs.oldData {Object} New data. - */ - this.createEvent("recordSetUpdateEvent"); - this._oRecordSet.subscribe("recordUpdateEvent", this._onRecordUpdate, this, true); - - - YAHOO.widget.DataTable._nCount++; - this.fireEvent("tableInitEvent"); -}; - -if(YAHOO.util.EventProvider) { - YAHOO.augment(YAHOO.widget.DataTable, YAHOO.util.EventProvider); -} -else { -} - -///////////////////////////////////////////////////////////////////////////// -// -// Public constants -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Class name assigned to TBODY element that holds data rows. - * - * @property CLASS_BODY - * @type String - * @static - * @final - * @default "yui-dt-body" - */ -YAHOO.widget.DataTable.CLASS_BODY = "yui-dt-body"; - -/** - * Class name assigned to container element within THEAD. - * - * @property CLASS_HEADCONTAINER - * @type String - * @static - * @final - */ -YAHOO.widget.DataTable.CLASS_HEADCONTAINER = "yui-dt-headcontainer"; - -/** - * Class name assigned to resizer handle element within THEAD. - * - * @property CLASS_HEADRESIZER - * @type String - * @static - * @final - * @default "yui-dt-headresizer" - */ -YAHOO.widget.DataTable.CLASS_HEADRESIZER = "yui-dt-headresizer"; - -/** - * Class name assigned to text displayed within THEAD. - * - * @property CLASS_HEADTEXT - * @type String - * @static - * @final - * @default "yui-dt-headtext" - */ -YAHOO.widget.DataTable.CLASS_HEADTEXT = "yui-dt-headtext"; - -/** - * Class name assigned to even TR elements. - * - * @property CLASS_EVEN - * @type String - * @static - * @final - * @default "yui-dt-even - */ -YAHOO.widget.DataTable.CLASS_EVEN = "yui-dt-even"; - -/** - * Class name assigned to odd TR elements. - * - * @property CLASS_ODD - * @type String - * @static - * @final - * @default "yui-dt-odd" - */ -YAHOO.widget.DataTable.CLASS_ODD = "yui-dt-odd"; - -/** - * Class name assigned to empty elements. - * - * @property CLASS_EMPTY - * @type String - * @static - * @final - * @default "yui-dt-empty" - */ -YAHOO.widget.DataTable.CLASS_EMPTY = "yui-dt-empty"; - -/** - * Class name assigned to loading message. - * - * @property CLASS_LOADING - * @type String - * @static - * @final - * @default "yui-dt-loading" - */ -YAHOO.widget.DataTable.CLASS_LOADING = "yui-dt-loading"; - -/** - * Class name assigned to selected elements. - * - * @property CLASS_SELECTED - * @type String - * @static - * @final - * @default "yui-dt-selected" - */ -YAHOO.widget.DataTable.CLASS_SELECTED = "yui-dt-selected"; - -/** - * Class name assigned to highlighted element. - * - * @property CLASS_HIGHLIGHT - * @type String - * @static - * @final - * @default "yui-dt-highlight" - */ -YAHOO.widget.DataTable.CLASS_HIGHLIGHT = "yui-dt-highlight"; - -/** - * Class name assigned to certain elements of a scrollable DataTable. - * - * @property CLASS_SCROLLABLE - * @type String - * @static - * @final - * @default "yui-dt-scrollable" - */ -YAHOO.widget.DataTable.CLASS_SCROLLABLE = "yui-dt-scrollable"; - -/** - * Class name assigned to column headers of sortable Columns. - * - * @property CLASS_SORTABLE - * @type String - * @static - * @final - * @default "yui-dt-sortable" - */ -YAHOO.widget.DataTable.CLASS_SORTABLE = "yui-dt-sortable"; - -/** - * Class name assigned to column headers when sorted in ascending order. - * - * @property CLASS_SORTEDBYASC - * @type String - * @static - * @final - * @default "yui-dt-sortedbyasc" - */ -YAHOO.widget.DataTable.CLASS_SORTEDBYASC = "yui-dt-sortedbyasc"; - -/** - * Class name assigned to column headers when sorted in descending order. - * - * @property CLASS_SORTEDBYDESC - * @type String - * @static - * @final - * @default "yui-dt-sortedbydesc" - */ -YAHOO.widget.DataTable.CLASS_SORTEDBYDESC = "yui-dt-sortedbydesc"; - -/** - * Class name assigned to the pagination link "<<". - * - * @property CLASS_FIRSTLINK - * @type String - * @static - * @final - * @default "yui-dt-firstlink" - */ -YAHOO.widget.DataTable.CLASS_FIRSTLINK = "yui-dt-firstlink"; - -/** - * Class name assigned to the pagination link "<<" when it is disabled. - * - * @property CLASS_FIRSTPAGE - * @type String - * @static - * @final - * @default "yui-dt-firstpage" - */ -YAHOO.widget.DataTable.CLASS_FIRSTPAGE = "yui-dt-firstpage"; - -/** - * Class name assigned to the pagination link ">>". - * - * @property CLASS_LASTLINK - * @type String - * @static - * @final - * @default "yui-dt-lastlink" - */ -YAHOO.widget.DataTable.CLASS_LASTLINK = "yui-dt-lastlink"; - -/** - * Class name assigned to the pagination link ">>" when it is disabled. - * - * @property CLASS_LASTPAGE - * @type String - * @static - * @final - * @default "yui-dt-lastpage" - */ -YAHOO.widget.DataTable.CLASS_LASTPAGE = "yui-dt-lastpage"; - -/** - * Class name assigned to the pagination link "<". - * - * @property CLASS_PREVLINK - * @type String - * @static - * @final - * @default "yui-dt-prevlink" - */ -YAHOO.widget.DataTable.CLASS_PREVLINK = "yui-dt-prevlink"; - -/** - * Class name assigned to the pagination link "<" when it is disabled. - * - * @property CLASS_PREVPAGE - * @type String - * @static - * @final - * @default "yui-dt-prevpage" - */ -YAHOO.widget.DataTable.CLASS_PREVPAGE = "yui-dt-prevpage"; - -/** - * Class name assigned to the pagination link ">". - * - * @property CLASS_NEXTLINK - * @type String - * @static - * @final - * @default "yui-dt-nextlink" - */ -YAHOO.widget.DataTable.CLASS_NEXTLINK = "yui-dt-nextlink"; - -/** - * Class name assigned to the pagination link ">" when it is disabled. - * - * @property CLASS_NEXTPAGE - * @type String - * @static - * @final - * @default "yui-dt-nextpage" - */ -YAHOO.widget.DataTable.CLASS_NEXTPAGE = "yui-dt-nextpage"; - - -/** - * Class name assigned to pagination links to specific page numbers. - * - * @property CLASS_PAGELINK - * @type String - * @static - * @final - * @default "yui-dt-pagelink" - */ -YAHOO.widget.DataTable.CLASS_PAGELINK = "yui-dt-pagelink"; - -/** - * Class name assigned to pagination links for specific page numbers that are disabled. - * - * @property CLASS_CURRENTPAGE - * @type String - * @static - * @final - * @default "yui-dt-currentpage" - */ -YAHOO.widget.DataTable.CLASS_CURRENTPAGE = "yui-dt-currentpage"; - -/** - * Class name assigned to the pagination SELECT element. - * - * @property CLASS_PAGESELECT - * @type String - * @static - * @final - * @default "yui-dt-pageselect" - */ -YAHOO.widget.DataTable.CLASS_PAGESELECT = "yui-dt-pageselect"; - -/** - * Class name assigned to the pagination links container element. - * - * @property CLASS_PAGELINKS - * @type String - * @static - * @final - * @default "yui-dt-pagelinks" - */ -YAHOO.widget.DataTable.CLASS_PAGELINKS = "yui-dt-pagelinks"; - -/** - * Class name assigned to editable TD elements. - * - * @property CLASS_EDITABLE - * @type String - * @static - * @final - * @default "yui-dt-editable" - */ -YAHOO.widget.DataTable.CLASS_EDITABLE = "yui-dt-editable"; - -/** - * Class name assigned to TD elements of type "checkbox". - * - * @property CLASS_CHECKBOX - * @type String - * @static - * @final - * @default "yui-dt-checkbox" - */ -YAHOO.widget.DataTable.CLASS_CHECKBOX = "yui-dt-checkbox"; - -/** - * Class name assigned to TD elements of type "currency". - * - * @property CLASS_CURRENCY - * @type String - * @static - * @final - * @default "yui-dt-currency" - */ -YAHOO.widget.DataTable.CLASS_CURRENCY = "yui-dt-currency"; - -/** - * Class name assigned to TD elements of type "date". - * - * @property CLASS_DATE - * @type String - * @static - * @final - * @default "yui-dt-date" - */ -YAHOO.widget.DataTable.CLASS_DATE = "yui-dt-date"; - -/** - * Class name assigned to TD elements of type "email". - * - * @property CLASS_EMAIL - * @type String - * @static - * @final - * @default "yui-dt-email" - */ -YAHOO.widget.DataTable.CLASS_EMAIL = "yui-dt-email"; - -/** - * Class name assigned to TD elements of type "link". - * - * @property CLASS_LINK - * @type String - * @static - * @final - * @default "yui-dt-link" - */ -YAHOO.widget.DataTable.CLASS_LINK = "yui-dt-link"; - -/** - * Class name assigned to TD elements of type "number". - * - * @property CLASS_NUMBER - * @type String - * @static - * @final - * @default "yui-dt-number" - */ -YAHOO.widget.DataTable.CLASS_NUMBER = "yui-dt-number"; - -/** - * Class name assigned to TD elements of type "string". - * - * @property CLASS_STRING - * @type String - * @static - * @final - * @default "yui-dt-string" - */ -YAHOO.widget.DataTable.CLASS_STRING = "yui-dt-string"; - -/** - * Message to display if DataTable has no data. - * - * @property MSG_EMPTY - * @type String - * @static - * @final - * @default "No records found." - */ -YAHOO.widget.DataTable.MSG_EMPTY = "No records found."; - -/** - * Message to display while DataTable is loading data. - * - * @property MSG_LOADING - * @type String - * @static - * @final - * @default "Loading data..." - */ -YAHOO.widget.DataTable.MSG_LOADING = "Loading data..."; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple DataTable instances. - * - * @property _nCount - * @type Number - * @private - * @static - */ -YAHOO.widget.DataTable._nCount = 0; - -/** - * Instance index. - * - * @property _nIndex - * @type Number - * @private - */ -YAHOO.widget.DataTable.prototype._nIndex = null; - -/** - * Unique instance name. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.DataTable.prototype._sName = null; - -//TODO: convert these to public members - -/** - * Container element reference. Is null unless the TABLE is built from scratch into the - * provided container. - * - * @property _elContainer - * @type HTMLElement - * @private - */ -YAHOO.widget.DataTable.prototype._elContainer = null; - -/** - * TABLE element reference. - * - * @property _elTable - * @type HTMLElement - * @private - */ -YAHOO.widget.DataTable.prototype._elTable = null; - -/** - * TBODY element reference. - * - * @property _elBody - * @type HTMLElement - * @private - */ -YAHOO.widget.DataTable.prototype._elBody = null; - -/** - * ColumnSet instance. - * - * @property _oColumnSet - * @type YAHOO.widget.ColumnSet - * @private - */ -YAHOO.widget.DataTable.prototype._oColumnSet = null; - -/** - * RecordSet instance. - * - * @property _oRecordSet - * @type YAHOO.widget.RecordSet - * @private - */ -YAHOO.widget.DataTable.prototype._oRecordSet = null; - -/** - * Array of Records that are in the selected state. - * - * @property _aSelectedRecords - * @type YAHOO.widget.Record[] - * @private - */ -YAHOO.widget.DataTable.prototype._aSelectedRecords = null; - -/** - * Internal variable to track whether widget has focus. - * - * @property _bFocused - * @type Boolean - * @private - */ -YAHOO.widget.DataTable.prototype._bFocused = false; - -/** - * Total number of pages, calculated on the fly. - * - * @property _totalPages - * @type Number - * @private - */ -YAHOO.widget.DataTable.prototype._totalPages = null; - - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Creates HTML markup for TABLE, THEAD, TBODY. - * - * @method _initTable - * @private - */ -YAHOO.widget.DataTable.prototype._initTable = function() { - // Clear the container - this._elContainer.innerHTML = ""; - - // Set up scrolling - if(this.scrollable) { - //TODO: conf height - YAHOO.util.Dom.addClass(this._elContainer,YAHOO.widget.DataTable.CLASS_SCROLLABLE); - } - - // Create TABLE - this._elTable = this._elContainer.appendChild(document.createElement("table")); - var elTable = this._elTable; - elTable.tabIndex = 0; - - // Create SUMMARY, if applicable - if(this.summary) { - elTable.summary = this.summary; - } - - // Create CAPTION, if applicable - if(this.caption) { - this._elCaption = elTable.appendChild(document.createElement("caption")); - this._elCaption.innerHTML = this.caption; - } - - // Create THEAD - this._initHead(elTable, this._oColumnSet); - - - // Create TBODY for messages - var elMsgBody = document.createElement("tbody"); - elMsgBody.tabIndex = -1; - this._elMsgRow = elMsgBody.appendChild(document.createElement("tr")); - var elMsgRow = this._elMsgRow; - var elMsgCell = elMsgRow.appendChild(document.createElement("td")); - elMsgCell.colSpan = this._oColumnSet.keys.length; - this._elMsgCell = elMsgCell; - this._elMsgBody = elTable.appendChild(elMsgBody); - this.showLoadingMessage(); - - // Create TBODY for data - this._elBody = elTable.appendChild(document.createElement("tbody")); - this._elBody.tabIndex = -1; - YAHOO.util.Dom.addClass(this._elBody,YAHOO.widget.DataTable.CLASS_BODY); - if(this.scrollable) { - YAHOO.util.Dom.addClass(this._elBody,YAHOO.widget.DataTable.CLASS_SCROLLABLE); - } -}; - -/** - * Populates THEAD element with TH cells as defined by ColumnSet. - * - * @method _initHead - * @private - */ -YAHOO.widget.DataTable.prototype._initHead = function() { - var i,oColumn; - - // Create THEAD - var elHead = document.createElement("thead"); - elHead.tabIndex = -1; - - // Iterate through each row of Column headers... - var colTree = this._oColumnSet.tree; - for(i=0; i<colTree.length; i++) { - var elHeadRow = elHead.appendChild(document.createElement("tr")); - elHeadRow.id = this.id+"-hdrow"+i; - - // ...and create THEAD cells - for(var j=0; j<colTree[i].length; j++) { - oColumn = colTree[i][j]; - var elHeadCell = elHeadRow.appendChild(document.createElement("th")); - elHeadCell.id = oColumn.getId(); - this._initHeadCell(elHeadCell,oColumn,i,j); - } - } - - this._elHead = this._elTable.appendChild(elHead); - - // Add Resizer only after DOM has been updated... - // ...and skip the last column - for(i=0; i<this._oColumnSet.keys.length-1; i++) { - oColumn = this._oColumnSet.keys[i]; - if(oColumn.resizeable && YAHOO.util.DD) { - //TODO: deal with fixed width tables - //TODO: no more oColumn.isLast - if(!this.fixedWidth || (this.fixedwidth && !oColumn.isLast)) { - // TODO: better way to get elHeadContainer - var elHeadContainer = (YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_HEADCONTAINER,"div",YAHOO.util.Dom.get(oColumn.getId())))[0]; - var elHeadResizer = elHeadContainer.appendChild(document.createElement("span")); - elHeadResizer.id = oColumn.getId() + "-resizer"; - YAHOO.util.Dom.addClass(elHeadResizer,YAHOO.widget.DataTable.CLASS_HEADRESIZER); - oColumn.ddResizer = new YAHOO.util.WidthResizer( - this, oColumn.getId(), elHeadResizer.id, elHeadResizer.id); - var cancelClick = function(e) { - YAHOO.util.Event.stopPropagation(e); - }; - YAHOO.util.Event.addListener(elHeadResizer,"click",cancelClick); - } - if(this.fixedWidth) { - elHeadContainer.style.overflow = "hidden"; - elHeadContent.style.overflow = "hidden"; - } - } - } - -}; - -/** - * Populates TH cell as defined by Column. - * - * @method _initHeadCell - * @param elHeadCell {HTMLElement} TH cell element reference. - * @param oColumn {YAHOO.widget.Column} Column object. - * @param row {number} Row index. - * @param col {number} Column index. - * @private - */ -YAHOO.widget.DataTable.prototype._initHeadCell = function(elHeadCell,oColumn,row,col) { - // Clear out the cell of prior content - // TODO: purgeListeners and other validation-related things - var index = this._nIndex; - elHeadCell.columnIndex = col; - if(oColumn.abbr) { - elHeadCell.abbr = oColumn.abbr; - } - if(oColumn.width) { - elHeadCell.style.width = oColumn.width; - } - if(oColumn.className) { - YAHOO.util.Dom.addClass(elHeadCell,oColumn.className); - } - // Apply CSS for sorted tables - if(this.sortedBy && this.sortedBy.colKey) { - if(this.sortedBy.colKey == oColumn.key) { - var sortClass = (this.sortedBy.dir && (this.sortedBy.dir != "asc")) ? - YAHOO.widget.DataTable.CLASS_SORTEDBYDESC : - YAHOO.widget.DataTable.CLASS_SORTEDBYASC; - YAHOO.util.Dom.addClass(elHeadCell,sortClass); - this.sortedBy._id = elHeadCell.id; - } - } - - elHeadCell.innerHTML = ""; - - var elHeadContainer = elHeadCell.appendChild(document.createElement("div")); - elHeadContainer.id = this.id+"-hdrow"+row+"-container"+col; - YAHOO.util.Dom.addClass(elHeadContainer,YAHOO.widget.DataTable.CLASS_HEADCONTAINER); - var elHeadContent = elHeadContainer.appendChild(document.createElement("span")); - elHeadContent.id = this.id+"-hdrow"+row+"-text"+col; - YAHOO.util.Dom.addClass(elHeadContent,YAHOO.widget.DataTable.CLASS_HEADTEXT); - - elHeadCell.rowSpan = oColumn.getRowSpan(); - elHeadCell.colSpan = oColumn.getColSpan(); - - var contentText = oColumn.text || oColumn.key || ""; - if(oColumn.sortable) { - YAHOO.util.Dom.addClass(elHeadContent,YAHOO.widget.DataTable.CLASS_SORTABLE); - //TODO: Make hash configurable to be a server link - //TODO: Make title configurable - //TODO: Separate contentText from an accessibility link that says - // Click to sort ascending and push it offscreen - elHeadContent.innerHTML = "<a href=\"#\" title=\"Click to sort\">" + contentText + "</a>"; - //elHeadContent.innerHTML = contentText; - - } - else { - elHeadContent.innerHTML = contentText; - } -}; - -/** - * Add a new row to table body at position i if given, or to the bottom - * otherwise. Does not fire any events. - * - * @method _addRow - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param index {Number} Position at which to add row. - * @return {String} ID of the added TR element. - * @private - */ -YAHOO.widget.DataTable.prototype._addRow = function(oRecord, index) { - this.hideTableMessages(); - - // Is this an insert or an append? - var insert = (isNaN(index)) ? false : true; - if(!insert) { - index = this._elBody.rows.length; - } - - var oColumnSet = this._oColumnSet; - var oRecordSet = this._oRecordSet; - - var elRow = (insert && this._elBody.rows[index]) ? - this._elBody.insertBefore(document.createElement("tr"),this._elBody.rows[index]) : - this._elBody.appendChild(document.createElement("tr")); - var recId = oRecord.id; - elRow.id = this.id+"-bdrow"+index; - elRow.recordId = recId; - - // Create TBODY cells - for(var j=0; j<oColumnSet.keys.length; j++) { - var oColumn = oColumnSet.keys[j]; - var elCell = elRow.appendChild(document.createElement("td")); - elCell.id = this.id+"-bdrow"+index+"-cell"+j; - elCell.headers = oColumn.id; - elCell.columnIndex = j; - elCell.headers = oColumnSet.headers[j]; - - oColumn.format(elCell, oRecord); - /*p.abx {word-wrap:break-word;} -ought to solve the problem for Safari (the long words will wrap in your -tds, instead of overflowing to the next td. -(this is supported by IE win as well, so hide it if needed). - -One thing, though: it doesn't work in combination with -'white-space:nowrap'.*/ - -// need a div wrapper for safari? - if(this.fixedWidth) { - elCell.style.overflow = "hidden"; - //elCell.style.width = "20px"; - } - } - - if(this.isEmpty && (this._elBody.rows.length > 0)) { - //TODO: hideMessages() - //this._initRows() - //this.isEmpty = false; - } - - // Striping - if(!insert) { - if(index%2) { - YAHOO.util.Dom.addClass(elRow, YAHOO.widget.DataTable.CLASS_ODD); - } - else { - YAHOO.util.Dom.addClass(elRow, YAHOO.widget.DataTable.CLASS_EVEN); - } - } - else { - //TODO: pass in a subset for better performance - this._restripeRows(); - } - - return elRow.id; -}; - -/** - * Restripes rows by applying class YAHOO.widget.DataTable.CLASS_EVEN or - * YAHOO.widget.DataTable.CLASS_ODD. - * - * @method _restripeRows - * @param range {Number} (optional) Range defines a subset of rows to restripe. - * @private - */ -YAHOO.widget.DataTable.prototype._restripeRows = function(range) { - if(!range) { - var rows = this._elBody.rows; - for(var i=0; i<rows.length; i++) { - if(i%2) { - YAHOO.util.Dom.removeClass(rows[i], YAHOO.widget.DataTable.CLASS_EVEN); - YAHOO.util.Dom.addClass(rows[i], YAHOO.widget.DataTable.CLASS_ODD); - } - else { - YAHOO.util.Dom.removeClass(rows[i], YAHOO.widget.DataTable.CLASS_ODD); - YAHOO.util.Dom.addClass(rows[i], YAHOO.widget.DataTable.CLASS_EVEN); - } - } - } - else { - //TODO: allow restriping of a subset of rows for performance - } -}; - -/** - * Updates existing row at position i with data from the given Record. Does not - * fire any events. - * - * @method _updateRow - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param index {Number} Position at which to update row. - * @return {String} ID of the updated TR element. - * @private - */ -YAHOO.widget.DataTable.prototype._updateRow = function(oRecord, index) { - this.hideTableMessages(); - - var elRow = this._elBody.rows[index]; - elRow.recordId = oRecord.id; - - var columns = this._oColumnSet.keys; - // ...Update TBODY cells with new data - for(var j=0; j<columns.length; j++) { - columns[j].format(elRow.cells[j], oRecord); - } - return elRow.id; -}; - -/** - * Sets elements to selected state. Does not fire any events. Does not affect - * internal tracker. - * - * @method _select - * @param els {HTMLElement[] | String[]} Array of HTML elements by reference or ID string. - * @private - */ -YAHOO.widget.DataTable.prototype._select = function(els) { -//TODO: put els in an array if it is just one element? - for(var i=0; i<els.length; i++) { - // Set the style - YAHOO.util.Dom.addClass(YAHOO.util.Dom.get(els[i]),YAHOO.widget.DataTable.CLASS_SELECTED); - } - this._lastSelected = els[els.length-1]; -}; - -/** - * Sets elements to the unselected state. Does not fire any events. Does not - * affect internal tracker. - * - * @method _unselect - * @param els {HTMLElement[] | String[]} Array of HTML elements by reference or ID string. - * @private - */ -YAHOO.widget.DataTable.prototype._unselect = function(els) { - for(var i=0; i<els.length; i++) { - // Remove the style - YAHOO.util.Dom.removeClass(YAHOO.util.Dom.get(els[i]),YAHOO.widget.DataTable.CLASS_SELECTED); - } -}; - -/** - * Unselects all selected rows. Does not fire any events. Does not affect internal - * tracker. - * - * @method _unselectAllRows - * @private - */ -YAHOO.widget.DataTable.prototype._unselectAllRows = function() { - var selectedRows = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody); - this._unselect(selectedRows); -}; - -/** - * Unselects all selected cells. - * - * @method _unselectAllCells - * @private - */ -YAHOO.widget.DataTable.prototype._unselectAllCells = function() { - var selectedCells = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody); - this._unselect(selectedCells); -}; - -/** - * Deletes a given row element as well its corresponding Record in the RecordSet. - * Does not fire any events. - * - * @method _deleteRow - * @param elRow {element} HTML table row element reference. - * @private - */ -YAHOO.widget.DataTable.prototype._deleteRow = function(elRow) { -//TODO: sniff elRow.rowIndex - var allRows = this._elBody.rows; - var id = elRow.id; - var recordId = elRow.recordId; - for(var i=0; i< allRows.length; i++) { - if(id == allRows[i].id) { - this._elBody.deleteRow(i); - - // Update the RecordSet - this._oRecordSet.deleteRecord(i); - break; - } - } - if(this._elBody.rows.length === 0) { - this.showEmptyMessage(); - } -}; -///////////////////////////////////////////////////////////////////////////// -// -// Private DOM Event Handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Handles blur events on the TABLE element. - * - * @method _onBlur - * @param e {HTMLEvent} The blur event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onBlur = function(e, oSelf) { - this._bFocused = false; -}; - -/** - * Handles mouseover events on the TABLE element. - * - * @method _onMouseover - * @param e {HTMLEvent} The mouseover event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onMouseover = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "td": - oSelf.fireEvent("cellMouseoverEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - oSelf.fireEvent("headCellMouseoverEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - if(elTarget) { - elTag = elTarget.tagName.toLowerCase(); - } - else { - break; - } - } - } - oSelf.fireEvent("tableMouseoverEvent",{target:elTarget,event:e}); -}; - -/** - * Handles mouseout events on the TABLE element. - * - * @method _onMouseout - * @param e {HTMLEvent} The mouseout event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onMouseout = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "td": - oSelf.fireEvent("cellMouseoutEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - oSelf.fireEvent("headCellMouseoutEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - if(elTarget) { - elTag = elTarget.tagName.toLowerCase(); - } - else { - break; - } - } - } - oSelf.fireEvent("tableMouseoutEvent",{target:elTarget,event:e}); -}; - -/** - * Handles mousedown events on the TABLE element. - * - * @method _onMousedown - * @param e {HTMLEvent} The mousedown event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onMousedown = function(e, oSelf) { - //YAHOO.util.Event.stopEvent(e); - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "td": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("cellMousedownEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("headCellMousedownEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - if(elTarget) { - elTag = elTarget.tagName.toLowerCase(); - } - else { - break; - } - } - } - oSelf.fireEvent("tableMousedownEvent",{target:elTarget,event:e}); -}; - -/** - * Handles click events on the TABLE element. - * - * @method _onClick - * @param e {HTMLEvent} The click event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onClick = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; // True if event should stop propagating - - if(oSelf.activeEditor) { //&& (oSelf.activeEditor.column != column) - oSelf.activeEditor.hide(); - oSelf.activeEditor = null; - - // Editor causes widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "input": - if(elTarget.type.toLowerCase() == "checkbox") { - oSelf.fireEvent("checkboxClickEvent",{target:elTarget,event:e}); - } - else if(elTarget.type.toLowerCase() == "radio") { - oSelf.fireEvent("radioClickEvent",{target:elTarget,event:e}); - } - knownTag = true; - break; - case "td": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("cellClickEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("headCellClickEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - elTag = elTarget.tagName.toLowerCase(); - } - } - oSelf.focusTable(); - oSelf.fireEvent("tableClickEvent",{target:elTarget,event:e}); -}; - -/** - * Handles doubleclick events on the TABLE element. - * - * @method _onDoubleclick - * @param e {HTMLEvent} The doubleclick event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onDoubleclick = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; - - if(oSelf.activeEditor) { //&& (oSelf.activeEditor.column != column) - oSelf.activeEditor.hide(); - oSelf.activeEditor = null; - - // Editor causes widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "td": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("cellDoubleclickEvent",{target:elTarget,event:e}); - knownTag = true; - break; - case "th": - YAHOO.util.Event.stopEvent(e); - oSelf.fireEvent("headCellDoubleclickEvent",{target:elTarget,event:e}); - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - elTag = elTarget.tagName.toLowerCase(); - } - } - oSelf.fireEvent("tableDoubleclickEvent",{target:elTarget,event:e}); -}; - -/** - * Handles keypress events on the TABLE. Mainly to support stopEvent on Mac. - * - * @method _onKeypress - * @param e {HTMLEvent} The key event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onKeypress = function(e, oSelf) { - var isMac = (navigator.userAgent.toLowerCase().indexOf("mac") != -1); - if(isMac) { - // arrow down - if(e.keyCode == 40) { - YAHOO.util.Event.stopEvent(e); - } - // arrow up - else if(e.keyCode == 38) { - YAHOO.util.Event.stopEvent(e); - } - } -}; - -/** - * Handles keydown events on the TABLE. Executes arrow selection. - * - * @method _onKeydown - * @param e {HTMLEvent} The key event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onKeydown = function(e, oSelf) { - var oldSelected = oSelf._lastSelected; - // Only move selection if one is already selected - // TODO: config to allow selection even if one is NOT already selected - // TODO: if something isn't selected already, arrow key should select first or last one - if(oldSelected && oSelf.isSelected(oldSelected)) { - var newSelected; - // arrow down - if(e.keyCode == 40) { - YAHOO.util.Event.stopEvent(e); - // row mode - if(oldSelected.tagName.toLowerCase() == "tr") { - // We have room to move down - if(oldSelected.sectionRowIndex+1 < oSelf._elBody.rows.length) { - if(!e.shiftKey) { - oSelf.unselectAllRows(); - } - newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex+1]; - oSelf.select(newSelected); - - } - } - // cell mode - else if(oldSelected.tagName.toLowerCase() == "td") { - /*// We have room to move down - if(oldSelected.sectionRowIndex+1 < oSelf._elBody.rows.length) { - if(!e.shiftKey) { - oSelf.unselectAllRows(); - } - newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex+1]; - oSelf.select(newSelected); - }*/ - } - // Arrows can cause widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - // arrow up - else if(e.keyCode == 38) { - YAHOO.util.Event.stopEvent(e); - // row mode - if(oldSelected.tagName.toLowerCase() == "tr") { - // We have room to move up - if((oldSelected.sectionRowIndex > 0)) { - if(!e.shiftKey) { - oSelf.unselectAllRows(); - } - newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex-1]; - oSelf.select(newSelected); - } - } - // cell mode - else if(oldSelected.tagName.toLowerCase() == "td") { - // We have room to move up - if((oldSelected.sectionRowIndex > 0)) { - if(!e.shiftKey) { - oSelf.unselectAllRows(); - } - newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex-1]; - oSelf.select(newSelected); - } - } - // Arrows can cause widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - } -}; - -/** - * Handles keyup events on the TABLE. Executes deletion - * - * @method _onKeyup - * @param e {HTMLEvent} The key event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onKeyup = function(e, oSelf) { - var key = YAHOO.util.Event.getCharCode(e); - // delete - if(key == 46) {//TODO: && this.isFocused - //TODO: delete row - } -}; - -/** - * Handles keyup events on the DOCUMENT. Executes interaction with editor. - * - * @method _onDocumentKeyup - * @param e {HTMLEvent} The key event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onDocumentKeyup = function(e, oSelf) { - // esc Clears active editor - if((e.keyCode == 27) && (oSelf.activeEditor)) { - oSelf.activeEditor.hide(); - oSelf.activeEditor = null; - - // Editor causes widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - } - // enter Saves active editor data - if((e.keyCode == 13) && (oSelf.activeEditor)) { - var elCell = oSelf.activeEditor.cell; - var oColumn = oSelf.activeEditor.column; - var oRecord = oSelf.activeEditor.record; - var oldValue = oRecord[oColumn.key]; - var newValue = oSelf.activeEditor.getValue(); - - //Update Record - //TODO: Column.key may be null! - oSelf._oRecordSet.updateRecord(oRecord,oColumn.key,newValue); - - //Update cell - oSelf.formatCell(elCell); - - // Hide editor - oSelf.activeEditor.hide(); - oSelf.activeEditor = null; - - // Editor causes widget to lose focus - oSelf._bFocused = false; - oSelf.focusTable(); - oSelf.fireEvent("cellEditEvent",{target:elCell,oldData:oldValue,newData:newValue}); - } -}; - -/** - * Handles click events on paginator links. - * - * @method _onPagerClick - * @param e {HTMLEvent} The click event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onPagerClick = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - var knownTag = false; // True if event should stop propagating - - if (elTag != "table") { - while(!knownTag) { - switch(elTag) { - case "body": - knownTag = true; - break; - case "a": - YAHOO.util.Event.stopEvent(e); - switch(elTarget.className) { - case YAHOO.widget.DataTable.CLASS_PAGELINK: - oSelf.showPage(parseInt(elTarget.innerHTML,10)); - break; - case YAHOO.widget.DataTable.CLASS_FIRSTLINK: - oSelf.showPage(1); - break; - case YAHOO.widget.DataTable.CLASS_LASTLINK: - oSelf.showPage(oSelf._totalPages); - break; - case YAHOO.widget.DataTable.CLASS_PREVLINK: - oSelf.showPage(oSelf.pageCurrent-1); - break; - case YAHOO.widget.DataTable.CLASS_NEXTLINK: - oSelf.showPage(oSelf.pageCurrent+1); - break; - } - knownTag = true; - break; - default: - break; - } - elTarget = elTarget.parentNode; - if(elTarget) { - elTag = elTarget.tagName.toLowerCase(); - } - else { - break; - } - } - } -}; - -/** - * Handles change events on paginator SELECT. - * - * @method _onPagerSelect - * @param e {HTMLEvent} The change event. - * @param oSelf {YAHOO.widget.DataTable} DataTable instance. - * @private - */ -YAHOO.widget.DataTable.prototype._onPagerSelect = function(e, oSelf) { - var elTarget = YAHOO.util.Event.getTarget(e); - var elTag = elTarget.tagName.toLowerCase(); - - // How many rows per page - var oldRowsPerPage = oSelf.rowsPerPage; - var rowsPerPage = parseInt(elTarget[elTarget.selectedIndex].text,10); - if(rowsPerPage && (rowsPerPage != oSelf.rowsPerPage)) { - if(rowsPerPage > oldRowsPerPage) { - oSelf.pageCurrent = 1; - } - oSelf.rowsPerPage = rowsPerPage; - oSelf.paginateRows(); - } -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private Custom Event Handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Handles row delete events. - * - * @method _onRowDelete - * @param oArgs.rowIndexes {Number[]} The indexes of the deleted rows. - * @private - */ -YAHOO.widget.DataTable.prototype._onRowDelete = function(oArgs) { - this._restripeRows(); -}; - -/** - * Passes along recordSetUpdate Event when recordUpdateEvent is caught from RecordSet. - * - * @event _onRecordUpdate - * @param oArgs.record {YAHOO.widget.Record} The Record instance. - * @param oArgs.key {String} The Record key. - * @param oArgs.newData {Object} New data. - * @param oArgs.oldData {Object} New data. - * @private - */ -YAHOO.widget.DataTable.prototype._onRecordUpdate = function(oArgs) { - this.fireEvent("recordSetUpdateEvent",oArgs); -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * DataSource instance. - * - * @property dataSource - * @type YAHOO.util.DataSource - */ -YAHOO.widget.DataTable.prototype.dataSource = null; - -/** - * Initial request to send to DataSource. - * - * @property initialRequest - * @type String - * @default "" - */ -YAHOO.widget.DataTable.prototype.initialRequest = ""; - -/** - * Defines value of CAPTION attribute. - * - * @property caption - * @type String - */ -YAHOO.widget.DataTable.prototype.caption = null; - -/** - * Defines value of SUMMARY attribute. - * - * @property summary - * @type String - */ -YAHOO.widget.DataTable.prototype.summary = null; - -/** - * True if DataTable's width is a fixed size. - * - * @property fixedWidth - * @type Boolean - * @default false - */ -YAHOO.widget.DataTable.prototype.fixedWidth = false; - -/** - * True if TBODY should scroll while THEAD remains fixed. - * - * @property scrollable - * @type Boolean - * @default false - */ -YAHOO.widget.DataTable.prototype.scrollable = false; - -/** - * True if only one row may be selected at a time. - * - * @property rowSingleSelect - * @type Boolean - * @default false - */ -YAHOO.widget.DataTable.prototype.rowSingleSelect = false; - -/** - * ContextMenu instance. - * - * @property contextMenu - * @type YAHOO.widget.ContextMenu - */ -YAHOO.widget.DataTable.prototype.contextMenu = null; - -/** - * Current page number. - * - * @property pageCurrent - * @type Number - * @default 1 - */ -YAHOO.widget.DataTable.prototype.pageCurrent = 1; - -/** - * Rows per page. - * - * @property rowsPerPage - * @type Number - * @default 500 - */ -YAHOO.widget.DataTable.prototype.rowsPerPage = 500; - -/** - * Record index of first row of current page. - * - * @property startRecordIndex - * @type Number - * @default 1 - */ -YAHOO.widget.DataTable.prototype.startRecordIndex = 1; - -/** - * Maximum number of pagination page links to show. Any page links beyond this number are - * available through the "<" and ">" links. A negative value will display all page links. - * - * @property pageLinksLength - * @type Number - * @default -1 - */ -YAHOO.widget.DataTable.prototype.pageLinksLength = -1; - -/** - * Options to show in the rows-per-page pagination dropdown, should be an array - * of numbers. Null or an empty array causes no dropdown to be displayed. - * - * @property rowsPerPageDropdown - * @type Number[] - */ -YAHOO.widget.DataTable.prototype.rowsPerPageDropdown = null; - -/** - * First pagination page link. - * - * @property pageLinksStart - * @type Number - * @default 1 - */ -YAHOO.widget.DataTable.prototype.pageLinksStart = 1; - -/** - * An array of DIV elements into which pagination elements can go. - * - * @property pagers - * @type HTMLElement[] - */ -YAHOO.widget.DataTable.prototype.pagers = null; - -/** - * True if the DataTable is empty of data. False if DataTable is populated with - * data from RecordSet. - * - * @property isEmpty - * @type Boolean - */ -YAHOO.widget.DataTable.prototype.isEmpty = false; - -/** - * Object literal holds sort metadata: - * sortedBy.colKey - * sortedBy.dir - * - * - * @property sortedBy - * @type Object - */ -YAHOO.widget.DataTable.prototype.sortedBy = null; - - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor to the unique name of the DataSource instance. - * - * @method toString - * @return {String} Unique name of the DataSource instance. - */ - -YAHOO.widget.DataTable.prototype.toString = function() { - return "DataTable " + this._sName; -}; - -/** - * Returns element reference to TABLE. - * - * @method getTable - * @return {HTMLElement} Reference to TABLE element. - */ -YAHOO.widget.DataTable.prototype.getTable = function() { - return(this._elTable); -}; - -/** - * Returns element reference to THEAD. - * - * @method getHead - * @return {HTMLElement} Reference to THEAD element. - */ -YAHOO.widget.DataTable.prototype.getHead = function() { - return(this._elHead); -}; - -/** - * Returns element reference to TBODY. - * - * @method getBody - * @return {HTMLElement} Reference to TBODY element. - */ -YAHOO.widget.DataTable.prototype.getBody = function() { - return(this._elBody); -}; - -/** - * Returns element reference to given TR cell. - * - * @method getRow - * @param index {Number} Row number. - * @return {HTMLElement} Reference to TR element. - */ -YAHOO.widget.DataTable.prototype.getRow = function(index) { - return(this._elBody.rows[index]); -}; - -/** - * Returns element reference to given TD cell. - * - * @method getCell - * @param row {Number} Row number. - * @param col {Number} Column number. - * @return {HTMLElement} Reference to TD element. - */ -YAHOO.widget.DataTable.prototype.getCell = function(row, col) { - return(this._elBody.rows[row].cells[col]); -}; - -/** - * Placeholder row to indicate table data is empty. - * - * @method showEmptyMessage - */ -YAHOO.widget.DataTable.prototype.showEmptyMessage = function() { - if(this.isEmpty) { - return; - } - if(this.isLoading) { - this.hideTableMessages(); - } - - this._elMsgBody.style.display = ""; - var elCell = this._elMsgCell; - elCell.className = YAHOO.widget.DataTable.CLASS_EMPTY; - elCell.innerHTML = YAHOO.widget.DataTable.MSG_EMPTY; - this.isEmpty = true; -}; - -/** - * Placeholder row to indicate table data is loading. - * - * @method showLoadingMessage - */ -YAHOO.widget.DataTable.prototype.showLoadingMessage = function() { - if(this.isLoading) { - return; - } - if(this.isEmpty) { - this.hideTableMessages(); - } - - this._elMsgBody.style.display = ""; - var elCell = this._elMsgCell; - elCell.className = YAHOO.widget.DataTable.CLASS_LOADING; - elCell.innerHTML = YAHOO.widget.DataTable.MSG_LOADING; - this.isLoading = true; -}; - -/** - * Hide any placeholder message row. - * - * @method hideTableMessages - */ -YAHOO.widget.DataTable.prototype.hideTableMessages = function() { - if(!this.isEmpty && !this.isLoading) { - return; - } - - this._elMsgBody.style.display = "none"; - - this.isEmpty = false; - this.isLoading = false; -}; - -/** - * Sets focus on the TABLE element. - * - * @method focusTable - */ -YAHOO.widget.DataTable.prototype.focusTable = function() { - var elTable = this._elTable; - if(!this._bFocused) { - // http://developer.mozilla.org/en/docs/index.php?title=Key-navigable_custom_DHTML_widgets - // The timeout is necessary in both IE and Firefox 1.5, to prevent scripts from doing - // strange unexpected things as the user clicks on buttons and other controls. - setTimeout(function() { elTable.focus(); },0); - this._bFocused = true; - this.fireEvent("tableFocusEvent"); - } -}; - -/** - * Overridable method gives implementers a hook to access data before - * it gets added to RecordSet and rendered to the TBODY. - * - * @method doBeforeLoadData - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - * @return {Boolean} Return true to continue loading data into RecordSet and - * updating DataTable with new Records, false to cancel. - */ -YAHOO.widget.DataTable.prototype.doBeforeLoadData = function(sRequest, oResponse) { - return true; -}; - -/** - * Add rows to bottom of table body. - * - * @method appendRow - * @param aRecords {YAHOO.widget.Record[]} Array of Records. - */ -YAHOO.widget.DataTable.prototype.appendRows = function(aRecords) { - if(aRecords && aRecords.length > 0) { - this.hideTableMessages(); - - var rowIds = []; - for(var i=0; i<aRecords.length; i++) { - var rowId = this._addRow(aRecords[i]); - rowIds.push(rowId); - } - - this.fireEvent("rowAppendEvent", {rowIds:rowIds}); - } -}; - -/** - * Add rows to top of table body. - * - * @method insertRows - * @param aRecords {YAHOO.widget.Record[]} Array of Records. - */ -YAHOO.widget.DataTable.prototype.insertRows = function(aRecords) { - if(aRecords && aRecords.length > 0) { - this.hideTableMessages(); - - var rowIds = []; - for(var i=0; i<aRecords.length; i++) { - var rowId = this._addRow(aRecords[i],0); - rowIds.push(rowId); - } - - this.fireEvent("rowInsertEvent", {rowIds:rowIds}); - } -}; - -/** - * Replaces existing rows of table body with new Records. - * - * @method replaceRows - * @param aRecords {YAHOO.widget.Record[]} Array of Records. - */ -YAHOO.widget.DataTable.prototype.replaceRows = function(aRecords) { - var i; - - if(aRecords && aRecords.length > 0) { - this.hideTableMessages(); - - var elBody = this._elBody; - var elRows = this._elBody.rows; - - // Remove extra rows - while(elBody.hasChildNodes() && (elRows.length > aRecords.length)) { - elBody.deleteRow(0); - } - - // Unselect rows in the UI but keep tracking selected rows - var selectedRecords = this.getSelectedRecordIds(); - if(selectedRecords.length > 0) { - this._unselectAllRows(); - } - - var rowIds = []; - // Format in-place existing rows - for(i=0; i<elRows.length; i++) { - if(aRecords[i]) { - var oRecord = aRecords[i]; - rowIds.push(this._updateRow(oRecord,i)); - } - } - - // Add rows as necessary - for(i=elRows.length; i<aRecords.length; i++) { - rowIds.push(this._addRow(aRecords[i])); - } - - // Select any rows as necessary - for(i=0; i<selectedRecords.length; i++) { - var allRows = elBody.rows; - for(var j=0; j<allRows.length; j++) { - if(selectedRecords[i] == allRows[j].recordId) { - this._select([allRows[j]]); - } - } - } - - this.fireEvent("rowReplaceEvent", {rowIds:rowIds}); - } -}; - -/** - * Convenience method to add a new row to table body at position index if given, - * or to the bottom otherwise. - * - * @method addRow - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param index {Number} Position at which to add row. - */ -YAHOO.widget.DataTable.prototype.addRow = function(oRecord, index) { - if(oRecord) { - var rowId = this._addRow(oRecord, index); - if(index !== undefined) { - this.fireEvent("rowInsertEvent", {rowIds:[rowId]}); - } - else { - this.fireEvent("rowAppendEvent", {rowIds:[rowId]}); - } - } -}; - -/** - * Updates existing row at position index with data from the given Record. - * - * @method updateRow - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param index {Number} Position at which to update row. - */ -YAHOO.widget.DataTable.prototype.updateRow = function(oRecord, index) { - if(oRecord) { - var rowId = this._updateRow(oRecord, index); - this.fireEvent("rowUpdateEvent", {rowIds:[rowId]}); - } -}; - -/** - * Calls delete on selected rows. - * - * @method deleteSelectedRows - */ -YAHOO.widget.DataTable.prototype.deleteRows = function(rows) { - var rowIndexes = []; - for(var i=0; i<rows.length; i++) { - var rowIndex = (rows[i].sectionRowIndex !== undefined) ? rows[i].sectionRowIndex : null; - rowIndexes.push(rowIndex); - this._deleteRow(rows[i]); - this.fireEvent("rowDeleteEvent", {rowIndexes:rowIndexes}); - } -}; - -/** - * Deletes a given row element as well its corresponding Record in the RecordSet. - * - * @method deleteRow - * @param elRow {element} HTML table row element reference. - */ -YAHOO.widget.DataTable.prototype.deleteRow = function(elRow) { - if(elRow) { - var rowIndex = (elRow.sectionRowIndex !== undefined) ? elRow.sectionRowIndex : null; - this._deleteRow(elRow); - this.fireEvent("rowDeleteEvent", {rowIndexes:[rowIndex]}); - } -}; - -/** - * Sets one or more elements to the highlighted state. - * - * @method highlight - * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element - * reference, TR String ID, array of HTML TR element, or array of TR element IDs. - */ -YAHOO.widget.DataTable.prototype.highlight = function(els) { - if(els.constructor != Array) { - els = [els]; - } - YAHOO.util.Dom.addClass(els,YAHOO.widget.DataTable.CLASS_HIGHLIGHT); - this.fireEvent("highlightEvent",{els:els}); -}; - -/** - * Sets one or more elements to the unhighlighted state. - * - * @method unhighlight - * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element - * reference, TR String ID, array of HTML TR element, or array of TR element IDs. - */ -YAHOO.widget.DataTable.prototype.unhighlight = function(els) { - if(els.constructor != Array) { - els = [els]; - } - YAHOO.util.Dom.removeClass(els,YAHOO.widget.DataTable.CLASS_HIGHLIGHT); - this.fireEvent("unhighlightEvent",{els:els}); -}; - - -/** - * Sets one or more elements to the selected state. - * - * @method select - * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element - * reference, TR String ID, array of HTML TR element, or array of TR element IDs. - */ -YAHOO.widget.DataTable.prototype.select = function(els) { - if(els) { - if(els.constructor != Array) { - els = [els]; - } - this._select(els); - - // Add Record ID to internal tracker - var tracker = this._aSelectedRecords || []; - for(var i=0; i<els.length; i++) { - var id = els[i].recordId; - // Remove if already there - // Use Array.indexOf if available... - if(tracker.indexOf && (tracker.indexOf(id) > -1)) { - tracker.splice(tracker.indexOf(id),1); - } - // ...or do it the old-fashioned way - else { - for(var j=0; j<tracker.length; j++) { - if(tracker[j] === id){ - tracker.splice(j,1); - } - } - } - // Add to the end - tracker.push(id); - } - this._aSelectedRecords = tracker; - this.fireEvent("selectEvent",{els:els}); - } -}; - -/** - * Sets one or more elements to the unselected state. - * - * @method unselect - * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML element - * reference, element ID, array of HTML elements, or array of element IDs - */ -YAHOO.widget.DataTable.prototype.unselect = function(els) { - if(els) { - if(els.constructor != Array) { - els = [els]; - } - this._unselect(els); - // Remove Record ID from internal tracker - var tracker = this._aSelectedRecords || []; - for(var i=0; i<els.length; i++) { - var id = els[i].recordId; - - // Use Array.indexOf if available... - if(tracker.indexOf && (tracker.indexOf(id) > -1)) { - tracker.splice(tracker.indexOf(id),1); - } - // ...or do it the old-fashioned way - else { - for(var j=0; j<tracker.length; j++) { - if(tracker[j] === id){ - tracker.splice(j,1); - } - } - } - } - this._aSelectedRecords = tracker; - this.fireEvent("unselectEvent",{els:els}); - } -}; - -/** - * Unselects all selected rows. - * - * @method unselectAllRows - */ -YAHOO.widget.DataTable.prototype.unselectAllRows = function() { - var selectedRows = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody); - this.unselect(selectedRows); - this.fireEvent("unselectEvent", {els:selectedRows}); -}; - -/** - * Unselects all selected cells. - * - * @method unselectAllCells - */ -YAHOO.widget.DataTable.prototype.unselectAllCells = function() { - var selectedCells = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody); - this.unselect(selectedCells); - this.fireEvent("unselectEvent", {els:selectedCells}); -}; - - -/** - * Returns true if given element is select, false otherwise. - * - * @method isSelected - * @param el {element} HTML element reference. - * @return {boolean} True if element is selected. - */ -YAHOO.widget.DataTable.prototype.isSelected = function(el) { - return YAHOO.util.Dom.hasClass(el,YAHOO.widget.DataTable.CLASS_SELECTED); -}; - -/** - * Returns array of selected Record IDs. - * - * @method getSelectedRecordIds - * @return {HTMLElement[]} Array of selected TR elements. - */ -YAHOO.widget.DataTable.prototype.getSelectedRecordIds = function() { - return this._aSelectedRecords || []; -}; - -/** - * Returns array of selected rows. - * - * @method getSelectedRows - * @return {HTMLElement[]} Array of selected TR elements. - */ -YAHOO.widget.DataTable.prototype.getSelectedRows = function() { - //TODO: keep internal array if this is non performant - return YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"tr",this._elBody); -}; - -/** - * Returns array of selected TD cells. - * - * @method getSelectedCells - * @return {HTMLElement[]} Array of selected TD elements. - */ -YAHOO.widget.DataTable.prototype.getSelectedCells = function() { - //TODO: keep internal array - return YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_SELECTED,"td",this._elBody); -}; - -/** - * Returns pointer to the DataTable instance's ColumnSet instance. - * - * @method getColumnSet - * @return {YAHOO.widget.ColumnSet} ColumnSet instance. - */ -YAHOO.widget.DataTable.prototype.getColumnSet = function() { - return this._oColumnSet; -}; - -/** - * Returns pointer to the DataTable instance's RecordSet instance. - * - * @method getRecordSet - * @return {YAHOO.widget.RecordSet} RecordSet instance. - */ -YAHOO.widget.DataTable.prototype.getRecordSet = function() { - return this._oRecordSet; -}; - -/** - * Displays a specific page of a paginated DataTable. - * - * @method showPage - * @param nPage {Number} Which page. - */ -YAHOO.widget.DataTable.prototype.showPage = function(nPage) { - // Validate input - if(!nPage || isNaN(nPage) || (nPage < 1) || (nPage > this._totalPages)) { - nPage = 1; - } - this.pageCurrent = nPage; - this.paginateRows(); -}; - -/** - * If pagination is enabled, paginates all data in RecordSet and renders - * paginator UI, others renders normal TBODY without any paginator UI. - * - * @method paginateRows - */ -YAHOO.widget.DataTable.prototype.paginateRows = function() { - var i; - - // How many total Records - var recordsLength = this._oRecordSet.getLength(); - - // How many rows this page - var maxRows = (this.rowsPerPage < recordsLength) ? - this.rowsPerPage : recordsLength; - - // How many total pages - this._totalPages = Math.ceil(recordsLength / maxRows); - - // First row of this page - this.startRecordIndex = (this.pageCurrent-1) * this.rowsPerPage; - - // How many page links to display - var pageLinksLength = - ((this.pageLinksLength > 0) && (this.pageLinksLength < this._totalPages)) ? - this.pageLinksLength : this._totalPages; - - // First link of this page - this.pageLinksStart = (Math.ceil(this.pageCurrent/pageLinksLength-1) * pageLinksLength) + 1; - - // Show Records for this page - var pageRecords = this._oRecordSet.getRecords(this.startRecordIndex, this.rowsPerPage); - this.replaceRows(pageRecords); - - if(this.rowsPerPage < recordsLength) { - // Markup for page links - var isFirstPage = (this.pageCurrent == 1) ? true : false; - var isLastPage = (this.pageCurrent == this._totalPages) ? true : false; - var firstPageLink = (isFirstPage) ? - " <span class=\"" + YAHOO.widget.DataTable.CLASS_FIRSTPAGE + "\"><<</span> " : - " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_FIRSTLINK + "\"><<</a> "; - var prevPageLink = (isFirstPage) ? - " <span class=\"" + YAHOO.widget.DataTable.CLASS_PREVPAGE + "\"><</span> " : - " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_PREVLINK + "\"><</a> " ; - var nextPageLink = (isLastPage) ? - " <span class=\"" + YAHOO.widget.DataTable.CLASS_NEXTPAGE + "\">></span> " : - " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_NEXTLINK + "\">></a> " ; - var lastPageLink = (isLastPage) ? - " <span class=\"" + YAHOO.widget.DataTable.CLASS_LASTPAGE + "\">>></span> " : - " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_LASTLINK + "\">>></a> "; - var markup = firstPageLink + prevPageLink; - var maxLinks = (this.pageLinksStart+pageLinksLength < this._totalPages) ? - this.pageLinksStart+pageLinksLength-1 : this._totalPages; - for(i=this.pageLinksStart; i<=maxLinks; i++) { - if(i != this.pageCurrent) { - markup += " <a href=\"#\" class=\"" + YAHOO.widget.DataTable.CLASS_PAGELINK + "\">" + i + "</a> "; - } - else { - markup += " <span class=\"" + YAHOO.widget.DataTable.CLASS_CURRENTPAGE + "\">" + i + "</span>"; - } - } - markup += nextPageLink + lastPageLink; - - // Markup for rows-per-page dropdowns - var dropdown = this.rowsPerPageDropdown; - var select1, select2; - if(dropdown && (dropdown.constructor == Array) && (dropdown.length > 0)) { - select1 = document.createElement("select"); - select1.className = YAHOO.widget.DataTable.CLASS_PAGESELECT; - select2 = document.createElement("select"); - select2.className = YAHOO.widget.DataTable.CLASS_PAGESELECT; - - for(i=0; i<dropdown.length; i++) { - var option1 = document.createElement("option"); - var option2 = document.createElement("option"); - option1.value = dropdown[i]; - option2.value = dropdown[i]; - option1.innerHTML = dropdown[i]; - option2.innerHTML = dropdown[i]; - - if(this.rowsPerPage === dropdown[i]) { - option1.selected = true; - option2.selected = true; - } - option1 = select1.appendChild(option1); - option2 = select2.appendChild(option2); - } - } - - // Populate each pager container with markup - if(!this.pagers || (this.pagers.length === 0)) { - var pager1 = document.createElement("span"); - pager1.className = YAHOO.widget.DataTable.CLASS_PAGELINKS; - - var pager2 = document.createElement("span"); - pager2.className = YAHOO.widget.DataTable.CLASS_PAGELINKS; - - pager1 = this._elContainer.insertBefore(pager1, this._elTable); - select1 = (select1 === undefined) ? null : - this._elContainer.insertBefore(select1, this._elTable); - select2 = (select2 === undefined) ? null : - this._elContainer.insertBefore(select2, this._elTable.nextSibling); - pager2 = this._elContainer.insertBefore(pager2, this._elTable.nextSibling); - this.pagers = [ - {links:pager1,select:select1}, - {links:pager2,select:select2} - ]; - } - for(i=0; i<this.pagers.length; i++) { - this.pagers[i].links.innerHTML = markup; - YAHOO.util.Event.purgeElement(this.pagers[i].links); - if(this.pagers[i].select) { - YAHOO.util.Event.purgeElement(this.pagers[i].select); - } - this.pagers[i].innerHTML = markup; - YAHOO.util.Event.addListener(this.pagers[i].links,"click",this._onPagerClick,this); - if(this.pagers[i].select) { - YAHOO.util.Event.addListener(this.pagers[i].select,"change",this._onPagerSelect,this); - } - } - } - this.fireEvent("paginateEvent"); -}; - -/** - * Sort given column. - * - * @method sortColumn - * @param oColumn {YAHOO.widget.Column} Column to sort. TODO: accept the TH or TH.key - */ -YAHOO.widget.DataTable.prototype.sortColumn = function(oColumn) { - if(!oColumn) { - return; - } - if(!oColumn instanceof YAHOO.widget.Column) { - //TODO: Figure out the column based on TH ref or TH.key - return; - } - if(oColumn.sortable) { - // What is the default sort direction? - var sortDir = (oColumn.sortOptions && oColumn.sortOptions.defaultOrder) ? oColumn.sortOptions.defaultOrder : "asc"; - - //TODO: what if column doesn't have key? - // Is this column sorted already? - if(oColumn.key && this.sortedBy && (this.sortedBy.colKey == oColumn.key)) { - if(this.sortedBy.dir) { - sortDir = (this.sortedBy.dir == "asc") ? "desc" : "asc"; - } - else { - sortDir = (sortDir == "asc") ? "desc" : "asc"; - } - } - else if(!this.sortedBy) { - this.sortedBy = {}; - } - - // Define the sort handler function based on the direction - var sortFnc = null; - if((sortDir == "desc") && oColumn.sortOptions && oColumn.sortOptions.descFunction) { - sortFnc = oColumn.sortOptions.descFunction; - } - else if((sortDir == "asc") && oColumn.sortOptions && oColumn.sortOptions.ascFunction) { - sortFnc = oColumn.sortOptions.ascFunction; - } - - // Custom function was not provided so use the built-in sorter - // ONLY IF column key is defined - // TODO: use diff default functions based on column data type - // TODO: nested/cumulative/hierarchical sorting - if(!sortFnc && oColumn.key) { - var sorted; - sortFnc = function(a, b) { - if(sortDir == "desc") { - sorted = YAHOO.util.Sort.compareDesc(a[oColumn.key],b[oColumn.key]); - if(sorted === 0) { - return YAHOO.util.Sort.compareDesc(a.id,b.id); - } - else { - return sorted; - } - } - else { - sorted = YAHOO.util.Sort.compareAsc(a[oColumn.key],b[oColumn.key]); - if(sorted === 0) { - return YAHOO.util.Sort.compareAsc(a.id,b.id); - } - else { - return sorted; - } - } - }; - } - - if(sortFnc) { - // Do the actual sort - this._oRecordSet.sort(sortFnc); - - // Update the UI - this.paginateRows(); - - // Update classes - YAHOO.util.Dom.removeClass(this.sortedBy._id,YAHOO.widget.DataTable.CLASS_SORTEDBYASC); - YAHOO.util.Dom.removeClass(this.sortedBy._id,YAHOO.widget.DataTable.CLASS_SORTEDBYDESC); - var newClass = (sortDir == "asc") ? YAHOO.widget.DataTable.CLASS_SORTEDBYASC : YAHOO.widget.DataTable.CLASS_SORTEDBYDESC; - YAHOO.util.Dom.addClass(oColumn.getId(), newClass); - - // Keep track of currently sorted column - this.sortedBy.colKey = oColumn.key; - this.sortedBy.dir = sortDir; - this.sortedBy._id = oColumn.getId(); - - this.fireEvent("columnSortEvent",{column:oColumn,dir:sortDir}); - } - } - else { - //TODO - } -}; - -/** - * Shows editor for given cell. - * - * @method editCell - */ -YAHOO.widget.DataTable.prototype.editCell = function(elCell) { - if(elCell && !isNaN(elCell.columnIndex)) { - var column = this._oColumnSet.keys[elCell.columnIndex]; - if(column && column.editor) { - this.activeEditor = column.getEditor(elCell,this._oRecordSet.getRecord(elCell.parentNode.recordId)); - } - this._bFocused = true; - this.fireEvent("editorShowEvent",{target:elCell,column:column}); - } -}; - -/** - * Formats given cell. - * - * @method formatCell - */ -YAHOO.widget.DataTable.prototype.formatCell = function(elCell) { - if(elCell && !isNaN(elCell.columnIndex)) { - var column = this._oColumnSet.keys[elCell.columnIndex]; - column.format(elCell,this._oRecordSet.getRecord(elCell.parentNode.recordId)); - this.fireEvent("cellFormatEvent", {el:elCell}); - } -}; - - -///////////////////////////////////////////////////////////////////////////// -// -// Public Custom Event Handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Overridable custom event handler to sort column. - * - * @method onEventSortColumn - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventSortColumn = function(oArgs) { - var evt = oArgs.event; - var target = oArgs.target; - YAHOO.util.Event.stopEvent(evt); - - //TODO: traverse DOM to find a columnIndex, incl safety net if none exists - var columnIndex = target.columnIndex; - if(!isNaN(columnIndex)) { - this.sortColumn(this._oColumnSet.keys[columnIndex]); - } -}; - -/** - * Overridable custom event handler to select row. - * - * @method onEventSelectRow - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventSelectRow = function(oArgs) { - var i; - var evt = oArgs.event; - var target = oArgs.target; - - //TODO: add a safety net in case TR is never reached - // Walk up the DOM until we get to the TR - while(target.tagName.toLowerCase() != "tr") { - target = target.parentNode; - } - - if(this.isSelected(target)) { - this.unselect(target); - } - else { - if(this.rowSingleSelect && !evt.ctrlKey && !evt.shiftKey) { - this.unselectAllRows(); - } - if(evt.shiftKey) { - var startRow = this._lastSelected; - if(startRow && this.isSelected(startRow)) { - this.unselectAllRows(); - if(startRow.sectionRowIndex < target.sectionRowIndex) { - for(i=startRow.sectionRowIndex; i<=target.sectionRowIndex; i++) { - this.select(this._elBody.rows[i]); - } - } - else { - for(i=target.sectionRowIndex; i<=startRow.sectionRowIndex; i++) { - this.select(this._elBody.rows[i]); - } - } - } - else { - this.select(target); - } - } - else { - this.select(target); - } - } -}; - -/** - * Overridable custom event handler to select cell. - * - * @method onEventSelectCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventSelectCell = function(oArgs) { - var evt = oArgs.event; - var target = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(target.tagName.toLowerCase() != "td") { - target = target.parentNode; - } - - if(this.isSelected(target)) { - this.unselect(target); - } - else { - if(this.rowSingleSelect && !evt.ctrlKey) { - this.unselectAllCells(); - } - this.select(target); - } -}; - -/** - * Overridable custom event handler to format cell. - * - * @method onEventFormatCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventFormatCell = function(oArgs) { - var evt = oArgs.event; - var element = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(element.tagName.toLowerCase() != "td") { - element = element.parentNode; - } - - this.formatCell(element); -}; - -/** - * Overridable custom event handler to highlight cell. - * - * @method onEventHighlightCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventHighlightCell = function(oArgs) { - var evt = oArgs.event; - var element = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(element.tagName.toLowerCase() != "td") { - element = element.parentNode; - } - this.highlight(element); -}; - -/** - * Overridable custom event handler to unhighlight cell. - * - * @method onEventUnhighlightCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventUnhighlightCell = function(oArgs) { - var evt = oArgs.event; - var element = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(element.tagName.toLowerCase() != "td") { - element = element.parentNode; - } - - this.unhighlight(element); -}; -/** - * Overridable custom event handler to edit cell. - * - * @method onEventEditCell - * @param oArgs.event {HTMLEvent} Event object. - * @param oArgs.target {HTMLElement} Target element. - */ -YAHOO.widget.DataTable.prototype.onEventEditCell = function(oArgs) { - var evt = oArgs.event; - var element = oArgs.target; - - //TODO: add a safety net in case TD is never reached - // Walk up the DOM until we get to the TD - while(element.tagName.toLowerCase() != "td") { - element = element.parentNode; - } - - this.editCell(element); -}; - -/** - * Handles data return for adding new rows to table, including updating pagination. - * - * @method onDataReturnPaginateRows - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - */ -YAHOO.widget.DataTable.prototype.onDataReturnPaginateRows = function(sRequest, oResponse) { - this.fireEvent("dataReturnEvent", {request:sRequest,response:oResponse}); - - var ok = this.doBeforeLoadData(sRequest, oResponse); - if(ok) { - // Update the RecordSet from the response - var newRecords = this._oRecordSet.append(oResponse); - if(newRecords) { - // Update markup - this.paginateRows(); - } - } -}; - -/** - * Handles data return for adding new rows to bottom of table. - * - * @method onDataReturnAppendRows - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - */ -YAHOO.widget.DataTable.prototype.onDataReturnAppendRows = function(sRequest, oResponse) { - this.fireEvent("dataReturnEvent", {request:sRequest,response:oResponse}); - - var ok = this.doBeforeLoadData(sRequest, oResponse); - if(ok) { - // Update the RecordSet from the response - var newRecords = this._oRecordSet.append(oResponse); - if(newRecords) { - // Update markup - this.appendRows(newRecords); - } - } -}; - -/** - * Handles data return for inserting new rows to top of table. - * - * @method onDataReturnInsertRows - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - */ -YAHOO.widget.DataTable.prototype.onDataReturnInsertRows = function(sRequest, oResponse) { - this.fireEvent("dataReturnEvent", {request:sRequest,response:oResponse}); - - var ok = this.doBeforeLoadData(sRequest, oResponse); - if(ok) { - // Update the RecordSet from the response - var newRecords = this._oRecordSet.insert(oResponse); - if(newRecords) { - // Update markup - this.insertRows(newRecords); - } - } -}; - -/** - * Handles data return for replacing all existing of table with new rows. - * - * @method onDataReturnReplaceRows - * @param sRequest {String} Original request. - * @param oResponse {Object} Response object. - */ -YAHOO.widget.DataTable.prototype.onDataReturnReplaceRows = function(sRequest, oResponse) { - this.fireEvent("dataReturnEvent", {request:sRequest,response:oResponse}); - - var ok = this.doBeforeLoadData(sRequest, oResponse); - if(ok) { - // Update the RecordSet from the response - var newRecords = this._oRecordSet.replace(oResponse); - if(newRecords) { - this.replaceRows(newRecords); - } - } -}; - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The ColumnSet class defines and manages a DataTable's Columns, - * including nested hierarchies and access to individual Column instances. - * - * @class ColumnSet - * @uses YAHOO.util.EventProvider - * @constructor - * @param aHeaders {Object[]} Array of object literals that define header cells. - */ -YAHOO.widget.ColumnSet = function(aHeaders) { -//TODO: break out nested functions into private methods - this._sName = "instance" + YAHOO.widget.ColumnSet._nCount; - - // Top-down tree representation of all Columns - var tree = []; - // Flat representation of all Columns - var flat = []; - // Flat representation of only Columns that display data - var keys = []; - // ID index of nested parent heirarchies for HEADERS attribute - var headers = []; - - var nodelevel = -1; - - // Internal recursive function to parse Columns out of object literal defs - var parseColumns = function(nodeList, parent) { - nodelevel++; - // A node level is an array of Columns - if(!tree[nodelevel]) { - tree[nodelevel] = []; - } - - // Determine depth of descendants at this level for node's rowspan - var nodeLevelMaxChildren = 0; - var recurseChildren = function(nodeList) { - var tmpMax = 0; - for(var i=0; i<nodeList.length; i++) { - if(nodeList[i].children) { - tmpMax++; - recurseChildren(nodeList[i].children); - } - if(tmpMax > nodeLevelMaxChildren) { - nodeLevelMaxChildren = tmpMax; - } - } - }; - recurseChildren(nodeList); - - // Parse each node for attributes and any children - for(var j=0; j<nodeList.length; j++) { - // Instantiate a Column for each node - var oColumn = new YAHOO.widget.Column(nodeList[j]); - flat.push(oColumn); - - // Assign parent, if applicable - if(parent) { - oColumn._parent = parent; - } - - // Start with default values - oColumn._rowspan = 1; - oColumn._colspan = 1; - - // Column may have children - if(nodeList[j].children) { - var children = nodeList[j].children; - var length = children.length; - - // Cascade certain properties to children if not defined on their own - for(var k=0; k<length; k++) { - var child = children[k]; - if(oColumn.className && (child.className === undefined)) { - child.className = oColumn.className; - } - if(oColumn.editor && (child.editor === undefined)) { - child.editor = oColumn.editor; - } - if(oColumn.formatter && (child.formatter === undefined)) { - child.formatter = oColumn.formatter; - } - if(oColumn.parser && (child.parser === undefined)) { - child.parser = oColumn.parser; - } - if(oColumn.resizeable && (child.resizeable === undefined)) { - child.resizeable = oColumn.resizeable; - } - if(oColumn.type && (child.type === undefined)) { - child.type = oColumn.type; - } - if(oColumn.width && (child.width === undefined)) { - child.width = oColumn.width; - } - } - - // Children increase colspan of the Column - oColumn._colspan = length; - - // Children increase colspan of the Column's parent - if (parent && parent._colspan) { - parent._colspan += length-1; - parent._children = []; - parent._children.push(oColumn); - } - - // Children must also be parsed - if(!tree[nodelevel+1]) { - tree[nodelevel+1] = []; - } - parseColumns(children, oColumn); - } - - // This Column does not have children, - // but other Columns at this level do - else if(nodeLevelMaxChildren > 0) { - // Children of siblings increase the rowspan of the Column - oColumn._rowspan += nodeLevelMaxChildren; - //if(oColumn.key) { - oColumn._index = keys.length; - keys.push(oColumn); - //} - } - // This entire node level does not have any children - else { - //if(oColumn.key) { - oColumn._index = keys.length; - keys.push(oColumn); - //} - } - - // Add the Column to the top-down tree - tree[nodelevel].push(oColumn); - } - nodelevel--; - }; - - // Do the parsing - if(aHeaders.length > 0) { - parseColumns(aHeaders); - } - - // Store header nesting in an array - var recurseAncestors = function(i, oColumn) { - headers[i].push(oColumn._id); - if(oColumn._parent) { - recurseAncestors(i, oColumn._parent); - } - }; - for(var i=0; i<keys.length; i++) { - headers[i] = []; - recurseAncestors(i, keys[i]); - headers[i] = headers[i].reverse(); - headers[i] = headers[i].join(" "); - } - - this.tree = tree; - this.flat = flat; - this.keys = keys; - this.headers = headers; - - YAHOO.widget.ColumnSet._nCount++; -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple data table instances. - * - * @property _nCount - * @type number - * @private - * @static - */ -YAHOO.widget.ColumnSet._nCount = 0; - -/** - * Unique instance name. - * - * @property _sName - * @type String - * @private - */ -YAHOO.widget.ColumnSet.prototype._sName = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Top-down tree representation of Column hierarchy. - * - * @property tree - * @type YAHOO.widget.Column[] - */ -YAHOO.widget.ColumnSet.prototype.tree = null; - -/** - * Flattened representation of all Columns. - * - * @property flat - * @type YAHOO.widget.Column[] - * @default [] - */ -YAHOO.widget.ColumnSet.prototype.flat = null; - -/** - * Array of Columns that map one-to-one to a table column. - * - * @property keys - * @type YAHOO.widget.Column[] - * @default [] - */ -YAHOO.widget.ColumnSet.prototype.keys = null; - -/** - * ID index of nested parent heirarchies for HEADERS accessibility attribute. - * - * @property headers - * @type String[] - * @default [] - */ -YAHOO.widget.ColumnSet.prototype.headers = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor to the unique name of the ColumnSet instance. - * - * @method toString - * @return {String} Unique name of the ColumnSet instance. - */ - -YAHOO.widget.ColumnSet.prototype.toString = function() { - return "ColumnSet " + this._sName; -}; - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The Column class defines and manages attributes of DataTable Columns - * - * - * @class Column - * @constructor - * @param oConfigs {Object} Object literal of configuration values. - */ -YAHOO.widget.Column = function(oConfigs) { - // Internal variables - this._id = "yui-dtcol"+YAHOO.widget.Column._nCount; - - // Object literal defines Column attributes - if(typeof oConfigs == "object") { - for(var sConfig in oConfigs) { - if(sConfig) { - this[sConfig] = oConfigs[sConfig]; - } - } - } - - YAHOO.widget.Column._nCount++; -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal instance counter. - * - * @property _nCount - * @type Number - * @static - * @default 0 - */ -YAHOO.widget.Column._nCount = 0; - - -/** - * Unique ID, also assigned as DOM ID. - * - * @property _id - * @type String - * @private - */ -YAHOO.widget.Column.prototype._id = null; - -/** - * Reference to Column's index within its ColumnSet's key array, or null if not applicable. - * - * @property _index - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._index = null; - -/** - * Number of table cells the Column spans. - * - * @property _colspan - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._colspan = 1; - -/** - * Number of table rows the Column spans. - * - * @property _rowspan - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._rowspan = 1; - -/** - * Column's parent, or null. - * - * @property _parent - * @type YAHOO.widget.Column - * @private - */ -YAHOO.widget.Column.prototype._parent = null; - -/** - * Array of Column's chilren, or null. - * - * @property _children - * @type YAHOO.widget.Column[] - * @private - */ -YAHOO.widget.Column.prototype._children = null; - -//TODO: clean these up - -/** - * Current offsetWidth of the Column (in pixels). - * - * @property _width - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._width = null; - -/** - * Minimum width the Column can support (in pixels). Value is populated only if table - * is fixedwidth, null otherwise. - * - * @property _minWidth - * @type Number - * @private - */ -YAHOO.widget.Column.prototype._minWidth = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Associated database field, or null. - * - * @property key - * @type String - */ -YAHOO.widget.Column.prototype.key = null; - -/** - * Text or HTML for display in Column's assocated TH element. - * - * @property text - * @type String - */ -YAHOO.widget.Column.prototype.text = null; - -/** - * Data types: "string", "number", "date", "currency", "checkbox", "select", - * "email", "link". - * - * @property type - * @type String - * @default "string" - */ -YAHOO.widget.Column.prototype.type = "string"; - -/** - * Column head cell ABBR for accessibility. - * - * @property abbr - * @type String - */ -YAHOO.widget.Column.prototype.abbr = null; - -/** - * Array of object literals that define children (nested headers) of a Column. - * - * @property children - * @type Object[] - */ -YAHOO.widget.Column.prototype.children = null; - -/** - * Column width. - * - * @property width - * @type String - */ -YAHOO.widget.Column.prototype.width = null; - -/** - * Custom CSS class to be applied to every cell in the Column. - * - * @property className - * @type String - */ -YAHOO.widget.Column.prototype.className = null; - -/** - * Defines a custom format function for Column, otherwise default is used, - * according to Column type. - * - * @property formatter - * @type HTMLFunction - */ -YAHOO.widget.Column.prototype.formatter = null; - -/** - * Defines a custom parse function for Column, otherwise default is used, - * according to Column type. - * - * @property parser - * @type HTMLFunction - */ -YAHOO.widget.Column.prototype.parser = null; - -/** - * Defines the type of editor for Column, otherwise Column is not editable. - * - * @property editor - * @type String - */ -YAHOO.widget.Column.prototype.editor = null; - -/** - * True if Column is resizeable, false otherwise. - * - * @property resizeable - * @type Boolean - * @default false - */ -YAHOO.widget.Column.prototype.resizeable = false; - -/** - * True if Column is sortable, false otherwise. - * - * @property sortable - * @type Boolean - * @default false - */ -YAHOO.widget.Column.prototype.sortable = false; - -/** - * Custom sort handler to arrange Column in descending order. - * - * @property sortOptions.descFunction - * @type Function - * @default null - */ -YAHOO.widget.Column.prototype.descFunction = null; - -/** - * Custom sort handler to arrange Column in ascending order. - * - * @property sortOptions.ascFunction - * @type Function - * @default null - */ -YAHOO.widget.Column.prototype.ascFunction = null; - - - - - - - - - - - - - - - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor returns Column's ID string. - * - * @method getId - * @return {String} Column's ID string. - */ -YAHOO.widget.Column.prototype.getId = function() { - return this._id; -}; - -/** - * Public accessor returns Column's colspan number. - * - * @method getColSpan - * @return {Number} Column's colspan number. - */ -YAHOO.widget.Column.prototype.getColSpan = function() { - return this._colspan; -}; - -/** - * Public accessor returns Column's rowspan number. - * - * @method getRowSpan - * @return {Number} Column's rowspan number. - */ -YAHOO.widget.Column.prototype.getRowSpan = function() { - return this._rowspan; -}; - - -/** - * Outputs markup into the given TD based on given Record. - * - * @method format - * @param elCell {HTMLElement} TD to format for display. - * @param oRecord {YAHOO.widget.Record} Record that holds data for the row. - * @return {HTML} Markup. - */ -YAHOO.widget.Column.prototype.format = function(elCell,oRecord) { - var oData = (this.key) ? oRecord[this.key] : null; - if(this.formatter) { - this.formatter(elCell, oRecord, this, oData); - } - else { - var type = this.type; - var markup = ""; - var classname = ""; - switch(type) { - case "checkbox": - YAHOO.widget.Column.formatCheckbox(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_CHECKBOX; - break; - case "currency": - YAHOO.widget.Column.formatCurrency(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_CURRENCY; - break; - case "date": - YAHOO.widget.Column.formatDate(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_DATE; - break; - case "email": - YAHOO.widget.Column.formatEmail(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_EMAIL; - break; - case "link": - YAHOO.widget.Column.formatLink(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_LINK; - break; - case "number": - YAHOO.widget.Column.formatNumber(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_NUMBER; - break; - case "select": - YAHOO.widget.Column.formatSelect(elCell, oRecord, this, oData); - classname = YAHOO.widget.DataTable.CLASS_SELECT; - break; - default: - elCell.innerHTML = (oData) ? oData.toString() : ""; - //elCell.innerHTML = (oData) ? "<a href=\"#\">"+oData.toString()+"</a>" : ""; - classname = YAHOO.widget.DataTable.CLASS_STRING; - break; - } - - YAHOO.util.Dom.addClass(elCell, classname); - if(this.className) { - YAHOO.util.Dom.addClass(elCell, this.className); - } - } - - if(this.editor) { - YAHOO.util.Dom.addClass(elCell,YAHOO.widget.DataTable.CLASS_EDITABLE); - } -}; - - -/** - * Formats cells in Columns of type "checkbox". - * - * @method formatCheckbox - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatCheckbox = function(elCell, oRecord, oColumn, oData) { - var bChecked = oData; - bChecked = (bChecked) ? " checked" : ""; - elCell.innerHTML = "<input type=\"checkbox\"" + bChecked + - " class=\"" + YAHOO.widget.DataTable.CLASS_CHECKBOX + "\">"; -}; - -/** - * Formats cells in Columns of type "currency". Can be overridden for custom formatting. - * - * @method formatCurrency - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatCurrency = function(elCell, oRecord, oColumn, oData) { - // Make it dollars - var nAmount = oData; - var markup; - if(nAmount) { - markup = "$"+nAmount; - - // Normalize to the penny - var dotIndex = markup.indexOf("."); - if(dotIndex < 0) { - markup += ".00"; - } - else { - while(dotIndex != markup.length-3) { - markup += "0"; - } - } - } - else { - markup = ""; - } - elCell.innerHTML = markup; -}; - -/** - * Formats cells in Columns of type "date". - * - * @method formatDate - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatDate = function(elCell, oRecord, oColumn, oData) { - var oDate = oData; - if(oDate) { - elCell.innerHTML = oDate.getMonth() + "/" + oDate.getDate() + "/" + oDate.getFullYear(); - } - else { - elCell.innerHTML = ""; - } -}; - -/** - * Formats cells in Columns of type "email". - * - * @method formatEmail - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatEmail = function(elCell, oRecord, oColumn, oData) { - var sEmail = oData; - if(sEmail) { - elCell.innerHTML = "<a href=\"mailto:" + sEmail + "\">" + sEmail + "</a>"; - } - else { - elCell.innerHTML = ""; - } -}; - -/** - * Formats cells in Columns of type "link". - * - * @method formatLink - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatLink = function(elCell, oRecord, oColumn, oData) { - var sLink = oData; - if(sLink) { - elCell.innerHTML = "<a href=\"" + sLink + "\">" + sLink + "</a>"; - } - else { - elCell.innerHTML = ""; - } -}; - -/** - * Formats cells in Columns of type "number". - * - * @method formatNumber - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatNumber = function(elCell, oRecord, oColumn, oData) { - var nNumber = oData; - if(nNumber) { - elCell.innerHTML = nNumber.toString(); - } - else { - elCell.innerHTML = ""; - } -}; - -/** - * Formats cells in Columns of type "select". - * - * @method formatSelect - * @param elCell {HTMLElement} Table cell element. - * @param oRecord {YAHOO.widget.Record} Record instance. - * @param oColumn {YAHOO.widget.Column} Column instance. - * @param oData {Object} Data value for the cell, or null - * @static - */ -YAHOO.widget.Column.formatSelect = function(elCell, oRecord, oColumn, oData) { - var selectedValue = oData; - var options = oColumn.selectOptions; - - var markup = "<select>"; - if(options) { - for(var i=0; i<options.length; i++) { - var option = options[i]; - markup += "<option value=\"" + option + "\""; - if(selectedValue === option) { - markup += " selected"; - } - markup += ">" + option + "</option>"; - } - } - else { - if(selectedValue) { - markup += "<option value=\"" + selectedValue + "\" selected>" + selectedValue + "</option>"; - } - } - markup += "</select>"; - elCell.innerHTML = markup; -}; - -/** - * Takes innerHTML from TD and parses out data for storage in RecordSet. - * - * @method parse - * @param sMarkup {String} The TD's innerHTML value. - * @return {Object} Data. - */ -YAHOO.widget.Column.prototype.parse = function(sMarkup) { - if(this.parser) { - return this.parser(sMarkup); - } - else { - var data = null; - switch(this.type) { - case "checkbox": - data = YAHOO.widget.Column.parseCheckbox(sMarkup); - break; - case "currency": - data = YAHOO.widget.Column.parseCurrency(sMarkup); - break; - case "date": - data = YAHOO.widget.Column.parseDate(sMarkup); - break; - case "number": - data = YAHOO.widget.Column.parseNumber(sMarkup); - break; - case "select": - data = YAHOO.widget.Column.parseSelect(sMarkup); - break; - default: - if(sMarkup) { - data = sMarkup; - } - break; - } - return data; - } -}; - -/** - * Default parse function for Columns of type "checkbox" takes markup and - * extracts data. Can be overridden for custom parsing. - * - * @method parseCheckbox - * @param sMarkup - * @return {bChecked} True if checkbox is checked. - */ -YAHOO.widget.Column.parseCheckbox = function(sMarkup) { - return (sMarkup.indexOf("checked") < 0) ? false : true; -}; - -/** - * Default parse function for Columns of type "currency" takes markup and - * extracts data. Can be overridden for custom parsing. - * - * @method parseCurrency - * @param sMarkup - * @return {nAmount} Floating point amount. - */ -YAHOO.widget.Column.parseCurrency = function(sMarkup) { - return parseFloat(sMarkup.substring(1)); -}; - -/** - * Default parse function for Columns of type "date" takes markup and extracts - * data. Can be overridden for custom parsing. - * - * @method parseDate - * @param sMarkup - * @return {oDate} Date instance. - */ -YAHOO.widget.Column.parseDate = function(sMarkup) { - var mm = sMarkup.substring(0,sMarkup.indexOf("/")); - sMarkup = sMarkup.substring(sMarkup.indexOf("/")+1); - var dd = sMarkup.substring(0,sMarkup.indexOf("/")); - var yy = sMarkup.substring(sMarkup.indexOf("/")+1); - return new Date(yy, mm, dd); -}; - -/** - * Default parse function for Columns of type "number" takes markup and extracts - * data. Can be overridden for custom parsing. - * - * @method parseNumber - * @param sMarkup - * @return {nNumber} Number. - */ -YAHOO.widget.Column.parseNumber = function(sMarkup) { - return parseFloat(sMarkup); -}; - -/** - * Default parse function for Columns of type "select" takes markup and extracts - * data. Can be overridden for custom parsing. - * - * @method parseSelect - * @param sMarkup - * @return {sValue} Value of selected option. - */ -YAHOO.widget.Column.parseSelect = function(sMarkup) { - //return (sMarkup.indexOf("checked") < 0) ? false : true; -}; - -/** - * Outputs editor markup into the given TD based on given Record. - * - * @method showEditor - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @return YAHOO.widget.ColumnEditor - */ -YAHOO.widget.Column.prototype.getEditor = function(elCell, oRecord) { -//Sync up the arg signature for ColumnEditor constructor and show() - var oEditor = this.editor; - if(oEditor.constructor == String) { - oEditor = new YAHOO.widget.ColumnEditor(this.editor); - oEditor.show(elCell, oRecord, this); - this.editor = oEditor; - } - else if(oEditor instanceof YAHOO.widget.ColumnEditor) { - oEditor.show(elCell, oRecord, this); - } - return oEditor; -}; - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The ColumnEditor defines and manages inline editing functionality for a - * DataTable Column. - * - * @class ColumnEditor - * @constructor - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @param oColumn {YAHOO.widget.Column} The DataTable Column of the cell. - * @parem sType {String} Type identifier - */ -YAHOO.widget.ColumnEditor = function(sType) { - this.type = sType; - - //TODO: make sure ColumnEditors get destroyed if widget gets destroyed - // Works better to attach ColumnEditor to document.body - // rather than the DataTable container - // elTable comes in as a cell. Traverse up DOM to find the table. - // TODO: safety net in case table is never found. - //while(elCell.nodeName.toLowerCase() != "table") { - // elCell = elCell.parentNode; - //} - //this.tableContainer = elCell.parentNode; - - var container = document.body.appendChild(document.createElement("div"));//this.tableContainer.appendChild(document.createElement("div")); - container.style.position = "absolute"; - container.style.zIndex = 9000; - container.id = "yui-dt-coled" + YAHOO.widget.ColumnEditor._nCount; - this.container = container; - - switch(this.type) { - case "textbox": - this.createTextboxEditor(); - break; - case "textarea": - this.createTextareaEditor(); - break; - default: - break; - } - - YAHOO.widget.ColumnEditor._nCount++; -}; - - - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal instance counter. - * - * @property _nCount - * @type Number - * @static - * @default 0 - */ -YAHOO.widget.ColumnEditor._nCount =0; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Reference to the container DOM element for the ColumnEditor. - * - * @property container - * @type HTMLElement - */ -YAHOO.widget.ColumnEditor.prototype.container = null; - -/** - * Reference to the ColumnEditor's Column instance. - * - * @property column - * @type YAHOO.widget.Column - */ -YAHOO.widget.ColumnEditor.prototype.column = null; - -/** - * Type of editor: "textbox", etc. - * - * @property type - * @type String - */ -YAHOO.widget.ColumnEditor.prototype.type = null; - - - -/** - * Reference to form element(s) of the ColumnEditor. - * - * @property input - * @type HTMLElement || HTMLElement[] - */ -YAHOO.widget.ColumnEditor.prototype.input = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Shows ColumnEditor. - * - * @method show - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @param oColumn {YAHOO.widget.Column} The DataTable Column of the cell. - */ -YAHOO.widget.ColumnEditor.prototype.show = function(elCell, oRecord, oColumn) { - this.cell = elCell; - this.record = oRecord; - this.column = oColumn; - switch(this.type) { - case "textbox": - this.showTextboxEditor(elCell, oRecord, oColumn); - break; - case "textarea": - this.showTextareaEditor(elCell, oRecord, oColumn); - break; - default: - break; - } -}; - -/** - * Returns ColumnEditor data value. - * - * @method getValue - * @return Object - */ -YAHOO.widget.ColumnEditor.prototype.getValue = function() { - var value; - switch(this.type) { - case "textbox": - value = this.getTextboxEditorValue(); - break; - case "textarea": - value = this.getTextareaEditorValue(); - break; - default: - break; - } - return value; -}; - -/** - * Creates a textbox editor in the DOM. - * - * @method createTextboxEditor - * @return {HTML} ??? - */ -YAHOO.widget.ColumnEditor.prototype.createTextboxEditor = function() { - var elTextbox = this.container.appendChild(document.createElement("input")); - // For FF bug 236791 - elTextbox.setAttribute("autocomplete","off"); - this.input = elTextbox; -}; - -/** - * Creates a textarea editor in the DOM. - * - * @method createTextareaEditor - * @return {HTML} ??? - */ -YAHOO.widget.ColumnEditor.prototype.createTextareaEditor = function() { - var elTextarea = this.container.appendChild(document.createElement("textarea")); - this.input = elTextarea; -}; - -/** - * Shows ColumnEditor - * - * @method showTextboxEditor - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @param oColumn {YAHOO.widget.Column} The DataTable Column of the cell. - */ -YAHOO.widget.ColumnEditor.prototype.showTextboxEditor = function(elCell, oRecord, oColumn) { - // Size and value - this.input.style.width = (parseInt(elCell.offsetWidth,10)-7) + "px"; - this.input.style.height = (parseInt(elCell.offsetHeight,10)-7) + "px"; - this.input.value = elCell.innerHTML; - - // Position and show - var x,y; - - // Don't use getXY for Opera - if(navigator.userAgent.toLowerCase().indexOf("opera") != -1) { - x = elCell.offsetLeft; - y = elCell.offsetTop; - while(elCell.offsetParent) { - x += elCell.offsetParent.offsetLeft; - y += elCell.offsetParent.offsetTop; - elCell = elCell.offsetParent; - } - } - else { - var xy = YAHOO.util.Dom.getXY(elCell); - x = parseInt(YAHOO.util.Dom.getX(elCell),10);//xy[0] + 1; - y = parseInt(YAHOO.util.Dom.getY(elCell),10);//xy[1] + 1; - } - this.container.style.left = x + "px"; - this.container.style.top = y + "px"; - this.container.style.display = "block"; - - this.input.tabIndex = 0; - this.input.focus(); - this.input.select(); -}; - -/** - * Shows ColumnEditor - * - * @method showTextareaEditor - * @param elCell {HTMLElement} The cell to edit. - * @param oRecord {YAHOO.widget.Record} The DataTable Record of the cell. - * @param oColumn {YAHOO.widget.Column} The DataTable Column of the cell. - */ -YAHOO.widget.ColumnEditor.prototype.showTextareaEditor = function(elCell, oRecord, oColumn) { - // Size and value - this.input.style.width = (parseInt(elCell.offsetWidth,10)-7) + "px"; - this.input.style.height = 4*(parseInt(elCell.offsetHeight,10)-7) + "px"; - this.input.value = elCell.innerHTML; - - // Position and show - var x,y; - - // Don't use getXY for Opera - if(navigator.userAgent.toLowerCase().indexOf("opera") != -1) { - x = elCell.offsetLeft; - y = elCell.offsetTop; - while(elCell.offsetParent) { - x += elCell.offsetParent.offsetLeft; - y += elCell.offsetParent.offsetTop; - elCell = elCell.offsetParent; - } - } - else { - var xy = YAHOO.util.Dom.getXY(elCell); - x = parseInt(YAHOO.util.Dom.getX(elCell),10);//xy[0] + 1; - y = parseInt(YAHOO.util.Dom.getY(elCell),10);//xy[1] + 1; - } - this.container.style.left = x + "px"; - this.container.style.top = y + "px"; - this.container.style.display = "block"; - - this.input.tabIndex = 0; - this.input.focus(); - this.input.select(); -}; - -/** - * Hides ColumnEditor - * - * @method hide - */ -YAHOO.widget.ColumnEditor.prototype.hide = function() { - this.input.tabIndex = -1; - this.container.style.display = "none"; -}; - -/** - * Returns ColumnEditor value - * - * @method getTextboxEditorValue - * @return String - */ -YAHOO.widget.ColumnEditor.prototype.getTextboxEditorValue = function() { - return this.input.value; -}; - -/** - * Returns ColumnEditor value - * - * @method getTextareaEditorValue - * @return String - */ -YAHOO.widget.ColumnEditor.prototype.getTextareaEditorValue = function() { - return this.input.value; -}; - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * Sort static utility to support Column sorting. - * - * @class Sort - * @static - */ -YAHOO.util.Sort = { - ///////////////////////////////////////////////////////////////////////////// - // - // Public methods - // - ///////////////////////////////////////////////////////////////////////////// - - /** - * Comparator function for sort in ascending order. String sorting is case insensitive. - * - * @method compareAsc - * @param a {object} First sort argument. - * @param b {object} Second sort argument. - */ - compareAsc: function(a, b) { - //TODO: is typeof better or is constructor property better? - if(a.constructor == String) { - a = a.toLowerCase(); - } - if(b.constructor == String) { - b = b.toLowerCase(); - } - if(a < b) { - return -1; - } - else if (a > b) { - return 1; - } - else { - return 0; - } - }, - - /** - * Comparator function for sort in descending order. String sorting is case insensitive. - * - * @method compareDesc - * @param a {object} First sort argument. - * @param b {object} Second sort argument. - */ - compareDesc: function(a, b) { - //TODO: is typeof better or is constructor property better? - if(a.constructor == String) { - a = a.toLowerCase(); - } - if(b.constructor == String) { - b = b.toLowerCase(); - } - if(a < b) { - return 1; - } - else if (a > b) { - return -1; - } - else { - return 0; - } - } -}; - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * WidthResizer subclasses DragDrop to support resizeable Columns. - * - * @class WidthResizer - * @extends YAHOO.util.DragDrop - * @constructor - * @param colElId {string} ID of the Column's TH element being resized - * @param handleElId {string} ID of the handle element that causes the resize - * @param sGroup {string} Group name of related DragDrop items - */ -YAHOO.util.WidthResizer = function(oDataTable, colId, handleId, sGroup, config) { - if (colId) { - this.cell = YAHOO.util.Dom.get(colId); - this.init(handleId, sGroup, config); - //this.initFrame(); - this.datatable = oDataTable; - this.setYConstraint(0,0); - } - else { - } -}; - -if(YAHOO.util.DD) { - YAHOO.extend(YAHOO.util.WidthResizer, YAHOO.util.DD); -} - -///////////////////////////////////////////////////////////////////////////// -// -// Public DOM event handlers -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Handles mousedown events on the Column resizer. - * - * @method onMouseDown - * @param e {string} The mousedown event - */ -YAHOO.util.WidthResizer.prototype.onMouseDown = function(e) { - this.startWidth = this.cell.offsetWidth; - this.startPos = YAHOO.util.Dom.getX(this.getDragEl()); - - if(this.datatable.fixedwidth) { - var cellText = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_COLUMNTEXT,"span",this.cell)[0]; - this.minWidth = cellText.offsetWidth + 6; - var sib = this.cell.nextSibling; - var sibCellText = YAHOO.util.Dom.getElementsByClassName(YAHOO.widget.DataTable.CLASS_COLUMNTEXT,"span",sib)[0]; - this.sibMinWidth = sibCellText.offsetWidth + 6; -//!! - var left = ((this.startWidth - this.minWidth) < 0) ? 0 : (this.startWidth - this.minWidth); - var right = ((sib.offsetWidth - this.sibMinWidth) < 0) ? 0 : (sib.offsetWidth - this.sibMinWidth); - this.setXConstraint(left, right); - } - -}; - -/** - * Handles mouseup events on the Column resizer. - * - * @method onMouseUp - * @param e {string} The mouseup event - */ -YAHOO.util.WidthResizer.prototype.onMouseUp = function(e) { - //TODO: replace the resizer where it belongs: - var resizeStyle = YAHOO.util.Dom.get(this.handleElId).style; - resizeStyle.left = "auto"; - resizeStyle.right = 0; - resizeStyle.marginRight = "-6px"; - resizeStyle.width = "6px"; - //.yui-dt-headresizer {position:absolute;margin-right:-6px;right:0;bottom:0;width:6px;height:100%;cursor:w-resize;cursor:col-resize;} - - - //var cells = this.datatable._elTable.tHead.rows[this.datatable._elTable.tHead.rows.length-1].cells; - //for(var i=0; i<cells.length; i++) { - //cells[i].style.width = "5px"; - //} - - //TODO: set new ColumnSet width values - this.datatable.fireEvent("columnResizeEvent",{datatable:this.datatable,target:YAHOO.util.Dom.get(this.id)}); -}; - -/** - * Handles drag events on the Column resizer. - * - * @method onDrag - * @param e {string} The drag event - */ -YAHOO.util.WidthResizer.prototype.onDrag = function(e) { - - if(newWidth < this.minWidth) { - newWidth = this.minWidth; - } - - // Resize the Column - var oDataTable = this.datatable; - var elCell = this.cell; - - - // Resize the other Columns - if(oDataTable.fixedwidth) { - // Moving right or left? - var sib = elCell.nextSibling; - //var sibIndex = elCell.index + 1; - var sibnewwidth = sib.offsetWidth - offsetX; - if(sibnewwidth < this.sibMinWidth) { - sibnewwidth = this.sibMinWidth; - } - - //TODO: how else to cycle through all the Columns without having to use an index property? - for(var i=0; i<oDataTable._oColumnSet.length; i++) { - if((i != elCell.index) && (i!=sibIndex)) { - YAHOO.util.Dom.get(oDataTable._oColumnSet.keys[i].id).style.width = oDataTable._oColumnSet.keys[i].width + "px"; - } - } - sib.style.width = sibnewwidth; - elCell.style.width = newWidth + "px"; - //oDataTable._oColumnSet.flat[sibIndex].width = sibnewwidth; - //oDataTable._oColumnSet.flat[elCell.index].width = newWidth; - - } - else { - elCell.style.width = newWidth + "px"; - } -}; - - - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * A RecordSet defines and manages a set of Records. - * - * @class RecordSet - * @param data {Object || Object[]} An object literal or an array of data. - * @constructor - */ -YAHOO.widget.RecordSet = function(data) { - // Internal variables - this._nIndex = YAHOO.widget.RecordSet._nCount; - this._records = []; - - if(data) { - if(data.constructor == Array) { - this.addRecords(data); - } - else if(data.constructor == Object) { - this.addRecord(data); - } - } - - /** - * Fired when a Record is updated with new data. - * - * @event recordUpdateEvent - * @param oArgs.record {YAHOO.widget.Record} The Record instance. - * @param oArgs.key {String} The Record key. - * @param oArgs.newData {Object} New data. - * @param oArgs.oldData {Object} Old data. - * - */ - this.createEvent("recordUpdateEvent"); - - - YAHOO.widget.RecordSet._nCount++; -}; - -if(YAHOO.util.EventProvider) { - YAHOO.augment(YAHOO.widget.RecordSet, YAHOO.util.EventProvider); -} -else { -} - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// -/** - * Internal class variable to index multiple data table instances. - * - * @property _nCount - * @type number - * @private - * @static - */ -YAHOO.widget.RecordSet._nCount = 0; - -/** - * Instance index. - * - * @property _nIndex - * @type number - * @private - */ -YAHOO.widget.RecordSet.prototype._nIndex = null; - -/** - * Internal counter of how many records are in the RecordSet - * - * @property _length - * @private - */ -YAHOO.widget.RecordSet.prototype._length = null; - -///////////////////////////////////////////////////////////////////////////// -// -// Private methods -// -///////////////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Public accessor to the unique name of the RecordSet instance. - * - * @method toString - * @return {string} Unique name of the RecordSet instance - */ -YAHOO.widget.RecordSet.prototype.toString = function() { - return "RecordSet instance " + this._nIndex; -}; - -/** - * Returns the number of non-null records in the sparse RecordSet - * - * @method getLength - * @return {Number} Number records in the RecordSet - */ -YAHOO.widget.RecordSet.prototype.getLength = function() { - return this._length; -}; - -/** - * Returns record with given name, at the given index, or null. - * - * @method getRecord - * @param identifier {String || Number} Record ID or record index - * @return {Object} Record object - */ -YAHOO.widget.RecordSet.prototype.getRecord = function(identifier) { - if(identifier) { - if(identifier.constructor == String) { - for(var i=0; i<this._records.length; i++) { - if(this._records[i].id == identifier) { - return this._records[i]; - } - } - return null; - } - else { - return this._records[identifier]; - } - } - return null; -}; - -/** - * Returns an array of Records from the RecordSet. - * - * @method getRecords - * @param i {number} Index of which record to start at - * @param range {number} (optional) Number of records to get - * @return {Array} Array of records starting at given index and lenth equal to - * given range. If range is null, entire RecordSet array is returned. - */ -YAHOO.widget.RecordSet.prototype.getRecords = function(i, range) { - if(i === undefined) { - return this._records; - } - i = parseInt(i,10); - if(isNaN(i)) { - return null; - } - if(range === undefined) { - return this._records.slice(i); - } - range = parseInt(range,10); - if(isNaN(range)) { - return null; - } - return this._records.slice(i, i+range); -}; - -/** - * Returns index for the given record. - * - * @method getRecordIndex - * @param oRecord {object} Record object - * @return {number} index - */ - -/*YAHOO.widget.RecordSet.prototype.getRecordIndex = function(oRecord) { - //TODO: return i; -};*/ - -/** - * Returns the record(2) with the given value at the given key. - * - * @method getRecordBy - * @param sKey {String} Key to search. - * @param oValue {Object} to match against. - * @return {YAHOO.widget.Record || YAHOO.widget.Record[]} Record or array of - * Records with the given value at the given key, or null. - */ -/*YAHOO.widget.RecordSet.prototype.getRecordBy = function(sKey, oValue) { - TODO: redo to match new algorithm - var record = null; - var length = this._records.length; - for(var i=length-1; i>0; i--) { - record = this._records[i]; - if(record && (record.extid == extId)) { - return record; - } - } - return null; - -};*/ - -/** - * Updates given Record at given key with given data. - * - * @method updateRecord - * @param oRecord {YAHOO.widget.Record} A Record instance. - * @param sKey {String} Key. - * @param oData {Object) New data. - */ -YAHOO.widget.RecordSet.prototype.updateRecord = function(oRecord, sKey, oData) { - var oldData = oRecord[sKey]; - oRecord[sKey] = oData; - this.fireEvent("recordUpdateEvent",{record:oRecord,key:sKey,newData:oData,oldData:oldData}); -}; - -/** - * Adds one Record to the RecordSet at the given index. If index is null, - * then adds the Record to the end of the RecordSet. - * - * @method addRecord - * @param oObjectLiteral {Object} An object literal of data. - * @param index {Number} (optional) Position index. - * @return {YAHOO.widget.Record} A Record instance. - */ -YAHOO.widget.RecordSet.prototype.addRecord = function(oObjectLiteral, index) { - if(oObjectLiteral) { - var oRecord = new YAHOO.widget.Record(oObjectLiteral); - if(!isNaN(index) && (index > -1)) { - this._records.splice(index,0,oRecord); - } - else { - this._records.push(oRecord); - } - this._length++; - return oRecord; - } - else { - return null; - } -}; - -/** - * Adds multiple Records to the RecordSet at the given index. If index is null, - * then adds the Records to the end of the RecordSet. - * - * @method addRecords - * @param data {Object[]} An array of object literal data. - * @param index {Number} (optional) Position index. - * @return {YAHOO.widget.Record} An array of Record instances. - */ -YAHOO.widget.RecordSet.prototype.addRecords = function(data, index) { - if(data) { - if(data.constructor == Array) { - var newRecords = []; - // Can't go backwards bc we need to preserve order - for(var i=0; i<data.length; i++) { - var record = this.addRecord(data[i], index); - newRecords.push(record); - } - return newRecords; - } - else if(data.constructor == Object) { - return this.addRecord(data); - } - } - else { - return null; - } -}; - -/** - * Convenience method to append the given data to the end of the RecordSet. - * - * @method append - * @param data {Object || Object[]} An object literal or array of data. - * @return {YAHOO.widget.Record || YAHOO.widget.Record[]} A Record or array of Records. - */ -YAHOO.widget.RecordSet.prototype.append = function(data) { - if(data) { - if(data.constructor == Array) { - var newRecords = []; - // Cant't go backwards bc we need to preserve order - for(var i=0; i<data.length; i++) { - var record = this.addRecord(data[i]); - newRecords.push(record); - } - return newRecords; - } - else if(data.constructor == Object) { - return this.addRecord(data); - } - } - else { - return null; - } - -}; - -/** - * Convenience method to insert the given data into the beginning of the RecordSet. - * - * @method insert - * @param data {Object || Object[]} An object literal or array of data. - * @return {YAHOO.widget.Record || YAHOO.widget.Record[]} A Record or array of Records. - */ -YAHOO.widget.RecordSet.prototype.insert = function(data) { - if(data) { - if(data.constructor == Array) { - var newRecords = []; - // Can't go backwards bc we need to preserve order - for(var i=data.length-1; i>-1; i--) { - var record = this.addRecord(data[i], 0); - newRecords.push(record); - } - return newRecords; - } - else if(data.constructor == Object) { - return this.addRecord(data, 0); - } - } - else { - return null; - } -}; - -/** - * Replaces all Records in RecordSet with new data. - * - * @method replace - * @param data {Object || Object[]} An object literal or array or data. - * @return {YAHOO.widget.Record || YAHOO.widget.Record[]} A Record or array of Records. - */ -YAHOO.widget.RecordSet.prototype.replace = function(data) { - if(data) { - this.reset(); - return this.append(data); - } - else { - return null; - } -}; - -/** - * Sorts RecordSet by given function. - * - * @method sort - * @param fnSort {Function} Reference to a sort function. - * @return {Array} Sorted array of Records - */ -YAHOO.widget.RecordSet.prototype.sort = function(fnSort) { - return this._records.sort(fnSort); -}; - - -/** - * Removes the record at the given index from the RecordSet. If a range is - * given, starts at the given index and removes all records in the range. - * - * @method deleteRecord - * @param i {Number} Record index - * @param range {Number} (optional) Range of records to remove, or null. - */ -YAHOO.widget.RecordSet.prototype.deleteRecord = function(i, range) { - if(!range || isNaN(range)) { - range = 1; - } - if(i && !isNaN(i)) { - this._records.splice(i, range); - this._length = this._length - range; - } -}; - -/** - * Removes all Records from the RecordSet. - * - * @method reset - */ -YAHOO.widget.RecordSet.prototype.reset = function() { - this._records = []; - this._length = 0; -}; - - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The Record class defines a DataTable record. - * - * @class Record - * @constructor - * @param oConfigs {Object} (optional) Object literal of key/value pairs. - */ -YAHOO.widget.Record = function(oLiteral) { - if(typeof oLiteral == "object") { - for(var sKey in oLiteral) { - if(sKey) { - this[sKey] = oLiteral[sKey]; - } - } - } - this.id = "yui-dtrec"+YAHOO.widget.Record._nCount; - YAHOO.widget.Record._nCount++; -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Private member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Internal class variable to index multiple data table instances. - * - * @property _nCount - * @type number - * @private - * @static - */ -YAHOO.widget.Record._nCount = 0; - -///////////////////////////////////////////////////////////////////////////// -// -// Public member variables -// -///////////////////////////////////////////////////////////////////////////// - -/** - * Unique name assigned at instantation, indicates original order. - * - * @property id - * @type string - */ -YAHOO.widget.Record.prototype.id = null; - -YAHOO.register("datatable", YAHOO.widget.DataTable, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/dom/README b/interface/web/js/yui/dom/README deleted file mode 100644 index c4b3104321..0000000000 --- a/interface/web/js/yui/dom/README +++ /dev/null @@ -1,79 +0,0 @@ -Dom Release Notes - -** version 2.2.0 ** -* no change - - -*** version 0.12.2 *** -* no change - -*** version 0.12.1 *** - -* getElementsByClassName no longer reverts to document when "root" not found -* setXY no longer makes a second call to getXY unless noRetry is false -* minified version no longer strips line breaks - -*** version 0.12.0 *** - -* fixed getXY for IE null parent -* branching set/getStyle at load time instead of run time - -*** version 0.11.3 *** - -* fixed getX and getY returning incorrect values for collections -* fixed getXY incorrectly calculated for Opera inline elements -* fixed isAncestor failure in safari when 2nd arg is document.documentElement -* fixed infinite loop in replaceClass when oldClassName == newClassName -* getDocumentWidth no longer includes scrollbars - - -*** version 0.11.2 *** -* limit depth of parent.document crawl to 1 for getXY -* test offsetParent instead of parentNode for getXY -* return null if no el fo r get -* just addClass if no class to replace for replaceClass - - -*** version 0.11.1 *** - -* return null if el is null for get() -* test offsetParent rather than parentNode for getXY() -* limit depth of parent.document crawl for IE getXY() to 1 -* if no oldClassName to replace, just addClass for replaceClass() - - -*** version 0.11.0 *** -* Work around Opera 9 broken currentStyle -* Removed timeout wrapper from setXY retry -* Tagname tests now case-insensitive -* Internal "this" references changed to allow for method shorthand -* get/setStyle now accept both camel and hyphen case -* Gecko reverted to crawling offsets for getXY - - -*** version 0.10.0 *** - -* Safari now fails gracefully when querying computedStyle of an unavailable element - -* Class management functions added (hasClass, addClass, removeClass, replaceClass, getElementsByClassName) - -* All methods that accept HTMLElements or IDs now also accept arrays of HTMLElements and/or IDs - -* GenerateId method added - -* isAncestor method added - -* inDocument method added - -* getElementsBy method added - -* batch method added - -* getClientHeight/Width deprecated in favor of getViewportHeight/Width - -* getDocumentHeight/Width methods added - -*** version 0.9.0 *** - -* Initial release - diff --git a/interface/web/js/yui/dom/dom-debug.js b/interface/web/js/yui/dom/dom-debug.js deleted file mode 100644 index 2c3c292f67..0000000000 --- a/interface/web/js/yui/dom/dom-debug.js +++ /dev/null @@ -1,935 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -*/ - -/** - * The dom module provides helper methods for manipulating Dom elements. - * @module dom - * - */ - -(function() { - var Y = YAHOO.util, // internal shorthand - getStyle, // for load time browser branching - setStyle, // ditto - id_counter = 0, // for use with generateId - propertyCache = {}; // for faster hyphen converts - - // brower detection - var ua = navigator.userAgent.toLowerCase(), - isOpera = (ua.indexOf('opera') > -1), - isSafari = (ua.indexOf('safari') > -1), - isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1), - isIE = (!isOpera && ua.indexOf('msie') > -1); - - // regex cache - var patterns = { - HYPHEN: /(-[a-z])/i - }; - - var logger = {}; - logger.log = function() { YAHOO.log.apply(window, arguments); }; - - var toCamel = function(property) { - if ( !patterns.HYPHEN.test(property) ) { - return property; // no hyphens - } - - if (propertyCache[property]) { // already converted - return propertyCache[property]; - } - - while( patterns.HYPHEN.exec(property) ) { - property = property.replace(RegExp.$1, - RegExp.$1.substr(1).toUpperCase()); - } - - propertyCache[property] = property; - return property; - //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug - }; - - // branching at load instead of runtime - if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method - getStyle = function(el, property) { - var value = null; - - var computed = document.defaultView.getComputedStyle(el, ''); - if (computed) { // test computed before touching for safari - value = computed[toCamel(property)]; - } - - return el.style[property] || value; - }; - } else if (document.documentElement.currentStyle && isIE) { // IE method - getStyle = function(el, property) { - switch( toCamel(property) ) { - case 'opacity' :// IE opacity uses filter - var val = 100; - try { // will error if no DXImageTransform - val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity; - - } catch(e) { - try { // make sure its in the document - val = el.filters('alpha').opacity; - } catch(e) { - logger.log('getStyle: IE filter failed', - 'error', 'Dom'); - } - } - return val / 100; - break; - default: - // test currentStyle before touching - var value = el.currentStyle ? el.currentStyle[property] : null; - return ( el.style[property] || value ); - } - }; - } else { // default to inline only - getStyle = function(el, property) { return el.style[property]; }; - } - - if (isIE) { - setStyle = function(el, property, val) { - switch (property) { - case 'opacity': - if ( typeof el.style.filter == 'string' ) { // in case not appended - el.style.filter = 'alpha(opacity=' + val * 100 + ')'; - - if (!el.currentStyle || !el.currentStyle.hasLayout) { - el.style.zoom = 1; // when no layout or cant tell - } - } - break; - default: - el.style[property] = val; - } - }; - } else { - setStyle = function(el, property, val) { - el.style[property] = val; - }; - } - - /** - * Provides helper methods for DOM elements. - * @namespace YAHOO.util - * @class Dom - */ - YAHOO.util.Dom = { - /** - * Returns an HTMLElement reference. - * @method get - * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements. - */ - get: function(el) { - if (!el) { return null; } // nothing to work with - - if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is - logger.log('get(' + el + ') returning ' + el, 'info', 'Dom'); - return el; - } - - if (typeof el == 'string') { // ID - logger.log('get("' + el + '") returning ' + document.getElementById(el), 'info', 'Dom'); - return document.getElementById(el); - } - else { // array of ID's and/or elements - var collection = []; - for (var i = 0, len = el.length; i < len; ++i) { - collection[collection.length] = Y.Dom.get(el[i]); - } - - logger.log('get("' + el + '") returning ' + collection, 'info', 'Dom'); - return collection; - } - - logger.log('element ' + el + ' not found', 'error', 'Dom'); - return null; // safety, should never happen - }, - - /** - * Normalizes currentStyle and ComputedStyle. - * @method getStyle - * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {String} property The style property whose value is returned. - * @return {String | Array} The current value of the style property for the element(s). - */ - getStyle: function(el, property) { - property = toCamel(property); - - var f = function(element) { - return getStyle(element, property); - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers. - * @method setStyle - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {String} property The style property to be set. - * @param {String} val The value to apply to the given property. - */ - setStyle: function(el, property, val) { - property = toCamel(property); - - var f = function(element) { - setStyle(element, property, val); - logger.log('setStyle setting ' + property + ' to ' + val, 'info', 'Dom'); - - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method getXY - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @return {Array} The XY position of the element(s) - */ - getXY: function(el) { - var f = function(el) { - - // has to be part of document to have pageXY - if (el.parentNode === null || el.offsetParent === null || - this.getStyle(el, 'display') == 'none') { - logger.log('getXY failed: element not available', 'error', 'Dom'); - return false; - } - - var parentNode = null; - var pos = []; - var box; - - if (el.getBoundingClientRect) { // IE - box = el.getBoundingClientRect(); - var doc = document; - if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll - doc = parent.document; - - if ( !this.isAncestor(doc.documentElement, el) ) { - logger.log('getXY failed: element not available', 'error', 'Dom'); - return false; - } - - } - - var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop); - var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft); - - return [box.left + scrollLeft, box.top + scrollTop]; - } - else { // safari, opera, & gecko - pos = [el.offsetLeft, el.offsetTop]; - parentNode = el.offsetParent; - if (parentNode != el) { - while (parentNode) { - pos[0] += parentNode.offsetLeft; - pos[1] += parentNode.offsetTop; - parentNode = parentNode.offsetParent; - } - } - if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases - pos[0] -= document.body.offsetLeft; - pos[1] -= document.body.offsetTop; - } - } - - if (el.parentNode) { parentNode = el.parentNode; } - else { parentNode = null; } - - while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML') - { // account for any scrolled ancestors - if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug - pos[0] -= parentNode.scrollLeft; - pos[1] -= parentNode.scrollTop; - } - - if (parentNode.parentNode) { - parentNode = parentNode.parentNode; - } else { parentNode = null; } - } - - logger.log('getXY returning ' + pos, 'info', 'Dom'); - - return pos; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method getX - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @return {String | Array} The X position of the element(s) - */ - getX: function(el) { - var f = function(el) { - return Y.Dom.getXY(el)[0]; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method getY - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @return {String | Array} The Y position of the element(s) - */ - getY: function(el) { - var f = function(el) { - return Y.Dom.getXY(el)[1]; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Set the position of an html element in page coordinates, regardless of how the element is positioned. - * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method setXY - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @param {Array} pos Contains X & Y values for new position (coordinates are page-based) - * @param {Boolean} noRetry By default we try and set the position a second time if the first fails - */ - setXY: function(el, pos, noRetry) { - var f = function(el) { - var style_pos = this.getStyle(el, 'position'); - if (style_pos == 'static') { // default to relative - this.setStyle(el, 'position', 'relative'); - style_pos = 'relative'; - } - - var pageXY = this.getXY(el); - if (pageXY === false) { // has to be part of doc to have pageXY - logger.log('setXY failed: element not available', 'error', 'Dom'); - return false; - } - - var delta = [ // assuming pixels; if not we will have to retry - parseInt( this.getStyle(el, 'left'), 10 ), - parseInt( this.getStyle(el, 'top'), 10 ) - ]; - - if ( isNaN(delta[0]) ) {// in case of 'auto' - delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft; - } - if ( isNaN(delta[1]) ) { // in case of 'auto' - delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop; - } - - if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; } - if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; } - - if (!noRetry) { - var newXY = this.getXY(el); - - // if retry is true, try one more time if we miss - if ( (pos[0] !== null && newXY[0] != pos[0]) || - (pos[1] !== null && newXY[1] != pos[1]) ) { - this.setXY(el, pos, true); - } - } - - logger.log('setXY setting position to ' + pos, 'info', 'Dom'); - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Set the X position of an html element in page coordinates, regardless of how the element is positioned. - * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method setX - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {Int} x The value to use as the X coordinate for the element(s). - */ - setX: function(el, x) { - Y.Dom.setXY(el, [x, null]); - }, - - /** - * Set the Y position of an html element in page coordinates, regardless of how the element is positioned. - * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method setY - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {Int} x To use as the Y coordinate for the element(s). - */ - setY: function(el, y) { - Y.Dom.setXY(el, [null, y]); - }, - - /** - * Returns the region position of the given element. - * The element must be part of the DOM tree to have a region (display:none or elements not appended return false). - * @method getRegion - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data. - */ - getRegion: function(el) { - var f = function(el) { - var region = new Y.Region.getRegion(el); - logger.log('getRegion returning ' + region, 'info', 'Dom'); - return region; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Returns the width of the client (viewport). - * @method getClientWidth - * @deprecated Now using getViewportWidth. This interface left intact for back compat. - * @return {Int} The width of the viewable area of the page. - */ - getClientWidth: function() { - return Y.Dom.getViewportWidth(); - }, - - /** - * Returns the height of the client (viewport). - * @method getClientHeight - * @deprecated Now using getViewportHeight. This interface left intact for back compat. - * @return {Int} The height of the viewable area of the page. - */ - getClientHeight: function() { - return Y.Dom.getViewportHeight(); - }, - - /** - * Returns a array of HTMLElements with the given class. - * For optimized performance, include a tag and/or root node when possible. - * @method getElementsByClassName - * @param {String} className The class name to match against - * @param {String} tag (optional) The tag name of the elements being collected - * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point - * @return {Array} An array of elements that have the given class name - */ - getElementsByClassName: function(className, tag, root) { - var method = function(el) { return Y.Dom.hasClass(el, className); }; - return Y.Dom.getElementsBy(method, tag, root); - }, - - /** - * Determines whether an HTMLElement has the given className. - * @method hasClass - * @param {String | HTMLElement | Array} el The element or collection to test - * @param {String} className the class name to search for - * @return {Boolean | Array} A boolean value or array of boolean values - */ - hasClass: function(el, className) { - var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); - - var f = function(el) { - logger.log('hasClass returning ' + re.test(el['className']), 'info', 'Dom'); - return re.test(el['className']); - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Adds a class name to a given element or collection of elements. - * @method addClass - * @param {String | HTMLElement | Array} el The element or collection to add the class to - * @param {String} className the class name to add to the class attribute - */ - addClass: function(el, className) { - var f = function(el) { - if (this.hasClass(el, className)) { return; } // already present - - logger.log('addClass adding ' + className, 'info', 'Dom'); - - el['className'] = [el['className'], className].join(' '); - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Removes a class name from a given element or collection of elements. - * @method removeClass - * @param {String | HTMLElement | Array} el The element or collection to remove the class from - * @param {String} className the class name to remove from the class attribute - */ - removeClass: function(el, className) { - var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g'); - - var f = function(el) { - if (!this.hasClass(el, className)) { return; } // not present - - logger.log('removeClass removing ' + className, 'info', 'Dom'); - - var c = el['className']; - el['className'] = c.replace(re, ' '); - if ( this.hasClass(el, className) ) { // in case of multiple adjacent - this.removeClass(el, className); - } - - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Replace a class with another class for a given element or collection of elements. - * If no oldClassName is present, the newClassName is simply added. - * @method replaceClass - * @param {String | HTMLElement | Array} el The element or collection to remove the class from - * @param {String} oldClassName the class name to be replaced - * @param {String} newClassName the class name that will be replacing the old class name - */ - replaceClass: function(el, oldClassName, newClassName) { - if (oldClassName === newClassName) { // avoid infinite loop - return false; - } - - var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g'); - - var f = function(el) { - logger.log('replaceClass replacing ' + oldClassName + ' with ' + newClassName, 'info', 'Dom'); - - if ( !this.hasClass(el, oldClassName) ) { - this.addClass(el, newClassName); // just add it if nothing to replace - return; // note return - } - - el['className'] = el['className'].replace(re, ' ' + newClassName + ' '); - - if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent - this.replaceClass(el, oldClassName, newClassName); - } - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Generates a unique ID - * @method generateId - * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present). - * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen"). - * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element) - */ - generateId: function(el, prefix) { - prefix = prefix || 'yui-gen'; - el = el || {}; - - var f = function(el) { - if (el) { - el = Y.Dom.get(el); - } else { - el = {}; // just generating ID in this case - } - - if (!el.id) { - el.id = prefix + id_counter++; - logger.log('generateId generating ' + el.id, 'info', 'Dom'); - } // dont override existing - - logger.log('generateId returning ' + el.id, 'info', 'Dom'); - - return el.id; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy. - * @method isAncestor - * @param {String | HTMLElement} haystack The possible ancestor - * @param {String | HTMLElement} needle The possible descendent - * @return {Boolean} Whether or not the haystack is an ancestor of needle - */ - isAncestor: function(haystack, needle) { - haystack = Y.Dom.get(haystack); - if (!haystack || !needle) { return false; } - - var f = function(needle) { - if (haystack.contains && !isSafari) { // safari "contains" is broken - logger.log('isAncestor returning ' + haystack.contains(needle), 'info', 'Dom'); - return haystack.contains(needle); - } - else if ( haystack.compareDocumentPosition ) { - logger.log('isAncestor returning ' + !!(haystack.compareDocumentPosition(needle) & 16), 'info', 'Dom'); - return !!(haystack.compareDocumentPosition(needle) & 16); - } - else { // loop up and test each parent - var parent = needle.parentNode; - - while (parent) { - if (parent == haystack) { - logger.log('isAncestor returning true', 'info', 'Dom'); - return true; - } - else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') { - logger.log('isAncestor returning false', 'info', 'Dom'); - return false; - } - - parent = parent.parentNode; - } - logger.log('isAncestor returning false', 'info', 'Dom'); - return false; - } - }; - - return Y.Dom.batch(needle, f, Y.Dom, true); - }, - - /** - * Determines whether an HTMLElement is present in the current document. - * @method inDocument - * @param {String | HTMLElement} el The element to search for - * @return {Boolean} Whether or not the element is present in the current document - */ - inDocument: function(el) { - var f = function(el) { - return this.isAncestor(document.documentElement, el); - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Returns a array of HTMLElements that pass the test applied by supplied boolean method. - * For optimized performance, include a tag and/or root node when possible. - * @method getElementsBy - * @param {Function} method - A boolean method for testing elements which receives the element as its only argument. - - * @param {String} tag (optional) The tag name of the elements being collected - * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point - * @return {Array} Array of HTMLElements - */ - getElementsBy: function(method, tag, root) { - tag = tag || '*'; - - var nodes = []; - - if (root) { - root = Y.Dom.get(root); - if (!root) { // if no root node, then no children - return nodes; - } - } else { - root = document; - } - - var elements = root.getElementsByTagName(tag); - - if ( !elements.length && (tag == '*' && root.all) ) { - elements = root.all; // IE < 6 - } - - for (var i = 0, len = elements.length; i < len; ++i) { - if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; } - } - - logger.log('getElementsBy returning ' + nodes, 'info', 'Dom'); - - return nodes; - }, - - /** - * Returns an array of elements that have had the supplied method applied. - * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ). - * @method batch - * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to - * @param {Function} method The method to apply to the element(s) - * @param {Any} o (optional) An optional arg that is passed to the supplied method - * @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o" - * @return {HTMLElement | Array} The element(s) with the method applied - */ - batch: function(el, method, o, override) { - var id = el; - el = Y.Dom.get(el); - - var scope = (override) ? o : window; - - if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection) - if (!el) { - logger.log(id + ' not available', 'error', 'Dom'); - return false; - } - return method.call(scope, el, o); - } - - var collection = []; - - for (var i = 0, len = el.length; i < len; ++i) { - if (!el[i]) { - id = el[i]; - logger.log(id + ' not available', 'error', 'Dom'); - } - collection[collection.length] = method.call(scope, el[i], o); - } - - return collection; - }, - - /** - * Returns the height of the document. - * @method getDocumentHeight - * @return {Int} The height of the actual document (which includes the body and its margin). - */ - getDocumentHeight: function() { - var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight; - - var h = Math.max(scrollHeight, Y.Dom.getViewportHeight()); - logger.log('getDocumentHeight returning ' + h, 'info', 'Dom'); - return h; - }, - - /** - * Returns the width of the document. - * @method getDocumentWidth - * @return {Int} The width of the actual document (which includes the body and its margin). - */ - getDocumentWidth: function() { - var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth; - var w = Math.max(scrollWidth, Y.Dom.getViewportWidth()); - logger.log('getDocumentWidth returning ' + w, 'info', 'Dom'); - return w; - }, - - /** - * Returns the current height of the viewport. - * @method getViewportHeight - * @return {Int} The height of the viewable area of the page (excludes scrollbars). - */ - getViewportHeight: function() { - var height = self.innerHeight; // Safari, Opera - var mode = document.compatMode; - - if ( (mode || isIE) && !isOpera ) { // IE, Gecko - height = (mode == 'CSS1Compat') ? - document.documentElement.clientHeight : // Standards - document.body.clientHeight; // Quirks - } - - logger.log('getViewportHeight returning ' + height, 'info', 'Dom'); - return height; - }, - - /** - * Returns the current width of the viewport. - * @method getViewportWidth - * @return {Int} The width of the viewable area of the page (excludes scrollbars). - */ - - getViewportWidth: function() { - var width = self.innerWidth; // Safari - var mode = document.compatMode; - - if (mode || isIE) { // IE, Gecko, Opera - width = (mode == 'CSS1Compat') ? - document.documentElement.clientWidth : // Standards - document.body.clientWidth; // Quirks - } - logger.log('getViewportWidth returning ' + width, 'info', 'Dom'); - return width; - } - }; -})(); -/** - * A region is a representation of an object on a grid. It is defined - * by the top, right, bottom, left extents, so is rectangular by default. If - * other shapes are required, this class could be extended to support it. - * @namespace YAHOO.util - * @class Region - * @param {Int} t the top extent - * @param {Int} r the right extent - * @param {Int} b the bottom extent - * @param {Int} l the left extent - * @constructor - */ -YAHOO.util.Region = function(t, r, b, l) { - - /** - * The region's top extent - * @property top - * @type Int - */ - this.top = t; - - /** - * The region's top extent as index, for symmetry with set/getXY - * @property 1 - * @type Int - */ - this[1] = t; - - /** - * The region's right extent - * @property right - * @type int - */ - this.right = r; - - /** - * The region's bottom extent - * @property bottom - * @type Int - */ - this.bottom = b; - - /** - * The region's left extent - * @property left - * @type Int - */ - this.left = l; - - /** - * The region's left extent as index, for symmetry with set/getXY - * @property 0 - * @type Int - */ - this[0] = l; -}; - -/** - * Returns true if this region contains the region passed in - * @method contains - * @param {Region} region The region to evaluate - * @return {Boolean} True if the region is contained with this region, - * else false - */ -YAHOO.util.Region.prototype.contains = function(region) { - return ( region.left >= this.left && - region.right <= this.right && - region.top >= this.top && - region.bottom <= this.bottom ); - - // this.logger.debug("does " + this + " contain " + region + " ... " + ret); -}; - -/** - * Returns the area of the region - * @method getArea - * @return {Int} the region's area - */ -YAHOO.util.Region.prototype.getArea = function() { - return ( (this.bottom - this.top) * (this.right - this.left) ); -}; - -/** - * Returns the region where the passed in region overlaps with this one - * @method intersect - * @param {Region} region The region that intersects - * @return {Region} The overlap region, or null if there is no overlap - */ -YAHOO.util.Region.prototype.intersect = function(region) { - var t = Math.max( this.top, region.top ); - var r = Math.min( this.right, region.right ); - var b = Math.min( this.bottom, region.bottom ); - var l = Math.max( this.left, region.left ); - - if (b >= t && r >= l) { - return new YAHOO.util.Region(t, r, b, l); - } else { - return null; - } -}; - -/** - * Returns the region representing the smallest region that can contain both - * the passed in region and this region. - * @method union - * @param {Region} region The region that to create the union with - * @return {Region} The union region - */ -YAHOO.util.Region.prototype.union = function(region) { - var t = Math.min( this.top, region.top ); - var r = Math.max( this.right, region.right ); - var b = Math.max( this.bottom, region.bottom ); - var l = Math.min( this.left, region.left ); - - return new YAHOO.util.Region(t, r, b, l); -}; - -/** - * toString - * @method toString - * @return string the region properties - */ -YAHOO.util.Region.prototype.toString = function() { - return ( "Region {" + - "top: " + this.top + - ", right: " + this.right + - ", bottom: " + this.bottom + - ", left: " + this.left + - "}" ); -}; - -/** - * Returns a region that is occupied by the DOM element - * @method getRegion - * @param {HTMLElement} el The element - * @return {Region} The region that the element occupies - * @static - */ -YAHOO.util.Region.getRegion = function(el) { - var p = YAHOO.util.Dom.getXY(el); - - var t = p[1]; - var r = p[0] + el.offsetWidth; - var b = p[1] + el.offsetHeight; - var l = p[0]; - - return new YAHOO.util.Region(t, r, b, l); -}; - -///////////////////////////////////////////////////////////////////////////// - - -/** - * A point is a region that is special in that it represents a single point on - * the grid. - * @namespace YAHOO.util - * @class Point - * @param {Int} x The X position of the point - * @param {Int} y The Y position of the point - * @constructor - * @extends YAHOO.util.Region - */ -YAHOO.util.Point = function(x, y) { - if (x instanceof Array) { // accept output from Dom.getXY - y = x[1]; - x = x[0]; - } - - /** - * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry) - * @property x - * @type Int - */ - - this.x = this.right = this.left = this[0] = x; - - /** - * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry) - * @property y - * @type Int - */ - this.y = this.top = this.bottom = this[1] = y; -}; - -YAHOO.util.Point.prototype = new YAHOO.util.Region(); - -YAHOO.register("dom", YAHOO.util.Dom, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/dom/dom-min.js b/interface/web/js/yui/dom/dom-min.js deleted file mode 100644 index 6826c180eb..0000000000 --- a/interface/web/js/yui/dom/dom-min.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -(function(){var Y=YAHOO.util,getStyle,setStyle,id_counter=0,propertyCache={};var ua=navigator.userAgent.toLowerCase(),isOpera=(ua.indexOf('opera')>-1),isSafari=(ua.indexOf('safari')>-1),isGecko=(!isOpera&&!isSafari&&ua.indexOf('gecko')>-1),isIE=(!isOpera&&ua.indexOf('msie')>-1);var patterns={HYPHEN:/(-[a-z])/i};var toCamel=function(property){if(!patterns.HYPHEN.test(property)){return property;} -if(propertyCache[property]){return propertyCache[property];} -while(patterns.HYPHEN.exec(property)){property=property.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());} -propertyCache[property]=property;return property;};if(document.defaultView&&document.defaultView.getComputedStyle){getStyle=function(el,property){var value=null;var computed=document.defaultView.getComputedStyle(el,'');if(computed){value=computed[toCamel(property)];} -return el.style[property]||value;};}else if(document.documentElement.currentStyle&&isIE){getStyle=function(el,property){switch(toCamel(property)){case'opacity':var val=100;try{val=el.filters['DXImageTransform.Microsoft.Alpha'].opacity;}catch(e){try{val=el.filters('alpha').opacity;}catch(e){}} -return val/100;break;default:var value=el.currentStyle?el.currentStyle[property]:null;return(el.style[property]||value);}};}else{getStyle=function(el,property){return el.style[property];};} -if(isIE){setStyle=function(el,property,val){switch(property){case'opacity':if(typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}} -break;default:el.style[property]=val;}};}else{setStyle=function(el,property,val){el.style[property]=val;};} -YAHOO.util.Dom={get:function(el){if(!el){return null;} -if(typeof el!='string'&&!(el instanceof Array)){return el;} -if(typeof el=='string'){return document.getElementById(el);} -else{var collection=[];for(var i=0,len=el.length;i<len;++i){collection[collection.length]=Y.Dom.get(el[i]);} -return collection;} -return null;},getStyle:function(el,property){property=toCamel(property);var f=function(element){return getStyle(element,property);};return Y.Dom.batch(el,f,Y.Dom,true);},setStyle:function(el,property,val){property=toCamel(property);var f=function(element){setStyle(element,property,val);};Y.Dom.batch(el,f,Y.Dom,true);},getXY:function(el){var f=function(el){if(el.parentNode===null||el.offsetParent===null||this.getStyle(el,'display')=='none'){return false;} -var parentNode=null;var pos=[];var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var doc=document;if(!this.inDocument(el)&&parent.document!=document){doc=parent.document;if(!this.isAncestor(doc.documentElement,el)){return false;}} -var scrollTop=Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);var scrollLeft=Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);return[box.left+scrollLeft,box.top+scrollTop];} -else{pos=[el.offsetLeft,el.offsetTop];parentNode=el.offsetParent;if(parentNode!=el){while(parentNode){pos[0]+=parentNode.offsetLeft;pos[1]+=parentNode.offsetTop;parentNode=parentNode.offsetParent;}} -if(isSafari&&this.getStyle(el,'position')=='absolute'){pos[0]-=document.body.offsetLeft;pos[1]-=document.body.offsetTop;}} -if(el.parentNode){parentNode=el.parentNode;} -else{parentNode=null;} -while(parentNode&&parentNode.tagName.toUpperCase()!='BODY'&&parentNode.tagName.toUpperCase()!='HTML') -{if(Y.Dom.getStyle(parentNode,'display')!='inline'){pos[0]-=parentNode.scrollLeft;pos[1]-=parentNode.scrollTop;} -if(parentNode.parentNode){parentNode=parentNode.parentNode;}else{parentNode=null;}} -return pos;};return Y.Dom.batch(el,f,Y.Dom,true);},getX:function(el){var f=function(el){return Y.Dom.getXY(el)[0];};return Y.Dom.batch(el,f,Y.Dom,true);},getY:function(el){var f=function(el){return Y.Dom.getXY(el)[1];};return Y.Dom.batch(el,f,Y.Dom,true);},setXY:function(el,pos,noRetry){var f=function(el){var style_pos=this.getStyle(el,'position');if(style_pos=='static'){this.setStyle(el,'position','relative');style_pos='relative';} -var pageXY=this.getXY(el);if(pageXY===false){return false;} -var delta=[parseInt(this.getStyle(el,'left'),10),parseInt(this.getStyle(el,'top'),10)];if(isNaN(delta[0])){delta[0]=(style_pos=='relative')?0:el.offsetLeft;} -if(isNaN(delta[1])){delta[1]=(style_pos=='relative')?0:el.offsetTop;} -if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+'px';} -if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+'px';} -if(!noRetry){var newXY=this.getXY(el);if((pos[0]!==null&&newXY[0]!=pos[0])||(pos[1]!==null&&newXY[1]!=pos[1])){this.setXY(el,pos,true);}}};Y.Dom.batch(el,f,Y.Dom,true);},setX:function(el,x){Y.Dom.setXY(el,[x,null]);},setY:function(el,y){Y.Dom.setXY(el,[null,y]);},getRegion:function(el){var f=function(el){var region=new Y.Region.getRegion(el);return region;};return Y.Dom.batch(el,f,Y.Dom,true);},getClientWidth:function(){return Y.Dom.getViewportWidth();},getClientHeight:function(){return Y.Dom.getViewportHeight();},getElementsByClassName:function(className,tag,root){var method=function(el){return Y.Dom.hasClass(el,className);};return Y.Dom.getElementsBy(method,tag,root);},hasClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');var f=function(el){return re.test(el['className']);};return Y.Dom.batch(el,f,Y.Dom,true);},addClass:function(el,className){var f=function(el){if(this.hasClass(el,className)){return;} -el['className']=[el['className'],className].join(' ');};Y.Dom.batch(el,f,Y.Dom,true);},removeClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,className)){return;} -var c=el['className'];el['className']=c.replace(re,' ');if(this.hasClass(el,className)){this.removeClass(el,className);}};Y.Dom.batch(el,f,Y.Dom,true);},replaceClass:function(el,oldClassName,newClassName){if(oldClassName===newClassName){return false;} -var re=new RegExp('(?:^|\\s+)'+oldClassName+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,oldClassName)){this.addClass(el,newClassName);return;} -el['className']=el['className'].replace(re,' '+newClassName+' ');if(this.hasClass(el,oldClassName)){this.replaceClass(el,oldClassName,newClassName);}};Y.Dom.batch(el,f,Y.Dom,true);},generateId:function(el,prefix){prefix=prefix||'yui-gen';el=el||{};var f=function(el){if(el){el=Y.Dom.get(el);}else{el={};} -if(!el.id){el.id=prefix+id_counter++;} -return el.id;};return Y.Dom.batch(el,f,Y.Dom,true);},isAncestor:function(haystack,needle){haystack=Y.Dom.get(haystack);if(!haystack||!needle){return false;} -var f=function(needle){if(haystack.contains&&!isSafari){return haystack.contains(needle);} -else if(haystack.compareDocumentPosition){return!!(haystack.compareDocumentPosition(needle)&16);} -else{var parent=needle.parentNode;while(parent){if(parent==haystack){return true;} -else if(!parent.tagName||parent.tagName.toUpperCase()=='HTML'){return false;} -parent=parent.parentNode;} -return false;}};return Y.Dom.batch(needle,f,Y.Dom,true);},inDocument:function(el){var f=function(el){return this.isAncestor(document.documentElement,el);};return Y.Dom.batch(el,f,Y.Dom,true);},getElementsBy:function(method,tag,root){tag=tag||'*';var nodes=[];if(root){root=Y.Dom.get(root);if(!root){return nodes;}}else{root=document;} -var elements=root.getElementsByTagName(tag);if(!elements.length&&(tag=='*'&&root.all)){elements=root.all;} -for(var i=0,len=elements.length;i<len;++i){if(method(elements[i])){nodes[nodes.length]=elements[i];}} -return nodes;},batch:function(el,method,o,override){var id=el;el=Y.Dom.get(el);var scope=(override)?o:window;if(!el||el.tagName||!el.length){if(!el){return false;} -return method.call(scope,el,o);} -var collection=[];for(var i=0,len=el.length;i<len;++i){if(!el[i]){id=el[i];} -collection[collection.length]=method.call(scope,el[i],o);} -return collection;},getDocumentHeight:function(){var scrollHeight=(document.compatMode!='CSS1Compat')?document.body.scrollHeight:document.documentElement.scrollHeight;var h=Math.max(scrollHeight,Y.Dom.getViewportHeight());return h;},getDocumentWidth:function(){var scrollWidth=(document.compatMode!='CSS1Compat')?document.body.scrollWidth:document.documentElement.scrollWidth;var w=Math.max(scrollWidth,Y.Dom.getViewportWidth());return w;},getViewportHeight:function(){var height=self.innerHeight;var mode=document.compatMode;if((mode||isIE)&&!isOpera){height=(mode=='CSS1Compat')?document.documentElement.clientHeight:document.body.clientHeight;} -return height;},getViewportWidth:function(){var width=self.innerWidth;var mode=document.compatMode;if(mode||isIE){width=(mode=='CSS1Compat')?document.documentElement.clientWidth:document.body.clientWidth;} -return width;}};})();YAHOO.util.Region=function(t,r,b,l){this.top=t;this[1]=t;this.right=r;this.bottom=b;this.left=l;this[0]=l;};YAHOO.util.Region.prototype.contains=function(region){return(region.left>=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];} -this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region();YAHOO.register("dom",YAHOO.util.Dom,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/dom/dom.js b/interface/web/js/yui/dom/dom.js deleted file mode 100644 index 93febc4484..0000000000 --- a/interface/web/js/yui/dom/dom.js +++ /dev/null @@ -1,901 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -*/ - -/** - * The dom module provides helper methods for manipulating Dom elements. - * @module dom - * - */ - -(function() { - var Y = YAHOO.util, // internal shorthand - getStyle, // for load time browser branching - setStyle, // ditto - id_counter = 0, // for use with generateId - propertyCache = {}; // for faster hyphen converts - - // brower detection - var ua = navigator.userAgent.toLowerCase(), - isOpera = (ua.indexOf('opera') > -1), - isSafari = (ua.indexOf('safari') > -1), - isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1), - isIE = (!isOpera && ua.indexOf('msie') > -1); - - // regex cache - var patterns = { - HYPHEN: /(-[a-z])/i - }; - - - var toCamel = function(property) { - if ( !patterns.HYPHEN.test(property) ) { - return property; // no hyphens - } - - if (propertyCache[property]) { // already converted - return propertyCache[property]; - } - - while( patterns.HYPHEN.exec(property) ) { - property = property.replace(RegExp.$1, - RegExp.$1.substr(1).toUpperCase()); - } - - propertyCache[property] = property; - return property; - //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug - }; - - // branching at load instead of runtime - if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method - getStyle = function(el, property) { - var value = null; - - var computed = document.defaultView.getComputedStyle(el, ''); - if (computed) { // test computed before touching for safari - value = computed[toCamel(property)]; - } - - return el.style[property] || value; - }; - } else if (document.documentElement.currentStyle && isIE) { // IE method - getStyle = function(el, property) { - switch( toCamel(property) ) { - case 'opacity' :// IE opacity uses filter - var val = 100; - try { // will error if no DXImageTransform - val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity; - - } catch(e) { - try { // make sure its in the document - val = el.filters('alpha').opacity; - } catch(e) { - } - } - return val / 100; - break; - default: - // test currentStyle before touching - var value = el.currentStyle ? el.currentStyle[property] : null; - return ( el.style[property] || value ); - } - }; - } else { // default to inline only - getStyle = function(el, property) { return el.style[property]; }; - } - - if (isIE) { - setStyle = function(el, property, val) { - switch (property) { - case 'opacity': - if ( typeof el.style.filter == 'string' ) { // in case not appended - el.style.filter = 'alpha(opacity=' + val * 100 + ')'; - - if (!el.currentStyle || !el.currentStyle.hasLayout) { - el.style.zoom = 1; // when no layout or cant tell - } - } - break; - default: - el.style[property] = val; - } - }; - } else { - setStyle = function(el, property, val) { - el.style[property] = val; - }; - } - - /** - * Provides helper methods for DOM elements. - * @namespace YAHOO.util - * @class Dom - */ - YAHOO.util.Dom = { - /** - * Returns an HTMLElement reference. - * @method get - * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements. - */ - get: function(el) { - if (!el) { return null; } // nothing to work with - - if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is - return el; - } - - if (typeof el == 'string') { // ID - return document.getElementById(el); - } - else { // array of ID's and/or elements - var collection = []; - for (var i = 0, len = el.length; i < len; ++i) { - collection[collection.length] = Y.Dom.get(el[i]); - } - - return collection; - } - - return null; // safety, should never happen - }, - - /** - * Normalizes currentStyle and ComputedStyle. - * @method getStyle - * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {String} property The style property whose value is returned. - * @return {String | Array} The current value of the style property for the element(s). - */ - getStyle: function(el, property) { - property = toCamel(property); - - var f = function(element) { - return getStyle(element, property); - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers. - * @method setStyle - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {String} property The style property to be set. - * @param {String} val The value to apply to the given property. - */ - setStyle: function(el, property, val) { - property = toCamel(property); - - var f = function(element) { - setStyle(element, property, val); - - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method getXY - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @return {Array} The XY position of the element(s) - */ - getXY: function(el) { - var f = function(el) { - - // has to be part of document to have pageXY - if (el.parentNode === null || el.offsetParent === null || - this.getStyle(el, 'display') == 'none') { - return false; - } - - var parentNode = null; - var pos = []; - var box; - - if (el.getBoundingClientRect) { // IE - box = el.getBoundingClientRect(); - var doc = document; - if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll - doc = parent.document; - - if ( !this.isAncestor(doc.documentElement, el) ) { - return false; - } - - } - - var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop); - var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft); - - return [box.left + scrollLeft, box.top + scrollTop]; - } - else { // safari, opera, & gecko - pos = [el.offsetLeft, el.offsetTop]; - parentNode = el.offsetParent; - if (parentNode != el) { - while (parentNode) { - pos[0] += parentNode.offsetLeft; - pos[1] += parentNode.offsetTop; - parentNode = parentNode.offsetParent; - } - } - if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases - pos[0] -= document.body.offsetLeft; - pos[1] -= document.body.offsetTop; - } - } - - if (el.parentNode) { parentNode = el.parentNode; } - else { parentNode = null; } - - while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML') - { // account for any scrolled ancestors - if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug - pos[0] -= parentNode.scrollLeft; - pos[1] -= parentNode.scrollTop; - } - - if (parentNode.parentNode) { - parentNode = parentNode.parentNode; - } else { parentNode = null; } - } - - - return pos; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method getX - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @return {String | Array} The X position of the element(s) - */ - getX: function(el) { - var f = function(el) { - return Y.Dom.getXY(el)[0]; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method getY - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @return {String | Array} The Y position of the element(s) - */ - getY: function(el) { - var f = function(el) { - return Y.Dom.getXY(el)[1]; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Set the position of an html element in page coordinates, regardless of how the element is positioned. - * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method setXY - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @param {Array} pos Contains X & Y values for new position (coordinates are page-based) - * @param {Boolean} noRetry By default we try and set the position a second time if the first fails - */ - setXY: function(el, pos, noRetry) { - var f = function(el) { - var style_pos = this.getStyle(el, 'position'); - if (style_pos == 'static') { // default to relative - this.setStyle(el, 'position', 'relative'); - style_pos = 'relative'; - } - - var pageXY = this.getXY(el); - if (pageXY === false) { // has to be part of doc to have pageXY - return false; - } - - var delta = [ // assuming pixels; if not we will have to retry - parseInt( this.getStyle(el, 'left'), 10 ), - parseInt( this.getStyle(el, 'top'), 10 ) - ]; - - if ( isNaN(delta[0]) ) {// in case of 'auto' - delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft; - } - if ( isNaN(delta[1]) ) { // in case of 'auto' - delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop; - } - - if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; } - if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; } - - if (!noRetry) { - var newXY = this.getXY(el); - - // if retry is true, try one more time if we miss - if ( (pos[0] !== null && newXY[0] != pos[0]) || - (pos[1] !== null && newXY[1] != pos[1]) ) { - this.setXY(el, pos, true); - } - } - - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Set the X position of an html element in page coordinates, regardless of how the element is positioned. - * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method setX - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {Int} x The value to use as the X coordinate for the element(s). - */ - setX: function(el, x) { - Y.Dom.setXY(el, [x, null]); - }, - - /** - * Set the Y position of an html element in page coordinates, regardless of how the element is positioned. - * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @method setY - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {Int} x To use as the Y coordinate for the element(s). - */ - setY: function(el, y) { - Y.Dom.setXY(el, [null, y]); - }, - - /** - * Returns the region position of the given element. - * The element must be part of the DOM tree to have a region (display:none or elements not appended return false). - * @method getRegion - * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data. - */ - getRegion: function(el) { - var f = function(el) { - var region = new Y.Region.getRegion(el); - return region; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Returns the width of the client (viewport). - * @method getClientWidth - * @deprecated Now using getViewportWidth. This interface left intact for back compat. - * @return {Int} The width of the viewable area of the page. - */ - getClientWidth: function() { - return Y.Dom.getViewportWidth(); - }, - - /** - * Returns the height of the client (viewport). - * @method getClientHeight - * @deprecated Now using getViewportHeight. This interface left intact for back compat. - * @return {Int} The height of the viewable area of the page. - */ - getClientHeight: function() { - return Y.Dom.getViewportHeight(); - }, - - /** - * Returns a array of HTMLElements with the given class. - * For optimized performance, include a tag and/or root node when possible. - * @method getElementsByClassName - * @param {String} className The class name to match against - * @param {String} tag (optional) The tag name of the elements being collected - * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point - * @return {Array} An array of elements that have the given class name - */ - getElementsByClassName: function(className, tag, root) { - var method = function(el) { return Y.Dom.hasClass(el, className); }; - return Y.Dom.getElementsBy(method, tag, root); - }, - - /** - * Determines whether an HTMLElement has the given className. - * @method hasClass - * @param {String | HTMLElement | Array} el The element or collection to test - * @param {String} className the class name to search for - * @return {Boolean | Array} A boolean value or array of boolean values - */ - hasClass: function(el, className) { - var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); - - var f = function(el) { - return re.test(el['className']); - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Adds a class name to a given element or collection of elements. - * @method addClass - * @param {String | HTMLElement | Array} el The element or collection to add the class to - * @param {String} className the class name to add to the class attribute - */ - addClass: function(el, className) { - var f = function(el) { - if (this.hasClass(el, className)) { return; } // already present - - - el['className'] = [el['className'], className].join(' '); - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Removes a class name from a given element or collection of elements. - * @method removeClass - * @param {String | HTMLElement | Array} el The element or collection to remove the class from - * @param {String} className the class name to remove from the class attribute - */ - removeClass: function(el, className) { - var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g'); - - var f = function(el) { - if (!this.hasClass(el, className)) { return; } // not present - - - var c = el['className']; - el['className'] = c.replace(re, ' '); - if ( this.hasClass(el, className) ) { // in case of multiple adjacent - this.removeClass(el, className); - } - - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Replace a class with another class for a given element or collection of elements. - * If no oldClassName is present, the newClassName is simply added. - * @method replaceClass - * @param {String | HTMLElement | Array} el The element or collection to remove the class from - * @param {String} oldClassName the class name to be replaced - * @param {String} newClassName the class name that will be replacing the old class name - */ - replaceClass: function(el, oldClassName, newClassName) { - if (oldClassName === newClassName) { // avoid infinite loop - return false; - } - - var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g'); - - var f = function(el) { - - if ( !this.hasClass(el, oldClassName) ) { - this.addClass(el, newClassName); // just add it if nothing to replace - return; // note return - } - - el['className'] = el['className'].replace(re, ' ' + newClassName + ' '); - - if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent - this.replaceClass(el, oldClassName, newClassName); - } - }; - - Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Generates a unique ID - * @method generateId - * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present). - * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen"). - * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element) - */ - generateId: function(el, prefix) { - prefix = prefix || 'yui-gen'; - el = el || {}; - - var f = function(el) { - if (el) { - el = Y.Dom.get(el); - } else { - el = {}; // just generating ID in this case - } - - if (!el.id) { - el.id = prefix + id_counter++; - } // dont override existing - - - return el.id; - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy. - * @method isAncestor - * @param {String | HTMLElement} haystack The possible ancestor - * @param {String | HTMLElement} needle The possible descendent - * @return {Boolean} Whether or not the haystack is an ancestor of needle - */ - isAncestor: function(haystack, needle) { - haystack = Y.Dom.get(haystack); - if (!haystack || !needle) { return false; } - - var f = function(needle) { - if (haystack.contains && !isSafari) { // safari "contains" is broken - return haystack.contains(needle); - } - else if ( haystack.compareDocumentPosition ) { - return !!(haystack.compareDocumentPosition(needle) & 16); - } - else { // loop up and test each parent - var parent = needle.parentNode; - - while (parent) { - if (parent == haystack) { - return true; - } - else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') { - return false; - } - - parent = parent.parentNode; - } - return false; - } - }; - - return Y.Dom.batch(needle, f, Y.Dom, true); - }, - - /** - * Determines whether an HTMLElement is present in the current document. - * @method inDocument - * @param {String | HTMLElement} el The element to search for - * @return {Boolean} Whether or not the element is present in the current document - */ - inDocument: function(el) { - var f = function(el) { - return this.isAncestor(document.documentElement, el); - }; - - return Y.Dom.batch(el, f, Y.Dom, true); - }, - - /** - * Returns a array of HTMLElements that pass the test applied by supplied boolean method. - * For optimized performance, include a tag and/or root node when possible. - * @method getElementsBy - * @param {Function} method - A boolean method for testing elements which receives the element as its only argument. - - * @param {String} tag (optional) The tag name of the elements being collected - * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point - * @return {Array} Array of HTMLElements - */ - getElementsBy: function(method, tag, root) { - tag = tag || '*'; - - var nodes = []; - - if (root) { - root = Y.Dom.get(root); - if (!root) { // if no root node, then no children - return nodes; - } - } else { - root = document; - } - - var elements = root.getElementsByTagName(tag); - - if ( !elements.length && (tag == '*' && root.all) ) { - elements = root.all; // IE < 6 - } - - for (var i = 0, len = elements.length; i < len; ++i) { - if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; } - } - - - return nodes; - }, - - /** - * Returns an array of elements that have had the supplied method applied. - * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ). - * @method batch - * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to - * @param {Function} method The method to apply to the element(s) - * @param {Any} o (optional) An optional arg that is passed to the supplied method - * @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o" - * @return {HTMLElement | Array} The element(s) with the method applied - */ - batch: function(el, method, o, override) { - var id = el; - el = Y.Dom.get(el); - - var scope = (override) ? o : window; - - if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection) - if (!el) { - return false; - } - return method.call(scope, el, o); - } - - var collection = []; - - for (var i = 0, len = el.length; i < len; ++i) { - if (!el[i]) { - id = el[i]; - } - collection[collection.length] = method.call(scope, el[i], o); - } - - return collection; - }, - - /** - * Returns the height of the document. - * @method getDocumentHeight - * @return {Int} The height of the actual document (which includes the body and its margin). - */ - getDocumentHeight: function() { - var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight; - - var h = Math.max(scrollHeight, Y.Dom.getViewportHeight()); - return h; - }, - - /** - * Returns the width of the document. - * @method getDocumentWidth - * @return {Int} The width of the actual document (which includes the body and its margin). - */ - getDocumentWidth: function() { - var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth; - var w = Math.max(scrollWidth, Y.Dom.getViewportWidth()); - return w; - }, - - /** - * Returns the current height of the viewport. - * @method getViewportHeight - * @return {Int} The height of the viewable area of the page (excludes scrollbars). - */ - getViewportHeight: function() { - var height = self.innerHeight; // Safari, Opera - var mode = document.compatMode; - - if ( (mode || isIE) && !isOpera ) { // IE, Gecko - height = (mode == 'CSS1Compat') ? - document.documentElement.clientHeight : // Standards - document.body.clientHeight; // Quirks - } - - return height; - }, - - /** - * Returns the current width of the viewport. - * @method getViewportWidth - * @return {Int} The width of the viewable area of the page (excludes scrollbars). - */ - - getViewportWidth: function() { - var width = self.innerWidth; // Safari - var mode = document.compatMode; - - if (mode || isIE) { // IE, Gecko, Opera - width = (mode == 'CSS1Compat') ? - document.documentElement.clientWidth : // Standards - document.body.clientWidth; // Quirks - } - return width; - } - }; -})(); -/** - * A region is a representation of an object on a grid. It is defined - * by the top, right, bottom, left extents, so is rectangular by default. If - * other shapes are required, this class could be extended to support it. - * @namespace YAHOO.util - * @class Region - * @param {Int} t the top extent - * @param {Int} r the right extent - * @param {Int} b the bottom extent - * @param {Int} l the left extent - * @constructor - */ -YAHOO.util.Region = function(t, r, b, l) { - - /** - * The region's top extent - * @property top - * @type Int - */ - this.top = t; - - /** - * The region's top extent as index, for symmetry with set/getXY - * @property 1 - * @type Int - */ - this[1] = t; - - /** - * The region's right extent - * @property right - * @type int - */ - this.right = r; - - /** - * The region's bottom extent - * @property bottom - * @type Int - */ - this.bottom = b; - - /** - * The region's left extent - * @property left - * @type Int - */ - this.left = l; - - /** - * The region's left extent as index, for symmetry with set/getXY - * @property 0 - * @type Int - */ - this[0] = l; -}; - -/** - * Returns true if this region contains the region passed in - * @method contains - * @param {Region} region The region to evaluate - * @return {Boolean} True if the region is contained with this region, - * else false - */ -YAHOO.util.Region.prototype.contains = function(region) { - return ( region.left >= this.left && - region.right <= this.right && - region.top >= this.top && - region.bottom <= this.bottom ); - -}; - -/** - * Returns the area of the region - * @method getArea - * @return {Int} the region's area - */ -YAHOO.util.Region.prototype.getArea = function() { - return ( (this.bottom - this.top) * (this.right - this.left) ); -}; - -/** - * Returns the region where the passed in region overlaps with this one - * @method intersect - * @param {Region} region The region that intersects - * @return {Region} The overlap region, or null if there is no overlap - */ -YAHOO.util.Region.prototype.intersect = function(region) { - var t = Math.max( this.top, region.top ); - var r = Math.min( this.right, region.right ); - var b = Math.min( this.bottom, region.bottom ); - var l = Math.max( this.left, region.left ); - - if (b >= t && r >= l) { - return new YAHOO.util.Region(t, r, b, l); - } else { - return null; - } -}; - -/** - * Returns the region representing the smallest region that can contain both - * the passed in region and this region. - * @method union - * @param {Region} region The region that to create the union with - * @return {Region} The union region - */ -YAHOO.util.Region.prototype.union = function(region) { - var t = Math.min( this.top, region.top ); - var r = Math.max( this.right, region.right ); - var b = Math.max( this.bottom, region.bottom ); - var l = Math.min( this.left, region.left ); - - return new YAHOO.util.Region(t, r, b, l); -}; - -/** - * toString - * @method toString - * @return string the region properties - */ -YAHOO.util.Region.prototype.toString = function() { - return ( "Region {" + - "top: " + this.top + - ", right: " + this.right + - ", bottom: " + this.bottom + - ", left: " + this.left + - "}" ); -}; - -/** - * Returns a region that is occupied by the DOM element - * @method getRegion - * @param {HTMLElement} el The element - * @return {Region} The region that the element occupies - * @static - */ -YAHOO.util.Region.getRegion = function(el) { - var p = YAHOO.util.Dom.getXY(el); - - var t = p[1]; - var r = p[0] + el.offsetWidth; - var b = p[1] + el.offsetHeight; - var l = p[0]; - - return new YAHOO.util.Region(t, r, b, l); -}; - -///////////////////////////////////////////////////////////////////////////// - - -/** - * A point is a region that is special in that it represents a single point on - * the grid. - * @namespace YAHOO.util - * @class Point - * @param {Int} x The X position of the point - * @param {Int} y The Y position of the point - * @constructor - * @extends YAHOO.util.Region - */ -YAHOO.util.Point = function(x, y) { - if (x instanceof Array) { // accept output from Dom.getXY - y = x[1]; - x = x[0]; - } - - /** - * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry) - * @property x - * @type Int - */ - - this.x = this.right = this.left = this[0] = x; - - /** - * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry) - * @property y - * @type Int - */ - this.y = this.top = this.bottom = this[1] = y; -}; - -YAHOO.util.Point.prototype = new YAHOO.util.Region(); - -YAHOO.register("dom", YAHOO.util.Dom, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/dragdrop/README b/interface/web/js/yui/dragdrop/README deleted file mode 100644 index 861174a4da..0000000000 --- a/interface/web/js/yui/dragdrop/README +++ /dev/null @@ -1,118 +0,0 @@ -Drag and Drop Release Notes - -2.2.0 - - * onMouseDown event is executed before element positions are calculated - - * refreshCache refreshes everything if groups array is not provided - - * setX/setYConstraint doesn't fail when presented ints cast as strings - -0.12.2 - - * No change - -0.12.1 - - * Added a STRICT_INTERSECT drag and drop interaction mode. This alters the - behavior of DDM::getBestMatch. INTERSECT mode first tests the cursor - location, and if it is over the target that target wins, otherwise it - tests the overlap of the elements. STRICT_INTERSECT mode tests only - the overlap, the largest overlap wins. - - * getBestMatch will work for targeted elements that have no overlap. - -0.12.0 - - * The logic to determine if a drag should be initiated has been isolated - to the clickValidator method. This method can be overridden to provide - custom valdiation logic. For example, it is possible to specify hotspots - of any dimension or shape. The provided example shows how to make only - a circular region in the middle of the element initiate a drag. - - * Added a new drag and drop event: onInvalidDrop. This is executed when - the dragged element in dropped in a location without a target. Previously - this condition could only detected by implementing handlers for three - other events. - - * Now accepts an element reference in lieu of an id. Ids will - be generated if the element does not have one. - - * Fixed horizontal autoscroll when scrollTop is zero. - - * Added hasOuterHandles property to bypass the isOverTarget check in the - mousedown validation routine. Fixes setOuterHandleElId. - -0.11.4 - - * YAHOO.util.DragDropMgr.swapNode now handles adjacent nodes properly - - * Fixed missing variable declarations - -0.11.3 - - * Fixed a JavaScript error that would be generated when trying to implement - DDProxy using the default settings and a tiny element. - - * Fixed an error that resulted when constraints were applied to DragDrop - instances. - -0.11.2 - - * Drag and drop will no longer interfere with selecting text on elements - that are not involved in drag and drop. - - * The shared drag and drop proxy element now resizes correctly when autoResize - is enabled. - -0.11.1 - - * Fixes an issue where the setXY cache could get out of sync if the element's - offsetParent is changed during onDragDrop. - -0.11.0 - - * The Dom.util.setXY calculation for the initial placement of the dragged - element is cached during the drag, enhancing the drag performance. - - * DDProxy no longer enforces having a single proxy element for all instances. - dragElId can be set in the config object in the constructor. If the - element already exists it will use that element, otherwise a new one will - be created with that id. - - * DDProxy->borderWidth has been removed. The value is calculated on the fly - instead. - - * Added DragDrop->clearTicks and DragDrop->clearConstraints - - * All drag and drop constructors now have an additional, optional parameter - call "config". It is an object that can contain properties for a - number of configuration settings. - - * Drag and drop will not be disabled for elements that cannot have their - location determined. - - * isLegalTarget won't return dd objects that are not targetable. - - * Added DragDrop->removeFromGroup. - - * Constraints are now applied properly when determining which drag and drop - events should fire. - - -0.10.0 - - * Improved the performance when in intersect mode - - * It was possible for the drag and drop initialization to be skipped - for very slow loading pages. This was fixed. - - * New methods to exclude regions within your drag and drop element: - addInvalidHandleId(), addInvalidHandleClass() - - * Added an onAvailable handler that is executed after the initial state is set. - - * Drag and drop is more forgiving when the implementer attempts to create the - instance prior to the element being in the document, but after the window - load event has fired. - diff --git a/interface/web/js/yui/dragdrop/dragdrop-debug.js b/interface/web/js/yui/dragdrop/dragdrop-debug.js deleted file mode 100644 index a6b5eb4544..0000000000 --- a/interface/web/js/yui/dragdrop/dragdrop-debug.js +++ /dev/null @@ -1,3068 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The drag and drop utility provides a framework for building drag and drop - * applications. In addition to enabling drag and drop for specific elements, - * the drag and drop elements are tracked by the manager class, and the - * interactions between the various elements are tracked during the drag and - * the implementing code is notified about these important moments. - * @module dragdrop - * @title Drag and Drop - * @requires yahoo,dom,event - * @namespace YAHOO.util - */ - -// Only load the library once. Rewriting the manager class would orphan -// existing drag and drop instances. -if (!YAHOO.util.DragDropMgr) { - -/** - * DragDropMgr is a singleton that tracks the element interaction for - * all DragDrop items in the window. Generally, you will not call - * this class directly, but it does have helper methods that could - * be useful in your DragDrop implementations. - * @class DragDropMgr - * @static - */ -YAHOO.util.DragDropMgr = function() { - - var Event = YAHOO.util.Event; - - return { - - /** - * Two dimensional Array of registered DragDrop objects. The first - * dimension is the DragDrop item group, the second the DragDrop - * object. - * @property ids - * @type {string: string} - * @private - * @static - */ - ids: {}, - - /** - * Array of element ids defined as drag handles. Used to determine - * if the element that generated the mousedown event is actually the - * handle and not the html element itself. - * @property handleIds - * @type {string: string} - * @private - * @static - */ - handleIds: {}, - - /** - * the DragDrop object that is currently being dragged - * @property dragCurrent - * @type DragDrop - * @private - * @static - **/ - dragCurrent: null, - - /** - * the DragDrop object(s) that are being hovered over - * @property dragOvers - * @type Array - * @private - * @static - */ - dragOvers: {}, - - /** - * the X distance between the cursor and the object being dragged - * @property deltaX - * @type int - * @private - * @static - */ - deltaX: 0, - - /** - * the Y distance between the cursor and the object being dragged - * @property deltaY - * @type int - * @private - * @static - */ - deltaY: 0, - - /** - * Flag to determine if we should prevent the default behavior of the - * events we define. By default this is true, but this can be set to - * false if you need the default behavior (not recommended) - * @property preventDefault - * @type boolean - * @static - */ - preventDefault: true, - - /** - * Flag to determine if we should stop the propagation of the events - * we generate. This is true by default but you may want to set it to - * false if the html element contains other features that require the - * mouse click. - * @property stopPropagation - * @type boolean - * @static - */ - stopPropagation: true, - - /** - * Internal flag that is set to true when drag and drop has been - * intialized - * @property initialized - * @private - * @static - */ - initalized: false, - - /** - * All drag and drop can be disabled. - * @property locked - * @private - * @static - */ - locked: false, - - /** - * Called the first time an element is registered. - * @method init - * @private - * @static - */ - init: function() { - this.logger = new YAHOO.widget.LogWriter("DragDropMgr"); - this.initialized = true; - }, - - /** - * In point mode, drag and drop interaction is defined by the - * location of the cursor during the drag/drop - * @property POINT - * @type int - * @static - * @final - */ - POINT: 0, - - /** - * In intersect mode, drag and drop interaction is defined by the - * cursor position or the amount of overlap of two or more drag and - * drop objects. - * @property INTERSECT - * @type int - * @static - * @final - */ - INTERSECT: 1, - - /** - * In intersect mode, drag and drop interaction is defined only by the - * overlap of two or more drag and drop objects. - * @property STRICT_INTERSECT - * @type int - * @static - * @final - */ - STRICT_INTERSECT: 2, - - /** - * The current drag and drop mode. Default: POINT - * @property mode - * @type int - * @static - */ - mode: 0, - - /** - * Runs method on all drag and drop objects - * @method _execOnAll - * @private - * @static - */ - _execOnAll: function(sMethod, args) { - for (var i in this.ids) { - for (var j in this.ids[i]) { - var oDD = this.ids[i][j]; - if (! this.isTypeOfDD(oDD)) { - continue; - } - oDD[sMethod].apply(oDD, args); - } - } - }, - - /** - * Drag and drop initialization. Sets up the global event handlers - * @method _onLoad - * @private - * @static - */ - _onLoad: function() { - - this.init(); - - this.logger.log("DDM onload"); - - Event.on(document, "mouseup", this.handleMouseUp, this, true); - Event.on(document, "mousemove", this.handleMouseMove, this, true); - Event.on(window, "unload", this._onUnload, this, true); - Event.on(window, "resize", this._onResize, this, true); - // Event.on(window, "mouseout", this._test); - - }, - - /** - * Reset constraints on all drag and drop objs - * @method _onResize - * @private - * @static - */ - _onResize: function(e) { - this.logger.log("window resize"); - this._execOnAll("resetConstraints", []); - }, - - /** - * Lock all drag and drop functionality - * @method lock - * @static - */ - lock: function() { this.locked = true; }, - - /** - * Unlock all drag and drop functionality - * @method unlock - * @static - */ - unlock: function() { this.locked = false; }, - - /** - * Is drag and drop locked? - * @method isLocked - * @return {boolean} True if drag and drop is locked, false otherwise. - * @static - */ - isLocked: function() { return this.locked; }, - - /** - * Location cache that is set for all drag drop objects when a drag is - * initiated, cleared when the drag is finished. - * @property locationCache - * @private - * @static - */ - locationCache: {}, - - /** - * Set useCache to false if you want to force object the lookup of each - * drag and drop linked element constantly during a drag. - * @property useCache - * @type boolean - * @static - */ - useCache: true, - - /** - * The number of pixels that the mouse needs to move after the - * mousedown before the drag is initiated. Default=3; - * @property clickPixelThresh - * @type int - * @static - */ - clickPixelThresh: 3, - - /** - * The number of milliseconds after the mousedown event to initiate the - * drag if we don't get a mouseup event. Default=1000 - * @property clickTimeThresh - * @type int - * @static - */ - clickTimeThresh: 1000, - - /** - * Flag that indicates that either the drag pixel threshold or the - * mousdown time threshold has been met - * @property dragThreshMet - * @type boolean - * @private - * @static - */ - dragThreshMet: false, - - /** - * Timeout used for the click time threshold - * @property clickTimeout - * @type Object - * @private - * @static - */ - clickTimeout: null, - - /** - * The X position of the mousedown event stored for later use when a - * drag threshold is met. - * @property startX - * @type int - * @private - * @static - */ - startX: 0, - - /** - * The Y position of the mousedown event stored for later use when a - * drag threshold is met. - * @property startY - * @type int - * @private - * @static - */ - startY: 0, - - /** - * Each DragDrop instance must be registered with the DragDropMgr. - * This is executed in DragDrop.init() - * @method regDragDrop - * @param {DragDrop} oDD the DragDrop object to register - * @param {String} sGroup the name of the group this element belongs to - * @static - */ - regDragDrop: function(oDD, sGroup) { - if (!this.initialized) { this.init(); } - - if (!this.ids[sGroup]) { - this.ids[sGroup] = {}; - } - this.ids[sGroup][oDD.id] = oDD; - }, - - /** - * Removes the supplied dd instance from the supplied group. Executed - * by DragDrop.removeFromGroup, so don't call this function directly. - * @method removeDDFromGroup - * @private - * @static - */ - removeDDFromGroup: function(oDD, sGroup) { - if (!this.ids[sGroup]) { - this.ids[sGroup] = {}; - } - - var obj = this.ids[sGroup]; - if (obj && obj[oDD.id]) { - delete obj[oDD.id]; - } - }, - - /** - * Unregisters a drag and drop item. This is executed in - * DragDrop.unreg, use that method instead of calling this directly. - * @method _remove - * @private - * @static - */ - _remove: function(oDD) { - for (var g in oDD.groups) { - if (g && this.ids[g][oDD.id]) { - delete this.ids[g][oDD.id]; - //this.logger.log("NEW LEN " + this.ids.length, "warn"); - } - } - delete this.handleIds[oDD.id]; - }, - - /** - * Each DragDrop handle element must be registered. This is done - * automatically when executing DragDrop.setHandleElId() - * @method regHandle - * @param {String} sDDId the DragDrop id this element is a handle for - * @param {String} sHandleId the id of the element that is the drag - * handle - * @static - */ - regHandle: function(sDDId, sHandleId) { - if (!this.handleIds[sDDId]) { - this.handleIds[sDDId] = {}; - } - this.handleIds[sDDId][sHandleId] = sHandleId; - }, - - /** - * Utility function to determine if a given element has been - * registered as a drag drop item. - * @method isDragDrop - * @param {String} id the element id to check - * @return {boolean} true if this element is a DragDrop item, - * false otherwise - * @static - */ - isDragDrop: function(id) { - return ( this.getDDById(id) ) ? true : false; - }, - - /** - * Returns the drag and drop instances that are in all groups the - * passed in instance belongs to. - * @method getRelated - * @param {DragDrop} p_oDD the obj to get related data for - * @param {boolean} bTargetsOnly if true, only return targetable objs - * @return {DragDrop[]} the related instances - * @static - */ - getRelated: function(p_oDD, bTargetsOnly) { - var oDDs = []; - for (var i in p_oDD.groups) { - for (j in this.ids[i]) { - var dd = this.ids[i][j]; - if (! this.isTypeOfDD(dd)) { - continue; - } - if (!bTargetsOnly || dd.isTarget) { - oDDs[oDDs.length] = dd; - } - } - } - - return oDDs; - }, - - /** - * Returns true if the specified dd target is a legal target for - * the specifice drag obj - * @method isLegalTarget - * @param {DragDrop} the drag obj - * @param {DragDrop} the target - * @return {boolean} true if the target is a legal target for the - * dd obj - * @static - */ - isLegalTarget: function (oDD, oTargetDD) { - var targets = this.getRelated(oDD, true); - for (var i=0, len=targets.length;i<len;++i) { - if (targets[i].id == oTargetDD.id) { - return true; - } - } - - return false; - }, - - /** - * My goal is to be able to transparently determine if an object is - * typeof DragDrop, and the exact subclass of DragDrop. typeof - * returns "object", oDD.constructor.toString() always returns - * "DragDrop" and not the name of the subclass. So for now it just - * evaluates a well-known variable in DragDrop. - * @method isTypeOfDD - * @param {Object} the object to evaluate - * @return {boolean} true if typeof oDD = DragDrop - * @static - */ - isTypeOfDD: function (oDD) { - return (oDD && oDD.__ygDragDrop); - }, - - /** - * Utility function to determine if a given element has been - * registered as a drag drop handle for the given Drag Drop object. - * @method isHandle - * @param {String} id the element id to check - * @return {boolean} true if this element is a DragDrop handle, false - * otherwise - * @static - */ - isHandle: function(sDDId, sHandleId) { - return ( this.handleIds[sDDId] && - this.handleIds[sDDId][sHandleId] ); - }, - - /** - * Returns the DragDrop instance for a given id - * @method getDDById - * @param {String} id the id of the DragDrop object - * @return {DragDrop} the drag drop object, null if it is not found - * @static - */ - getDDById: function(id) { - for (var i in this.ids) { - if (this.ids[i][id]) { - return this.ids[i][id]; - } - } - return null; - }, - - /** - * Fired after a registered DragDrop object gets the mousedown event. - * Sets up the events required to track the object being dragged - * @method handleMouseDown - * @param {Event} e the event - * @param oDD the DragDrop object being dragged - * @private - * @static - */ - handleMouseDown: function(e, oDD) { - - this.currentTarget = YAHOO.util.Event.getTarget(e); - - this.logger.log("mousedown - adding event handlers"); - this.dragCurrent = oDD; - - var el = oDD.getEl(); - - // track start position - this.startX = YAHOO.util.Event.getPageX(e); - this.startY = YAHOO.util.Event.getPageY(e); - - this.deltaX = this.startX - el.offsetLeft; - this.deltaY = this.startY - el.offsetTop; - - this.dragThreshMet = false; - - this.clickTimeout = setTimeout( - function() { - var DDM = YAHOO.util.DDM; - DDM.startDrag(DDM.startX, DDM.startY); - }, - this.clickTimeThresh ); - }, - - /** - * Fired when either the drag pixel threshol or the mousedown hold - * time threshold has been met. - * @method startDrag - * @param x {int} the X position of the original mousedown - * @param y {int} the Y position of the original mousedown - * @static - */ - startDrag: function(x, y) { - this.logger.log("firing drag start events"); - clearTimeout(this.clickTimeout); - if (this.dragCurrent) { - this.dragCurrent.b4StartDrag(x, y); - this.dragCurrent.startDrag(x, y); - } - this.dragThreshMet = true; - }, - - /** - * Internal function to handle the mouseup event. Will be invoked - * from the context of the document. - * @method handleMouseUp - * @param {Event} e the event - * @private - * @static - */ - handleMouseUp: function(e) { - - if (! this.dragCurrent) { - return; - } - - clearTimeout(this.clickTimeout); - - if (this.dragThreshMet) { - this.logger.log("mouseup detected - completing drag"); - this.fireEvents(e, true); - } else { - this.logger.log("drag threshold not met"); - } - - this.stopDrag(e); - - this.stopEvent(e); - }, - - /** - * Utility to stop event propagation and event default, if these - * features are turned on. - * @method stopEvent - * @param {Event} e the event as returned by this.getEvent() - * @static - */ - stopEvent: function(e) { - if (this.stopPropagation) { - YAHOO.util.Event.stopPropagation(e); - } - - if (this.preventDefault) { - YAHOO.util.Event.preventDefault(e); - } - }, - - /** - * Internal function to clean up event handlers after the drag - * operation is complete - * @method stopDrag - * @param {Event} e the event - * @private - * @static - */ - stopDrag: function(e) { - // this.logger.log("mouseup - removing event handlers"); - - // Fire the drag end event for the item that was dragged - if (this.dragCurrent) { - if (this.dragThreshMet) { - this.logger.log("firing endDrag events"); - this.dragCurrent.b4EndDrag(e); - this.dragCurrent.endDrag(e); - } - - this.logger.log("firing mouseUp event"); - this.dragCurrent.onMouseUp(e); - } - - this.dragCurrent = null; - this.dragOvers = {}; - }, - - - /** - * Internal function to handle the mousemove event. Will be invoked - * from the context of the html element. - * - * @TODO figure out what we can do about mouse events lost when the - * user drags objects beyond the window boundary. Currently we can - * detect this in internet explorer by verifying that the mouse is - * down during the mousemove event. Firefox doesn't give us the - * button state on the mousemove event. - * @method handleMouseMove - * @param {Event} e the event - * @private - * @static - */ - handleMouseMove: function(e) { - //this.logger.log("handlemousemove"); - if (! this.dragCurrent) { - // this.logger.log("no current drag obj"); - return true; - } - - // var button = e.which || e.button; - // this.logger.log("which: " + e.which + ", button: "+ e.button); - - // check for IE mouseup outside of page boundary - if (YAHOO.util.Event.isIE && !e.button) { - this.logger.log("button failure"); - this.stopEvent(e); - return this.handleMouseUp(e); - } - - if (!this.dragThreshMet) { - var diffX = Math.abs(this.startX - YAHOO.util.Event.getPageX(e)); - var diffY = Math.abs(this.startY - YAHOO.util.Event.getPageY(e)); - // this.logger.log("diffX: " + diffX + "diffY: " + diffY); - if (diffX > this.clickPixelThresh || - diffY > this.clickPixelThresh) { - this.logger.log("pixel threshold met"); - this.startDrag(this.startX, this.startY); - } - } - - if (this.dragThreshMet) { - this.dragCurrent.b4Drag(e); - this.dragCurrent.onDrag(e); - this.fireEvents(e, false); - } - - this.stopEvent(e); - - return true; - }, - - /** - * Iterates over all of the DragDrop elements to find ones we are - * hovering over or dropping on - * @method fireEvents - * @param {Event} e the event - * @param {boolean} isDrop is this a drop op or a mouseover op? - * @private - * @static - */ - fireEvents: function(e, isDrop) { - var dc = this.dragCurrent; - - // If the user did the mouse up outside of the window, we could - // get here even though we have ended the drag. - if (!dc || dc.isLocked()) { - return; - } - - var x = YAHOO.util.Event.getPageX(e); - var y = YAHOO.util.Event.getPageY(e); - var pt = new YAHOO.util.Point(x,y); - - // cache the previous dragOver array - var oldOvers = []; - - var outEvts = []; - var overEvts = []; - var dropEvts = []; - var enterEvts = []; - - // Check to see if the object(s) we were hovering over is no longer - // being hovered over so we can fire the onDragOut event - for (var i in this.dragOvers) { - - var ddo = this.dragOvers[i]; - - if (! this.isTypeOfDD(ddo)) { - continue; - } - - if (! this.isOverTarget(pt, ddo, this.mode)) { - outEvts.push( ddo ); - } - - oldOvers[i] = true; - delete this.dragOvers[i]; - } - - for (var sGroup in dc.groups) { - // this.logger.log("Processing group " + sGroup); - - if ("string" != typeof sGroup) { - continue; - } - - for (i in this.ids[sGroup]) { - var oDD = this.ids[sGroup][i]; - if (! this.isTypeOfDD(oDD)) { - continue; - } - - if (oDD.isTarget && !oDD.isLocked() && oDD != dc) { - if (this.isOverTarget(pt, oDD, this.mode)) { - // look for drop interactions - if (isDrop) { - dropEvts.push( oDD ); - // look for drag enter and drag over interactions - } else { - - // initial drag over: dragEnter fires - if (!oldOvers[oDD.id]) { - enterEvts.push( oDD ); - // subsequent drag overs: dragOver fires - } else { - overEvts.push( oDD ); - } - - this.dragOvers[oDD.id] = oDD; - } - } - } - } - } - - if (this.mode) { - if (outEvts.length) { - this.logger.log(dc.id+" onDragOut: " + outEvts); - dc.b4DragOut(e, outEvts); - dc.onDragOut(e, outEvts); - } - - if (enterEvts.length) { - this.logger.log(dc.id+" onDragEnter: " + enterEvts); - dc.onDragEnter(e, enterEvts); - } - - if (overEvts.length) { - this.logger.log(dc.id+" onDragOver: " + overEvts); - dc.b4DragOver(e, overEvts); - dc.onDragOver(e, overEvts); - } - - if (dropEvts.length) { - this.logger.log(dc.id+" onDragDrop: " + dropEvts); - dc.b4DragDrop(e, dropEvts); - dc.onDragDrop(e, dropEvts); - } - - } else { - // fire dragout events - var len = 0; - for (i=0, len=outEvts.length; i<len; ++i) { - this.logger.log(dc.id+" onDragOut: " + outEvts[i].id); - dc.b4DragOut(e, outEvts[i].id); - dc.onDragOut(e, outEvts[i].id); - } - - // fire enter events - for (i=0,len=enterEvts.length; i<len; ++i) { - this.logger.log(dc.id + " onDragEnter " + enterEvts[i].id); - // dc.b4DragEnter(e, oDD.id); - dc.onDragEnter(e, enterEvts[i].id); - } - - // fire over events - for (i=0,len=overEvts.length; i<len; ++i) { - this.logger.log(dc.id + " onDragOver " + overEvts[i].id); - dc.b4DragOver(e, overEvts[i].id); - dc.onDragOver(e, overEvts[i].id); - } - - // fire drop events - for (i=0, len=dropEvts.length; i<len; ++i) { - this.logger.log(dc.id + " dropped on " + dropEvts[i].id); - dc.b4DragDrop(e, dropEvts[i].id); - dc.onDragDrop(e, dropEvts[i].id); - } - - } - - // notify about a drop that did not find a target - if (isDrop && !dropEvts.length) { - this.logger.log(dc.id + " dropped, but not on a target"); - dc.onInvalidDrop(e); - } - - }, - - /** - * Helper function for getting the best match from the list of drag - * and drop objects returned by the drag and drop events when we are - * in INTERSECT mode. It returns either the first object that the - * cursor is over, or the object that has the greatest overlap with - * the dragged element. - * @method getBestMatch - * @param {DragDrop[]} dds The array of drag and drop objects - * targeted - * @return {DragDrop} The best single match - * @static - */ - getBestMatch: function(dds) { - var winner = null; - - var len = dds.length; - - if (len == 1) { - winner = dds[0]; - } else { - // Loop through the targeted items - for (var i=0; i<len; ++i) { - var dd = dds[i]; - // If the cursor is over the object, it wins. If the - // cursor is over multiple matches, the first one we come - // to wins. - if (this.mode == this.INTERSECT && dd.cursorIsOver) { - winner = dd; - break; - // Otherwise the object with the most overlap wins - } else { - if (!winner || !winner.overlap || (dd.overlap && - winner.overlap.getArea() < dd.overlap.getArea())) { - winner = dd; - } - } - } - } - - return winner; - }, - - /** - * Refreshes the cache of the top-left and bottom-right points of the - * drag and drop objects in the specified group(s). This is in the - * format that is stored in the drag and drop instance, so typical - * usage is: - * <code> - * YAHOO.util.DragDropMgr.refreshCache(ddinstance.groups); - * </code> - * Alternatively: - * <code> - * YAHOO.util.DragDropMgr.refreshCache({group1:true, group2:true}); - * </code> - * @TODO this really should be an indexed array. Alternatively this - * method could accept both. - * @method refreshCache - * @param {Object} groups an associative array of groups to refresh - * @static - */ - refreshCache: function(groups) { - this.logger.log("refreshing element location cache"); - - // refresh everything if group array is not provided - var g = groups || this.ids; - - for (var sGroup in g) { - if ("string" != typeof sGroup) { - continue; - } - for (var i in this.ids[sGroup]) { - var oDD = this.ids[sGroup][i]; - - if (this.isTypeOfDD(oDD)) { - var loc = this.getLocation(oDD); - if (loc) { - this.locationCache[oDD.id] = loc; - } else { - delete this.locationCache[oDD.id]; -this.logger.log("Could not get the loc for " + oDD.id, "warn"); - } - } - } - } - }, - - /** - * This checks to make sure an element exists and is in the DOM. The - * main purpose is to handle cases where innerHTML is used to remove - * drag and drop objects from the DOM. IE provides an 'unspecified - * error' when trying to access the offsetParent of such an element - * @method verifyEl - * @param {HTMLElement} el the element to check - * @return {boolean} true if the element looks usable - * @static - */ - verifyEl: function(el) { - try { - if (el) { - var parent = el.offsetParent; - if (parent) { - return true; - } - } - } catch(e) { - this.logger.log("detected problem with an element"); - } - - return false; - }, - - /** - * Returns a Region object containing the drag and drop element's position - * and size, including the padding configured for it - * @method getLocation - * @param {DragDrop} oDD the drag and drop object to get the - * location for - * @return {YAHOO.util.Region} a Region object representing the total area - * the element occupies, including any padding - * the instance is configured for. - * @static - */ - getLocation: function(oDD) { - if (! this.isTypeOfDD(oDD)) { - this.logger.log(oDD + " is not a DD obj"); - return null; - } - - var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l; - - try { - pos= YAHOO.util.Dom.getXY(el); - } catch (e) { } - - if (!pos) { - this.logger.log("getXY failed"); - return null; - } - - x1 = pos[0]; - x2 = x1 + el.offsetWidth; - y1 = pos[1]; - y2 = y1 + el.offsetHeight; - - t = y1 - oDD.padding[0]; - r = x2 + oDD.padding[1]; - b = y2 + oDD.padding[2]; - l = x1 - oDD.padding[3]; - - return new YAHOO.util.Region( t, r, b, l ); - }, - - /** - * Checks the cursor location to see if it over the target - * @method isOverTarget - * @param {YAHOO.util.Point} pt The point to evaluate - * @param {DragDrop} oTarget the DragDrop object we are inspecting - * @return {boolean} true if the mouse is over the target - * @private - * @static - */ - isOverTarget: function(pt, oTarget, intersect) { - // use cache if available - var loc = this.locationCache[oTarget.id]; - if (!loc || !this.useCache) { - this.logger.log("cache not populated"); - loc = this.getLocation(oTarget); - this.locationCache[oTarget.id] = loc; - - this.logger.log("cache: " + loc); - } - - if (!loc) { - this.logger.log("could not get the location of the element"); - return false; - } - - //this.logger.log("loc: " + loc + ", pt: " + pt); - oTarget.cursorIsOver = loc.contains( pt ); - - // DragDrop is using this as a sanity check for the initial mousedown - // in this case we are done. In POINT mode, if the drag obj has no - // contraints, we are done. Otherwise we need to evaluate the - // region the target as occupies to determine if the dragged element - // overlaps with it. - - var dc = this.dragCurrent; - if (!dc || !dc.getTargetCoord || - (!intersect && !dc.constrainX && !dc.constrainY)) { - - //if (oTarget.cursorIsOver) { - //this.logger.log("over " + oTarget + ", " + loc + ", " + pt, "warn"); - //} - return oTarget.cursorIsOver; - } - - oTarget.overlap = null; - - // Get the current location of the drag element, this is the - // location of the mouse event less the delta that represents - // where the original mousedown happened on the element. We - // need to consider constraints and ticks as well. - var pos = dc.getTargetCoord(pt.x, pt.y); - - var el = dc.getDragEl(); - var curRegion = new YAHOO.util.Region( pos.y, - pos.x + el.offsetWidth, - pos.y + el.offsetHeight, - pos.x ); - - var overlap = curRegion.intersect(loc); - - if (overlap) { - oTarget.overlap = overlap; - return (intersect) ? true : oTarget.cursorIsOver; - } else { - return false; - } - }, - - /** - * unload event handler - * @method _onUnload - * @private - * @static - */ - _onUnload: function(e, me) { - this.unregAll(); - }, - - /** - * Cleans up the drag and drop events and objects. - * @method unregAll - * @private - * @static - */ - unregAll: function() { - this.logger.log("unregister all"); - - if (this.dragCurrent) { - this.stopDrag(); - this.dragCurrent = null; - } - - this._execOnAll("unreg", []); - - for (i in this.elementCache) { - delete this.elementCache[i]; - } - - this.elementCache = {}; - this.ids = {}; - }, - - /** - * A cache of DOM elements - * @property elementCache - * @private - * @static - */ - elementCache: {}, - - /** - * Get the wrapper for the DOM element specified - * @method getElWrapper - * @param {String} id the id of the element to get - * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element - * @private - * @deprecated This wrapper isn't that useful - * @static - */ - getElWrapper: function(id) { - var oWrapper = this.elementCache[id]; - if (!oWrapper || !oWrapper.el) { - oWrapper = this.elementCache[id] = - new this.ElementWrapper(YAHOO.util.Dom.get(id)); - } - return oWrapper; - }, - - /** - * Returns the actual DOM element - * @method getElement - * @param {String} id the id of the elment to get - * @return {Object} The element - * @deprecated use YAHOO.util.Dom.get instead - * @static - */ - getElement: function(id) { - return YAHOO.util.Dom.get(id); - }, - - /** - * Returns the style property for the DOM element (i.e., - * document.getElById(id).style) - * @method getCss - * @param {String} id the id of the elment to get - * @return {Object} The style property of the element - * @deprecated use YAHOO.util.Dom instead - * @static - */ - getCss: function(id) { - var el = YAHOO.util.Dom.get(id); - return (el) ? el.style : null; - }, - - /** - * Inner class for cached elements - * @class DragDropMgr.ElementWrapper - * @for DragDropMgr - * @private - * @deprecated - */ - ElementWrapper: function(el) { - /** - * The element - * @property el - */ - this.el = el || null; - /** - * The element id - * @property id - */ - this.id = this.el && el.id; - /** - * A reference to the style property - * @property css - */ - this.css = this.el && el.style; - }, - - /** - * Returns the X position of an html element - * @method getPosX - * @param el the element for which to get the position - * @return {int} the X coordinate - * @for DragDropMgr - * @deprecated use YAHOO.util.Dom.getX instead - * @static - */ - getPosX: function(el) { - return YAHOO.util.Dom.getX(el); - }, - - /** - * Returns the Y position of an html element - * @method getPosY - * @param el the element for which to get the position - * @return {int} the Y coordinate - * @deprecated use YAHOO.util.Dom.getY instead - * @static - */ - getPosY: function(el) { - return YAHOO.util.Dom.getY(el); - }, - - /** - * Swap two nodes. In IE, we use the native method, for others we - * emulate the IE behavior - * @method swapNode - * @param n1 the first node to swap - * @param n2 the other node to swap - * @static - */ - swapNode: function(n1, n2) { - if (n1.swapNode) { - n1.swapNode(n2); - } else { - var p = n2.parentNode; - var s = n2.nextSibling; - - if (s == n1) { - p.insertBefore(n1, n2); - } else if (n2 == n1.nextSibling) { - p.insertBefore(n2, n1); - } else { - n1.parentNode.replaceChild(n2, n1); - p.insertBefore(n1, s); - } - } - }, - - /** - * Returns the current scroll position - * @method getScroll - * @private - * @static - */ - getScroll: function () { - var t, l, dde=document.documentElement, db=document.body; - if (dde && (dde.scrollTop || dde.scrollLeft)) { - t = dde.scrollTop; - l = dde.scrollLeft; - } else if (db) { - t = db.scrollTop; - l = db.scrollLeft; - } else { - YAHOO.log("could not get scroll property"); - } - return { top: t, left: l }; - }, - - /** - * Returns the specified element style property - * @method getStyle - * @param {HTMLElement} el the element - * @param {string} styleProp the style property - * @return {string} The value of the style property - * @deprecated use YAHOO.util.Dom.getStyle - * @static - */ - getStyle: function(el, styleProp) { - return YAHOO.util.Dom.getStyle(el, styleProp); - }, - - /** - * Gets the scrollTop - * @method getScrollTop - * @return {int} the document's scrollTop - * @static - */ - getScrollTop: function () { return this.getScroll().top; }, - - /** - * Gets the scrollLeft - * @method getScrollLeft - * @return {int} the document's scrollTop - * @static - */ - getScrollLeft: function () { return this.getScroll().left; }, - - /** - * Sets the x/y position of an element to the location of the - * target element. - * @method moveToEl - * @param {HTMLElement} moveEl The element to move - * @param {HTMLElement} targetEl The position reference element - * @static - */ - moveToEl: function (moveEl, targetEl) { - var aCoord = YAHOO.util.Dom.getXY(targetEl); - this.logger.log("moveToEl: " + aCoord); - YAHOO.util.Dom.setXY(moveEl, aCoord); - }, - - /** - * Gets the client height - * @method getClientHeight - * @return {int} client height in px - * @deprecated use YAHOO.util.Dom.getViewportHeight instead - * @static - */ - getClientHeight: function() { - return YAHOO.util.Dom.getViewportHeight(); - }, - - /** - * Gets the client width - * @method getClientWidth - * @return {int} client width in px - * @deprecated use YAHOO.util.Dom.getViewportWidth instead - * @static - */ - getClientWidth: function() { - return YAHOO.util.Dom.getViewportWidth(); - }, - - /** - * Numeric array sort function - * @method numericSort - * @static - */ - numericSort: function(a, b) { return (a - b); }, - - /** - * Internal counter - * @property _timeoutCount - * @private - * @static - */ - _timeoutCount: 0, - - /** - * Trying to make the load order less important. Without this we get - * an error if this file is loaded before the Event Utility. - * @method _addListeners - * @private - * @static - */ - _addListeners: function() { - var DDM = YAHOO.util.DDM; - if ( YAHOO.util.Event && document ) { - DDM._onLoad(); - } else { - if (DDM._timeoutCount > 2000) { - DDM.logger.log("DragDrop requires the Event Utility"); - } else { - setTimeout(DDM._addListeners, 10); - if (document && document.body) { - DDM._timeoutCount += 1; - } - } - } - }, - - /** - * Recursively searches the immediate parent and all child nodes for - * the handle element in order to determine wheter or not it was - * clicked. - * @method handleWasClicked - * @param node the html element to inspect - * @static - */ - handleWasClicked: function(node, id) { - if (this.isHandle(id, node.id)) { - this.logger.log("clicked node is a handle"); - return true; - } else { - // check to see if this is a text node child of the one we want - var p = node.parentNode; - // this.logger.log("p: " + p); - - while (p) { - if (this.isHandle(id, p.id)) { - return true; - } else { - this.logger.log(p.id + " is not a handle"); - p = p.parentNode; - } - } - } - - return false; - } - - }; - -}(); - -// shorter alias, save a few bytes -YAHOO.util.DDM = YAHOO.util.DragDropMgr; -YAHOO.util.DDM._addListeners(); - -} - -(function() { - -var Event=YAHOO.util.Event; -var Dom=YAHOO.util.Dom; - -/** - * Defines the interface and base operation of items that that can be - * dragged or can be drop targets. It was designed to be extended, overriding - * the event handlers for startDrag, onDrag, onDragOver, onDragOut. - * Up to three html elements can be associated with a DragDrop instance: - * <ul> - * <li>linked element: the element that is passed into the constructor. - * This is the element which defines the boundaries for interaction with - * other DragDrop objects.</li> - * <li>handle element(s): The drag operation only occurs if the element that - * was clicked matches a handle element. By default this is the linked - * element, but there are times that you will want only a portion of the - * linked element to initiate the drag operation, and the setHandleElId() - * method provides a way to define this.</li> - * <li>drag element: this represents an the element that would be moved along - * with the cursor during a drag operation. By default, this is the linked - * element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define - * a separate element that would be moved, as in {@link YAHOO.util.DDProxy} - * </li> - * </ul> - * This class should not be instantiated until the onload event to ensure that - * the associated elements are available. - * The following would define a DragDrop obj that would interact with any - * other DragDrop obj in the "group1" group: - * <pre> - * dd = new YAHOO.util.DragDrop("div1", "group1"); - * </pre> - * Since none of the event handlers have been implemented, nothing would - * actually happen if you were to run the code above. Normally you would - * override this class or one of the default implementations, but you can - * also override the methods you want on an instance of the class... - * <pre> - * dd.onDragDrop = function(e, id) { - * alert("dd was dropped on " + id); - * } - * </pre> - * @namespace YAHOO.util - * @class DragDrop - * @constructor - * @param {String} id of the element that is linked to this instance - * @param {String} sGroup the group of related DragDrop objects - * @param {object} config an object containing configurable attributes - * Valid properties for DragDrop: - * padding, isTarget, maintainOffset, primaryButtonOnly, - */ -YAHOO.util.DragDrop = function(id, sGroup, config) { - if (id) { - this.init(id, sGroup, config); - } -}; - -YAHOO.util.DragDrop.prototype = { - - /** - * The id of the element associated with this object. This is what we - * refer to as the "linked element" because the size and position of - * this element is used to determine when the drag and drop objects have - * interacted. - * @property id - * @type String - */ - id: null, - - /** - * Configuration attributes passed into the constructor - * @property config - * @type object - */ - config: null, - - /** - * The id of the element that will be dragged. By default this is same - * as the linked element , but could be changed to another element. Ex: - * YAHOO.util.DDProxy - * @property dragElId - * @type String - * @private - */ - dragElId: null, - - /** - * the id of the element that initiates the drag operation. By default - * this is the linked element, but could be changed to be a child of this - * element. This lets us do things like only starting the drag when the - * header element within the linked html element is clicked. - * @property handleElId - * @type String - * @private - */ - handleElId: null, - - /** - * An associative array of HTML tags that will be ignored if clicked. - * @property invalidHandleTypes - * @type {string: string} - */ - invalidHandleTypes: null, - - /** - * An associative array of ids for elements that will be ignored if clicked - * @property invalidHandleIds - * @type {string: string} - */ - invalidHandleIds: null, - - /** - * An indexted array of css class names for elements that will be ignored - * if clicked. - * @property invalidHandleClasses - * @type string[] - */ - invalidHandleClasses: null, - - /** - * The linked element's absolute X position at the time the drag was - * started - * @property startPageX - * @type int - * @private - */ - startPageX: 0, - - /** - * The linked element's absolute X position at the time the drag was - * started - * @property startPageY - * @type int - * @private - */ - startPageY: 0, - - /** - * The group defines a logical collection of DragDrop objects that are - * related. Instances only get events when interacting with other - * DragDrop object in the same group. This lets us define multiple - * groups using a single DragDrop subclass if we want. - * @property groups - * @type {string: string} - */ - groups: null, - - /** - * Individual drag/drop instances can be locked. This will prevent - * onmousedown start drag. - * @property locked - * @type boolean - * @private - */ - locked: false, - - /** - * Lock this instance - * @method lock - */ - lock: function() { this.locked = true; }, - - /** - * Unlock this instace - * @method unlock - */ - unlock: function() { this.locked = false; }, - - /** - * By default, all insances can be a drop target. This can be disabled by - * setting isTarget to false. - * @method isTarget - * @type boolean - */ - isTarget: true, - - /** - * The padding configured for this drag and drop object for calculating - * the drop zone intersection with this object. - * @method padding - * @type int[] - */ - padding: null, - - /** - * Cached reference to the linked element - * @property _domRef - * @private - */ - _domRef: null, - - /** - * Internal typeof flag - * @property __ygDragDrop - * @private - */ - __ygDragDrop: true, - - /** - * Set to true when horizontal contraints are applied - * @property constrainX - * @type boolean - * @private - */ - constrainX: false, - - /** - * Set to true when vertical contraints are applied - * @property constrainY - * @type boolean - * @private - */ - constrainY: false, - - /** - * The left constraint - * @property minX - * @type int - * @private - */ - minX: 0, - - /** - * The right constraint - * @property maxX - * @type int - * @private - */ - maxX: 0, - - /** - * The up constraint - * @property minY - * @type int - * @type int - * @private - */ - minY: 0, - - /** - * The down constraint - * @property maxY - * @type int - * @private - */ - maxY: 0, - - /** - * Maintain offsets when we resetconstraints. Set to true when you want - * the position of the element relative to its parent to stay the same - * when the page changes - * - * @property maintainOffset - * @type boolean - */ - maintainOffset: false, - - /** - * Array of pixel locations the element will snap to if we specified a - * horizontal graduation/interval. This array is generated automatically - * when you define a tick interval. - * @property xTicks - * @type int[] - */ - xTicks: null, - - /** - * Array of pixel locations the element will snap to if we specified a - * vertical graduation/interval. This array is generated automatically - * when you define a tick interval. - * @property yTicks - * @type int[] - */ - yTicks: null, - - /** - * By default the drag and drop instance will only respond to the primary - * button click (left button for a right-handed mouse). Set to true to - * allow drag and drop to start with any mouse click that is propogated - * by the browser - * @property primaryButtonOnly - * @type boolean - */ - primaryButtonOnly: true, - - /** - * The availabe property is false until the linked dom element is accessible. - * @property available - * @type boolean - */ - available: false, - - /** - * By default, drags can only be initiated if the mousedown occurs in the - * region the linked element is. This is done in part to work around a - * bug in some browsers that mis-report the mousedown if the previous - * mouseup happened outside of the window. This property is set to true - * if outer handles are defined. - * - * @property hasOuterHandles - * @type boolean - * @default false - */ - hasOuterHandles: false, - - /** - * Code that executes immediately before the startDrag event - * @method b4StartDrag - * @private - */ - b4StartDrag: function(x, y) { }, - - /** - * Abstract method called after a drag/drop object is clicked - * and the drag or mousedown time thresholds have beeen met. - * @method startDrag - * @param {int} X click location - * @param {int} Y click location - */ - startDrag: function(x, y) { /* override this */ }, - - /** - * Code that executes immediately before the onDrag event - * @method b4Drag - * @private - */ - b4Drag: function(e) { }, - - /** - * Abstract method called during the onMouseMove event while dragging an - * object. - * @method onDrag - * @param {Event} e the mousemove event - */ - onDrag: function(e) { /* override this */ }, - - /** - * Abstract method called when this element fist begins hovering over - * another DragDrop obj - * @method onDragEnter - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this is hovering over. In INTERSECT mode, an array of one or more - * dragdrop items being hovered over. - */ - onDragEnter: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragOver event - * @method b4DragOver - * @private - */ - b4DragOver: function(e) { }, - - /** - * Abstract method called when this element is hovering over another - * DragDrop obj - * @method onDragOver - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this is hovering over. In INTERSECT mode, an array of dd items - * being hovered over. - */ - onDragOver: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragOut event - * @method b4DragOut - * @private - */ - b4DragOut: function(e) { }, - - /** - * Abstract method called when we are no longer hovering over an element - * @method onDragOut - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this was hovering over. In INTERSECT mode, an array of dd items - * that the mouse is no longer over. - */ - onDragOut: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragDrop event - * @method b4DragDrop - * @private - */ - b4DragDrop: function(e) { }, - - /** - * Abstract method called when this item is dropped on another DragDrop - * obj - * @method onDragDrop - * @param {Event} e the mouseup event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this was dropped on. In INTERSECT mode, an array of dd items this - * was dropped on. - */ - onDragDrop: function(e, id) { /* override this */ }, - - /** - * Abstract method called when this item is dropped on an area with no - * drop target - * @method onInvalidDrop - * @param {Event} e the mouseup event - */ - onInvalidDrop: function(e) { /* override this */ }, - - /** - * Code that executes immediately before the endDrag event - * @method b4EndDrag - * @private - */ - b4EndDrag: function(e) { }, - - /** - * Fired when we are done dragging the object - * @method endDrag - * @param {Event} e the mouseup event - */ - endDrag: function(e) { /* override this */ }, - - /** - * Code executed immediately before the onMouseDown event - * @method b4MouseDown - * @param {Event} e the mousedown event - * @private - */ - b4MouseDown: function(e) { }, - - /** - * Event handler that fires when a drag/drop obj gets a mousedown - * @method onMouseDown - * @param {Event} e the mousedown event - */ - onMouseDown: function(e) { /* override this */ }, - - /** - * Event handler that fires when a drag/drop obj gets a mouseup - * @method onMouseUp - * @param {Event} e the mouseup event - */ - onMouseUp: function(e) { /* override this */ }, - - /** - * Override the onAvailable method to do what is needed after the initial - * position was determined. - * @method onAvailable - */ - onAvailable: function () { - this.logger.log("onAvailable (base)"); - }, - - /** - * Returns a reference to the linked element - * @method getEl - * @return {HTMLElement} the html element - */ - getEl: function() { - if (!this._domRef) { - this._domRef = Dom.get(this.id); - } - - return this._domRef; - }, - - /** - * Returns a reference to the actual element to drag. By default this is - * the same as the html element, but it can be assigned to another - * element. An example of this can be found in YAHOO.util.DDProxy - * @method getDragEl - * @return {HTMLElement} the html element - */ - getDragEl: function() { - return Dom.get(this.dragElId); - }, - - /** - * Sets up the DragDrop object. Must be called in the constructor of any - * YAHOO.util.DragDrop subclass - * @method init - * @param id the id of the linked element - * @param {String} sGroup the group of related items - * @param {object} config configuration attributes - */ - init: function(id, sGroup, config) { - this.initTarget(id, sGroup, config); - Event.on(this.id, "mousedown", this.handleMouseDown, this, true); - // Event.on(this.id, "selectstart", Event.preventDefault); - }, - - /** - * Initializes Targeting functionality only... the object does not - * get a mousedown handler. - * @method initTarget - * @param id the id of the linked element - * @param {String} sGroup the group of related items - * @param {object} config configuration attributes - */ - initTarget: function(id, sGroup, config) { - - // configuration attributes - this.config = config || {}; - - // create a local reference to the drag and drop manager - this.DDM = YAHOO.util.DDM; - // initialize the groups array - this.groups = {}; - - // assume that we have an element reference instead of an id if the - // parameter is not a string - if (typeof id !== "string") { - YAHOO.log("id is not a string, assuming it is an HTMLElement"); - id = Dom.generateId(id); - } - - // set the id - this.id = id; - - // add to an interaction group - this.addToGroup((sGroup) ? sGroup : "default"); - - // We don't want to register this as the handle with the manager - // so we just set the id rather than calling the setter. - this.handleElId = id; - - Event.onAvailable(id, this.handleOnAvailable, this, true); - - // create a logger instance - this.logger = (YAHOO.widget.LogWriter) ? - new YAHOO.widget.LogWriter(this.toString()) : YAHOO; - - // the linked element is the element that gets dragged by default - this.setDragElId(id); - - // by default, clicked anchors will not start drag operations. - // @TODO what else should be here? Probably form fields. - this.invalidHandleTypes = { A: "A" }; - this.invalidHandleIds = {}; - this.invalidHandleClasses = []; - - this.applyConfig(); - }, - - /** - * Applies the configuration parameters that were passed into the constructor. - * This is supposed to happen at each level through the inheritance chain. So - * a DDProxy implentation will execute apply config on DDProxy, DD, and - * DragDrop in order to get all of the parameters that are available in - * each object. - * @method applyConfig - */ - applyConfig: function() { - - // configurable properties: - // padding, isTarget, maintainOffset, primaryButtonOnly - this.padding = this.config.padding || [0, 0, 0, 0]; - this.isTarget = (this.config.isTarget !== false); - this.maintainOffset = (this.config.maintainOffset); - this.primaryButtonOnly = (this.config.primaryButtonOnly !== false); - - }, - - /** - * Executed when the linked element is available - * @method handleOnAvailable - * @private - */ - handleOnAvailable: function() { - this.logger.log("handleOnAvailable"); - this.available = true; - this.resetConstraints(); - this.onAvailable(); - }, - - /** - * Configures the padding for the target zone in px. Effectively expands - * (or reduces) the virtual object size for targeting calculations. - * Supports css-style shorthand; if only one parameter is passed, all sides - * will have that padding, and if only two are passed, the top and bottom - * will have the first param, the left and right the second. - * @method setPadding - * @param {int} iTop Top pad - * @param {int} iRight Right pad - * @param {int} iBot Bot pad - * @param {int} iLeft Left pad - */ - setPadding: function(iTop, iRight, iBot, iLeft) { - // this.padding = [iLeft, iRight, iTop, iBot]; - if (!iRight && 0 !== iRight) { - this.padding = [iTop, iTop, iTop, iTop]; - } else if (!iBot && 0 !== iBot) { - this.padding = [iTop, iRight, iTop, iRight]; - } else { - this.padding = [iTop, iRight, iBot, iLeft]; - } - }, - - /** - * Stores the initial placement of the linked element. - * @method setInitialPosition - * @param {int} diffX the X offset, default 0 - * @param {int} diffY the Y offset, default 0 - */ - setInitPosition: function(diffX, diffY) { - var el = this.getEl(); - - if (!this.DDM.verifyEl(el)) { - this.logger.log(this.id + " element is broken"); - return; - } - - var dx = diffX || 0; - var dy = diffY || 0; - - var p = Dom.getXY( el ); - - this.initPageX = p[0] - dx; - this.initPageY = p[1] - dy; - - this.lastPageX = p[0]; - this.lastPageY = p[1]; - - this.logger.log(this.id + " inital position: " + this.initPageX + - ", " + this.initPageY); - - - this.setStartPosition(p); - }, - - /** - * Sets the start position of the element. This is set when the obj - * is initialized, the reset when a drag is started. - * @method setStartPosition - * @param pos current position (from previous lookup) - * @private - */ - setStartPosition: function(pos) { - var p = pos || Dom.getXY( this.getEl() ); - - this.deltaSetXY = null; - - this.startPageX = p[0]; - this.startPageY = p[1]; - }, - - /** - * Add this instance to a group of related drag/drop objects. All - * instances belong to at least one group, and can belong to as many - * groups as needed. - * @method addToGroup - * @param sGroup {string} the name of the group - */ - addToGroup: function(sGroup) { - this.groups[sGroup] = true; - this.DDM.regDragDrop(this, sGroup); - }, - - /** - * Remove's this instance from the supplied interaction group - * @method removeFromGroup - * @param {string} sGroup The group to drop - */ - removeFromGroup: function(sGroup) { - this.logger.log("Removing from group: " + sGroup); - if (this.groups[sGroup]) { - delete this.groups[sGroup]; - } - - this.DDM.removeDDFromGroup(this, sGroup); - }, - - /** - * Allows you to specify that an element other than the linked element - * will be moved with the cursor during a drag - * @method setDragElId - * @param id {string} the id of the element that will be used to initiate the drag - */ - setDragElId: function(id) { - this.dragElId = id; - }, - - /** - * Allows you to specify a child of the linked element that should be - * used to initiate the drag operation. An example of this would be if - * you have a content div with text and links. Clicking anywhere in the - * content area would normally start the drag operation. Use this method - * to specify that an element inside of the content div is the element - * that starts the drag operation. - * @method setHandleElId - * @param id {string} the id of the element that will be used to - * initiate the drag. - */ - setHandleElId: function(id) { - if (typeof id !== "string") { - YAHOO.log("id is not a string, assuming it is an HTMLElement"); - id = Dom.generateId(id); - } - this.handleElId = id; - this.DDM.regHandle(this.id, id); - }, - - /** - * Allows you to set an element outside of the linked element as a drag - * handle - * @method setOuterHandleElId - * @param id the id of the element that will be used to initiate the drag - */ - setOuterHandleElId: function(id) { - if (typeof id !== "string") { - YAHOO.log("id is not a string, assuming it is an HTMLElement"); - id = Dom.generateId(id); - } - this.logger.log("Adding outer handle event: " + id); - Event.on(id, "mousedown", - this.handleMouseDown, this, true); - this.setHandleElId(id); - - this.hasOuterHandles = true; - }, - - /** - * Remove all drag and drop hooks for this element - * @method unreg - */ - unreg: function() { - this.logger.log("DragDrop obj cleanup " + this.id); - Event.removeListener(this.id, "mousedown", - this.handleMouseDown); - this._domRef = null; - this.DDM._remove(this); - }, - - /** - * Returns true if this instance is locked, or the drag drop mgr is locked - * (meaning that all drag/drop is disabled on the page.) - * @method isLocked - * @return {boolean} true if this obj or all drag/drop is locked, else - * false - */ - isLocked: function() { - return (this.DDM.isLocked() || this.locked); - }, - - /** - * Fired when this object is clicked - * @method handleMouseDown - * @param {Event} e - * @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj) - * @private - */ - handleMouseDown: function(e, oDD) { - - var button = e.which || e.button; - this.logger.log("button: " + button); - - if (this.primaryButtonOnly && button > 1) { - this.logger.log("Mousedown was not produced by the primary button"); - return; - } - - if (this.isLocked()) { - this.logger.log("Drag and drop is disabled, aborting"); - return; - } - - this.logger.log("mousedown " + this.id); - - this.logger.log("firing onMouseDown events"); - - // firing the mousedown events prior to calculating positions - this.b4MouseDown(e); - this.onMouseDown(e); - - this.DDM.refreshCache(this.groups); - // var self = this; - // setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0); - - // Only process the event if we really clicked within the linked - // element. The reason we make this check is that in the case that - // another element was moved between the clicked element and the - // cursor in the time between the mousedown and mouseup events. When - // this happens, the element gets the next mousedown event - // regardless of where on the screen it happened. - var pt = new YAHOO.util.Point(Event.getPageX(e), Event.getPageY(e)); - if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) { - this.logger.log("Click was not over the element: " + this.id); - } else { - if (this.clickValidator(e)) { - - this.logger.log("click was a valid handle"); - - // set the initial element position - this.setStartPosition(); - - // start tracking mousemove distance and mousedown time to - // determine when to start the actual drag - this.DDM.handleMouseDown(e, this); - - // this mousedown is mine - this.DDM.stopEvent(e); - } else { - -this.logger.log("clickValidator returned false, drag not initiated"); - - } - } - }, - - clickValidator: function(e) { - var target = Event.getTarget(e); - return ( this.isValidHandleChild(target) && - (this.id == this.handleElId || - this.DDM.handleWasClicked(target, this.id)) ); - }, - - /** - * Allows you to specify a tag name that should not start a drag operation - * when clicked. This is designed to facilitate embedding links within a - * drag handle that do something other than start the drag. - * @method addInvalidHandleType - * @param {string} tagName the type of element to exclude - */ - addInvalidHandleType: function(tagName) { - var type = tagName.toUpperCase(); - this.invalidHandleTypes[type] = type; - }, - - /** - * Lets you to specify an element id for a child of a drag handle - * that should not initiate a drag - * @method addInvalidHandleId - * @param {string} id the element id of the element you wish to ignore - */ - addInvalidHandleId: function(id) { - if (typeof id !== "string") { - YAHOO.log("id is not a string, assuming it is an HTMLElement"); - id = Dom.generateId(id); - } - this.invalidHandleIds[id] = id; - }, - - - /** - * Lets you specify a css class of elements that will not initiate a drag - * @method addInvalidHandleClass - * @param {string} cssClass the class of the elements you wish to ignore - */ - addInvalidHandleClass: function(cssClass) { - this.invalidHandleClasses.push(cssClass); - }, - - /** - * Unsets an excluded tag name set by addInvalidHandleType - * @method removeInvalidHandleType - * @param {string} tagName the type of element to unexclude - */ - removeInvalidHandleType: function(tagName) { - var type = tagName.toUpperCase(); - // this.invalidHandleTypes[type] = null; - delete this.invalidHandleTypes[type]; - }, - - /** - * Unsets an invalid handle id - * @method removeInvalidHandleId - * @param {string} id the id of the element to re-enable - */ - removeInvalidHandleId: function(id) { - if (typeof id !== "string") { - YAHOO.log("id is not a string, assuming it is an HTMLElement"); - id = Dom.generateId(id); - } - delete this.invalidHandleIds[id]; - }, - - /** - * Unsets an invalid css class - * @method removeInvalidHandleClass - * @param {string} cssClass the class of the element(s) you wish to - * re-enable - */ - removeInvalidHandleClass: function(cssClass) { - for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) { - if (this.invalidHandleClasses[i] == cssClass) { - delete this.invalidHandleClasses[i]; - } - } - }, - - /** - * Checks the tag exclusion list to see if this click should be ignored - * @method isValidHandleChild - * @param {HTMLElement} node the HTMLElement to evaluate - * @return {boolean} true if this is a valid tag type, false if not - */ - isValidHandleChild: function(node) { - - var valid = true; - // var n = (node.nodeName == "#text") ? node.parentNode : node; - var nodeName; - try { - nodeName = node.nodeName.toUpperCase(); - } catch(e) { - nodeName = node.nodeName; - } - valid = valid && !this.invalidHandleTypes[nodeName]; - valid = valid && !this.invalidHandleIds[node.id]; - - for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) { - valid = !Dom.hasClass(node, this.invalidHandleClasses[i]); - } - - this.logger.log("Valid handle? ... " + valid); - - return valid; - - }, - - /** - * Create the array of horizontal tick marks if an interval was specified - * in setXConstraint(). - * @method setXTicks - * @private - */ - setXTicks: function(iStartX, iTickSize) { - this.xTicks = []; - this.xTickSize = iTickSize; - - var tickMap = {}; - - for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) { - if (!tickMap[i]) { - this.xTicks[this.xTicks.length] = i; - tickMap[i] = true; - } - } - - for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) { - if (!tickMap[i]) { - this.xTicks[this.xTicks.length] = i; - tickMap[i] = true; - } - } - - this.xTicks.sort(this.DDM.numericSort) ; - this.logger.log("xTicks: " + this.xTicks.join()); - }, - - /** - * Create the array of vertical tick marks if an interval was specified in - * setYConstraint(). - * @method setYTicks - * @private - */ - setYTicks: function(iStartY, iTickSize) { - // this.logger.log("setYTicks: " + iStartY + ", " + iTickSize - // + ", " + this.initPageY + ", " + this.minY + ", " + this.maxY ); - this.yTicks = []; - this.yTickSize = iTickSize; - - var tickMap = {}; - - for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) { - if (!tickMap[i]) { - this.yTicks[this.yTicks.length] = i; - tickMap[i] = true; - } - } - - for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) { - if (!tickMap[i]) { - this.yTicks[this.yTicks.length] = i; - tickMap[i] = true; - } - } - - this.yTicks.sort(this.DDM.numericSort) ; - this.logger.log("yTicks: " + this.yTicks.join()); - }, - - /** - * By default, the element can be dragged any place on the screen. Use - * this method to limit the horizontal travel of the element. Pass in - * 0,0 for the parameters if you want to lock the drag to the y axis. - * @method setXConstraint - * @param {int} iLeft the number of pixels the element can move to the left - * @param {int} iRight the number of pixels the element can move to the - * right - * @param {int} iTickSize optional parameter for specifying that the - * element - * should move iTickSize pixels at a time. - */ - setXConstraint: function(iLeft, iRight, iTickSize) { - this.leftConstraint = parseInt(iLeft, 10); - this.rightConstraint = parseInt(iRight, 10); - - this.minX = this.initPageX - this.leftConstraint; - this.maxX = this.initPageX + this.rightConstraint; - if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); } - - this.constrainX = true; - this.logger.log("initPageX:" + this.initPageX + " minX:" + this.minX + - " maxX:" + this.maxX); - }, - - /** - * Clears any constraints applied to this instance. Also clears ticks - * since they can't exist independent of a constraint at this time. - * @method clearConstraints - */ - clearConstraints: function() { - this.logger.log("Clearing constraints"); - this.constrainX = false; - this.constrainY = false; - this.clearTicks(); - }, - - /** - * Clears any tick interval defined for this instance - * @method clearTicks - */ - clearTicks: function() { - this.logger.log("Clearing ticks"); - this.xTicks = null; - this.yTicks = null; - this.xTickSize = 0; - this.yTickSize = 0; - }, - - /** - * By default, the element can be dragged any place on the screen. Set - * this to limit the vertical travel of the element. Pass in 0,0 for the - * parameters if you want to lock the drag to the x axis. - * @method setYConstraint - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize optional parameter for specifying that the - * element should move iTickSize pixels at a time. - */ - setYConstraint: function(iUp, iDown, iTickSize) { - this.logger.log("setYConstraint: " + iUp + "," + iDown + "," + iTickSize); - this.topConstraint = parseInt(iUp, 10); - this.bottomConstraint = parseInt(iDown, 10); - - this.minY = this.initPageY - this.topConstraint; - this.maxY = this.initPageY + this.bottomConstraint; - if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); } - - this.constrainY = true; - - this.logger.log("initPageY:" + this.initPageY + " minY:" + this.minY + - " maxY:" + this.maxY); - }, - - /** - * resetConstraints must be called if you manually reposition a dd element. - * @method resetConstraints - * @param {boolean} maintainOffset - */ - resetConstraints: function() { - - this.logger.log("resetConstraints"); - - // Maintain offsets if necessary - if (this.initPageX || this.initPageX === 0) { - this.logger.log("init pagexy: " + this.initPageX + ", " + - this.initPageY); - this.logger.log("last pagexy: " + this.lastPageX + ", " + - this.lastPageY); - // figure out how much this thing has moved - var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0; - var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0; - - this.setInitPosition(dx, dy); - - // This is the first time we have detected the element's position - } else { - this.setInitPosition(); - } - - if (this.constrainX) { - this.setXConstraint( this.leftConstraint, - this.rightConstraint, - this.xTickSize ); - } - - if (this.constrainY) { - this.setYConstraint( this.topConstraint, - this.bottomConstraint, - this.yTickSize ); - } - }, - - /** - * Normally the drag element is moved pixel by pixel, but we can specify - * that it move a number of pixels at a time. This method resolves the - * location when we have it set up like this. - * @method getTick - * @param {int} val where we want to place the object - * @param {int[]} tickArray sorted array of valid points - * @return {int} the closest tick - * @private - */ - getTick: function(val, tickArray) { - - if (!tickArray) { - // If tick interval is not defined, it is effectively 1 pixel, - // so we return the value passed to us. - return val; - } else if (tickArray[0] >= val) { - // The value is lower than the first tick, so we return the first - // tick. - return tickArray[0]; - } else { - for (var i=0, len=tickArray.length; i<len; ++i) { - var next = i + 1; - if (tickArray[next] && tickArray[next] >= val) { - var diff1 = val - tickArray[i]; - var diff2 = tickArray[next] - val; - return (diff2 > diff1) ? tickArray[i] : tickArray[next]; - } - } - - // The value is larger than the last tick, so we return the last - // tick. - return tickArray[tickArray.length - 1]; - } - }, - - /** - * toString method - * @method toString - * @return {string} string representation of the dd obj - */ - toString: function() { - return ("DragDrop " + this.id); - } - -}; - -})(); -/** - * A DragDrop implementation where the linked element follows the - * mouse cursor during a drag. - * @class DD - * @extends YAHOO.util.DragDrop - * @constructor - * @param {String} id the id of the linked element - * @param {String} sGroup the group of related DragDrop items - * @param {object} config an object containing configurable attributes - * Valid properties for DD: - * scroll - */ -YAHOO.util.DD = function(id, sGroup, config) { - if (id) { - this.init(id, sGroup, config); - } -}; - -YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop, { - - /** - * When set to true, the utility automatically tries to scroll the browser - * window wehn a drag and drop element is dragged near the viewport boundary. - * Defaults to true. - * @property scroll - * @type boolean - */ - scroll: true, - - /** - * Sets the pointer offset to the distance between the linked element's top - * left corner and the location the element was clicked - * @method autoOffset - * @param {int} iPageX the X coordinate of the click - * @param {int} iPageY the Y coordinate of the click - */ - autoOffset: function(iPageX, iPageY) { - var x = iPageX - this.startPageX; - var y = iPageY - this.startPageY; - this.setDelta(x, y); - // this.logger.log("autoOffset el pos: " + aCoord + ", delta: " + x + "," + y); - }, - - /** - * Sets the pointer offset. You can call this directly to force the - * offset to be in a particular location (e.g., pass in 0,0 to set it - * to the center of the object, as done in YAHOO.widget.Slider) - * @method setDelta - * @param {int} iDeltaX the distance from the left - * @param {int} iDeltaY the distance from the top - */ - setDelta: function(iDeltaX, iDeltaY) { - this.deltaX = iDeltaX; - this.deltaY = iDeltaY; - this.logger.log("deltaX:" + this.deltaX + ", deltaY:" + this.deltaY); - }, - - /** - * Sets the drag element to the location of the mousedown or click event, - * maintaining the cursor location relative to the location on the element - * that was clicked. Override this if you want to place the element in a - * location other than where the cursor is. - * @method setDragElPos - * @param {int} iPageX the X coordinate of the mousedown or drag event - * @param {int} iPageY the Y coordinate of the mousedown or drag event - */ - setDragElPos: function(iPageX, iPageY) { - // the first time we do this, we are going to check to make sure - // the element has css positioning - - var el = this.getDragEl(); - this.alignElWithMouse(el, iPageX, iPageY); - }, - - /** - * Sets the element to the location of the mousedown or click event, - * maintaining the cursor location relative to the location on the element - * that was clicked. Override this if you want to place the element in a - * location other than where the cursor is. - * @method alignElWithMouse - * @param {HTMLElement} el the element to move - * @param {int} iPageX the X coordinate of the mousedown or drag event - * @param {int} iPageY the Y coordinate of the mousedown or drag event - */ - alignElWithMouse: function(el, iPageX, iPageY) { - var oCoord = this.getTargetCoord(iPageX, iPageY); - // this.logger.log("****alignElWithMouse : " + el.id + ", " + aCoord + ", " + el.style.display); - - if (!this.deltaSetXY) { - var aCoord = [oCoord.x, oCoord.y]; - YAHOO.util.Dom.setXY(el, aCoord); - var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 ); - var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 ); - - this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ]; - } else { - YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px"); - YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px"); - } - - this.cachePosition(oCoord.x, oCoord.y); - this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth); - }, - - /** - * Saves the most recent position so that we can reset the constraints and - * tick marks on-demand. We need to know this so that we can calculate the - * number of pixels the element is offset from its original position. - * @method cachePosition - * @param iPageX the current x position (optional, this just makes it so we - * don't have to look it up again) - * @param iPageY the current y position (optional, this just makes it so we - * don't have to look it up again) - */ - cachePosition: function(iPageX, iPageY) { - if (iPageX) { - this.lastPageX = iPageX; - this.lastPageY = iPageY; - } else { - var aCoord = YAHOO.util.Dom.getXY(this.getEl()); - this.lastPageX = aCoord[0]; - this.lastPageY = aCoord[1]; - } - }, - - /** - * Auto-scroll the window if the dragged object has been moved beyond the - * visible window boundary. - * @method autoScroll - * @param {int} x the drag element's x position - * @param {int} y the drag element's y position - * @param {int} h the height of the drag element - * @param {int} w the width of the drag element - * @private - */ - autoScroll: function(x, y, h, w) { - - if (this.scroll) { - // The client height - var clientH = this.DDM.getClientHeight(); - - // The client width - var clientW = this.DDM.getClientWidth(); - - // The amt scrolled down - var st = this.DDM.getScrollTop(); - - // The amt scrolled right - var sl = this.DDM.getScrollLeft(); - - // Location of the bottom of the element - var bot = h + y; - - // Location of the right of the element - var right = w + x; - - // The distance from the cursor to the bottom of the visible area, - // adjusted so that we don't scroll if the cursor is beyond the - // element drag constraints - var toBot = (clientH + st - y - this.deltaY); - - // The distance from the cursor to the right of the visible area - var toRight = (clientW + sl - x - this.deltaX); - - // this.logger.log( " x: " + x + " y: " + y + " h: " + h + - // " clientH: " + clientH + " clientW: " + clientW + - // " st: " + st + " sl: " + sl + " bot: " + bot + - // " right: " + right + " toBot: " + toBot + " toRight: " + toRight); - - // How close to the edge the cursor must be before we scroll - // var thresh = (document.all) ? 100 : 40; - var thresh = 40; - - // How many pixels to scroll per autoscroll op. This helps to reduce - // clunky scrolling. IE is more sensitive about this ... it needs this - // value to be higher. - var scrAmt = (document.all) ? 80 : 30; - - // Scroll down if we are near the bottom of the visible page and the - // obj extends below the crease - if ( bot > clientH && toBot < thresh ) { - window.scrollTo(sl, st + scrAmt); - } - - // Scroll up if the window is scrolled down and the top of the object - // goes above the top border - if ( y < st && st > 0 && y - st < thresh ) { - window.scrollTo(sl, st - scrAmt); - } - - // Scroll right if the obj is beyond the right border and the cursor is - // near the border. - if ( right > clientW && toRight < thresh ) { - window.scrollTo(sl + scrAmt, st); - } - - // Scroll left if the window has been scrolled to the right and the obj - // extends past the left border - if ( x < sl && sl > 0 && x - sl < thresh ) { - window.scrollTo(sl - scrAmt, st); - } - } - }, - - /** - * Finds the location the element should be placed if we want to move - * it to where the mouse location less the click offset would place us. - * @method getTargetCoord - * @param {int} iPageX the X coordinate of the click - * @param {int} iPageY the Y coordinate of the click - * @return an object that contains the coordinates (Object.x and Object.y) - * @private - */ - getTargetCoord: function(iPageX, iPageY) { - - // this.logger.log("getTargetCoord: " + iPageX + ", " + iPageY); - - var x = iPageX - this.deltaX; - var y = iPageY - this.deltaY; - - if (this.constrainX) { - if (x < this.minX) { x = this.minX; } - if (x > this.maxX) { x = this.maxX; } - } - - if (this.constrainY) { - if (y < this.minY) { y = this.minY; } - if (y > this.maxY) { y = this.maxY; } - } - - x = this.getTick(x, this.xTicks); - y = this.getTick(y, this.yTicks); - - // this.logger.log("getTargetCoord " + - // " iPageX: " + iPageX + - // " iPageY: " + iPageY + - // " x: " + x + ", y: " + y); - - return {x:x, y:y}; - }, - - /* - * Sets up config options specific to this class. Overrides - * YAHOO.util.DragDrop, but all versions of this method through the - * inheritance chain are called - */ - applyConfig: function() { - YAHOO.util.DD.superclass.applyConfig.call(this); - this.scroll = (this.config.scroll !== false); - }, - - /* - * Event that fires prior to the onMouseDown event. Overrides - * YAHOO.util.DragDrop. - */ - b4MouseDown: function(e) { - this.setStartPosition(); - // this.resetConstraints(); - this.autoOffset(YAHOO.util.Event.getPageX(e), - YAHOO.util.Event.getPageY(e)); - }, - - /* - * Event that fires prior to the onDrag event. Overrides - * YAHOO.util.DragDrop. - */ - b4Drag: function(e) { - this.setDragElPos(YAHOO.util.Event.getPageX(e), - YAHOO.util.Event.getPageY(e)); - }, - - toString: function() { - return ("DD " + this.id); - } - - ////////////////////////////////////////////////////////////////////////// - // Debugging ygDragDrop events that can be overridden - ////////////////////////////////////////////////////////////////////////// - /* - startDrag: function(x, y) { - this.logger.log(this.id.toString() + " startDrag"); - }, - - onDrag: function(e) { - this.logger.log(this.id.toString() + " onDrag"); - }, - - onDragEnter: function(e, id) { - this.logger.log(this.id.toString() + " onDragEnter: " + id); - }, - - onDragOver: function(e, id) { - this.logger.log(this.id.toString() + " onDragOver: " + id); - }, - - onDragOut: function(e, id) { - this.logger.log(this.id.toString() + " onDragOut: " + id); - }, - - onDragDrop: function(e, id) { - this.logger.log(this.id.toString() + " onDragDrop: " + id); - }, - - endDrag: function(e) { - this.logger.log(this.id.toString() + " endDrag"); - } - - */ - -}); -/** - * A DragDrop implementation that inserts an empty, bordered div into - * the document that follows the cursor during drag operations. At the time of - * the click, the frame div is resized to the dimensions of the linked html - * element, and moved to the exact location of the linked element. - * - * References to the "frame" element refer to the single proxy element that - * was created to be dragged in place of all DDProxy elements on the - * page. - * - * @class DDProxy - * @extends YAHOO.util.DD - * @constructor - * @param {String} id the id of the linked html element - * @param {String} sGroup the group of related DragDrop objects - * @param {object} config an object containing configurable attributes - * Valid properties for DDProxy in addition to those in DragDrop: - * resizeFrame, centerFrame, dragElId - */ -YAHOO.util.DDProxy = function(id, sGroup, config) { - if (id) { - this.init(id, sGroup, config); - this.initFrame(); - } -}; - -/** - * The default drag frame div id - * @property YAHOO.util.DDProxy.dragElId - * @type String - * @static - */ -YAHOO.util.DDProxy.dragElId = "ygddfdiv"; - -YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD, { - - /** - * By default we resize the drag frame to be the same size as the element - * we want to drag (this is to get the frame effect). We can turn it off - * if we want a different behavior. - * @property resizeFrame - * @type boolean - */ - resizeFrame: true, - - /** - * By default the frame is positioned exactly where the drag element is, so - * we use the cursor offset provided by YAHOO.util.DD. Another option that works only if - * you do not have constraints on the obj is to have the drag frame centered - * around the cursor. Set centerFrame to true for this effect. - * @property centerFrame - * @type boolean - */ - centerFrame: false, - - /** - * Creates the proxy element if it does not yet exist - * @method createFrame - */ - createFrame: function() { - var self = this; - var body = document.body; - - if (!body || !body.firstChild) { - setTimeout( function() { self.createFrame(); }, 50 ); - return; - } - - var div = this.getDragEl(); - - if (!div) { - div = document.createElement("div"); - div.id = this.dragElId; - var s = div.style; - - s.position = "absolute"; - s.visibility = "hidden"; - s.cursor = "move"; - s.border = "2px solid #aaa"; - s.zIndex = 999; - - // appendChild can blow up IE if invoked prior to the window load event - // while rendering a table. It is possible there are other scenarios - // that would cause this to happen as well. - body.insertBefore(div, body.firstChild); - } - }, - - /** - * Initialization for the drag frame element. Must be called in the - * constructor of all subclasses - * @method initFrame - */ - initFrame: function() { - this.createFrame(); - }, - - applyConfig: function() { - this.logger.log("DDProxy applyConfig"); - YAHOO.util.DDProxy.superclass.applyConfig.call(this); - - this.resizeFrame = (this.config.resizeFrame !== false); - this.centerFrame = (this.config.centerFrame); - this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId); - }, - - /** - * Resizes the drag frame to the dimensions of the clicked object, positions - * it over the object, and finally displays it - * @method showFrame - * @param {int} iPageX X click position - * @param {int} iPageY Y click position - * @private - */ - showFrame: function(iPageX, iPageY) { - var el = this.getEl(); - var dragEl = this.getDragEl(); - var s = dragEl.style; - - this._resizeProxy(); - - if (this.centerFrame) { - this.setDelta( Math.round(parseInt(s.width, 10)/2), - Math.round(parseInt(s.height, 10)/2) ); - } - - this.setDragElPos(iPageX, iPageY); - - YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible"); - }, - - /** - * The proxy is automatically resized to the dimensions of the linked - * element when a drag is initiated, unless resizeFrame is set to false - * @method _resizeProxy - * @private - */ - _resizeProxy: function() { - if (this.resizeFrame) { - var DOM = YAHOO.util.Dom; - var el = this.getEl(); - var dragEl = this.getDragEl(); - - var bt = parseInt( DOM.getStyle(dragEl, "borderTopWidth" ), 10); - var br = parseInt( DOM.getStyle(dragEl, "borderRightWidth" ), 10); - var bb = parseInt( DOM.getStyle(dragEl, "borderBottomWidth" ), 10); - var bl = parseInt( DOM.getStyle(dragEl, "borderLeftWidth" ), 10); - - if (isNaN(bt)) { bt = 0; } - if (isNaN(br)) { br = 0; } - if (isNaN(bb)) { bb = 0; } - if (isNaN(bl)) { bl = 0; } - - this.logger.log("proxy size: " + bt + " " + br + " " + bb + " " + bl); - - var newWidth = Math.max(0, el.offsetWidth - br - bl); - var newHeight = Math.max(0, el.offsetHeight - bt - bb); - - this.logger.log("Resizing proxy element"); - - DOM.setStyle( dragEl, "width", newWidth + "px" ); - DOM.setStyle( dragEl, "height", newHeight + "px" ); - } - }, - - // overrides YAHOO.util.DragDrop - b4MouseDown: function(e) { - this.setStartPosition(); - var x = YAHOO.util.Event.getPageX(e); - var y = YAHOO.util.Event.getPageY(e); - this.autoOffset(x, y); - this.setDragElPos(x, y); - }, - - // overrides YAHOO.util.DragDrop - b4StartDrag: function(x, y) { - // show the drag frame - this.logger.log("start drag show frame, x: " + x + ", y: " + y); - this.showFrame(x, y); - }, - - // overrides YAHOO.util.DragDrop - b4EndDrag: function(e) { - this.logger.log(this.id + " b4EndDrag"); - YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden"); - }, - - // overrides YAHOO.util.DragDrop - // By default we try to move the element to the last location of the frame. - // This is so that the default behavior mirrors that of YAHOO.util.DD. - endDrag: function(e) { - var DOM = YAHOO.util.Dom; - this.logger.log(this.id + " endDrag"); - var lel = this.getEl(); - var del = this.getDragEl(); - - // Show the drag frame briefly so we can get its position - // del.style.visibility = ""; - DOM.setStyle(del, "visibility", ""); - - // Hide the linked element before the move to get around a Safari - // rendering bug. - //lel.style.visibility = "hidden"; - DOM.setStyle(lel, "visibility", "hidden"); - YAHOO.util.DDM.moveToEl(lel, del); - //del.style.visibility = "hidden"; - DOM.setStyle(del, "visibility", "hidden"); - //lel.style.visibility = ""; - DOM.setStyle(lel, "visibility", ""); - }, - - toString: function() { - return ("DDProxy " + this.id); - } - -}); -/** - * A DragDrop implementation that does not move, but can be a drop - * target. You would get the same result by simply omitting implementation - * for the event callbacks, but this way we reduce the processing cost of the - * event listener and the callbacks. - * @class DDTarget - * @extends YAHOO.util.DragDrop - * @constructor - * @param {String} id the id of the element that is a drop target - * @param {String} sGroup the group of related DragDrop objects - * @param {object} config an object containing configurable attributes - * Valid properties for DDTarget in addition to those in - * DragDrop: - * none - */ -YAHOO.util.DDTarget = function(id, sGroup, config) { - if (id) { - this.initTarget(id, sGroup, config); - } -}; - -// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop(); -YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop, { - toString: function() { - return ("DDTarget " + this.id); - } -}); -YAHOO.register("dragdrop", YAHOO.util.DragDropMgr, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/dragdrop/dragdrop-min.js b/interface/web/js/yui/dragdrop/dragdrop-min.js deleted file mode 100644 index 5d0bba3f0c..0000000000 --- a/interface/web/js/yui/dragdrop/dragdrop-min.js +++ /dev/null @@ -1,93 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -if(!YAHOO.util.DragDropMgr){YAHOO.util.DragDropMgr=function(){var Event=YAHOO.util.Event;return{ids:{},handleIds:{},dragCurrent:null,dragOvers:{},deltaX:0,deltaY:0,preventDefault:true,stopPropagation:true,initalized:false,locked:false,init:function(){this.initialized=true;},POINT:0,INTERSECT:1,STRICT_INTERSECT:2,mode:0,_execOnAll:function(sMethod,args){for(var i in this.ids){for(var j in this.ids[i]){var oDD=this.ids[i][j];if(!this.isTypeOfDD(oDD)){continue;} -oDD[sMethod].apply(oDD,args);}}},_onLoad:function(){this.init();Event.on(document,"mouseup",this.handleMouseUp,this,true);Event.on(document,"mousemove",this.handleMouseMove,this,true);Event.on(window,"unload",this._onUnload,this,true);Event.on(window,"resize",this._onResize,this,true);},_onResize:function(e){this._execOnAll("resetConstraints",[]);},lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isLocked:function(){return this.locked;},locationCache:{},useCache:true,clickPixelThresh:3,clickTimeThresh:1000,dragThreshMet:false,clickTimeout:null,startX:0,startY:0,regDragDrop:function(oDD,sGroup){if(!this.initialized){this.init();} -if(!this.ids[sGroup]){this.ids[sGroup]={};} -this.ids[sGroup][oDD.id]=oDD;},removeDDFromGroup:function(oDD,sGroup){if(!this.ids[sGroup]){this.ids[sGroup]={};} -var obj=this.ids[sGroup];if(obj&&obj[oDD.id]){delete obj[oDD.id];}},_remove:function(oDD){for(var g in oDD.groups){if(g&&this.ids[g][oDD.id]){delete this.ids[g][oDD.id];}} -delete this.handleIds[oDD.id];},regHandle:function(sDDId,sHandleId){if(!this.handleIds[sDDId]){this.handleIds[sDDId]={};} -this.handleIds[sDDId][sHandleId]=sHandleId;},isDragDrop:function(id){return(this.getDDById(id))?true:false;},getRelated:function(p_oDD,bTargetsOnly){var oDDs=[];for(var i in p_oDD.groups){for(j in this.ids[i]){var dd=this.ids[i][j];if(!this.isTypeOfDD(dd)){continue;} -if(!bTargetsOnly||dd.isTarget){oDDs[oDDs.length]=dd;}}} -return oDDs;},isLegalTarget:function(oDD,oTargetDD){var targets=this.getRelated(oDD,true);for(var i=0,len=targets.length;i<len;++i){if(targets[i].id==oTargetDD.id){return true;}} -return false;},isTypeOfDD:function(oDD){return(oDD&&oDD.__ygDragDrop);},isHandle:function(sDDId,sHandleId){return(this.handleIds[sDDId]&&this.handleIds[sDDId][sHandleId]);},getDDById:function(id){for(var i in this.ids){if(this.ids[i][id]){return this.ids[i][id];}} -return null;},handleMouseDown:function(e,oDD){this.currentTarget=YAHOO.util.Event.getTarget(e);this.dragCurrent=oDD;var el=oDD.getEl();this.startX=YAHOO.util.Event.getPageX(e);this.startY=YAHOO.util.Event.getPageY(e);this.deltaX=this.startX-el.offsetLeft;this.deltaY=this.startY-el.offsetTop;this.dragThreshMet=false;this.clickTimeout=setTimeout(function(){var DDM=YAHOO.util.DDM;DDM.startDrag(DDM.startX,DDM.startY);},this.clickTimeThresh);},startDrag:function(x,y){clearTimeout(this.clickTimeout);if(this.dragCurrent){this.dragCurrent.b4StartDrag(x,y);this.dragCurrent.startDrag(x,y);} -this.dragThreshMet=true;},handleMouseUp:function(e){if(!this.dragCurrent){return;} -clearTimeout(this.clickTimeout);if(this.dragThreshMet){this.fireEvents(e,true);}else{} -this.stopDrag(e);this.stopEvent(e);},stopEvent:function(e){if(this.stopPropagation){YAHOO.util.Event.stopPropagation(e);} -if(this.preventDefault){YAHOO.util.Event.preventDefault(e);}},stopDrag:function(e){if(this.dragCurrent){if(this.dragThreshMet){this.dragCurrent.b4EndDrag(e);this.dragCurrent.endDrag(e);} -this.dragCurrent.onMouseUp(e);} -this.dragCurrent=null;this.dragOvers={};},handleMouseMove:function(e){if(!this.dragCurrent){return true;} -if(YAHOO.util.Event.isIE&&!e.button){this.stopEvent(e);return this.handleMouseUp(e);} -if(!this.dragThreshMet){var diffX=Math.abs(this.startX-YAHOO.util.Event.getPageX(e));var diffY=Math.abs(this.startY-YAHOO.util.Event.getPageY(e));if(diffX>this.clickPixelThresh||diffY>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}} -if(this.dragThreshMet){this.dragCurrent.b4Drag(e);this.dragCurrent.onDrag(e);this.fireEvents(e,false);} -this.stopEvent(e);return true;},fireEvents:function(e,isDrop){var dc=this.dragCurrent;if(!dc||dc.isLocked()){return;} -var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);var pt=new YAHOO.util.Point(x,y);var oldOvers=[];var outEvts=[];var overEvts=[];var dropEvts=[];var enterEvts=[];for(var i in this.dragOvers){var ddo=this.dragOvers[i];if(!this.isTypeOfDD(ddo)){continue;} -if(!this.isOverTarget(pt,ddo,this.mode)){outEvts.push(ddo);} -oldOvers[i]=true;delete this.dragOvers[i];} -for(var sGroup in dc.groups){if("string"!=typeof sGroup){continue;} -for(i in this.ids[sGroup]){var oDD=this.ids[sGroup][i];if(!this.isTypeOfDD(oDD)){continue;} -if(oDD.isTarget&&!oDD.isLocked()&&oDD!=dc){if(this.isOverTarget(pt,oDD,this.mode)){if(isDrop){dropEvts.push(oDD);}else{if(!oldOvers[oDD.id]){enterEvts.push(oDD);}else{overEvts.push(oDD);} -this.dragOvers[oDD.id]=oDD;}}}}} -if(this.mode){if(outEvts.length){dc.b4DragOut(e,outEvts);dc.onDragOut(e,outEvts);} -if(enterEvts.length){dc.onDragEnter(e,enterEvts);} -if(overEvts.length){dc.b4DragOver(e,overEvts);dc.onDragOver(e,overEvts);} -if(dropEvts.length){dc.b4DragDrop(e,dropEvts);dc.onDragDrop(e,dropEvts);}}else{var len=0;for(i=0,len=outEvts.length;i<len;++i){dc.b4DragOut(e,outEvts[i].id);dc.onDragOut(e,outEvts[i].id);} -for(i=0,len=enterEvts.length;i<len;++i){dc.onDragEnter(e,enterEvts[i].id);} -for(i=0,len=overEvts.length;i<len;++i){dc.b4DragOver(e,overEvts[i].id);dc.onDragOver(e,overEvts[i].id);} -for(i=0,len=dropEvts.length;i<len;++i){dc.b4DragDrop(e,dropEvts[i].id);dc.onDragDrop(e,dropEvts[i].id);}} -if(isDrop&&!dropEvts.length){dc.onInvalidDrop(e);}},getBestMatch:function(dds){var winner=null;var len=dds.length;if(len==1){winner=dds[0];}else{for(var i=0;i<len;++i){var dd=dds[i];if(this.mode==this.INTERSECT&&dd.cursorIsOver){winner=dd;break;}else{if(!winner||!winner.overlap||(dd.overlap&&winner.overlap.getArea()<dd.overlap.getArea())){winner=dd;}}}} -return winner;},refreshCache:function(groups){var g=groups||this.ids;for(var sGroup in g){if("string"!=typeof sGroup){continue;} -for(var i in this.ids[sGroup]){var oDD=this.ids[sGroup][i];if(this.isTypeOfDD(oDD)){var loc=this.getLocation(oDD);if(loc){this.locationCache[oDD.id]=loc;}else{delete this.locationCache[oDD.id];}}}}},verifyEl:function(el){try{if(el){var parent=el.offsetParent;if(parent){return true;}}}catch(e){} -return false;},getLocation:function(oDD){if(!this.isTypeOfDD(oDD)){return null;} -var el=oDD.getEl(),pos,x1,x2,y1,y2,t,r,b,l;try{pos=YAHOO.util.Dom.getXY(el);}catch(e){} -if(!pos){return null;} -x1=pos[0];x2=x1+el.offsetWidth;y1=pos[1];y2=y1+el.offsetHeight;t=y1-oDD.padding[0];r=x2+oDD.padding[1];b=y2+oDD.padding[2];l=x1-oDD.padding[3];return new YAHOO.util.Region(t,r,b,l);},isOverTarget:function(pt,oTarget,intersect){var loc=this.locationCache[oTarget.id];if(!loc||!this.useCache){loc=this.getLocation(oTarget);this.locationCache[oTarget.id]=loc;} -if(!loc){return false;} -oTarget.cursorIsOver=loc.contains(pt);var dc=this.dragCurrent;if(!dc||!dc.getTargetCoord||(!intersect&&!dc.constrainX&&!dc.constrainY)){return oTarget.cursorIsOver;} -oTarget.overlap=null;var pos=dc.getTargetCoord(pt.x,pt.y);var el=dc.getDragEl();var curRegion=new YAHOO.util.Region(pos.y,pos.x+el.offsetWidth,pos.y+el.offsetHeight,pos.x);var overlap=curRegion.intersect(loc);if(overlap){oTarget.overlap=overlap;return(intersect)?true:oTarget.cursorIsOver;}else{return false;}},_onUnload:function(e,me){this.unregAll();},unregAll:function(){if(this.dragCurrent){this.stopDrag();this.dragCurrent=null;} -this._execOnAll("unreg",[]);for(i in this.elementCache){delete this.elementCache[i];} -this.elementCache={};this.ids={};},elementCache:{},getElWrapper:function(id){var oWrapper=this.elementCache[id];if(!oWrapper||!oWrapper.el){oWrapper=this.elementCache[id]=new this.ElementWrapper(YAHOO.util.Dom.get(id));} -return oWrapper;},getElement:function(id){return YAHOO.util.Dom.get(id);},getCss:function(id){var el=YAHOO.util.Dom.get(id);return(el)?el.style:null;},ElementWrapper:function(el){this.el=el||null;this.id=this.el&&el.id;this.css=this.el&&el.style;},getPosX:function(el){return YAHOO.util.Dom.getX(el);},getPosY:function(el){return YAHOO.util.Dom.getY(el);},swapNode:function(n1,n2){if(n1.swapNode){n1.swapNode(n2);}else{var p=n2.parentNode;var s=n2.nextSibling;if(s==n1){p.insertBefore(n1,n2);}else if(n2==n1.nextSibling){p.insertBefore(n2,n1);}else{n1.parentNode.replaceChild(n2,n1);p.insertBefore(n1,s);}}},getScroll:function(){var t,l,dde=document.documentElement,db=document.body;if(dde&&(dde.scrollTop||dde.scrollLeft)){t=dde.scrollTop;l=dde.scrollLeft;}else if(db){t=db.scrollTop;l=db.scrollLeft;}else{} -return{top:t,left:l};},getStyle:function(el,styleProp){return YAHOO.util.Dom.getStyle(el,styleProp);},getScrollTop:function(){return this.getScroll().top;},getScrollLeft:function(){return this.getScroll().left;},moveToEl:function(moveEl,targetEl){var aCoord=YAHOO.util.Dom.getXY(targetEl);YAHOO.util.Dom.setXY(moveEl,aCoord);},getClientHeight:function(){return YAHOO.util.Dom.getViewportHeight();},getClientWidth:function(){return YAHOO.util.Dom.getViewportWidth();},numericSort:function(a,b){return(a-b);},_timeoutCount:0,_addListeners:function(){var DDM=YAHOO.util.DDM;if(YAHOO.util.Event&&document){DDM._onLoad();}else{if(DDM._timeoutCount>2000){}else{setTimeout(DDM._addListeners,10);if(document&&document.body){DDM._timeoutCount+=1;}}}},handleWasClicked:function(node,id){if(this.isHandle(id,node.id)){return true;}else{var p=node.parentNode;while(p){if(this.isHandle(id,p.id)){return true;}else{p=p.parentNode;}}} -return false;}};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();} -(function(){var Event=YAHOO.util.Event;var Dom=YAHOO.util.Dom;YAHOO.util.DragDrop=function(id,sGroup,config){if(id){this.init(id,sGroup,config);}};YAHOO.util.DragDrop.prototype={id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,hasOuterHandles:false,b4StartDrag:function(x,y){},startDrag:function(x,y){},b4Drag:function(e){},onDrag:function(e){},onDragEnter:function(e,id){},b4DragOver:function(e){},onDragOver:function(e,id){},b4DragOut:function(e){},onDragOut:function(e,id){},b4DragDrop:function(e){},onDragDrop:function(e,id){},onInvalidDrop:function(e){},b4EndDrag:function(e){},endDrag:function(e){},b4MouseDown:function(e){},onMouseDown:function(e){},onMouseUp:function(e){},onAvailable:function(){},getEl:function(){if(!this._domRef){this._domRef=Dom.get(this.id);} -return this._domRef;},getDragEl:function(){return Dom.get(this.dragElId);},init:function(id,sGroup,config){this.initTarget(id,sGroup,config);Event.on(this.id,"mousedown",this.handleMouseDown,this,true);},initTarget:function(id,sGroup,config){this.config=config||{};this.DDM=YAHOO.util.DDM;this.groups={};if(typeof id!=="string"){id=Dom.generateId(id);} -this.id=id;this.addToGroup((sGroup)?sGroup:"default");this.handleElId=id;Event.onAvailable(id,this.handleOnAvailable,this,true);this.setDragElId(id);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);},handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(iTop,iRight,iBot,iLeft){if(!iRight&&0!==iRight){this.padding=[iTop,iTop,iTop,iTop];}else if(!iBot&&0!==iBot){this.padding=[iTop,iRight,iTop,iRight];}else{this.padding=[iTop,iRight,iBot,iLeft];}},setInitPosition:function(diffX,diffY){var el=this.getEl();if(!this.DDM.verifyEl(el)){return;} -var dx=diffX||0;var dy=diffY||0;var p=Dom.getXY(el);this.initPageX=p[0]-dx;this.initPageY=p[1]-dy;this.lastPageX=p[0];this.lastPageY=p[1];this.setStartPosition(p);},setStartPosition:function(pos){var p=pos||Dom.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=p[0];this.startPageY=p[1];},addToGroup:function(sGroup){this.groups[sGroup]=true;this.DDM.regDragDrop(this,sGroup);},removeFromGroup:function(sGroup){if(this.groups[sGroup]){delete this.groups[sGroup];} -this.DDM.removeDDFromGroup(this,sGroup);},setDragElId:function(id){this.dragElId=id;},setHandleElId:function(id){if(typeof id!=="string"){id=Dom.generateId(id);} -this.handleElId=id;this.DDM.regHandle(this.id,id);},setOuterHandleElId:function(id){if(typeof id!=="string"){id=Dom.generateId(id);} -Event.on(id,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(id);this.hasOuterHandles=true;},unreg:function(){Event.removeListener(this.id,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return(this.DDM.isLocked()||this.locked);},handleMouseDown:function(e,oDD){var button=e.which||e.button;if(this.primaryButtonOnly&&button>1){return;} -if(this.isLocked()){return;} -this.b4MouseDown(e);this.onMouseDown(e);this.DDM.refreshCache(this.groups);var pt=new YAHOO.util.Point(Event.getPageX(e),Event.getPageY(e));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(pt,this)){}else{if(this.clickValidator(e)){this.setStartPosition();this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}else{}}},clickValidator:function(e){var target=Event.getTarget(e);return(this.isValidHandleChild(target)&&(this.id==this.handleElId||this.DDM.handleWasClicked(target,this.id)));},addInvalidHandleType:function(tagName){var type=tagName.toUpperCase();this.invalidHandleTypes[type]=type;},addInvalidHandleId:function(id){if(typeof id!=="string"){id=Dom.generateId(id);} -this.invalidHandleIds[id]=id;},addInvalidHandleClass:function(cssClass){this.invalidHandleClasses.push(cssClass);},removeInvalidHandleType:function(tagName){var type=tagName.toUpperCase();delete this.invalidHandleTypes[type];},removeInvalidHandleId:function(id){if(typeof id!=="string"){id=Dom.generateId(id);} -delete this.invalidHandleIds[id];},removeInvalidHandleClass:function(cssClass){for(var i=0,len=this.invalidHandleClasses.length;i<len;++i){if(this.invalidHandleClasses[i]==cssClass){delete this.invalidHandleClasses[i];}}},isValidHandleChild:function(node){var valid=true;var nodeName;try{nodeName=node.nodeName.toUpperCase();}catch(e){nodeName=node.nodeName;} -valid=valid&&!this.invalidHandleTypes[nodeName];valid=valid&&!this.invalidHandleIds[node.id];for(var i=0,len=this.invalidHandleClasses.length;valid&&i<len;++i){valid=!Dom.hasClass(node,this.invalidHandleClasses[i]);} -return valid;},setXTicks:function(iStartX,iTickSize){this.xTicks=[];this.xTickSize=iTickSize;var tickMap={};for(var i=this.initPageX;i>=this.minX;i=i-iTickSize){if(!tickMap[i]){this.xTicks[this.xTicks.length]=i;tickMap[i]=true;}} -for(i=this.initPageX;i<=this.maxX;i=i+iTickSize){if(!tickMap[i]){this.xTicks[this.xTicks.length]=i;tickMap[i]=true;}} -this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(iStartY,iTickSize){this.yTicks=[];this.yTickSize=iTickSize;var tickMap={};for(var i=this.initPageY;i>=this.minY;i=i-iTickSize){if(!tickMap[i]){this.yTicks[this.yTicks.length]=i;tickMap[i]=true;}} -for(i=this.initPageY;i<=this.maxY;i=i+iTickSize){if(!tickMap[i]){this.yTicks[this.yTicks.length]=i;tickMap[i]=true;}} -this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(iLeft,iRight,iTickSize){this.leftConstraint=parseInt(iLeft,10);this.rightConstraint=parseInt(iRight,10);this.minX=this.initPageX-this.leftConstraint;this.maxX=this.initPageX+this.rightConstraint;if(iTickSize){this.setXTicks(this.initPageX,iTickSize);} -this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(iUp,iDown,iTickSize){this.topConstraint=parseInt(iUp,10);this.bottomConstraint=parseInt(iDown,10);this.minY=this.initPageY-this.topConstraint;this.maxY=this.initPageY+this.bottomConstraint;if(iTickSize){this.setYTicks(this.initPageY,iTickSize);} -this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var dx=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var dy=(this.maintainOffset)?this.lastPageY-this.initPageY:0;this.setInitPosition(dx,dy);}else{this.setInitPosition();} -if(this.constrainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);} -if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(val,tickArray){if(!tickArray){return val;}else if(tickArray[0]>=val){return tickArray[0];}else{for(var i=0,len=tickArray.length;i<len;++i){var next=i+1;if(tickArray[next]&&tickArray[next]>=val){var diff1=val-tickArray[i];var diff2=tickArray[next]-val;return(diff2>diff1)?tickArray[i]:tickArray[next];}} -return tickArray[tickArray.length-1];}},toString:function(){return("DragDrop "+this.id);}};})();YAHOO.util.DD=function(id,sGroup,config){if(id){this.init(id,sGroup,config);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop,{scroll:true,autoOffset:function(iPageX,iPageY){var x=iPageX-this.startPageX;var y=iPageY-this.startPageY;this.setDelta(x,y);},setDelta:function(iDeltaX,iDeltaY){this.deltaX=iDeltaX;this.deltaY=iDeltaY;},setDragElPos:function(iPageX,iPageY){var el=this.getDragEl();this.alignElWithMouse(el,iPageX,iPageY);},alignElWithMouse:function(el,iPageX,iPageY){var oCoord=this.getTargetCoord(iPageX,iPageY);if(!this.deltaSetXY){var aCoord=[oCoord.x,oCoord.y];YAHOO.util.Dom.setXY(el,aCoord);var newLeft=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var newTop=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);this.deltaSetXY=[newLeft-oCoord.x,newTop-oCoord.y];}else{YAHOO.util.Dom.setStyle(el,"left",(oCoord.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(el,"top",(oCoord.y+this.deltaSetXY[1])+"px");} -this.cachePosition(oCoord.x,oCoord.y);this.autoScroll(oCoord.x,oCoord.y,el.offsetHeight,el.offsetWidth);},cachePosition:function(iPageX,iPageY){if(iPageX){this.lastPageX=iPageX;this.lastPageY=iPageY;}else{var aCoord=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=aCoord[0];this.lastPageY=aCoord[1];}},autoScroll:function(x,y,h,w){if(this.scroll){var clientH=this.DDM.getClientHeight();var clientW=this.DDM.getClientWidth();var st=this.DDM.getScrollTop();var sl=this.DDM.getScrollLeft();var bot=h+y;var right=w+x;var toBot=(clientH+st-y-this.deltaY);var toRight=(clientW+sl-x-this.deltaX);var thresh=40;var scrAmt=(document.all)?80:30;if(bot>clientH&&toBot<thresh){window.scrollTo(sl,st+scrAmt);} -if(y<st&&st>0&&y-st<thresh){window.scrollTo(sl,st-scrAmt);} -if(right>clientW&&toRight<thresh){window.scrollTo(sl+scrAmt,st);} -if(x<sl&&sl>0&&x-sl<thresh){window.scrollTo(sl-scrAmt,st);}}},getTargetCoord:function(iPageX,iPageY){var x=iPageX-this.deltaX;var y=iPageY-this.deltaY;if(this.constrainX){if(x<this.minX){x=this.minX;} -if(x>this.maxX){x=this.maxX;}} -if(this.constrainY){if(y<this.minY){y=this.minY;} -if(y>this.maxY){y=this.maxY;}} -x=this.getTick(x,this.xTicks);y=this.getTick(y,this.yTicks);return{x:x,y:y};},applyConfig:function(){YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll=(this.config.scroll!==false);},b4MouseDown:function(e){this.setStartPosition();this.autoOffset(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));},b4Drag:function(e){this.setDragElPos(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));},toString:function(){return("DD "+this.id);}});YAHOO.util.DDProxy=function(id,sGroup,config){if(id){this.init(id,sGroup,config);this.initFrame();}};YAHOO.util.DDProxy.dragElId="ygddfdiv";YAHOO.extend(YAHOO.util.DDProxy,YAHOO.util.DD,{resizeFrame:true,centerFrame:false,createFrame:function(){var self=this;var body=document.body;if(!body||!body.firstChild){setTimeout(function(){self.createFrame();},50);return;} -var div=this.getDragEl();if(!div){div=document.createElement("div");div.id=this.dragElId;var s=div.style;s.position="absolute";s.visibility="hidden";s.cursor="move";s.border="2px solid #aaa";s.zIndex=999;body.insertBefore(div,body.firstChild);}},initFrame:function(){this.createFrame();},applyConfig:function(){YAHOO.util.DDProxy.superclass.applyConfig.call(this);this.resizeFrame=(this.config.resizeFrame!==false);this.centerFrame=(this.config.centerFrame);this.setDragElId(this.config.dragElId||YAHOO.util.DDProxy.dragElId);},showFrame:function(iPageX,iPageY){var el=this.getEl();var dragEl=this.getDragEl();var s=dragEl.style;this._resizeProxy();if(this.centerFrame){this.setDelta(Math.round(parseInt(s.width,10)/2),Math.round(parseInt(s.height,10)/2));} -this.setDragElPos(iPageX,iPageY);YAHOO.util.Dom.setStyle(dragEl,"visibility","visible");},_resizeProxy:function(){if(this.resizeFrame){var DOM=YAHOO.util.Dom;var el=this.getEl();var dragEl=this.getDragEl();var bt=parseInt(DOM.getStyle(dragEl,"borderTopWidth"),10);var br=parseInt(DOM.getStyle(dragEl,"borderRightWidth"),10);var bb=parseInt(DOM.getStyle(dragEl,"borderBottomWidth"),10);var bl=parseInt(DOM.getStyle(dragEl,"borderLeftWidth"),10);if(isNaN(bt)){bt=0;} -if(isNaN(br)){br=0;} -if(isNaN(bb)){bb=0;} -if(isNaN(bl)){bl=0;} -var newWidth=Math.max(0,el.offsetWidth-br-bl);var newHeight=Math.max(0,el.offsetHeight-bt-bb);DOM.setStyle(dragEl,"width",newWidth+"px");DOM.setStyle(dragEl,"height",newHeight+"px");}},b4MouseDown:function(e){this.setStartPosition();var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.autoOffset(x,y);this.setDragElPos(x,y);},b4StartDrag:function(x,y){this.showFrame(x,y);},b4EndDrag:function(e){YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden");},endDrag:function(e){var DOM=YAHOO.util.Dom;var lel=this.getEl();var del=this.getDragEl();DOM.setStyle(del,"visibility","");DOM.setStyle(lel,"visibility","hidden");YAHOO.util.DDM.moveToEl(lel,del);DOM.setStyle(del,"visibility","hidden");DOM.setStyle(lel,"visibility","");},toString:function(){return("DDProxy "+this.id);}});YAHOO.util.DDTarget=function(id,sGroup,config){if(id){this.initTarget(id,sGroup,config);}};YAHOO.extend(YAHOO.util.DDTarget,YAHOO.util.DragDrop,{toString:function(){return("DDTarget "+this.id);}});YAHOO.register("dragdrop",YAHOO.util.DragDropMgr,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/dragdrop/dragdrop.js b/interface/web/js/yui/dragdrop/dragdrop.js deleted file mode 100644 index 58a52a630d..0000000000 --- a/interface/web/js/yui/dragdrop/dragdrop.js +++ /dev/null @@ -1,2958 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The drag and drop utility provides a framework for building drag and drop - * applications. In addition to enabling drag and drop for specific elements, - * the drag and drop elements are tracked by the manager class, and the - * interactions between the various elements are tracked during the drag and - * the implementing code is notified about these important moments. - * @module dragdrop - * @title Drag and Drop - * @requires yahoo,dom,event - * @namespace YAHOO.util - */ - -// Only load the library once. Rewriting the manager class would orphan -// existing drag and drop instances. -if (!YAHOO.util.DragDropMgr) { - -/** - * DragDropMgr is a singleton that tracks the element interaction for - * all DragDrop items in the window. Generally, you will not call - * this class directly, but it does have helper methods that could - * be useful in your DragDrop implementations. - * @class DragDropMgr - * @static - */ -YAHOO.util.DragDropMgr = function() { - - var Event = YAHOO.util.Event; - - return { - - /** - * Two dimensional Array of registered DragDrop objects. The first - * dimension is the DragDrop item group, the second the DragDrop - * object. - * @property ids - * @type {string: string} - * @private - * @static - */ - ids: {}, - - /** - * Array of element ids defined as drag handles. Used to determine - * if the element that generated the mousedown event is actually the - * handle and not the html element itself. - * @property handleIds - * @type {string: string} - * @private - * @static - */ - handleIds: {}, - - /** - * the DragDrop object that is currently being dragged - * @property dragCurrent - * @type DragDrop - * @private - * @static - **/ - dragCurrent: null, - - /** - * the DragDrop object(s) that are being hovered over - * @property dragOvers - * @type Array - * @private - * @static - */ - dragOvers: {}, - - /** - * the X distance between the cursor and the object being dragged - * @property deltaX - * @type int - * @private - * @static - */ - deltaX: 0, - - /** - * the Y distance between the cursor and the object being dragged - * @property deltaY - * @type int - * @private - * @static - */ - deltaY: 0, - - /** - * Flag to determine if we should prevent the default behavior of the - * events we define. By default this is true, but this can be set to - * false if you need the default behavior (not recommended) - * @property preventDefault - * @type boolean - * @static - */ - preventDefault: true, - - /** - * Flag to determine if we should stop the propagation of the events - * we generate. This is true by default but you may want to set it to - * false if the html element contains other features that require the - * mouse click. - * @property stopPropagation - * @type boolean - * @static - */ - stopPropagation: true, - - /** - * Internal flag that is set to true when drag and drop has been - * intialized - * @property initialized - * @private - * @static - */ - initalized: false, - - /** - * All drag and drop can be disabled. - * @property locked - * @private - * @static - */ - locked: false, - - /** - * Called the first time an element is registered. - * @method init - * @private - * @static - */ - init: function() { - this.initialized = true; - }, - - /** - * In point mode, drag and drop interaction is defined by the - * location of the cursor during the drag/drop - * @property POINT - * @type int - * @static - * @final - */ - POINT: 0, - - /** - * In intersect mode, drag and drop interaction is defined by the - * cursor position or the amount of overlap of two or more drag and - * drop objects. - * @property INTERSECT - * @type int - * @static - * @final - */ - INTERSECT: 1, - - /** - * In intersect mode, drag and drop interaction is defined only by the - * overlap of two or more drag and drop objects. - * @property STRICT_INTERSECT - * @type int - * @static - * @final - */ - STRICT_INTERSECT: 2, - - /** - * The current drag and drop mode. Default: POINT - * @property mode - * @type int - * @static - */ - mode: 0, - - /** - * Runs method on all drag and drop objects - * @method _execOnAll - * @private - * @static - */ - _execOnAll: function(sMethod, args) { - for (var i in this.ids) { - for (var j in this.ids[i]) { - var oDD = this.ids[i][j]; - if (! this.isTypeOfDD(oDD)) { - continue; - } - oDD[sMethod].apply(oDD, args); - } - } - }, - - /** - * Drag and drop initialization. Sets up the global event handlers - * @method _onLoad - * @private - * @static - */ - _onLoad: function() { - - this.init(); - - - Event.on(document, "mouseup", this.handleMouseUp, this, true); - Event.on(document, "mousemove", this.handleMouseMove, this, true); - Event.on(window, "unload", this._onUnload, this, true); - Event.on(window, "resize", this._onResize, this, true); - // Event.on(window, "mouseout", this._test); - - }, - - /** - * Reset constraints on all drag and drop objs - * @method _onResize - * @private - * @static - */ - _onResize: function(e) { - this._execOnAll("resetConstraints", []); - }, - - /** - * Lock all drag and drop functionality - * @method lock - * @static - */ - lock: function() { this.locked = true; }, - - /** - * Unlock all drag and drop functionality - * @method unlock - * @static - */ - unlock: function() { this.locked = false; }, - - /** - * Is drag and drop locked? - * @method isLocked - * @return {boolean} True if drag and drop is locked, false otherwise. - * @static - */ - isLocked: function() { return this.locked; }, - - /** - * Location cache that is set for all drag drop objects when a drag is - * initiated, cleared when the drag is finished. - * @property locationCache - * @private - * @static - */ - locationCache: {}, - - /** - * Set useCache to false if you want to force object the lookup of each - * drag and drop linked element constantly during a drag. - * @property useCache - * @type boolean - * @static - */ - useCache: true, - - /** - * The number of pixels that the mouse needs to move after the - * mousedown before the drag is initiated. Default=3; - * @property clickPixelThresh - * @type int - * @static - */ - clickPixelThresh: 3, - - /** - * The number of milliseconds after the mousedown event to initiate the - * drag if we don't get a mouseup event. Default=1000 - * @property clickTimeThresh - * @type int - * @static - */ - clickTimeThresh: 1000, - - /** - * Flag that indicates that either the drag pixel threshold or the - * mousdown time threshold has been met - * @property dragThreshMet - * @type boolean - * @private - * @static - */ - dragThreshMet: false, - - /** - * Timeout used for the click time threshold - * @property clickTimeout - * @type Object - * @private - * @static - */ - clickTimeout: null, - - /** - * The X position of the mousedown event stored for later use when a - * drag threshold is met. - * @property startX - * @type int - * @private - * @static - */ - startX: 0, - - /** - * The Y position of the mousedown event stored for later use when a - * drag threshold is met. - * @property startY - * @type int - * @private - * @static - */ - startY: 0, - - /** - * Each DragDrop instance must be registered with the DragDropMgr. - * This is executed in DragDrop.init() - * @method regDragDrop - * @param {DragDrop} oDD the DragDrop object to register - * @param {String} sGroup the name of the group this element belongs to - * @static - */ - regDragDrop: function(oDD, sGroup) { - if (!this.initialized) { this.init(); } - - if (!this.ids[sGroup]) { - this.ids[sGroup] = {}; - } - this.ids[sGroup][oDD.id] = oDD; - }, - - /** - * Removes the supplied dd instance from the supplied group. Executed - * by DragDrop.removeFromGroup, so don't call this function directly. - * @method removeDDFromGroup - * @private - * @static - */ - removeDDFromGroup: function(oDD, sGroup) { - if (!this.ids[sGroup]) { - this.ids[sGroup] = {}; - } - - var obj = this.ids[sGroup]; - if (obj && obj[oDD.id]) { - delete obj[oDD.id]; - } - }, - - /** - * Unregisters a drag and drop item. This is executed in - * DragDrop.unreg, use that method instead of calling this directly. - * @method _remove - * @private - * @static - */ - _remove: function(oDD) { - for (var g in oDD.groups) { - if (g && this.ids[g][oDD.id]) { - delete this.ids[g][oDD.id]; - } - } - delete this.handleIds[oDD.id]; - }, - - /** - * Each DragDrop handle element must be registered. This is done - * automatically when executing DragDrop.setHandleElId() - * @method regHandle - * @param {String} sDDId the DragDrop id this element is a handle for - * @param {String} sHandleId the id of the element that is the drag - * handle - * @static - */ - regHandle: function(sDDId, sHandleId) { - if (!this.handleIds[sDDId]) { - this.handleIds[sDDId] = {}; - } - this.handleIds[sDDId][sHandleId] = sHandleId; - }, - - /** - * Utility function to determine if a given element has been - * registered as a drag drop item. - * @method isDragDrop - * @param {String} id the element id to check - * @return {boolean} true if this element is a DragDrop item, - * false otherwise - * @static - */ - isDragDrop: function(id) { - return ( this.getDDById(id) ) ? true : false; - }, - - /** - * Returns the drag and drop instances that are in all groups the - * passed in instance belongs to. - * @method getRelated - * @param {DragDrop} p_oDD the obj to get related data for - * @param {boolean} bTargetsOnly if true, only return targetable objs - * @return {DragDrop[]} the related instances - * @static - */ - getRelated: function(p_oDD, bTargetsOnly) { - var oDDs = []; - for (var i in p_oDD.groups) { - for (j in this.ids[i]) { - var dd = this.ids[i][j]; - if (! this.isTypeOfDD(dd)) { - continue; - } - if (!bTargetsOnly || dd.isTarget) { - oDDs[oDDs.length] = dd; - } - } - } - - return oDDs; - }, - - /** - * Returns true if the specified dd target is a legal target for - * the specifice drag obj - * @method isLegalTarget - * @param {DragDrop} the drag obj - * @param {DragDrop} the target - * @return {boolean} true if the target is a legal target for the - * dd obj - * @static - */ - isLegalTarget: function (oDD, oTargetDD) { - var targets = this.getRelated(oDD, true); - for (var i=0, len=targets.length;i<len;++i) { - if (targets[i].id == oTargetDD.id) { - return true; - } - } - - return false; - }, - - /** - * My goal is to be able to transparently determine if an object is - * typeof DragDrop, and the exact subclass of DragDrop. typeof - * returns "object", oDD.constructor.toString() always returns - * "DragDrop" and not the name of the subclass. So for now it just - * evaluates a well-known variable in DragDrop. - * @method isTypeOfDD - * @param {Object} the object to evaluate - * @return {boolean} true if typeof oDD = DragDrop - * @static - */ - isTypeOfDD: function (oDD) { - return (oDD && oDD.__ygDragDrop); - }, - - /** - * Utility function to determine if a given element has been - * registered as a drag drop handle for the given Drag Drop object. - * @method isHandle - * @param {String} id the element id to check - * @return {boolean} true if this element is a DragDrop handle, false - * otherwise - * @static - */ - isHandle: function(sDDId, sHandleId) { - return ( this.handleIds[sDDId] && - this.handleIds[sDDId][sHandleId] ); - }, - - /** - * Returns the DragDrop instance for a given id - * @method getDDById - * @param {String} id the id of the DragDrop object - * @return {DragDrop} the drag drop object, null if it is not found - * @static - */ - getDDById: function(id) { - for (var i in this.ids) { - if (this.ids[i][id]) { - return this.ids[i][id]; - } - } - return null; - }, - - /** - * Fired after a registered DragDrop object gets the mousedown event. - * Sets up the events required to track the object being dragged - * @method handleMouseDown - * @param {Event} e the event - * @param oDD the DragDrop object being dragged - * @private - * @static - */ - handleMouseDown: function(e, oDD) { - - this.currentTarget = YAHOO.util.Event.getTarget(e); - - this.dragCurrent = oDD; - - var el = oDD.getEl(); - - // track start position - this.startX = YAHOO.util.Event.getPageX(e); - this.startY = YAHOO.util.Event.getPageY(e); - - this.deltaX = this.startX - el.offsetLeft; - this.deltaY = this.startY - el.offsetTop; - - this.dragThreshMet = false; - - this.clickTimeout = setTimeout( - function() { - var DDM = YAHOO.util.DDM; - DDM.startDrag(DDM.startX, DDM.startY); - }, - this.clickTimeThresh ); - }, - - /** - * Fired when either the drag pixel threshol or the mousedown hold - * time threshold has been met. - * @method startDrag - * @param x {int} the X position of the original mousedown - * @param y {int} the Y position of the original mousedown - * @static - */ - startDrag: function(x, y) { - clearTimeout(this.clickTimeout); - if (this.dragCurrent) { - this.dragCurrent.b4StartDrag(x, y); - this.dragCurrent.startDrag(x, y); - } - this.dragThreshMet = true; - }, - - /** - * Internal function to handle the mouseup event. Will be invoked - * from the context of the document. - * @method handleMouseUp - * @param {Event} e the event - * @private - * @static - */ - handleMouseUp: function(e) { - - if (! this.dragCurrent) { - return; - } - - clearTimeout(this.clickTimeout); - - if (this.dragThreshMet) { - this.fireEvents(e, true); - } else { - } - - this.stopDrag(e); - - this.stopEvent(e); - }, - - /** - * Utility to stop event propagation and event default, if these - * features are turned on. - * @method stopEvent - * @param {Event} e the event as returned by this.getEvent() - * @static - */ - stopEvent: function(e) { - if (this.stopPropagation) { - YAHOO.util.Event.stopPropagation(e); - } - - if (this.preventDefault) { - YAHOO.util.Event.preventDefault(e); - } - }, - - /** - * Internal function to clean up event handlers after the drag - * operation is complete - * @method stopDrag - * @param {Event} e the event - * @private - * @static - */ - stopDrag: function(e) { - - // Fire the drag end event for the item that was dragged - if (this.dragCurrent) { - if (this.dragThreshMet) { - this.dragCurrent.b4EndDrag(e); - this.dragCurrent.endDrag(e); - } - - this.dragCurrent.onMouseUp(e); - } - - this.dragCurrent = null; - this.dragOvers = {}; - }, - - - /** - * Internal function to handle the mousemove event. Will be invoked - * from the context of the html element. - * - * @TODO figure out what we can do about mouse events lost when the - * user drags objects beyond the window boundary. Currently we can - * detect this in internet explorer by verifying that the mouse is - * down during the mousemove event. Firefox doesn't give us the - * button state on the mousemove event. - * @method handleMouseMove - * @param {Event} e the event - * @private - * @static - */ - handleMouseMove: function(e) { - if (! this.dragCurrent) { - return true; - } - - // var button = e.which || e.button; - - // check for IE mouseup outside of page boundary - if (YAHOO.util.Event.isIE && !e.button) { - this.stopEvent(e); - return this.handleMouseUp(e); - } - - if (!this.dragThreshMet) { - var diffX = Math.abs(this.startX - YAHOO.util.Event.getPageX(e)); - var diffY = Math.abs(this.startY - YAHOO.util.Event.getPageY(e)); - if (diffX > this.clickPixelThresh || - diffY > this.clickPixelThresh) { - this.startDrag(this.startX, this.startY); - } - } - - if (this.dragThreshMet) { - this.dragCurrent.b4Drag(e); - this.dragCurrent.onDrag(e); - this.fireEvents(e, false); - } - - this.stopEvent(e); - - return true; - }, - - /** - * Iterates over all of the DragDrop elements to find ones we are - * hovering over or dropping on - * @method fireEvents - * @param {Event} e the event - * @param {boolean} isDrop is this a drop op or a mouseover op? - * @private - * @static - */ - fireEvents: function(e, isDrop) { - var dc = this.dragCurrent; - - // If the user did the mouse up outside of the window, we could - // get here even though we have ended the drag. - if (!dc || dc.isLocked()) { - return; - } - - var x = YAHOO.util.Event.getPageX(e); - var y = YAHOO.util.Event.getPageY(e); - var pt = new YAHOO.util.Point(x,y); - - // cache the previous dragOver array - var oldOvers = []; - - var outEvts = []; - var overEvts = []; - var dropEvts = []; - var enterEvts = []; - - // Check to see if the object(s) we were hovering over is no longer - // being hovered over so we can fire the onDragOut event - for (var i in this.dragOvers) { - - var ddo = this.dragOvers[i]; - - if (! this.isTypeOfDD(ddo)) { - continue; - } - - if (! this.isOverTarget(pt, ddo, this.mode)) { - outEvts.push( ddo ); - } - - oldOvers[i] = true; - delete this.dragOvers[i]; - } - - for (var sGroup in dc.groups) { - - if ("string" != typeof sGroup) { - continue; - } - - for (i in this.ids[sGroup]) { - var oDD = this.ids[sGroup][i]; - if (! this.isTypeOfDD(oDD)) { - continue; - } - - if (oDD.isTarget && !oDD.isLocked() && oDD != dc) { - if (this.isOverTarget(pt, oDD, this.mode)) { - // look for drop interactions - if (isDrop) { - dropEvts.push( oDD ); - // look for drag enter and drag over interactions - } else { - - // initial drag over: dragEnter fires - if (!oldOvers[oDD.id]) { - enterEvts.push( oDD ); - // subsequent drag overs: dragOver fires - } else { - overEvts.push( oDD ); - } - - this.dragOvers[oDD.id] = oDD; - } - } - } - } - } - - if (this.mode) { - if (outEvts.length) { - dc.b4DragOut(e, outEvts); - dc.onDragOut(e, outEvts); - } - - if (enterEvts.length) { - dc.onDragEnter(e, enterEvts); - } - - if (overEvts.length) { - dc.b4DragOver(e, overEvts); - dc.onDragOver(e, overEvts); - } - - if (dropEvts.length) { - dc.b4DragDrop(e, dropEvts); - dc.onDragDrop(e, dropEvts); - } - - } else { - // fire dragout events - var len = 0; - for (i=0, len=outEvts.length; i<len; ++i) { - dc.b4DragOut(e, outEvts[i].id); - dc.onDragOut(e, outEvts[i].id); - } - - // fire enter events - for (i=0,len=enterEvts.length; i<len; ++i) { - // dc.b4DragEnter(e, oDD.id); - dc.onDragEnter(e, enterEvts[i].id); - } - - // fire over events - for (i=0,len=overEvts.length; i<len; ++i) { - dc.b4DragOver(e, overEvts[i].id); - dc.onDragOver(e, overEvts[i].id); - } - - // fire drop events - for (i=0, len=dropEvts.length; i<len; ++i) { - dc.b4DragDrop(e, dropEvts[i].id); - dc.onDragDrop(e, dropEvts[i].id); - } - - } - - // notify about a drop that did not find a target - if (isDrop && !dropEvts.length) { - dc.onInvalidDrop(e); - } - - }, - - /** - * Helper function for getting the best match from the list of drag - * and drop objects returned by the drag and drop events when we are - * in INTERSECT mode. It returns either the first object that the - * cursor is over, or the object that has the greatest overlap with - * the dragged element. - * @method getBestMatch - * @param {DragDrop[]} dds The array of drag and drop objects - * targeted - * @return {DragDrop} The best single match - * @static - */ - getBestMatch: function(dds) { - var winner = null; - - var len = dds.length; - - if (len == 1) { - winner = dds[0]; - } else { - // Loop through the targeted items - for (var i=0; i<len; ++i) { - var dd = dds[i]; - // If the cursor is over the object, it wins. If the - // cursor is over multiple matches, the first one we come - // to wins. - if (this.mode == this.INTERSECT && dd.cursorIsOver) { - winner = dd; - break; - // Otherwise the object with the most overlap wins - } else { - if (!winner || !winner.overlap || (dd.overlap && - winner.overlap.getArea() < dd.overlap.getArea())) { - winner = dd; - } - } - } - } - - return winner; - }, - - /** - * Refreshes the cache of the top-left and bottom-right points of the - * drag and drop objects in the specified group(s). This is in the - * format that is stored in the drag and drop instance, so typical - * usage is: - * <code> - * YAHOO.util.DragDropMgr.refreshCache(ddinstance.groups); - * </code> - * Alternatively: - * <code> - * YAHOO.util.DragDropMgr.refreshCache({group1:true, group2:true}); - * </code> - * @TODO this really should be an indexed array. Alternatively this - * method could accept both. - * @method refreshCache - * @param {Object} groups an associative array of groups to refresh - * @static - */ - refreshCache: function(groups) { - - // refresh everything if group array is not provided - var g = groups || this.ids; - - for (var sGroup in g) { - if ("string" != typeof sGroup) { - continue; - } - for (var i in this.ids[sGroup]) { - var oDD = this.ids[sGroup][i]; - - if (this.isTypeOfDD(oDD)) { - var loc = this.getLocation(oDD); - if (loc) { - this.locationCache[oDD.id] = loc; - } else { - delete this.locationCache[oDD.id]; - } - } - } - } - }, - - /** - * This checks to make sure an element exists and is in the DOM. The - * main purpose is to handle cases where innerHTML is used to remove - * drag and drop objects from the DOM. IE provides an 'unspecified - * error' when trying to access the offsetParent of such an element - * @method verifyEl - * @param {HTMLElement} el the element to check - * @return {boolean} true if the element looks usable - * @static - */ - verifyEl: function(el) { - try { - if (el) { - var parent = el.offsetParent; - if (parent) { - return true; - } - } - } catch(e) { - } - - return false; - }, - - /** - * Returns a Region object containing the drag and drop element's position - * and size, including the padding configured for it - * @method getLocation - * @param {DragDrop} oDD the drag and drop object to get the - * location for - * @return {YAHOO.util.Region} a Region object representing the total area - * the element occupies, including any padding - * the instance is configured for. - * @static - */ - getLocation: function(oDD) { - if (! this.isTypeOfDD(oDD)) { - return null; - } - - var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l; - - try { - pos= YAHOO.util.Dom.getXY(el); - } catch (e) { } - - if (!pos) { - return null; - } - - x1 = pos[0]; - x2 = x1 + el.offsetWidth; - y1 = pos[1]; - y2 = y1 + el.offsetHeight; - - t = y1 - oDD.padding[0]; - r = x2 + oDD.padding[1]; - b = y2 + oDD.padding[2]; - l = x1 - oDD.padding[3]; - - return new YAHOO.util.Region( t, r, b, l ); - }, - - /** - * Checks the cursor location to see if it over the target - * @method isOverTarget - * @param {YAHOO.util.Point} pt The point to evaluate - * @param {DragDrop} oTarget the DragDrop object we are inspecting - * @return {boolean} true if the mouse is over the target - * @private - * @static - */ - isOverTarget: function(pt, oTarget, intersect) { - // use cache if available - var loc = this.locationCache[oTarget.id]; - if (!loc || !this.useCache) { - loc = this.getLocation(oTarget); - this.locationCache[oTarget.id] = loc; - - } - - if (!loc) { - return false; - } - - oTarget.cursorIsOver = loc.contains( pt ); - - // DragDrop is using this as a sanity check for the initial mousedown - // in this case we are done. In POINT mode, if the drag obj has no - // contraints, we are done. Otherwise we need to evaluate the - // region the target as occupies to determine if the dragged element - // overlaps with it. - - var dc = this.dragCurrent; - if (!dc || !dc.getTargetCoord || - (!intersect && !dc.constrainX && !dc.constrainY)) { - - //if (oTarget.cursorIsOver) { - //} - return oTarget.cursorIsOver; - } - - oTarget.overlap = null; - - // Get the current location of the drag element, this is the - // location of the mouse event less the delta that represents - // where the original mousedown happened on the element. We - // need to consider constraints and ticks as well. - var pos = dc.getTargetCoord(pt.x, pt.y); - - var el = dc.getDragEl(); - var curRegion = new YAHOO.util.Region( pos.y, - pos.x + el.offsetWidth, - pos.y + el.offsetHeight, - pos.x ); - - var overlap = curRegion.intersect(loc); - - if (overlap) { - oTarget.overlap = overlap; - return (intersect) ? true : oTarget.cursorIsOver; - } else { - return false; - } - }, - - /** - * unload event handler - * @method _onUnload - * @private - * @static - */ - _onUnload: function(e, me) { - this.unregAll(); - }, - - /** - * Cleans up the drag and drop events and objects. - * @method unregAll - * @private - * @static - */ - unregAll: function() { - - if (this.dragCurrent) { - this.stopDrag(); - this.dragCurrent = null; - } - - this._execOnAll("unreg", []); - - for (i in this.elementCache) { - delete this.elementCache[i]; - } - - this.elementCache = {}; - this.ids = {}; - }, - - /** - * A cache of DOM elements - * @property elementCache - * @private - * @static - */ - elementCache: {}, - - /** - * Get the wrapper for the DOM element specified - * @method getElWrapper - * @param {String} id the id of the element to get - * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element - * @private - * @deprecated This wrapper isn't that useful - * @static - */ - getElWrapper: function(id) { - var oWrapper = this.elementCache[id]; - if (!oWrapper || !oWrapper.el) { - oWrapper = this.elementCache[id] = - new this.ElementWrapper(YAHOO.util.Dom.get(id)); - } - return oWrapper; - }, - - /** - * Returns the actual DOM element - * @method getElement - * @param {String} id the id of the elment to get - * @return {Object} The element - * @deprecated use YAHOO.util.Dom.get instead - * @static - */ - getElement: function(id) { - return YAHOO.util.Dom.get(id); - }, - - /** - * Returns the style property for the DOM element (i.e., - * document.getElById(id).style) - * @method getCss - * @param {String} id the id of the elment to get - * @return {Object} The style property of the element - * @deprecated use YAHOO.util.Dom instead - * @static - */ - getCss: function(id) { - var el = YAHOO.util.Dom.get(id); - return (el) ? el.style : null; - }, - - /** - * Inner class for cached elements - * @class DragDropMgr.ElementWrapper - * @for DragDropMgr - * @private - * @deprecated - */ - ElementWrapper: function(el) { - /** - * The element - * @property el - */ - this.el = el || null; - /** - * The element id - * @property id - */ - this.id = this.el && el.id; - /** - * A reference to the style property - * @property css - */ - this.css = this.el && el.style; - }, - - /** - * Returns the X position of an html element - * @method getPosX - * @param el the element for which to get the position - * @return {int} the X coordinate - * @for DragDropMgr - * @deprecated use YAHOO.util.Dom.getX instead - * @static - */ - getPosX: function(el) { - return YAHOO.util.Dom.getX(el); - }, - - /** - * Returns the Y position of an html element - * @method getPosY - * @param el the element for which to get the position - * @return {int} the Y coordinate - * @deprecated use YAHOO.util.Dom.getY instead - * @static - */ - getPosY: function(el) { - return YAHOO.util.Dom.getY(el); - }, - - /** - * Swap two nodes. In IE, we use the native method, for others we - * emulate the IE behavior - * @method swapNode - * @param n1 the first node to swap - * @param n2 the other node to swap - * @static - */ - swapNode: function(n1, n2) { - if (n1.swapNode) { - n1.swapNode(n2); - } else { - var p = n2.parentNode; - var s = n2.nextSibling; - - if (s == n1) { - p.insertBefore(n1, n2); - } else if (n2 == n1.nextSibling) { - p.insertBefore(n2, n1); - } else { - n1.parentNode.replaceChild(n2, n1); - p.insertBefore(n1, s); - } - } - }, - - /** - * Returns the current scroll position - * @method getScroll - * @private - * @static - */ - getScroll: function () { - var t, l, dde=document.documentElement, db=document.body; - if (dde && (dde.scrollTop || dde.scrollLeft)) { - t = dde.scrollTop; - l = dde.scrollLeft; - } else if (db) { - t = db.scrollTop; - l = db.scrollLeft; - } else { - } - return { top: t, left: l }; - }, - - /** - * Returns the specified element style property - * @method getStyle - * @param {HTMLElement} el the element - * @param {string} styleProp the style property - * @return {string} The value of the style property - * @deprecated use YAHOO.util.Dom.getStyle - * @static - */ - getStyle: function(el, styleProp) { - return YAHOO.util.Dom.getStyle(el, styleProp); - }, - - /** - * Gets the scrollTop - * @method getScrollTop - * @return {int} the document's scrollTop - * @static - */ - getScrollTop: function () { return this.getScroll().top; }, - - /** - * Gets the scrollLeft - * @method getScrollLeft - * @return {int} the document's scrollTop - * @static - */ - getScrollLeft: function () { return this.getScroll().left; }, - - /** - * Sets the x/y position of an element to the location of the - * target element. - * @method moveToEl - * @param {HTMLElement} moveEl The element to move - * @param {HTMLElement} targetEl The position reference element - * @static - */ - moveToEl: function (moveEl, targetEl) { - var aCoord = YAHOO.util.Dom.getXY(targetEl); - YAHOO.util.Dom.setXY(moveEl, aCoord); - }, - - /** - * Gets the client height - * @method getClientHeight - * @return {int} client height in px - * @deprecated use YAHOO.util.Dom.getViewportHeight instead - * @static - */ - getClientHeight: function() { - return YAHOO.util.Dom.getViewportHeight(); - }, - - /** - * Gets the client width - * @method getClientWidth - * @return {int} client width in px - * @deprecated use YAHOO.util.Dom.getViewportWidth instead - * @static - */ - getClientWidth: function() { - return YAHOO.util.Dom.getViewportWidth(); - }, - - /** - * Numeric array sort function - * @method numericSort - * @static - */ - numericSort: function(a, b) { return (a - b); }, - - /** - * Internal counter - * @property _timeoutCount - * @private - * @static - */ - _timeoutCount: 0, - - /** - * Trying to make the load order less important. Without this we get - * an error if this file is loaded before the Event Utility. - * @method _addListeners - * @private - * @static - */ - _addListeners: function() { - var DDM = YAHOO.util.DDM; - if ( YAHOO.util.Event && document ) { - DDM._onLoad(); - } else { - if (DDM._timeoutCount > 2000) { - } else { - setTimeout(DDM._addListeners, 10); - if (document && document.body) { - DDM._timeoutCount += 1; - } - } - } - }, - - /** - * Recursively searches the immediate parent and all child nodes for - * the handle element in order to determine wheter or not it was - * clicked. - * @method handleWasClicked - * @param node the html element to inspect - * @static - */ - handleWasClicked: function(node, id) { - if (this.isHandle(id, node.id)) { - return true; - } else { - // check to see if this is a text node child of the one we want - var p = node.parentNode; - - while (p) { - if (this.isHandle(id, p.id)) { - return true; - } else { - p = p.parentNode; - } - } - } - - return false; - } - - }; - -}(); - -// shorter alias, save a few bytes -YAHOO.util.DDM = YAHOO.util.DragDropMgr; -YAHOO.util.DDM._addListeners(); - -} - -(function() { - -var Event=YAHOO.util.Event; -var Dom=YAHOO.util.Dom; - -/** - * Defines the interface and base operation of items that that can be - * dragged or can be drop targets. It was designed to be extended, overriding - * the event handlers for startDrag, onDrag, onDragOver, onDragOut. - * Up to three html elements can be associated with a DragDrop instance: - * <ul> - * <li>linked element: the element that is passed into the constructor. - * This is the element which defines the boundaries for interaction with - * other DragDrop objects.</li> - * <li>handle element(s): The drag operation only occurs if the element that - * was clicked matches a handle element. By default this is the linked - * element, but there are times that you will want only a portion of the - * linked element to initiate the drag operation, and the setHandleElId() - * method provides a way to define this.</li> - * <li>drag element: this represents an the element that would be moved along - * with the cursor during a drag operation. By default, this is the linked - * element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define - * a separate element that would be moved, as in {@link YAHOO.util.DDProxy} - * </li> - * </ul> - * This class should not be instantiated until the onload event to ensure that - * the associated elements are available. - * The following would define a DragDrop obj that would interact with any - * other DragDrop obj in the "group1" group: - * <pre> - * dd = new YAHOO.util.DragDrop("div1", "group1"); - * </pre> - * Since none of the event handlers have been implemented, nothing would - * actually happen if you were to run the code above. Normally you would - * override this class or one of the default implementations, but you can - * also override the methods you want on an instance of the class... - * <pre> - * dd.onDragDrop = function(e, id) { - * alert("dd was dropped on " + id); - * } - * </pre> - * @namespace YAHOO.util - * @class DragDrop - * @constructor - * @param {String} id of the element that is linked to this instance - * @param {String} sGroup the group of related DragDrop objects - * @param {object} config an object containing configurable attributes - * Valid properties for DragDrop: - * padding, isTarget, maintainOffset, primaryButtonOnly, - */ -YAHOO.util.DragDrop = function(id, sGroup, config) { - if (id) { - this.init(id, sGroup, config); - } -}; - -YAHOO.util.DragDrop.prototype = { - - /** - * The id of the element associated with this object. This is what we - * refer to as the "linked element" because the size and position of - * this element is used to determine when the drag and drop objects have - * interacted. - * @property id - * @type String - */ - id: null, - - /** - * Configuration attributes passed into the constructor - * @property config - * @type object - */ - config: null, - - /** - * The id of the element that will be dragged. By default this is same - * as the linked element , but could be changed to another element. Ex: - * YAHOO.util.DDProxy - * @property dragElId - * @type String - * @private - */ - dragElId: null, - - /** - * the id of the element that initiates the drag operation. By default - * this is the linked element, but could be changed to be a child of this - * element. This lets us do things like only starting the drag when the - * header element within the linked html element is clicked. - * @property handleElId - * @type String - * @private - */ - handleElId: null, - - /** - * An associative array of HTML tags that will be ignored if clicked. - * @property invalidHandleTypes - * @type {string: string} - */ - invalidHandleTypes: null, - - /** - * An associative array of ids for elements that will be ignored if clicked - * @property invalidHandleIds - * @type {string: string} - */ - invalidHandleIds: null, - - /** - * An indexted array of css class names for elements that will be ignored - * if clicked. - * @property invalidHandleClasses - * @type string[] - */ - invalidHandleClasses: null, - - /** - * The linked element's absolute X position at the time the drag was - * started - * @property startPageX - * @type int - * @private - */ - startPageX: 0, - - /** - * The linked element's absolute X position at the time the drag was - * started - * @property startPageY - * @type int - * @private - */ - startPageY: 0, - - /** - * The group defines a logical collection of DragDrop objects that are - * related. Instances only get events when interacting with other - * DragDrop object in the same group. This lets us define multiple - * groups using a single DragDrop subclass if we want. - * @property groups - * @type {string: string} - */ - groups: null, - - /** - * Individual drag/drop instances can be locked. This will prevent - * onmousedown start drag. - * @property locked - * @type boolean - * @private - */ - locked: false, - - /** - * Lock this instance - * @method lock - */ - lock: function() { this.locked = true; }, - - /** - * Unlock this instace - * @method unlock - */ - unlock: function() { this.locked = false; }, - - /** - * By default, all insances can be a drop target. This can be disabled by - * setting isTarget to false. - * @method isTarget - * @type boolean - */ - isTarget: true, - - /** - * The padding configured for this drag and drop object for calculating - * the drop zone intersection with this object. - * @method padding - * @type int[] - */ - padding: null, - - /** - * Cached reference to the linked element - * @property _domRef - * @private - */ - _domRef: null, - - /** - * Internal typeof flag - * @property __ygDragDrop - * @private - */ - __ygDragDrop: true, - - /** - * Set to true when horizontal contraints are applied - * @property constrainX - * @type boolean - * @private - */ - constrainX: false, - - /** - * Set to true when vertical contraints are applied - * @property constrainY - * @type boolean - * @private - */ - constrainY: false, - - /** - * The left constraint - * @property minX - * @type int - * @private - */ - minX: 0, - - /** - * The right constraint - * @property maxX - * @type int - * @private - */ - maxX: 0, - - /** - * The up constraint - * @property minY - * @type int - * @type int - * @private - */ - minY: 0, - - /** - * The down constraint - * @property maxY - * @type int - * @private - */ - maxY: 0, - - /** - * Maintain offsets when we resetconstraints. Set to true when you want - * the position of the element relative to its parent to stay the same - * when the page changes - * - * @property maintainOffset - * @type boolean - */ - maintainOffset: false, - - /** - * Array of pixel locations the element will snap to if we specified a - * horizontal graduation/interval. This array is generated automatically - * when you define a tick interval. - * @property xTicks - * @type int[] - */ - xTicks: null, - - /** - * Array of pixel locations the element will snap to if we specified a - * vertical graduation/interval. This array is generated automatically - * when you define a tick interval. - * @property yTicks - * @type int[] - */ - yTicks: null, - - /** - * By default the drag and drop instance will only respond to the primary - * button click (left button for a right-handed mouse). Set to true to - * allow drag and drop to start with any mouse click that is propogated - * by the browser - * @property primaryButtonOnly - * @type boolean - */ - primaryButtonOnly: true, - - /** - * The availabe property is false until the linked dom element is accessible. - * @property available - * @type boolean - */ - available: false, - - /** - * By default, drags can only be initiated if the mousedown occurs in the - * region the linked element is. This is done in part to work around a - * bug in some browsers that mis-report the mousedown if the previous - * mouseup happened outside of the window. This property is set to true - * if outer handles are defined. - * - * @property hasOuterHandles - * @type boolean - * @default false - */ - hasOuterHandles: false, - - /** - * Code that executes immediately before the startDrag event - * @method b4StartDrag - * @private - */ - b4StartDrag: function(x, y) { }, - - /** - * Abstract method called after a drag/drop object is clicked - * and the drag or mousedown time thresholds have beeen met. - * @method startDrag - * @param {int} X click location - * @param {int} Y click location - */ - startDrag: function(x, y) { /* override this */ }, - - /** - * Code that executes immediately before the onDrag event - * @method b4Drag - * @private - */ - b4Drag: function(e) { }, - - /** - * Abstract method called during the onMouseMove event while dragging an - * object. - * @method onDrag - * @param {Event} e the mousemove event - */ - onDrag: function(e) { /* override this */ }, - - /** - * Abstract method called when this element fist begins hovering over - * another DragDrop obj - * @method onDragEnter - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this is hovering over. In INTERSECT mode, an array of one or more - * dragdrop items being hovered over. - */ - onDragEnter: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragOver event - * @method b4DragOver - * @private - */ - b4DragOver: function(e) { }, - - /** - * Abstract method called when this element is hovering over another - * DragDrop obj - * @method onDragOver - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this is hovering over. In INTERSECT mode, an array of dd items - * being hovered over. - */ - onDragOver: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragOut event - * @method b4DragOut - * @private - */ - b4DragOut: function(e) { }, - - /** - * Abstract method called when we are no longer hovering over an element - * @method onDragOut - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this was hovering over. In INTERSECT mode, an array of dd items - * that the mouse is no longer over. - */ - onDragOut: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragDrop event - * @method b4DragDrop - * @private - */ - b4DragDrop: function(e) { }, - - /** - * Abstract method called when this item is dropped on another DragDrop - * obj - * @method onDragDrop - * @param {Event} e the mouseup event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this was dropped on. In INTERSECT mode, an array of dd items this - * was dropped on. - */ - onDragDrop: function(e, id) { /* override this */ }, - - /** - * Abstract method called when this item is dropped on an area with no - * drop target - * @method onInvalidDrop - * @param {Event} e the mouseup event - */ - onInvalidDrop: function(e) { /* override this */ }, - - /** - * Code that executes immediately before the endDrag event - * @method b4EndDrag - * @private - */ - b4EndDrag: function(e) { }, - - /** - * Fired when we are done dragging the object - * @method endDrag - * @param {Event} e the mouseup event - */ - endDrag: function(e) { /* override this */ }, - - /** - * Code executed immediately before the onMouseDown event - * @method b4MouseDown - * @param {Event} e the mousedown event - * @private - */ - b4MouseDown: function(e) { }, - - /** - * Event handler that fires when a drag/drop obj gets a mousedown - * @method onMouseDown - * @param {Event} e the mousedown event - */ - onMouseDown: function(e) { /* override this */ }, - - /** - * Event handler that fires when a drag/drop obj gets a mouseup - * @method onMouseUp - * @param {Event} e the mouseup event - */ - onMouseUp: function(e) { /* override this */ }, - - /** - * Override the onAvailable method to do what is needed after the initial - * position was determined. - * @method onAvailable - */ - onAvailable: function () { - }, - - /** - * Returns a reference to the linked element - * @method getEl - * @return {HTMLElement} the html element - */ - getEl: function() { - if (!this._domRef) { - this._domRef = Dom.get(this.id); - } - - return this._domRef; - }, - - /** - * Returns a reference to the actual element to drag. By default this is - * the same as the html element, but it can be assigned to another - * element. An example of this can be found in YAHOO.util.DDProxy - * @method getDragEl - * @return {HTMLElement} the html element - */ - getDragEl: function() { - return Dom.get(this.dragElId); - }, - - /** - * Sets up the DragDrop object. Must be called in the constructor of any - * YAHOO.util.DragDrop subclass - * @method init - * @param id the id of the linked element - * @param {String} sGroup the group of related items - * @param {object} config configuration attributes - */ - init: function(id, sGroup, config) { - this.initTarget(id, sGroup, config); - Event.on(this.id, "mousedown", this.handleMouseDown, this, true); - // Event.on(this.id, "selectstart", Event.preventDefault); - }, - - /** - * Initializes Targeting functionality only... the object does not - * get a mousedown handler. - * @method initTarget - * @param id the id of the linked element - * @param {String} sGroup the group of related items - * @param {object} config configuration attributes - */ - initTarget: function(id, sGroup, config) { - - // configuration attributes - this.config = config || {}; - - // create a local reference to the drag and drop manager - this.DDM = YAHOO.util.DDM; - // initialize the groups array - this.groups = {}; - - // assume that we have an element reference instead of an id if the - // parameter is not a string - if (typeof id !== "string") { - id = Dom.generateId(id); - } - - // set the id - this.id = id; - - // add to an interaction group - this.addToGroup((sGroup) ? sGroup : "default"); - - // We don't want to register this as the handle with the manager - // so we just set the id rather than calling the setter. - this.handleElId = id; - - Event.onAvailable(id, this.handleOnAvailable, this, true); - - - // the linked element is the element that gets dragged by default - this.setDragElId(id); - - // by default, clicked anchors will not start drag operations. - // @TODO what else should be here? Probably form fields. - this.invalidHandleTypes = { A: "A" }; - this.invalidHandleIds = {}; - this.invalidHandleClasses = []; - - this.applyConfig(); - }, - - /** - * Applies the configuration parameters that were passed into the constructor. - * This is supposed to happen at each level through the inheritance chain. So - * a DDProxy implentation will execute apply config on DDProxy, DD, and - * DragDrop in order to get all of the parameters that are available in - * each object. - * @method applyConfig - */ - applyConfig: function() { - - // configurable properties: - // padding, isTarget, maintainOffset, primaryButtonOnly - this.padding = this.config.padding || [0, 0, 0, 0]; - this.isTarget = (this.config.isTarget !== false); - this.maintainOffset = (this.config.maintainOffset); - this.primaryButtonOnly = (this.config.primaryButtonOnly !== false); - - }, - - /** - * Executed when the linked element is available - * @method handleOnAvailable - * @private - */ - handleOnAvailable: function() { - this.available = true; - this.resetConstraints(); - this.onAvailable(); - }, - - /** - * Configures the padding for the target zone in px. Effectively expands - * (or reduces) the virtual object size for targeting calculations. - * Supports css-style shorthand; if only one parameter is passed, all sides - * will have that padding, and if only two are passed, the top and bottom - * will have the first param, the left and right the second. - * @method setPadding - * @param {int} iTop Top pad - * @param {int} iRight Right pad - * @param {int} iBot Bot pad - * @param {int} iLeft Left pad - */ - setPadding: function(iTop, iRight, iBot, iLeft) { - // this.padding = [iLeft, iRight, iTop, iBot]; - if (!iRight && 0 !== iRight) { - this.padding = [iTop, iTop, iTop, iTop]; - } else if (!iBot && 0 !== iBot) { - this.padding = [iTop, iRight, iTop, iRight]; - } else { - this.padding = [iTop, iRight, iBot, iLeft]; - } - }, - - /** - * Stores the initial placement of the linked element. - * @method setInitialPosition - * @param {int} diffX the X offset, default 0 - * @param {int} diffY the Y offset, default 0 - */ - setInitPosition: function(diffX, diffY) { - var el = this.getEl(); - - if (!this.DDM.verifyEl(el)) { - return; - } - - var dx = diffX || 0; - var dy = diffY || 0; - - var p = Dom.getXY( el ); - - this.initPageX = p[0] - dx; - this.initPageY = p[1] - dy; - - this.lastPageX = p[0]; - this.lastPageY = p[1]; - - - - this.setStartPosition(p); - }, - - /** - * Sets the start position of the element. This is set when the obj - * is initialized, the reset when a drag is started. - * @method setStartPosition - * @param pos current position (from previous lookup) - * @private - */ - setStartPosition: function(pos) { - var p = pos || Dom.getXY( this.getEl() ); - - this.deltaSetXY = null; - - this.startPageX = p[0]; - this.startPageY = p[1]; - }, - - /** - * Add this instance to a group of related drag/drop objects. All - * instances belong to at least one group, and can belong to as many - * groups as needed. - * @method addToGroup - * @param sGroup {string} the name of the group - */ - addToGroup: function(sGroup) { - this.groups[sGroup] = true; - this.DDM.regDragDrop(this, sGroup); - }, - - /** - * Remove's this instance from the supplied interaction group - * @method removeFromGroup - * @param {string} sGroup The group to drop - */ - removeFromGroup: function(sGroup) { - if (this.groups[sGroup]) { - delete this.groups[sGroup]; - } - - this.DDM.removeDDFromGroup(this, sGroup); - }, - - /** - * Allows you to specify that an element other than the linked element - * will be moved with the cursor during a drag - * @method setDragElId - * @param id {string} the id of the element that will be used to initiate the drag - */ - setDragElId: function(id) { - this.dragElId = id; - }, - - /** - * Allows you to specify a child of the linked element that should be - * used to initiate the drag operation. An example of this would be if - * you have a content div with text and links. Clicking anywhere in the - * content area would normally start the drag operation. Use this method - * to specify that an element inside of the content div is the element - * that starts the drag operation. - * @method setHandleElId - * @param id {string} the id of the element that will be used to - * initiate the drag. - */ - setHandleElId: function(id) { - if (typeof id !== "string") { - id = Dom.generateId(id); - } - this.handleElId = id; - this.DDM.regHandle(this.id, id); - }, - - /** - * Allows you to set an element outside of the linked element as a drag - * handle - * @method setOuterHandleElId - * @param id the id of the element that will be used to initiate the drag - */ - setOuterHandleElId: function(id) { - if (typeof id !== "string") { - id = Dom.generateId(id); - } - Event.on(id, "mousedown", - this.handleMouseDown, this, true); - this.setHandleElId(id); - - this.hasOuterHandles = true; - }, - - /** - * Remove all drag and drop hooks for this element - * @method unreg - */ - unreg: function() { - Event.removeListener(this.id, "mousedown", - this.handleMouseDown); - this._domRef = null; - this.DDM._remove(this); - }, - - /** - * Returns true if this instance is locked, or the drag drop mgr is locked - * (meaning that all drag/drop is disabled on the page.) - * @method isLocked - * @return {boolean} true if this obj or all drag/drop is locked, else - * false - */ - isLocked: function() { - return (this.DDM.isLocked() || this.locked); - }, - - /** - * Fired when this object is clicked - * @method handleMouseDown - * @param {Event} e - * @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj) - * @private - */ - handleMouseDown: function(e, oDD) { - - var button = e.which || e.button; - - if (this.primaryButtonOnly && button > 1) { - return; - } - - if (this.isLocked()) { - return; - } - - - - // firing the mousedown events prior to calculating positions - this.b4MouseDown(e); - this.onMouseDown(e); - - this.DDM.refreshCache(this.groups); - // var self = this; - // setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0); - - // Only process the event if we really clicked within the linked - // element. The reason we make this check is that in the case that - // another element was moved between the clicked element and the - // cursor in the time between the mousedown and mouseup events. When - // this happens, the element gets the next mousedown event - // regardless of where on the screen it happened. - var pt = new YAHOO.util.Point(Event.getPageX(e), Event.getPageY(e)); - if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) { - } else { - if (this.clickValidator(e)) { - - - // set the initial element position - this.setStartPosition(); - - // start tracking mousemove distance and mousedown time to - // determine when to start the actual drag - this.DDM.handleMouseDown(e, this); - - // this mousedown is mine - this.DDM.stopEvent(e); - } else { - - - } - } - }, - - clickValidator: function(e) { - var target = Event.getTarget(e); - return ( this.isValidHandleChild(target) && - (this.id == this.handleElId || - this.DDM.handleWasClicked(target, this.id)) ); - }, - - /** - * Allows you to specify a tag name that should not start a drag operation - * when clicked. This is designed to facilitate embedding links within a - * drag handle that do something other than start the drag. - * @method addInvalidHandleType - * @param {string} tagName the type of element to exclude - */ - addInvalidHandleType: function(tagName) { - var type = tagName.toUpperCase(); - this.invalidHandleTypes[type] = type; - }, - - /** - * Lets you to specify an element id for a child of a drag handle - * that should not initiate a drag - * @method addInvalidHandleId - * @param {string} id the element id of the element you wish to ignore - */ - addInvalidHandleId: function(id) { - if (typeof id !== "string") { - id = Dom.generateId(id); - } - this.invalidHandleIds[id] = id; - }, - - - /** - * Lets you specify a css class of elements that will not initiate a drag - * @method addInvalidHandleClass - * @param {string} cssClass the class of the elements you wish to ignore - */ - addInvalidHandleClass: function(cssClass) { - this.invalidHandleClasses.push(cssClass); - }, - - /** - * Unsets an excluded tag name set by addInvalidHandleType - * @method removeInvalidHandleType - * @param {string} tagName the type of element to unexclude - */ - removeInvalidHandleType: function(tagName) { - var type = tagName.toUpperCase(); - // this.invalidHandleTypes[type] = null; - delete this.invalidHandleTypes[type]; - }, - - /** - * Unsets an invalid handle id - * @method removeInvalidHandleId - * @param {string} id the id of the element to re-enable - */ - removeInvalidHandleId: function(id) { - if (typeof id !== "string") { - id = Dom.generateId(id); - } - delete this.invalidHandleIds[id]; - }, - - /** - * Unsets an invalid css class - * @method removeInvalidHandleClass - * @param {string} cssClass the class of the element(s) you wish to - * re-enable - */ - removeInvalidHandleClass: function(cssClass) { - for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) { - if (this.invalidHandleClasses[i] == cssClass) { - delete this.invalidHandleClasses[i]; - } - } - }, - - /** - * Checks the tag exclusion list to see if this click should be ignored - * @method isValidHandleChild - * @param {HTMLElement} node the HTMLElement to evaluate - * @return {boolean} true if this is a valid tag type, false if not - */ - isValidHandleChild: function(node) { - - var valid = true; - // var n = (node.nodeName == "#text") ? node.parentNode : node; - var nodeName; - try { - nodeName = node.nodeName.toUpperCase(); - } catch(e) { - nodeName = node.nodeName; - } - valid = valid && !this.invalidHandleTypes[nodeName]; - valid = valid && !this.invalidHandleIds[node.id]; - - for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) { - valid = !Dom.hasClass(node, this.invalidHandleClasses[i]); - } - - - return valid; - - }, - - /** - * Create the array of horizontal tick marks if an interval was specified - * in setXConstraint(). - * @method setXTicks - * @private - */ - setXTicks: function(iStartX, iTickSize) { - this.xTicks = []; - this.xTickSize = iTickSize; - - var tickMap = {}; - - for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) { - if (!tickMap[i]) { - this.xTicks[this.xTicks.length] = i; - tickMap[i] = true; - } - } - - for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) { - if (!tickMap[i]) { - this.xTicks[this.xTicks.length] = i; - tickMap[i] = true; - } - } - - this.xTicks.sort(this.DDM.numericSort) ; - }, - - /** - * Create the array of vertical tick marks if an interval was specified in - * setYConstraint(). - * @method setYTicks - * @private - */ - setYTicks: function(iStartY, iTickSize) { - this.yTicks = []; - this.yTickSize = iTickSize; - - var tickMap = {}; - - for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) { - if (!tickMap[i]) { - this.yTicks[this.yTicks.length] = i; - tickMap[i] = true; - } - } - - for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) { - if (!tickMap[i]) { - this.yTicks[this.yTicks.length] = i; - tickMap[i] = true; - } - } - - this.yTicks.sort(this.DDM.numericSort) ; - }, - - /** - * By default, the element can be dragged any place on the screen. Use - * this method to limit the horizontal travel of the element. Pass in - * 0,0 for the parameters if you want to lock the drag to the y axis. - * @method setXConstraint - * @param {int} iLeft the number of pixels the element can move to the left - * @param {int} iRight the number of pixels the element can move to the - * right - * @param {int} iTickSize optional parameter for specifying that the - * element - * should move iTickSize pixels at a time. - */ - setXConstraint: function(iLeft, iRight, iTickSize) { - this.leftConstraint = parseInt(iLeft, 10); - this.rightConstraint = parseInt(iRight, 10); - - this.minX = this.initPageX - this.leftConstraint; - this.maxX = this.initPageX + this.rightConstraint; - if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); } - - this.constrainX = true; - }, - - /** - * Clears any constraints applied to this instance. Also clears ticks - * since they can't exist independent of a constraint at this time. - * @method clearConstraints - */ - clearConstraints: function() { - this.constrainX = false; - this.constrainY = false; - this.clearTicks(); - }, - - /** - * Clears any tick interval defined for this instance - * @method clearTicks - */ - clearTicks: function() { - this.xTicks = null; - this.yTicks = null; - this.xTickSize = 0; - this.yTickSize = 0; - }, - - /** - * By default, the element can be dragged any place on the screen. Set - * this to limit the vertical travel of the element. Pass in 0,0 for the - * parameters if you want to lock the drag to the x axis. - * @method setYConstraint - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize optional parameter for specifying that the - * element should move iTickSize pixels at a time. - */ - setYConstraint: function(iUp, iDown, iTickSize) { - this.topConstraint = parseInt(iUp, 10); - this.bottomConstraint = parseInt(iDown, 10); - - this.minY = this.initPageY - this.topConstraint; - this.maxY = this.initPageY + this.bottomConstraint; - if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); } - - this.constrainY = true; - - }, - - /** - * resetConstraints must be called if you manually reposition a dd element. - * @method resetConstraints - * @param {boolean} maintainOffset - */ - resetConstraints: function() { - - - // Maintain offsets if necessary - if (this.initPageX || this.initPageX === 0) { - // figure out how much this thing has moved - var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0; - var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0; - - this.setInitPosition(dx, dy); - - // This is the first time we have detected the element's position - } else { - this.setInitPosition(); - } - - if (this.constrainX) { - this.setXConstraint( this.leftConstraint, - this.rightConstraint, - this.xTickSize ); - } - - if (this.constrainY) { - this.setYConstraint( this.topConstraint, - this.bottomConstraint, - this.yTickSize ); - } - }, - - /** - * Normally the drag element is moved pixel by pixel, but we can specify - * that it move a number of pixels at a time. This method resolves the - * location when we have it set up like this. - * @method getTick - * @param {int} val where we want to place the object - * @param {int[]} tickArray sorted array of valid points - * @return {int} the closest tick - * @private - */ - getTick: function(val, tickArray) { - - if (!tickArray) { - // If tick interval is not defined, it is effectively 1 pixel, - // so we return the value passed to us. - return val; - } else if (tickArray[0] >= val) { - // The value is lower than the first tick, so we return the first - // tick. - return tickArray[0]; - } else { - for (var i=0, len=tickArray.length; i<len; ++i) { - var next = i + 1; - if (tickArray[next] && tickArray[next] >= val) { - var diff1 = val - tickArray[i]; - var diff2 = tickArray[next] - val; - return (diff2 > diff1) ? tickArray[i] : tickArray[next]; - } - } - - // The value is larger than the last tick, so we return the last - // tick. - return tickArray[tickArray.length - 1]; - } - }, - - /** - * toString method - * @method toString - * @return {string} string representation of the dd obj - */ - toString: function() { - return ("DragDrop " + this.id); - } - -}; - -})(); -/** - * A DragDrop implementation where the linked element follows the - * mouse cursor during a drag. - * @class DD - * @extends YAHOO.util.DragDrop - * @constructor - * @param {String} id the id of the linked element - * @param {String} sGroup the group of related DragDrop items - * @param {object} config an object containing configurable attributes - * Valid properties for DD: - * scroll - */ -YAHOO.util.DD = function(id, sGroup, config) { - if (id) { - this.init(id, sGroup, config); - } -}; - -YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop, { - - /** - * When set to true, the utility automatically tries to scroll the browser - * window wehn a drag and drop element is dragged near the viewport boundary. - * Defaults to true. - * @property scroll - * @type boolean - */ - scroll: true, - - /** - * Sets the pointer offset to the distance between the linked element's top - * left corner and the location the element was clicked - * @method autoOffset - * @param {int} iPageX the X coordinate of the click - * @param {int} iPageY the Y coordinate of the click - */ - autoOffset: function(iPageX, iPageY) { - var x = iPageX - this.startPageX; - var y = iPageY - this.startPageY; - this.setDelta(x, y); - }, - - /** - * Sets the pointer offset. You can call this directly to force the - * offset to be in a particular location (e.g., pass in 0,0 to set it - * to the center of the object, as done in YAHOO.widget.Slider) - * @method setDelta - * @param {int} iDeltaX the distance from the left - * @param {int} iDeltaY the distance from the top - */ - setDelta: function(iDeltaX, iDeltaY) { - this.deltaX = iDeltaX; - this.deltaY = iDeltaY; - }, - - /** - * Sets the drag element to the location of the mousedown or click event, - * maintaining the cursor location relative to the location on the element - * that was clicked. Override this if you want to place the element in a - * location other than where the cursor is. - * @method setDragElPos - * @param {int} iPageX the X coordinate of the mousedown or drag event - * @param {int} iPageY the Y coordinate of the mousedown or drag event - */ - setDragElPos: function(iPageX, iPageY) { - // the first time we do this, we are going to check to make sure - // the element has css positioning - - var el = this.getDragEl(); - this.alignElWithMouse(el, iPageX, iPageY); - }, - - /** - * Sets the element to the location of the mousedown or click event, - * maintaining the cursor location relative to the location on the element - * that was clicked. Override this if you want to place the element in a - * location other than where the cursor is. - * @method alignElWithMouse - * @param {HTMLElement} el the element to move - * @param {int} iPageX the X coordinate of the mousedown or drag event - * @param {int} iPageY the Y coordinate of the mousedown or drag event - */ - alignElWithMouse: function(el, iPageX, iPageY) { - var oCoord = this.getTargetCoord(iPageX, iPageY); - - if (!this.deltaSetXY) { - var aCoord = [oCoord.x, oCoord.y]; - YAHOO.util.Dom.setXY(el, aCoord); - var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 ); - var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 ); - - this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ]; - } else { - YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px"); - YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px"); - } - - this.cachePosition(oCoord.x, oCoord.y); - this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth); - }, - - /** - * Saves the most recent position so that we can reset the constraints and - * tick marks on-demand. We need to know this so that we can calculate the - * number of pixels the element is offset from its original position. - * @method cachePosition - * @param iPageX the current x position (optional, this just makes it so we - * don't have to look it up again) - * @param iPageY the current y position (optional, this just makes it so we - * don't have to look it up again) - */ - cachePosition: function(iPageX, iPageY) { - if (iPageX) { - this.lastPageX = iPageX; - this.lastPageY = iPageY; - } else { - var aCoord = YAHOO.util.Dom.getXY(this.getEl()); - this.lastPageX = aCoord[0]; - this.lastPageY = aCoord[1]; - } - }, - - /** - * Auto-scroll the window if the dragged object has been moved beyond the - * visible window boundary. - * @method autoScroll - * @param {int} x the drag element's x position - * @param {int} y the drag element's y position - * @param {int} h the height of the drag element - * @param {int} w the width of the drag element - * @private - */ - autoScroll: function(x, y, h, w) { - - if (this.scroll) { - // The client height - var clientH = this.DDM.getClientHeight(); - - // The client width - var clientW = this.DDM.getClientWidth(); - - // The amt scrolled down - var st = this.DDM.getScrollTop(); - - // The amt scrolled right - var sl = this.DDM.getScrollLeft(); - - // Location of the bottom of the element - var bot = h + y; - - // Location of the right of the element - var right = w + x; - - // The distance from the cursor to the bottom of the visible area, - // adjusted so that we don't scroll if the cursor is beyond the - // element drag constraints - var toBot = (clientH + st - y - this.deltaY); - - // The distance from the cursor to the right of the visible area - var toRight = (clientW + sl - x - this.deltaX); - - - // How close to the edge the cursor must be before we scroll - // var thresh = (document.all) ? 100 : 40; - var thresh = 40; - - // How many pixels to scroll per autoscroll op. This helps to reduce - // clunky scrolling. IE is more sensitive about this ... it needs this - // value to be higher. - var scrAmt = (document.all) ? 80 : 30; - - // Scroll down if we are near the bottom of the visible page and the - // obj extends below the crease - if ( bot > clientH && toBot < thresh ) { - window.scrollTo(sl, st + scrAmt); - } - - // Scroll up if the window is scrolled down and the top of the object - // goes above the top border - if ( y < st && st > 0 && y - st < thresh ) { - window.scrollTo(sl, st - scrAmt); - } - - // Scroll right if the obj is beyond the right border and the cursor is - // near the border. - if ( right > clientW && toRight < thresh ) { - window.scrollTo(sl + scrAmt, st); - } - - // Scroll left if the window has been scrolled to the right and the obj - // extends past the left border - if ( x < sl && sl > 0 && x - sl < thresh ) { - window.scrollTo(sl - scrAmt, st); - } - } - }, - - /** - * Finds the location the element should be placed if we want to move - * it to where the mouse location less the click offset would place us. - * @method getTargetCoord - * @param {int} iPageX the X coordinate of the click - * @param {int} iPageY the Y coordinate of the click - * @return an object that contains the coordinates (Object.x and Object.y) - * @private - */ - getTargetCoord: function(iPageX, iPageY) { - - - var x = iPageX - this.deltaX; - var y = iPageY - this.deltaY; - - if (this.constrainX) { - if (x < this.minX) { x = this.minX; } - if (x > this.maxX) { x = this.maxX; } - } - - if (this.constrainY) { - if (y < this.minY) { y = this.minY; } - if (y > this.maxY) { y = this.maxY; } - } - - x = this.getTick(x, this.xTicks); - y = this.getTick(y, this.yTicks); - - - return {x:x, y:y}; - }, - - /* - * Sets up config options specific to this class. Overrides - * YAHOO.util.DragDrop, but all versions of this method through the - * inheritance chain are called - */ - applyConfig: function() { - YAHOO.util.DD.superclass.applyConfig.call(this); - this.scroll = (this.config.scroll !== false); - }, - - /* - * Event that fires prior to the onMouseDown event. Overrides - * YAHOO.util.DragDrop. - */ - b4MouseDown: function(e) { - this.setStartPosition(); - // this.resetConstraints(); - this.autoOffset(YAHOO.util.Event.getPageX(e), - YAHOO.util.Event.getPageY(e)); - }, - - /* - * Event that fires prior to the onDrag event. Overrides - * YAHOO.util.DragDrop. - */ - b4Drag: function(e) { - this.setDragElPos(YAHOO.util.Event.getPageX(e), - YAHOO.util.Event.getPageY(e)); - }, - - toString: function() { - return ("DD " + this.id); - } - - ////////////////////////////////////////////////////////////////////////// - // Debugging ygDragDrop events that can be overridden - ////////////////////////////////////////////////////////////////////////// - /* - startDrag: function(x, y) { - }, - - onDrag: function(e) { - }, - - onDragEnter: function(e, id) { - }, - - onDragOver: function(e, id) { - }, - - onDragOut: function(e, id) { - }, - - onDragDrop: function(e, id) { - }, - - endDrag: function(e) { - } - - */ - -}); -/** - * A DragDrop implementation that inserts an empty, bordered div into - * the document that follows the cursor during drag operations. At the time of - * the click, the frame div is resized to the dimensions of the linked html - * element, and moved to the exact location of the linked element. - * - * References to the "frame" element refer to the single proxy element that - * was created to be dragged in place of all DDProxy elements on the - * page. - * - * @class DDProxy - * @extends YAHOO.util.DD - * @constructor - * @param {String} id the id of the linked html element - * @param {String} sGroup the group of related DragDrop objects - * @param {object} config an object containing configurable attributes - * Valid properties for DDProxy in addition to those in DragDrop: - * resizeFrame, centerFrame, dragElId - */ -YAHOO.util.DDProxy = function(id, sGroup, config) { - if (id) { - this.init(id, sGroup, config); - this.initFrame(); - } -}; - -/** - * The default drag frame div id - * @property YAHOO.util.DDProxy.dragElId - * @type String - * @static - */ -YAHOO.util.DDProxy.dragElId = "ygddfdiv"; - -YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD, { - - /** - * By default we resize the drag frame to be the same size as the element - * we want to drag (this is to get the frame effect). We can turn it off - * if we want a different behavior. - * @property resizeFrame - * @type boolean - */ - resizeFrame: true, - - /** - * By default the frame is positioned exactly where the drag element is, so - * we use the cursor offset provided by YAHOO.util.DD. Another option that works only if - * you do not have constraints on the obj is to have the drag frame centered - * around the cursor. Set centerFrame to true for this effect. - * @property centerFrame - * @type boolean - */ - centerFrame: false, - - /** - * Creates the proxy element if it does not yet exist - * @method createFrame - */ - createFrame: function() { - var self = this; - var body = document.body; - - if (!body || !body.firstChild) { - setTimeout( function() { self.createFrame(); }, 50 ); - return; - } - - var div = this.getDragEl(); - - if (!div) { - div = document.createElement("div"); - div.id = this.dragElId; - var s = div.style; - - s.position = "absolute"; - s.visibility = "hidden"; - s.cursor = "move"; - s.border = "2px solid #aaa"; - s.zIndex = 999; - - // appendChild can blow up IE if invoked prior to the window load event - // while rendering a table. It is possible there are other scenarios - // that would cause this to happen as well. - body.insertBefore(div, body.firstChild); - } - }, - - /** - * Initialization for the drag frame element. Must be called in the - * constructor of all subclasses - * @method initFrame - */ - initFrame: function() { - this.createFrame(); - }, - - applyConfig: function() { - YAHOO.util.DDProxy.superclass.applyConfig.call(this); - - this.resizeFrame = (this.config.resizeFrame !== false); - this.centerFrame = (this.config.centerFrame); - this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId); - }, - - /** - * Resizes the drag frame to the dimensions of the clicked object, positions - * it over the object, and finally displays it - * @method showFrame - * @param {int} iPageX X click position - * @param {int} iPageY Y click position - * @private - */ - showFrame: function(iPageX, iPageY) { - var el = this.getEl(); - var dragEl = this.getDragEl(); - var s = dragEl.style; - - this._resizeProxy(); - - if (this.centerFrame) { - this.setDelta( Math.round(parseInt(s.width, 10)/2), - Math.round(parseInt(s.height, 10)/2) ); - } - - this.setDragElPos(iPageX, iPageY); - - YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible"); - }, - - /** - * The proxy is automatically resized to the dimensions of the linked - * element when a drag is initiated, unless resizeFrame is set to false - * @method _resizeProxy - * @private - */ - _resizeProxy: function() { - if (this.resizeFrame) { - var DOM = YAHOO.util.Dom; - var el = this.getEl(); - var dragEl = this.getDragEl(); - - var bt = parseInt( DOM.getStyle(dragEl, "borderTopWidth" ), 10); - var br = parseInt( DOM.getStyle(dragEl, "borderRightWidth" ), 10); - var bb = parseInt( DOM.getStyle(dragEl, "borderBottomWidth" ), 10); - var bl = parseInt( DOM.getStyle(dragEl, "borderLeftWidth" ), 10); - - if (isNaN(bt)) { bt = 0; } - if (isNaN(br)) { br = 0; } - if (isNaN(bb)) { bb = 0; } - if (isNaN(bl)) { bl = 0; } - - - var newWidth = Math.max(0, el.offsetWidth - br - bl); - var newHeight = Math.max(0, el.offsetHeight - bt - bb); - - - DOM.setStyle( dragEl, "width", newWidth + "px" ); - DOM.setStyle( dragEl, "height", newHeight + "px" ); - } - }, - - // overrides YAHOO.util.DragDrop - b4MouseDown: function(e) { - this.setStartPosition(); - var x = YAHOO.util.Event.getPageX(e); - var y = YAHOO.util.Event.getPageY(e); - this.autoOffset(x, y); - this.setDragElPos(x, y); - }, - - // overrides YAHOO.util.DragDrop - b4StartDrag: function(x, y) { - // show the drag frame - this.showFrame(x, y); - }, - - // overrides YAHOO.util.DragDrop - b4EndDrag: function(e) { - YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden"); - }, - - // overrides YAHOO.util.DragDrop - // By default we try to move the element to the last location of the frame. - // This is so that the default behavior mirrors that of YAHOO.util.DD. - endDrag: function(e) { - var DOM = YAHOO.util.Dom; - var lel = this.getEl(); - var del = this.getDragEl(); - - // Show the drag frame briefly so we can get its position - // del.style.visibility = ""; - DOM.setStyle(del, "visibility", ""); - - // Hide the linked element before the move to get around a Safari - // rendering bug. - //lel.style.visibility = "hidden"; - DOM.setStyle(lel, "visibility", "hidden"); - YAHOO.util.DDM.moveToEl(lel, del); - //del.style.visibility = "hidden"; - DOM.setStyle(del, "visibility", "hidden"); - //lel.style.visibility = ""; - DOM.setStyle(lel, "visibility", ""); - }, - - toString: function() { - return ("DDProxy " + this.id); - } - -}); -/** - * A DragDrop implementation that does not move, but can be a drop - * target. You would get the same result by simply omitting implementation - * for the event callbacks, but this way we reduce the processing cost of the - * event listener and the callbacks. - * @class DDTarget - * @extends YAHOO.util.DragDrop - * @constructor - * @param {String} id the id of the element that is a drop target - * @param {String} sGroup the group of related DragDrop objects - * @param {object} config an object containing configurable attributes - * Valid properties for DDTarget in addition to those in - * DragDrop: - * none - */ -YAHOO.util.DDTarget = function(id, sGroup, config) { - if (id) { - this.initTarget(id, sGroup, config); - } -}; - -// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop(); -YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop, { - toString: function() { - return ("DDTarget " + this.id); - } -}); -YAHOO.register("dragdrop", YAHOO.util.DragDropMgr, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/element/README b/interface/web/js/yui/element/README deleted file mode 100644 index 1076b61a62..0000000000 --- a/interface/web/js/yui/element/README +++ /dev/null @@ -1,7 +0,0 @@ -Element Release Notes - -*** version 2.2.0 *** - -* beta introduction (broken out of TabView for general use) - - * The Element class provides a wrapper for HTMLElements in the DOM and makes simpler common tasks such as adding listeners, manipulating the DOM, and setting and getting attributes. diff --git a/interface/web/js/yui/element/element-beta-debug.js b/interface/web/js/yui/element/element-beta-debug.js deleted file mode 100644 index 810a5ffd8e..0000000000 --- a/interface/web/js/yui/element/element-beta-debug.js +++ /dev/null @@ -1,906 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * Provides Attribute configurations. - * @namespace YAHOO.util - * @class Attribute - * @constructor - * @param hash {Object} The intial Attribute. - * @param {YAHOO.util.AttributeProvider} The owner of the Attribute instance. - */ - -YAHOO.util.Attribute = function(hash, owner) { - if (owner) { - this.owner = owner; - this.configure(hash, true); - } -}; - -YAHOO.util.Attribute.prototype = { - /** - * The name of the attribute. - * @property name - * @type String - */ - name: undefined, - - /** - * The value of the attribute. - * @property value - * @type String - */ - value: null, - - /** - * The owner of the attribute. - * @property owner - * @type YAHOO.util.AttributeProvider - */ - owner: null, - - /** - * Whether or not the attribute is read only. - * @property readOnly - * @type Boolean - */ - readOnly: false, - - /** - * Whether or not the attribute can only be written once. - * @property writeOnce - * @type Boolean - */ - writeOnce: false, - - /** - * The attribute's initial configuration. - * @private - * @property _initialConfig - * @type Object - */ - _initialConfig: null, - - /** - * Whether or not the attribute's value has been set. - * @private - * @property _written - * @type Boolean - */ - _written: false, - - /** - * The method to use when setting the attribute's value. - * The method recieves the new value as the only argument. - * @property method - * @type Function - */ - method: null, - - /** - * The validator to use when setting the attribute's value. - * @property validator - * @type Function - * @return Boolean - */ - validator: null, - - /** - * Retrieves the current value of the attribute. - * @method getValue - * @return {any} The current value of the attribute. - */ - getValue: function() { - return this.value; - }, - - /** - * Sets the value of the attribute and fires beforeChange and change events. - * @method setValue - * @param {Any} value The value to apply to the attribute. - * @param {Boolean} silent If true the change events will not be fired. - * @return {Boolean} Whether or not the value was set. - */ - setValue: function(value, silent) { - var beforeRetVal; - var owner = this.owner; - var name = this.name; - - var event = { - type: name, - prevValue: this.getValue(), - newValue: value - }; - - if (this.readOnly || ( this.writeOnce && this._written) ) { - return false; // write not allowed - } - - if (this.validator && !this.validator.call(owner, value) ) { - return false; // invalid value - } - - if (!silent) { - beforeRetVal = owner.fireBeforeChangeEvent(event); - if (beforeRetVal === false) { - YAHOO.log('setValue ' + name + - 'cancelled by beforeChange event', 'info', 'Attribute'); - return false; - } - } - - if (this.method) { - this.method.call(owner, value); - } - - this.value = value; - this._written = true; - - event.type = name; - - if (!silent) { - this.owner.fireChangeEvent(event); - } - - return true; - }, - - /** - * Allows for configuring the Attribute's properties. - * @method configure - * @param {Object} map A key-value map of Attribute properties. - * @param {Boolean} init Whether or not this should become the initial config. - */ - configure: function(map, init) { - map = map || {}; - this._written = false; // reset writeOnce - this._initialConfig = this._initialConfig || {}; - - for (var key in map) { - if ( key && YAHOO.lang.hasOwnProperty(map, key) ) { - this[key] = map[key]; - if (init) { - this._initialConfig[key] = map[key]; - } - } - } - }, - - /** - * Resets the value to the initial config value. - * @method resetValue - * @return {Boolean} Whether or not the value was set. - */ - resetValue: function() { - return this.setValue(this._initialConfig.value); - }, - - /** - * Resets the attribute config to the initial config state. - * @method resetConfig - */ - resetConfig: function() { - this.configure(this._initialConfig); - }, - - /** - * Resets the value to the current value. - * Useful when values may have gotten out of sync with actual properties. - * @method refresh - * @return {Boolean} Whether or not the value was set. - */ - refresh: function(silent) { - this.setValue(this.value, silent); - } -}; - -(function() { - var Lang = YAHOO.util.Lang; - - /* - Copyright (c) 2006, Yahoo! Inc. All rights reserved. - Code licensed under the BSD License: - http://developer.yahoo.net/yui/license.txt - */ - - /** - * Provides and manages YAHOO.util.Attribute instances - * @namespace YAHOO.util - * @class AttributeProvider - * @uses YAHOO.util.EventProvider - */ - YAHOO.util.AttributeProvider = function() {}; - - YAHOO.util.AttributeProvider.prototype = { - - /** - * A key-value map of Attribute configurations - * @property _configs - * @protected (may be used by subclasses and augmentors) - * @private - * @type {Object} - */ - _configs: null, - /** - * Returns the current value of the attribute. - * @method get - * @param {String} key The attribute whose value will be returned. - */ - get: function(key){ - var configs = this._configs || {}; - var config = configs[key]; - - if (!config) { - YAHOO.log(key + ' not found', 'error', 'AttributeProvider'); - return undefined; - } - - return config.value; - }, - - /** - * Sets the value of a config. - * @method set - * @param {String} key The name of the attribute - * @param {Any} value The value to apply to the attribute - * @param {Boolean} silent Whether or not to suppress change events - * @return {Boolean} Whether or not the value was set. - */ - set: function(key, value, silent){ - var configs = this._configs || {}; - var config = configs[key]; - - if (!config) { - YAHOO.log('set failed: ' + key + ' not found', - 'error', 'AttributeProvider'); - return false; - } - - return config.setValue(value, silent); - }, - - /** - * Returns an array of attribute names. - * @method getAttributeKeys - * @return {Array} An array of attribute names. - */ - getAttributeKeys: function(){ - var configs = this._configs; - var keys = []; - var config; - for (var key in configs) { - config = configs[key]; - if ( Lang.hasOwnProperty(configs, key) && - !Lang.isUndefined(config) ) { - keys[keys.length] = key; - } - } - - return keys; - }, - - /** - * Sets multiple attribute values. - * @method setAttributes - * @param {Object} map A key-value map of attributes - * @param {Boolean} silent Whether or not to suppress change events - */ - setAttributes: function(map, silent){ - for (var key in map) { - if ( Lang.hasOwnProperty(map, key) ) { - this.set(key, map[key], silent); - } - } - }, - - /** - * Resets the specified attribute's value to its initial value. - * @method resetValue - * @param {String} key The name of the attribute - * @param {Boolean} silent Whether or not to suppress change events - * @return {Boolean} Whether or not the value was set - */ - resetValue: function(key, silent){ - var configs = this._configs || {}; - if (configs[key]) { - this.set(key, configs[key]._initialConfig.value, silent); - return true; - } - return false; - }, - - /** - * Sets the attribute's value to its current value. - * @method refresh - * @param {String | Array} key The attribute(s) to refresh - * @param {Boolean} silent Whether or not to suppress change events - */ - refresh: function(key, silent){ - var configs = this._configs; - - key = ( ( Lang.isString(key) ) ? [key] : key ) || - this.getAttributeKeys(); - - for (var i = 0, len = key.length; i < len; ++i) { - if ( // only set if there is a value and not null - configs[key[i]] && - ! Lang.isUndefined(configs[key[i]].value) && - ! Lang.isNull(configs[key[i]].value) ) { - configs[key[i]].refresh(silent); - } - } - }, - - /** - * Adds an Attribute to the AttributeProvider instance. - * @method register - * @param {String} key The attribute's name - * @param {Object} map A key-value map containing the - * attribute's properties. - * @deprecated Use setAttributeConfig - */ - register: function(key, map) { - this.setAttributeConfig(key, map); - }, - - - /** - * Returns the attribute's properties. - * @method getAttributeConfig - * @param {String} key The attribute's name - * @private - * @return {object} A key-value map containing all of the - * attribute's properties. - */ - getAttributeConfig: function(key) { - var configs = this._configs || {}; - var config = configs[key] || {}; - var map = {}; // returning a copy to prevent overrides - - for (key in config) { - if ( Lang.hasOwnProperty(config, key) ) { - map[key] = config[key]; - } - } - - return map; - }, - - /** - * Sets or updates an Attribute instance's properties. - * @method setAttributeConfig - * @param {String} key The attribute's name. - * @param {Object} map A key-value map of attribute properties - * @param {Boolean} init Whether or not this should become the intial config. - */ - setAttributeConfig: function(key, map, init) { - var configs = this._configs || {}; - map = map || {}; - if (!configs[key]) { - map.name = key; - configs[key] = new YAHOO.util.Attribute(map, this); - } else { - configs[key].configure(map, init); - } - }, - - /** - * Sets or updates an Attribute instance's properties. - * @method configureAttribute - * @param {String} key The attribute's name. - * @param {Object} map A key-value map of attribute properties - * @param {Boolean} init Whether or not this should become the intial config. - */ - configureAttribute: function(key, map, init) { - this.setAttributeConfig(key, map, init); - }, - - /** - * Resets an attribute to its intial configuration. - * @method resetAttributeConfig - * @param {String} key The attribute's name. - * @private - */ - resetAttributeConfig: function(key){ - var configs = this._configs || {}; - configs[key].resetConfig(); - }, - - /** - * Fires the attribute's beforeChange event. - * @method fireBeforeChangeEvent - * @param {String} key The attribute's name. - * @param {Obj} e The event object to pass to handlers. - */ - fireBeforeChangeEvent: function(e) { - var type = 'before'; - type += e.type.charAt(0).toUpperCase() + e.type.substr(1) + 'Change'; - e.type = type; - return this.fireEvent(e.type, e); - }, - - /** - * Fires the attribute's change event. - * @method fireChangeEvent - * @param {String} key The attribute's name. - * @param {Obj} e The event object to pass to the handlers. - */ - fireChangeEvent: function(e) { - e.type += 'Change'; - return this.fireEvent(e.type, e); - } - }; - - YAHOO.augment(YAHOO.util.AttributeProvider, YAHOO.util.EventProvider); -})(); - -(function() { -// internal shorthand -var Dom = YAHOO.util.Dom, - EventPublisher = YAHOO.util.EventPublisher, - AttributeProvider = YAHOO.util.AttributeProvider; - -/** - * Element provides an wrapper object to simplify adding - * event listeners, using dom methods, and managing attributes. - * @module element - * @namespace YAHOO.util - * @requires yahoo, dom, event - * @beta - */ - -/** - * Element provides an wrapper object to simplify adding - * event listeners, using dom methods, and managing attributes. - * @class Element - * @uses YAHOO.util.AttributeProvider - * @constructor - * @param el {HTMLElement | String} The html element that - * represents the Element. - * @param {Object} map A key-value map of initial config names and values - */ -YAHOO.util.Element = function(el, map) { - if (arguments.length) { - this.init(el, map); - } -}; - -YAHOO.util.Element.prototype = { - /** - * Dom events supported by the Element instance. - * @property DOM_EVENTS - * @type Object - */ - DOM_EVENTS: null, - - /** - * Wrapper for HTMLElement method. - * @method appendChild - * @param {Boolean} deep Whether or not to do a deep clone - */ - appendChild: function(child) { - child = child.get ? child.get('element') : child; - this.get('element').appendChild(child); - }, - - /** - * Wrapper for HTMLElement method. - * @method getElementsByTagName - * @param {String} tag The tagName to collect - */ - getElementsByTagName: function(tag) { - return this.get('element').getElementsByTagName(tag); - }, - - /** - * Wrapper for HTMLElement method. - * @method hasChildNodes - * @return {Boolean} Whether or not the element has childNodes - */ - hasChildNodes: function() { - return this.get('element').hasChildNodes(); - }, - - /** - * Wrapper for HTMLElement method. - * @method insertBefore - * @param {HTMLElement} element The HTMLElement to insert - * @param {HTMLElement} before The HTMLElement to insert - * the element before. - */ - insertBefore: function(element, before) { - element = element.get ? element.get('element') : element; - before = (before && before.get) ? before.get('element') : before; - - this.get('element').insertBefore(element, before); - }, - - /** - * Wrapper for HTMLElement method. - * @method removeChild - * @param {HTMLElement} child The HTMLElement to remove - */ - removeChild: function(child) { - child = child.get ? child.get('element') : child; - this.get('element').removeChild(child); - return true; - }, - - /** - * Wrapper for HTMLElement method. - * @method replaceChild - * @param {HTMLElement} newNode The HTMLElement to insert - * @param {HTMLElement} oldNode The HTMLElement to replace - */ - replaceChild: function(newNode, oldNode) { - newNode = newNode.get ? newNode.get('element') : newNode; - oldNode = oldNode.get ? oldNode.get('element') : oldNode; - return this.get('element').replaceChild(newNode, oldNode); - }, - - - /** - * Registers Element specific attributes. - * @method initAttributes - * @param {Object} map A key-value map of initial attribute configs - */ - initAttributes: function(map) { - map = map || {}; - var element = Dom.get(map.element) || null; - - /** - * The HTMLElement the Element instance refers to. - * @config element - * @type HTMLElement - */ - this.setAttributeConfig('element', { - value: element, - readOnly: true - }); - }, - - /** - * Adds a listener for the given event. These may be DOM or - * customEvent listeners. Any event that is fired via fireEvent - * can be listened for. All handlers receive an event object. - * @method addListener - * @param {String} type The name of the event to listen for - * @param {Function} fn The handler to call when the event fires - * @param {Any} obj A variable to pass to the handler - * @param {Object} scope The object to use for the scope of the handler - */ - addListener: function(type, fn, obj, scope) { - var el = this.get('element'); - var scope = scope || this; - - el = this.get('id') || el; - - if (!this._events[type]) { // create on the fly - if ( this.DOM_EVENTS[type] ) { - YAHOO.util.Event.addListener(el, type, function(e) { - if (e.srcElement && !e.target) { // supplement IE with target - e.target = e.srcElement; - } - this.fireEvent(type, e); - }, obj, scope); - } - - this.createEvent(type, this); - this._events[type] = true; - } - - this.subscribe.apply(this, arguments); // notify via customEvent - }, - - - /** - * Alias for addListener - * @method on - * @param {String} type The name of the event to listen for - * @param {Function} fn The function call when the event fires - * @param {Any} obj A variable to pass to the handler - * @param {Object} scope The object to use for the scope of the handler - */ - on: function() { this.addListener.apply(this, arguments); }, - - - /** - * Remove an event listener - * @method removeListener - * @param {String} type The name of the event to listen for - * @param {Function} fn The function call when the event fires - */ - removeListener: function(type, fn) { - this.unsubscribe.apply(this, arguments); - }, - - /** - * Wrapper for Dom method. - * @method addClass - * @param {String} className The className to add - */ - addClass: function(className) { - Dom.addClass(this.get('element'), className); - }, - - /** - * Wrapper for Dom method. - * @method getElementsByClassName - * @param {String} className The className to collect - * @param {String} tag (optional) The tag to use in - * conjunction with class name - * @return {Array} Array of HTMLElements - */ - getElementsByClassName: function(className, tag) { - return Dom.getElementsByClassName(className, tag, - this.get('element') ); - }, - - /** - * Wrapper for Dom method. - * @method hasClass - * @param {String} className The className to add - * @return {Boolean} Whether or not the element has the class name - */ - hasClass: function(className) { - return Dom.hasClass(this.get('element'), className); - }, - - /** - * Wrapper for Dom method. - * @method removeClass - * @param {String} className The className to remove - */ - removeClass: function(className) { - return Dom.removeClass(this.get('element'), className); - }, - - /** - * Wrapper for Dom method. - * @method replaceClass - * @param {String} oldClassName The className to replace - * @param {String} newClassName The className to add - */ - replaceClass: function(oldClassName, newClassName) { - return Dom.replaceClass(this.get('element'), - oldClassName, newClassName); - }, - - /** - * Wrapper for Dom method. - * @method setStyle - * @param {String} property The style property to set - * @param {String} value The value to apply to the style property - */ - setStyle: function(property, value) { - var el = this.get('element'); - if (!el) { - this._queue[this._queue.length] = ['setStyle', arguments]; - return false; - } - return Dom.setStyle(this.get('element'), property, value); - }, - - /** - * Wrapper for Dom method. - * @method getStyle - * @param {String} property The style property to retrieve - * @return {String} The current value of the property - */ - getStyle: function(property) { - return Dom.getStyle(this.get('element'), property); - }, - - /** - * Apply any queued set calls. - * @method fireQueue - */ - fireQueue: function() { - var queue = this._queue; - for (var i = 0, len = queue.length; i < len; ++i) { - this[queue[i][0]].apply(this, queue[i][1]); - } - }, - - /** - * Appends the HTMLElement into either the supplied parentNode. - * @method appendTo - * @param {HTMLElement | Element} parentNode The node to append to - * @param {HTMLElement | Element} before An optional node to insert before - */ - appendTo: function(parent, before) { - parent = (parent.get) ? parent.get('element') : Dom.get(parent); - - this.fireEvent('beforeAppendTo', { - type: 'beforeAppendTo', - target: parent - }); - - - before = (before && before.get) ? - before.get('element') : Dom.get(before); - var element = this.get('element'); - - if (!element) { - YAHOO.log('appendTo failed: element not available', - 'error', 'Element'); - return false; - } - - if (!parent) { - YAHOO.log('appendTo failed: parent not available', - 'error', 'Element'); - return false; - } - - if (element.parent != parent) { - if (before) { - parent.insertBefore(element, before); - } else { - parent.appendChild(element); - } - } - - YAHOO.log(element + 'appended to ' + parent); - - this.fireEvent('appendTo', { - type: 'appendTo', - target: parent - }); - }, - - get: function(key) { - var configs = this._configs || {}; - var el = configs.element; // avoid loop due to 'element' - if (el && !configs[key] && !YAHOO.lang.isUndefined(el.value[key]) ) { - return el.value[key]; - } - - return AttributeProvider.prototype.get.call(this, key); - }, - - set: function(key, value, silent) { - var el = this.get('element'); - if (!el) { - this._queue[this._queue.length] = ['set', arguments]; - if (this._configs[key]) { - this._configs[key].value = value; // so "get" works while queueing - - } - return; - } - - // set it on the element if not configured and is an HTML attribute - if ( !this._configs[key] && !YAHOO.lang.isUndefined(el[key]) ) { - _registerHTMLAttr.call(this, key); - } - - return AttributeProvider.prototype.set.apply(this, arguments); - }, - - setAttributeConfig: function(key, map, init) { - var el = this.get('element'); - - if (el && !this._configs[key] && !YAHOO.lang.isUndefined(el[key]) ) { - _registerHTMLAttr.call(this, key, map); - } else { - AttributeProvider.prototype.setAttributeConfig.apply(this, arguments); - } - }, - - getAttributeKeys: function() { - var el = this.get('element'); - var keys = AttributeProvider.prototype.getAttributeKeys.call(this); - - //add any unconfigured element keys - for (var key in el) { - if (!this._configs[key]) { - keys[key] = keys[key] || el[key]; - } - } - - return keys; - }, - - init: function(el, attr) { - this._queue = this._queue || []; - this._events = this._events || {}; - this._configs = this._configs || {}; - attr = attr || {}; - attr.element = attr.element || el || null; - - this.DOM_EVENTS = { - 'click': true, - 'keydown': true, - 'keypress': true, - 'keyup': true, - 'mousedown': true, - 'mousemove': true, - 'mouseout': true, - 'mouseover': true, - 'mouseup': true - }; - - var readyHandler = function() { - this.initAttributes(attr); - this.setAttributes(attr, true); - this.fireQueue(); - this.fireEvent('contentReady', { - type: 'contentReady', - target: attr.element - }); - }; - - if ( YAHOO.lang.isString(el) ) { - _registerHTMLAttr.call(this, 'id', { value: el }); - YAHOO.util.Event.onAvailable(el, function() { - attr.element = Dom.get(el); - this.fireEvent('available', { - type: 'available', - target: attr.element - }); - }, this, true); - - YAHOO.util.Event.onContentReady(el, function() { - readyHandler.call(this); - }, this, true); - } else { - readyHandler.call(this); - } - } -}; - -/** - * Sets the value of the property and fires beforeChange and change events. - * @private - * @method _registerHTMLAttr - * @param {YAHOO.util.Element} element The Element instance to - * register the config to. - * @param {String} key The name of the config to register - * @param {Object} map A key-value map of the config's params - */ -var _registerHTMLAttr = function(key, map) { - var el = this.get('element'); - map = map || {}; - map.name = key; - map.method = map.method || function(value) { - el[key] = value; - }; - map.value = map.value || el[key]; - this._configs[key] = new YAHOO.util.Attribute(map, this); -}; - -/** - * Fires when the Element's HTMLElement can be retrieved by Id. - * <p>See: <a href="#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> available<br> - * <code><HTMLElement> - * target</code> the HTMLElement bound to this Element instance<br> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var target = e.target};<br> - * myTabs.addListener('available', handler);</code></p> - * @event available - */ - -/** - * Fires when the Element's HTMLElement subtree is rendered. - * <p>See: <a href="#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> contentReady<br> - * <code><HTMLElement> - * target</code> the HTMLElement bound to this Element instance<br> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var target = e.target};<br> - * myTabs.addListener('contentReady', handler);</code></p> - * @event contentReady - */ - - -YAHOO.augment(YAHOO.util.Element, AttributeProvider); -})(); - -YAHOO.register("element", YAHOO.util.Element, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/element/element-beta-min.js b/interface/web/js/yui/element/element-beta-min.js deleted file mode 100644 index d260934c07..0000000000 --- a/interface/web/js/yui/element/element-beta-min.js +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -YAHOO.util.Attribute=function(hash,owner){if(owner){this.owner=owner;this.configure(hash,true);}};YAHOO.util.Attribute.prototype={name:undefined,value:null,owner:null,readOnly:false,writeOnce:false,_initialConfig:null,_written:false,method:null,validator:null,getValue:function(){return this.value;},setValue:function(value,silent){var beforeRetVal;var owner=this.owner;var name=this.name;var event={type:name,prevValue:this.getValue(),newValue:value};if(this.readOnly||(this.writeOnce&&this._written)){return false;} -if(this.validator&&!this.validator.call(owner,value)){return false;} -if(!silent){beforeRetVal=owner.fireBeforeChangeEvent(event);if(beforeRetVal===false){return false;}} -if(this.method){this.method.call(owner,value);} -this.value=value;this._written=true;event.type=name;if(!silent){this.owner.fireChangeEvent(event);} -return true;},configure:function(map,init){map=map||{};this._written=false;this._initialConfig=this._initialConfig||{};for(var key in map){if(key&&YAHOO.lang.hasOwnProperty(map,key)){this[key]=map[key];if(init){this._initialConfig[key]=map[key];}}}},resetValue:function(){return this.setValue(this._initialConfig.value);},resetConfig:function(){this.configure(this._initialConfig);},refresh:function(silent){this.setValue(this.value,silent);}};(function(){var Lang=YAHOO.util.Lang;YAHOO.util.AttributeProvider=function(){};YAHOO.util.AttributeProvider.prototype={_configs:null,get:function(key){var configs=this._configs||{};var config=configs[key];if(!config){return undefined;} -return config.value;},set:function(key,value,silent){var configs=this._configs||{};var config=configs[key];if(!config){return false;} -return config.setValue(value,silent);},getAttributeKeys:function(){var configs=this._configs;var keys=[];var config;for(var key in configs){config=configs[key];if(Lang.hasOwnProperty(configs,key)&&!Lang.isUndefined(config)){keys[keys.length]=key;}} -return keys;},setAttributes:function(map,silent){for(var key in map){if(Lang.hasOwnProperty(map,key)){this.set(key,map[key],silent);}}},resetValue:function(key,silent){var configs=this._configs||{};if(configs[key]){this.set(key,configs[key]._initialConfig.value,silent);return true;} -return false;},refresh:function(key,silent){var configs=this._configs;key=((Lang.isString(key))?[key]:key)||this.getAttributeKeys();for(var i=0,len=key.length;i<len;++i){if(configs[key[i]]&&!Lang.isUndefined(configs[key[i]].value)&&!Lang.isNull(configs[key[i]].value)){configs[key[i]].refresh(silent);}}},register:function(key,map){this.setAttributeConfig(key,map);},getAttributeConfig:function(key){var configs=this._configs||{};var config=configs[key]||{};var map={};for(key in config){if(Lang.hasOwnProperty(config,key)){map[key]=config[key];}} -return map;},setAttributeConfig:function(key,map,init){var configs=this._configs||{};map=map||{};if(!configs[key]){map.name=key;configs[key]=new YAHOO.util.Attribute(map,this);}else{configs[key].configure(map,init);}},configureAttribute:function(key,map,init){this.setAttributeConfig(key,map,init);},resetAttributeConfig:function(key){var configs=this._configs||{};configs[key].resetConfig();},fireBeforeChangeEvent:function(e){var type='before';type+=e.type.charAt(0).toUpperCase()+e.type.substr(1)+'Change';e.type=type;return this.fireEvent(e.type,e);},fireChangeEvent:function(e){e.type+='Change';return this.fireEvent(e.type,e);}};YAHOO.augment(YAHOO.util.AttributeProvider,YAHOO.util.EventProvider);})();(function(){var Dom=YAHOO.util.Dom,EventPublisher=YAHOO.util.EventPublisher,AttributeProvider=YAHOO.util.AttributeProvider;YAHOO.util.Element=function(el,map){if(arguments.length){this.init(el,map);}};YAHOO.util.Element.prototype={DOM_EVENTS:null,appendChild:function(child){child=child.get?child.get('element'):child;this.get('element').appendChild(child);},getElementsByTagName:function(tag){return this.get('element').getElementsByTagName(tag);},hasChildNodes:function(){return this.get('element').hasChildNodes();},insertBefore:function(element,before){element=element.get?element.get('element'):element;before=(before&&before.get)?before.get('element'):before;this.get('element').insertBefore(element,before);},removeChild:function(child){child=child.get?child.get('element'):child;this.get('element').removeChild(child);return true;},replaceChild:function(newNode,oldNode){newNode=newNode.get?newNode.get('element'):newNode;oldNode=oldNode.get?oldNode.get('element'):oldNode;return this.get('element').replaceChild(newNode,oldNode);},initAttributes:function(map){map=map||{};var element=Dom.get(map.element)||null;this.setAttributeConfig('element',{value:element,readOnly:true});},addListener:function(type,fn,obj,scope){var el=this.get('element');var scope=scope||this;el=this.get('id')||el;if(!this._events[type]){if(this.DOM_EVENTS[type]){YAHOO.util.Event.addListener(el,type,function(e){if(e.srcElement&&!e.target){e.target=e.srcElement;} -this.fireEvent(type,e);},obj,scope);} -this.createEvent(type,this);this._events[type]=true;} -this.subscribe.apply(this,arguments);},on:function(){this.addListener.apply(this,arguments);},removeListener:function(type,fn){this.unsubscribe.apply(this,arguments);},addClass:function(className){Dom.addClass(this.get('element'),className);},getElementsByClassName:function(className,tag){return Dom.getElementsByClassName(className,tag,this.get('element'));},hasClass:function(className){return Dom.hasClass(this.get('element'),className);},removeClass:function(className){return Dom.removeClass(this.get('element'),className);},replaceClass:function(oldClassName,newClassName){return Dom.replaceClass(this.get('element'),oldClassName,newClassName);},setStyle:function(property,value){var el=this.get('element');if(!el){this._queue[this._queue.length]=['setStyle',arguments];return false;} -return Dom.setStyle(this.get('element'),property,value);},getStyle:function(property){return Dom.getStyle(this.get('element'),property);},fireQueue:function(){var queue=this._queue;for(var i=0,len=queue.length;i<len;++i){this[queue[i][0]].apply(this,queue[i][1]);}},appendTo:function(parent,before){parent=(parent.get)?parent.get('element'):Dom.get(parent);this.fireEvent('beforeAppendTo',{type:'beforeAppendTo',target:parent});before=(before&&before.get)?before.get('element'):Dom.get(before);var element=this.get('element');if(!element){return false;} -if(!parent){return false;} -if(element.parent!=parent){if(before){parent.insertBefore(element,before);}else{parent.appendChild(element);}} -this.fireEvent('appendTo',{type:'appendTo',target:parent});},get:function(key){var configs=this._configs||{};var el=configs.element;if(el&&!configs[key]&&!YAHOO.lang.isUndefined(el.value[key])){return el.value[key];} -return AttributeProvider.prototype.get.call(this,key);},set:function(key,value,silent){var el=this.get('element');if(!el){this._queue[this._queue.length]=['set',arguments];if(this._configs[key]){this._configs[key].value=value;} -return;} -if(!this._configs[key]&&!YAHOO.lang.isUndefined(el[key])){_registerHTMLAttr.call(this,key);} -return AttributeProvider.prototype.set.apply(this,arguments);},setAttributeConfig:function(key,map,init){var el=this.get('element');if(el&&!this._configs[key]&&!YAHOO.lang.isUndefined(el[key])){_registerHTMLAttr.call(this,key,map);}else{AttributeProvider.prototype.setAttributeConfig.apply(this,arguments);}},getAttributeKeys:function(){var el=this.get('element');var keys=AttributeProvider.prototype.getAttributeKeys.call(this);for(var key in el){if(!this._configs[key]){keys[key]=keys[key]||el[key];}} -return keys;},init:function(el,attr){this._queue=this._queue||[];this._events=this._events||{};this._configs=this._configs||{};attr=attr||{};attr.element=attr.element||el||null;this.DOM_EVENTS={'click':true,'keydown':true,'keypress':true,'keyup':true,'mousedown':true,'mousemove':true,'mouseout':true,'mouseover':true,'mouseup':true};var readyHandler=function(){this.initAttributes(attr);this.setAttributes(attr,true);this.fireQueue();this.fireEvent('contentReady',{type:'contentReady',target:attr.element});};if(YAHOO.lang.isString(el)){_registerHTMLAttr.call(this,'id',{value:el});YAHOO.util.Event.onAvailable(el,function(){attr.element=Dom.get(el);this.fireEvent('available',{type:'available',target:attr.element});},this,true);YAHOO.util.Event.onContentReady(el,function(){readyHandler.call(this);},this,true);}else{readyHandler.call(this);}}};var _registerHTMLAttr=function(key,map){var el=this.get('element');map=map||{};map.name=key;map.method=map.method||function(value){el[key]=value;};map.value=map.value||el[key];this._configs[key]=new YAHOO.util.Attribute(map,this);};YAHOO.augment(YAHOO.util.Element,AttributeProvider);})();YAHOO.register("element",YAHOO.util.Element,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/element/element-beta.js b/interface/web/js/yui/element/element-beta.js deleted file mode 100644 index bf4d408095..0000000000 --- a/interface/web/js/yui/element/element-beta.js +++ /dev/null @@ -1,896 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * Provides Attribute configurations. - * @namespace YAHOO.util - * @class Attribute - * @constructor - * @param hash {Object} The intial Attribute. - * @param {YAHOO.util.AttributeProvider} The owner of the Attribute instance. - */ - -YAHOO.util.Attribute = function(hash, owner) { - if (owner) { - this.owner = owner; - this.configure(hash, true); - } -}; - -YAHOO.util.Attribute.prototype = { - /** - * The name of the attribute. - * @property name - * @type String - */ - name: undefined, - - /** - * The value of the attribute. - * @property value - * @type String - */ - value: null, - - /** - * The owner of the attribute. - * @property owner - * @type YAHOO.util.AttributeProvider - */ - owner: null, - - /** - * Whether or not the attribute is read only. - * @property readOnly - * @type Boolean - */ - readOnly: false, - - /** - * Whether or not the attribute can only be written once. - * @property writeOnce - * @type Boolean - */ - writeOnce: false, - - /** - * The attribute's initial configuration. - * @private - * @property _initialConfig - * @type Object - */ - _initialConfig: null, - - /** - * Whether or not the attribute's value has been set. - * @private - * @property _written - * @type Boolean - */ - _written: false, - - /** - * The method to use when setting the attribute's value. - * The method recieves the new value as the only argument. - * @property method - * @type Function - */ - method: null, - - /** - * The validator to use when setting the attribute's value. - * @property validator - * @type Function - * @return Boolean - */ - validator: null, - - /** - * Retrieves the current value of the attribute. - * @method getValue - * @return {any} The current value of the attribute. - */ - getValue: function() { - return this.value; - }, - - /** - * Sets the value of the attribute and fires beforeChange and change events. - * @method setValue - * @param {Any} value The value to apply to the attribute. - * @param {Boolean} silent If true the change events will not be fired. - * @return {Boolean} Whether or not the value was set. - */ - setValue: function(value, silent) { - var beforeRetVal; - var owner = this.owner; - var name = this.name; - - var event = { - type: name, - prevValue: this.getValue(), - newValue: value - }; - - if (this.readOnly || ( this.writeOnce && this._written) ) { - return false; // write not allowed - } - - if (this.validator && !this.validator.call(owner, value) ) { - return false; // invalid value - } - - if (!silent) { - beforeRetVal = owner.fireBeforeChangeEvent(event); - if (beforeRetVal === false) { - return false; - } - } - - if (this.method) { - this.method.call(owner, value); - } - - this.value = value; - this._written = true; - - event.type = name; - - if (!silent) { - this.owner.fireChangeEvent(event); - } - - return true; - }, - - /** - * Allows for configuring the Attribute's properties. - * @method configure - * @param {Object} map A key-value map of Attribute properties. - * @param {Boolean} init Whether or not this should become the initial config. - */ - configure: function(map, init) { - map = map || {}; - this._written = false; // reset writeOnce - this._initialConfig = this._initialConfig || {}; - - for (var key in map) { - if ( key && YAHOO.lang.hasOwnProperty(map, key) ) { - this[key] = map[key]; - if (init) { - this._initialConfig[key] = map[key]; - } - } - } - }, - - /** - * Resets the value to the initial config value. - * @method resetValue - * @return {Boolean} Whether or not the value was set. - */ - resetValue: function() { - return this.setValue(this._initialConfig.value); - }, - - /** - * Resets the attribute config to the initial config state. - * @method resetConfig - */ - resetConfig: function() { - this.configure(this._initialConfig); - }, - - /** - * Resets the value to the current value. - * Useful when values may have gotten out of sync with actual properties. - * @method refresh - * @return {Boolean} Whether or not the value was set. - */ - refresh: function(silent) { - this.setValue(this.value, silent); - } -}; - -(function() { - var Lang = YAHOO.util.Lang; - - /* - Copyright (c) 2006, Yahoo! Inc. All rights reserved. - Code licensed under the BSD License: - http://developer.yahoo.net/yui/license.txt - */ - - /** - * Provides and manages YAHOO.util.Attribute instances - * @namespace YAHOO.util - * @class AttributeProvider - * @uses YAHOO.util.EventProvider - */ - YAHOO.util.AttributeProvider = function() {}; - - YAHOO.util.AttributeProvider.prototype = { - - /** - * A key-value map of Attribute configurations - * @property _configs - * @protected (may be used by subclasses and augmentors) - * @private - * @type {Object} - */ - _configs: null, - /** - * Returns the current value of the attribute. - * @method get - * @param {String} key The attribute whose value will be returned. - */ - get: function(key){ - var configs = this._configs || {}; - var config = configs[key]; - - if (!config) { - return undefined; - } - - return config.value; - }, - - /** - * Sets the value of a config. - * @method set - * @param {String} key The name of the attribute - * @param {Any} value The value to apply to the attribute - * @param {Boolean} silent Whether or not to suppress change events - * @return {Boolean} Whether or not the value was set. - */ - set: function(key, value, silent){ - var configs = this._configs || {}; - var config = configs[key]; - - if (!config) { - return false; - } - - return config.setValue(value, silent); - }, - - /** - * Returns an array of attribute names. - * @method getAttributeKeys - * @return {Array} An array of attribute names. - */ - getAttributeKeys: function(){ - var configs = this._configs; - var keys = []; - var config; - for (var key in configs) { - config = configs[key]; - if ( Lang.hasOwnProperty(configs, key) && - !Lang.isUndefined(config) ) { - keys[keys.length] = key; - } - } - - return keys; - }, - - /** - * Sets multiple attribute values. - * @method setAttributes - * @param {Object} map A key-value map of attributes - * @param {Boolean} silent Whether or not to suppress change events - */ - setAttributes: function(map, silent){ - for (var key in map) { - if ( Lang.hasOwnProperty(map, key) ) { - this.set(key, map[key], silent); - } - } - }, - - /** - * Resets the specified attribute's value to its initial value. - * @method resetValue - * @param {String} key The name of the attribute - * @param {Boolean} silent Whether or not to suppress change events - * @return {Boolean} Whether or not the value was set - */ - resetValue: function(key, silent){ - var configs = this._configs || {}; - if (configs[key]) { - this.set(key, configs[key]._initialConfig.value, silent); - return true; - } - return false; - }, - - /** - * Sets the attribute's value to its current value. - * @method refresh - * @param {String | Array} key The attribute(s) to refresh - * @param {Boolean} silent Whether or not to suppress change events - */ - refresh: function(key, silent){ - var configs = this._configs; - - key = ( ( Lang.isString(key) ) ? [key] : key ) || - this.getAttributeKeys(); - - for (var i = 0, len = key.length; i < len; ++i) { - if ( // only set if there is a value and not null - configs[key[i]] && - ! Lang.isUndefined(configs[key[i]].value) && - ! Lang.isNull(configs[key[i]].value) ) { - configs[key[i]].refresh(silent); - } - } - }, - - /** - * Adds an Attribute to the AttributeProvider instance. - * @method register - * @param {String} key The attribute's name - * @param {Object} map A key-value map containing the - * attribute's properties. - * @deprecated Use setAttributeConfig - */ - register: function(key, map) { - this.setAttributeConfig(key, map); - }, - - - /** - * Returns the attribute's properties. - * @method getAttributeConfig - * @param {String} key The attribute's name - * @private - * @return {object} A key-value map containing all of the - * attribute's properties. - */ - getAttributeConfig: function(key) { - var configs = this._configs || {}; - var config = configs[key] || {}; - var map = {}; // returning a copy to prevent overrides - - for (key in config) { - if ( Lang.hasOwnProperty(config, key) ) { - map[key] = config[key]; - } - } - - return map; - }, - - /** - * Sets or updates an Attribute instance's properties. - * @method setAttributeConfig - * @param {String} key The attribute's name. - * @param {Object} map A key-value map of attribute properties - * @param {Boolean} init Whether or not this should become the intial config. - */ - setAttributeConfig: function(key, map, init) { - var configs = this._configs || {}; - map = map || {}; - if (!configs[key]) { - map.name = key; - configs[key] = new YAHOO.util.Attribute(map, this); - } else { - configs[key].configure(map, init); - } - }, - - /** - * Sets or updates an Attribute instance's properties. - * @method configureAttribute - * @param {String} key The attribute's name. - * @param {Object} map A key-value map of attribute properties - * @param {Boolean} init Whether or not this should become the intial config. - */ - configureAttribute: function(key, map, init) { - this.setAttributeConfig(key, map, init); - }, - - /** - * Resets an attribute to its intial configuration. - * @method resetAttributeConfig - * @param {String} key The attribute's name. - * @private - */ - resetAttributeConfig: function(key){ - var configs = this._configs || {}; - configs[key].resetConfig(); - }, - - /** - * Fires the attribute's beforeChange event. - * @method fireBeforeChangeEvent - * @param {String} key The attribute's name. - * @param {Obj} e The event object to pass to handlers. - */ - fireBeforeChangeEvent: function(e) { - var type = 'before'; - type += e.type.charAt(0).toUpperCase() + e.type.substr(1) + 'Change'; - e.type = type; - return this.fireEvent(e.type, e); - }, - - /** - * Fires the attribute's change event. - * @method fireChangeEvent - * @param {String} key The attribute's name. - * @param {Obj} e The event object to pass to the handlers. - */ - fireChangeEvent: function(e) { - e.type += 'Change'; - return this.fireEvent(e.type, e); - } - }; - - YAHOO.augment(YAHOO.util.AttributeProvider, YAHOO.util.EventProvider); -})(); - -(function() { -// internal shorthand -var Dom = YAHOO.util.Dom, - EventPublisher = YAHOO.util.EventPublisher, - AttributeProvider = YAHOO.util.AttributeProvider; - -/** - * Element provides an wrapper object to simplify adding - * event listeners, using dom methods, and managing attributes. - * @module element - * @namespace YAHOO.util - * @requires yahoo, dom, event - * @beta - */ - -/** - * Element provides an wrapper object to simplify adding - * event listeners, using dom methods, and managing attributes. - * @class Element - * @uses YAHOO.util.AttributeProvider - * @constructor - * @param el {HTMLElement | String} The html element that - * represents the Element. - * @param {Object} map A key-value map of initial config names and values - */ -YAHOO.util.Element = function(el, map) { - if (arguments.length) { - this.init(el, map); - } -}; - -YAHOO.util.Element.prototype = { - /** - * Dom events supported by the Element instance. - * @property DOM_EVENTS - * @type Object - */ - DOM_EVENTS: null, - - /** - * Wrapper for HTMLElement method. - * @method appendChild - * @param {Boolean} deep Whether or not to do a deep clone - */ - appendChild: function(child) { - child = child.get ? child.get('element') : child; - this.get('element').appendChild(child); - }, - - /** - * Wrapper for HTMLElement method. - * @method getElementsByTagName - * @param {String} tag The tagName to collect - */ - getElementsByTagName: function(tag) { - return this.get('element').getElementsByTagName(tag); - }, - - /** - * Wrapper for HTMLElement method. - * @method hasChildNodes - * @return {Boolean} Whether or not the element has childNodes - */ - hasChildNodes: function() { - return this.get('element').hasChildNodes(); - }, - - /** - * Wrapper for HTMLElement method. - * @method insertBefore - * @param {HTMLElement} element The HTMLElement to insert - * @param {HTMLElement} before The HTMLElement to insert - * the element before. - */ - insertBefore: function(element, before) { - element = element.get ? element.get('element') : element; - before = (before && before.get) ? before.get('element') : before; - - this.get('element').insertBefore(element, before); - }, - - /** - * Wrapper for HTMLElement method. - * @method removeChild - * @param {HTMLElement} child The HTMLElement to remove - */ - removeChild: function(child) { - child = child.get ? child.get('element') : child; - this.get('element').removeChild(child); - return true; - }, - - /** - * Wrapper for HTMLElement method. - * @method replaceChild - * @param {HTMLElement} newNode The HTMLElement to insert - * @param {HTMLElement} oldNode The HTMLElement to replace - */ - replaceChild: function(newNode, oldNode) { - newNode = newNode.get ? newNode.get('element') : newNode; - oldNode = oldNode.get ? oldNode.get('element') : oldNode; - return this.get('element').replaceChild(newNode, oldNode); - }, - - - /** - * Registers Element specific attributes. - * @method initAttributes - * @param {Object} map A key-value map of initial attribute configs - */ - initAttributes: function(map) { - map = map || {}; - var element = Dom.get(map.element) || null; - - /** - * The HTMLElement the Element instance refers to. - * @config element - * @type HTMLElement - */ - this.setAttributeConfig('element', { - value: element, - readOnly: true - }); - }, - - /** - * Adds a listener for the given event. These may be DOM or - * customEvent listeners. Any event that is fired via fireEvent - * can be listened for. All handlers receive an event object. - * @method addListener - * @param {String} type The name of the event to listen for - * @param {Function} fn The handler to call when the event fires - * @param {Any} obj A variable to pass to the handler - * @param {Object} scope The object to use for the scope of the handler - */ - addListener: function(type, fn, obj, scope) { - var el = this.get('element'); - var scope = scope || this; - - el = this.get('id') || el; - - if (!this._events[type]) { // create on the fly - if ( this.DOM_EVENTS[type] ) { - YAHOO.util.Event.addListener(el, type, function(e) { - if (e.srcElement && !e.target) { // supplement IE with target - e.target = e.srcElement; - } - this.fireEvent(type, e); - }, obj, scope); - } - - this.createEvent(type, this); - this._events[type] = true; - } - - this.subscribe.apply(this, arguments); // notify via customEvent - }, - - - /** - * Alias for addListener - * @method on - * @param {String} type The name of the event to listen for - * @param {Function} fn The function call when the event fires - * @param {Any} obj A variable to pass to the handler - * @param {Object} scope The object to use for the scope of the handler - */ - on: function() { this.addListener.apply(this, arguments); }, - - - /** - * Remove an event listener - * @method removeListener - * @param {String} type The name of the event to listen for - * @param {Function} fn The function call when the event fires - */ - removeListener: function(type, fn) { - this.unsubscribe.apply(this, arguments); - }, - - /** - * Wrapper for Dom method. - * @method addClass - * @param {String} className The className to add - */ - addClass: function(className) { - Dom.addClass(this.get('element'), className); - }, - - /** - * Wrapper for Dom method. - * @method getElementsByClassName - * @param {String} className The className to collect - * @param {String} tag (optional) The tag to use in - * conjunction with class name - * @return {Array} Array of HTMLElements - */ - getElementsByClassName: function(className, tag) { - return Dom.getElementsByClassName(className, tag, - this.get('element') ); - }, - - /** - * Wrapper for Dom method. - * @method hasClass - * @param {String} className The className to add - * @return {Boolean} Whether or not the element has the class name - */ - hasClass: function(className) { - return Dom.hasClass(this.get('element'), className); - }, - - /** - * Wrapper for Dom method. - * @method removeClass - * @param {String} className The className to remove - */ - removeClass: function(className) { - return Dom.removeClass(this.get('element'), className); - }, - - /** - * Wrapper for Dom method. - * @method replaceClass - * @param {String} oldClassName The className to replace - * @param {String} newClassName The className to add - */ - replaceClass: function(oldClassName, newClassName) { - return Dom.replaceClass(this.get('element'), - oldClassName, newClassName); - }, - - /** - * Wrapper for Dom method. - * @method setStyle - * @param {String} property The style property to set - * @param {String} value The value to apply to the style property - */ - setStyle: function(property, value) { - var el = this.get('element'); - if (!el) { - this._queue[this._queue.length] = ['setStyle', arguments]; - return false; - } - return Dom.setStyle(this.get('element'), property, value); - }, - - /** - * Wrapper for Dom method. - * @method getStyle - * @param {String} property The style property to retrieve - * @return {String} The current value of the property - */ - getStyle: function(property) { - return Dom.getStyle(this.get('element'), property); - }, - - /** - * Apply any queued set calls. - * @method fireQueue - */ - fireQueue: function() { - var queue = this._queue; - for (var i = 0, len = queue.length; i < len; ++i) { - this[queue[i][0]].apply(this, queue[i][1]); - } - }, - - /** - * Appends the HTMLElement into either the supplied parentNode. - * @method appendTo - * @param {HTMLElement | Element} parentNode The node to append to - * @param {HTMLElement | Element} before An optional node to insert before - */ - appendTo: function(parent, before) { - parent = (parent.get) ? parent.get('element') : Dom.get(parent); - - this.fireEvent('beforeAppendTo', { - type: 'beforeAppendTo', - target: parent - }); - - - before = (before && before.get) ? - before.get('element') : Dom.get(before); - var element = this.get('element'); - - if (!element) { - return false; - } - - if (!parent) { - return false; - } - - if (element.parent != parent) { - if (before) { - parent.insertBefore(element, before); - } else { - parent.appendChild(element); - } - } - - - this.fireEvent('appendTo', { - type: 'appendTo', - target: parent - }); - }, - - get: function(key) { - var configs = this._configs || {}; - var el = configs.element; // avoid loop due to 'element' - if (el && !configs[key] && !YAHOO.lang.isUndefined(el.value[key]) ) { - return el.value[key]; - } - - return AttributeProvider.prototype.get.call(this, key); - }, - - set: function(key, value, silent) { - var el = this.get('element'); - if (!el) { - this._queue[this._queue.length] = ['set', arguments]; - if (this._configs[key]) { - this._configs[key].value = value; // so "get" works while queueing - - } - return; - } - - // set it on the element if not configured and is an HTML attribute - if ( !this._configs[key] && !YAHOO.lang.isUndefined(el[key]) ) { - _registerHTMLAttr.call(this, key); - } - - return AttributeProvider.prototype.set.apply(this, arguments); - }, - - setAttributeConfig: function(key, map, init) { - var el = this.get('element'); - - if (el && !this._configs[key] && !YAHOO.lang.isUndefined(el[key]) ) { - _registerHTMLAttr.call(this, key, map); - } else { - AttributeProvider.prototype.setAttributeConfig.apply(this, arguments); - } - }, - - getAttributeKeys: function() { - var el = this.get('element'); - var keys = AttributeProvider.prototype.getAttributeKeys.call(this); - - //add any unconfigured element keys - for (var key in el) { - if (!this._configs[key]) { - keys[key] = keys[key] || el[key]; - } - } - - return keys; - }, - - init: function(el, attr) { - this._queue = this._queue || []; - this._events = this._events || {}; - this._configs = this._configs || {}; - attr = attr || {}; - attr.element = attr.element || el || null; - - this.DOM_EVENTS = { - 'click': true, - 'keydown': true, - 'keypress': true, - 'keyup': true, - 'mousedown': true, - 'mousemove': true, - 'mouseout': true, - 'mouseover': true, - 'mouseup': true - }; - - var readyHandler = function() { - this.initAttributes(attr); - this.setAttributes(attr, true); - this.fireQueue(); - this.fireEvent('contentReady', { - type: 'contentReady', - target: attr.element - }); - }; - - if ( YAHOO.lang.isString(el) ) { - _registerHTMLAttr.call(this, 'id', { value: el }); - YAHOO.util.Event.onAvailable(el, function() { - attr.element = Dom.get(el); - this.fireEvent('available', { - type: 'available', - target: attr.element - }); - }, this, true); - - YAHOO.util.Event.onContentReady(el, function() { - readyHandler.call(this); - }, this, true); - } else { - readyHandler.call(this); - } - } -}; - -/** - * Sets the value of the property and fires beforeChange and change events. - * @private - * @method _registerHTMLAttr - * @param {YAHOO.util.Element} element The Element instance to - * register the config to. - * @param {String} key The name of the config to register - * @param {Object} map A key-value map of the config's params - */ -var _registerHTMLAttr = function(key, map) { - var el = this.get('element'); - map = map || {}; - map.name = key; - map.method = map.method || function(value) { - el[key] = value; - }; - map.value = map.value || el[key]; - this._configs[key] = new YAHOO.util.Attribute(map, this); -}; - -/** - * Fires when the Element's HTMLElement can be retrieved by Id. - * <p>See: <a href="#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> available<br> - * <code><HTMLElement> - * target</code> the HTMLElement bound to this Element instance<br> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var target = e.target};<br> - * myTabs.addListener('available', handler);</code></p> - * @event available - */ - -/** - * Fires when the Element's HTMLElement subtree is rendered. - * <p>See: <a href="#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> contentReady<br> - * <code><HTMLElement> - * target</code> the HTMLElement bound to this Element instance<br> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var target = e.target};<br> - * myTabs.addListener('contentReady', handler);</code></p> - * @event contentReady - */ - - -YAHOO.augment(YAHOO.util.Element, AttributeProvider); -})(); - -YAHOO.register("element", YAHOO.util.Element, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/event/README b/interface/web/js/yui/event/README deleted file mode 100644 index 99fb0e565f..0000000000 --- a/interface/web/js/yui/event/README +++ /dev/null @@ -1,161 +0,0 @@ - -YUI Library - Event - Release Notes - -2.2.0 - - * YAHOO.util.KeyListener was moved from the container package into event. - - * The Safari bug that made it so preventDefault would not work with click - and double-click listeners on anchor tags was resolved in version 2.0.4. - The workaround (using DOM0 events for these instead of the normal DOM2 - events) is now only used for releases prior to 2.0.4. - - * getListeners/purgeElement now work correctly with unload listeners - - * When legacyEvents are used (Safari<2.0.4 click events), if there was an - existing DOM0 event that the utility replaced, it is executed along with - the listeners that were added with the utility. - - * Restored Event.regCE for compatibility with a beta release of the library - that in use in an external API. - - * unsubscribe in CustomEvent and EventProvider will remove all listeners - if the listener is omitted. - - * Added unsubscribeAll to EventProvider - - * Added Event.lastError which stores the most recent error object if - a browser-specific add/remove listener call throws an exception. - -0.12.2 - - * Fixed a bug introduced in 0.12.1 release caused nested onAvailable - calls to fail. - -0.12.1 - - * If an error is thrown during the browser-specific add/remove lister call, - addListener/removeListener will catch the error and return false. - - * onAvailable array items are nulled out instead of deleted when completed to - get around an Opera issue introduced in a recent version of the browser. - -0.12.0 - - * If the function argument is not provided to Event.removeListener, all - all listeners for the specified event type on the element will be removed. - - * CustomEvent now has an optional parameter that defines the signature of - the listeners for this event. Two signatures are supported: - - YAHOO.util.CustomEvent.LIST: - param1: event name - param2: array of arguments provided to fire() - param3: <optional> the custom object supplied to subscribe() - - YAHOO.util.CustomEvent.FLAT: - param1: the first argument provided to fire() - param2: <optional> the custom object supplied to subscribe() - - The new flat signature makes it possible to provide a better API - when using custom events, and it makes it possible to transparently - wrap DOM events. - - * The parameters for overriding scope in both Event.addListener, and - CustomEvent.subscribe have been augmented. In addition to the - previous behavior where a true value would make the previous parameter - the execution scope, an object can be supplied instead. If an object - is provided, that object becomes the scope obj. This makes it possible - to pass a both a custom object and adjust the scope to a different object. - - * Added EventProvider, which is a wrapper for CustomEvent that makes it - possible to subscribe to events by name, whether or not the event has - been created. This class was designed to be used with YAHOO.augment. - EventProvider custom events are created with the new FLAT listener - signature. - - * CustomEvent subscribers can return false to stop the propagation of - the event. - - * CustomEvents now have an onSubscribe custom event that can used to the - case where a subscriber subscribes to an one-time event that has already - happened. Also provides a way for the implementer to defer initialization - logic until after the first subscription. - - * Event.getCharCode now always returns keyCode if charCode is not available. - - * Added Event.onContentReady, which is similar to onAvailable, but it also - checks simblings to try to determine when the element's children are - available. - -0.11.4 - - * Fixed a memory leak in IE6 that occurred when the utility was hosted in - an iframe. - - * Fixed an issue with Safari click listeners when listeners were removed. - -0.11.3 - - * The listener cache is now pruned when events are removed. This fixes - a performance issue when adding many listeners, removing them, and - adding them again repeatedly. - - * Safari click listeners will work correctly if a bound element is removed - from the DOM and a new element with the same ID is added. - - * Removed the code that automatically unsubscribed custom event listeners. - -0.11.0 - - * Added Event.purgeElement which will remove all listeners added via - addListener from the supplied element. If an optional "type" parameter - is supplied, only events of that type will be removed. Optionally, the - purge can be performed recursively on the element's children as well. - - * Added Event.getListeners which will return all listeners attached to - a given element.. either all listeners or listeners of a specific type. - - * getTarget now automatically resolves text nodes. The optional parameter - for this feature is now deprecated. - - * getRelatedTarget now resolves text nodes for the browsers that return the - text node rather than its host HTML element. - - * CustomEvent now logs the custom event activity if the logger widget is available - -0.10.0 - - * Added Safari dblclick to the list of legacy events. - - * When multiple identical event handlers are defined, multiple calls - to removeListener can now remove all of them. - - * removeListener works properly for unload events - - * Legacy event bookkeeping is more efficient, improving the performance for - adding Safari click events. - - * _unload() is more efficient, improving the page transition experience in - Safari in particular. - - * addListener, removeListener now return false if the function argument is - not valid. - - * Fixed an operator precedence issue in getCharCode. - - * Added Event.getXY, which returns [Event.getPageX(e), Event.getPageY(e)] - - * Added Event.onAvailable, which will execute the callback when the element - with the supplied id is found. Currently searches periodically until the - window load event or for up to 10 seconds after the onAvailable method - was executed. - - * The lazy listener attachment process now will poll beyond the window load - event in order to better handle the case when a listener is defined - late in the page but before the element is in the dom. - - * Fixed browser detection for Opera installations reporting as IE. - - * It is now possible to remove and re-add legacy events (Safari click event). - diff --git a/interface/web/js/yui/event/event-debug.js b/interface/web/js/yui/event/event-debug.js deleted file mode 100644 index 4e48bda992..0000000000 --- a/interface/web/js/yui/event/event-debug.js +++ /dev/null @@ -1,2076 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The Event Utility provides utilities for managing DOM Events and tools - * for building event systems - * - * @module event - * @title Event Utility - * @namespace YAHOO.util - * @requires yahoo - */ - -// The first instance of Event will win if it is loaded more than once. -// @TODO this needs to be changed so that only the state data that needs to -// be preserved is kept, while methods are overwritten/added as needed. -// This means that the module pattern can't be used. -if (!YAHOO.util.Event) { - -/** - * The event utility provides functions to add and remove event listeners, - * event cleansing. It also tries to automatically remove listeners it - * registers during the unload event. - * - * @class Event - * @static - */ - YAHOO.util.Event = function() { - - /** - * True after the onload event has fired - * @property loadComplete - * @type boolean - * @static - * @private - */ - var loadComplete = false; - - /** - * Cache of wrapped listeners - * @property listeners - * @type array - * @static - * @private - */ - var listeners = []; - - /** - * User-defined unload function that will be fired before all events - * are detached - * @property unloadListeners - * @type array - * @static - * @private - */ - var unloadListeners = []; - - /** - * Cache of DOM0 event handlers to work around issues with DOM2 events - * in Safari - * @property legacyEvents - * @static - * @private - */ - var legacyEvents = []; - - /** - * Listener stack for DOM0 events - * @property legacyHandlers - * @static - * @private - */ - var legacyHandlers = []; - - /** - * The number of times to poll after window.onload. This number is - * increased if additional late-bound handlers are requested after - * the page load. - * @property retryCount - * @static - * @private - */ - var retryCount = 0; - - /** - * onAvailable listeners - * @property onAvailStack - * @static - * @private - */ - var onAvailStack = []; - - /** - * Lookup table for legacy events - * @property legacyMap - * @static - * @private - */ - var legacyMap = []; - - /** - * Counter for auto id generation - * @property counter - * @static - * @private - */ - var counter = 0; - - /** - * addListener/removeListener can throw errors in unexpected scenarios. - * These errors are suppressed, the method returns false, and this property - * is set - * @property lastError - * @type Error - */ - var lastError = null; - - return { - - /** - * The number of times we should look for elements that are not - * in the DOM at the time the event is requested after the document - * has been loaded. The default is 200@amp;50 ms, so it will poll - * for 10 seconds or until all outstanding handlers are bound - * (whichever comes first). - * @property POLL_RETRYS - * @type int - * @static - * @final - */ - POLL_RETRYS: 200, - - /** - * The poll interval in milliseconds - * @property POLL_INTERVAL - * @type int - * @static - * @final - */ - POLL_INTERVAL: 20, - - /** - * Element to bind, int constant - * @property EL - * @type int - * @static - * @final - */ - EL: 0, - - /** - * Type of event, int constant - * @property TYPE - * @type int - * @static - * @final - */ - TYPE: 1, - - /** - * Function to execute, int constant - * @property FN - * @type int - * @static - * @final - */ - FN: 2, - - /** - * Function wrapped for scope correction and cleanup, int constant - * @property WFN - * @type int - * @static - * @final - */ - WFN: 3, - - /** - * Object passed in by the user that will be returned as a - * parameter to the callback, int constant - * @property OBJ - * @type int - * @static - * @final - */ - OBJ: 3, - - /** - * Adjusted scope, either the element we are registering the event - * on or the custom object passed in by the listener, int constant - * @property ADJ_SCOPE - * @type int - * @static - * @final - */ - ADJ_SCOPE: 4, - - /** - * Safari detection is necessary to work around the preventDefault - * bug that makes it so you can't cancel a href click from the - * handler. Since this function has been used outside of this - * utility, it was changed to detect all KHTML browser to be more - * friendly towards the non-Safari browsers that share the engine. - * Internally, the preventDefault bug detection now uses the - * webkit property. - * @property isSafari - * @private - * @static - * @deprecated - */ - isSafari: (/KHTML/gi).test(navigator.userAgent), - - /** - * If WebKit is detected, we keep track of the version number of - * the engine. - * Safari 1.3.2 (312.6): 312.8.1 <-- currently the latest - * available on Mac OSX 10.3. - * Safari 2.0.2: 416 <-- hasOwnProperty introduced - * Safari 2.0.4: 418 <-- preventDefault fixed (I believe) - * Safari 2.0.4 (419.3): 418.9.1 <-- current release - * - * http://developer.apple.com/internet/safari/uamatrix.html - * @property webkit - */ - webkit: function() { - var v=navigator.userAgent.match(/AppleWebKit\/([^ ]*)/); - if (v&&v[1]) { - return v[1]; - } - return null; - }(), - - /** - * IE detection needed to properly calculate pageX and pageY. - * capabilities checking didn't seem to work because another - * browser that does not provide the properties have the values - * calculated in a different manner than IE. - * @property isIE - * @private - * @static - */ - isIE: (!this.webkit && !navigator.userAgent.match(/opera/gi) && - navigator.userAgent.match(/msie/gi)), - - /** - * poll handle - * @property _interval - * @private - */ - _interval: null, - - /** - * @method startInterval - * @static - * @private - */ - startInterval: function() { - if (!this._interval) { - var self = this; - var callback = function() { self._tryPreloadAttach(); }; - this._interval = setInterval(callback, this.POLL_INTERVAL); - // this.timeout = setTimeout(callback, i); - } - }, - - /** - * Executes the supplied callback when the item with the supplied - * id is found. This is meant to be used to execute behavior as - * soon as possible as the page loads. If you use this after the - * initial page load it will poll for a fixed time for the element. - * The number of times it will poll and the frequency are - * configurable. By default it will poll for 10 seconds. - * - * @method onAvailable - * - * @param {string} p_id the id of the element to look for. - * @param {function} p_fn what to execute when the element is found. - * @param {object} p_obj an optional object to be passed back as - * a parameter to p_fn. - * @param {boolean} p_override If set to true, p_fn will execute - * in the scope of p_obj - * - * @static - */ - onAvailable: function(p_id, p_fn, p_obj, p_override) { - onAvailStack.push( { id: p_id, - fn: p_fn, - obj: p_obj, - override: p_override, - checkReady: false } ); - - retryCount = this.POLL_RETRYS; - this.startInterval(); - }, - - /** - * Works the same way as onAvailable, but additionally checks the - * state of sibling elements to determine if the content of the - * available element is safe to modify. - * - * @method onContentReady - * - * @param {string} p_id the id of the element to look for. - * @param {function} p_fn what to execute when the element is ready. - * @param {object} p_obj an optional object to be passed back as - * a parameter to p_fn. - * @param {boolean} p_override If set to true, p_fn will execute - * in the scope of p_obj - * - * @static - */ - onContentReady: function(p_id, p_fn, p_obj, p_override) { - onAvailStack.push( { id: p_id, - fn: p_fn, - obj: p_obj, - override: p_override, - checkReady: true } ); - - retryCount = this.POLL_RETRYS; - this.startInterval(); - }, - - /** - * Appends an event handler - * - * @method addListener - * - * @param {Object} el The html element to assign the - * event to - * @param {String} sType The type of event to append - * @param {Function} fn The method the event invokes - * @param {Object} 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 - * @return {boolean} True if the action was successful or defered, - * false if one or more of the elements - * could not have the listener attached, - * or if the operation throws an exception. - * @static - */ - addListener: function(el, sType, fn, obj, override) { - - - if (!fn || !fn.call) { - // this.logger.debug("Error, function is not valid " + fn); - return false; - } - - // The el argument can be an array of elements or element ids. - if ( this._isValidCollection(el)) { - var ok = true; - for (var i=0,len=el.length; i<len; ++i) { - ok = this.on(el[i], - sType, - fn, - obj, - override) && ok; - } - return ok; - - } else if (typeof el == "string") { - var oEl = this.getEl(el); - // If the el argument is a string, we assume it is - // actually the id of the element. If the page is loaded - // we convert el to the actual element, otherwise we - // defer attaching the event until onload event fires - - // check to see if we need to delay hooking up the event - // until after the page loads. - if (oEl) { - el = oEl; - } else { - // defer adding the event until the element is available - this.onAvailable(el, function() { - YAHOO.util.Event.on(el, sType, fn, obj, override); - }); - - return true; - } - } - - // Element should be an html element or an array if we get - // here. - if (!el) { - // this.logger.debug("unable to attach event " + sType); - return false; - } - - // we need to make sure we fire registered unload events - // prior to automatically unhooking them. So we hang on to - // these instead of attaching them to the window and fire the - // handles explicitly during our one unload event. - if ("unload" == sType && obj !== this) { - unloadListeners[unloadListeners.length] = - [el, sType, fn, obj, override]; - return true; - } - - // this.logger.debug("Adding handler: " + el + ", " + sType); - - // if the user chooses to override the scope, we use the custom - // object passed in, otherwise the executing scope will be the - // HTML element that the event is registered on - var scope = el; - if (override) { - if (override === true) { - scope = obj; - } else { - scope = override; - } - } - - // wrap the function so we can return the obj object when - // the event fires; - var wrappedFn = function(e) { - return fn.call(scope, YAHOO.util.Event.getEvent(e), - obj); - }; - - var li = [el, sType, fn, wrappedFn, scope]; - var index = listeners.length; - // cache the listener so we can try to automatically unload - listeners[index] = li; - - if (this.useLegacyEvent(el, sType)) { - var legacyIndex = this.getLegacyIndex(el, sType); - - // Add a new dom0 wrapper if one is not detected for this - // element - if ( legacyIndex == -1 || - el != legacyEvents[legacyIndex][0] ) { - - legacyIndex = legacyEvents.length; - legacyMap[el.id + sType] = legacyIndex; - - // cache the signature for the DOM0 event, and - // include the existing handler for the event, if any - legacyEvents[legacyIndex] = - [el, sType, el["on" + sType]]; - legacyHandlers[legacyIndex] = []; - - el["on" + sType] = - function(e) { - YAHOO.util.Event.fireLegacyEvent( - YAHOO.util.Event.getEvent(e), legacyIndex); - }; - } - - // add a reference to the wrapped listener to our custom - // stack of events - //legacyHandlers[legacyIndex].push(index); - legacyHandlers[legacyIndex].push(li); - - } else { - try { - this._simpleAdd(el, sType, wrappedFn, false); - } catch(ex) { - // handle an error trying to attach an event. If it fails - // we need to clean up the cache - this.lastError = ex; - this.removeListener(el, sType, fn); - return false; - } - } - - return true; - - }, - - /** - * When using legacy events, the handler is routed to this object - * so we can fire our custom listener stack. - * @method fireLegacyEvent - * @static - * @private - */ - fireLegacyEvent: function(e, legacyIndex) { - // this.logger.debug("fireLegacyEvent " + legacyIndex); - var ok=true,le,lh,li,scope,ret; - - lh = legacyHandlers[legacyIndex]; - for (var i=0,len=lh.length; i<len; ++i) { - li = lh[i]; - if ( li && li[this.WFN] ) { - scope = li[this.ADJ_SCOPE]; - ret = li[this.WFN].call(scope, e); - ok = (ok && ret); - } - } - - // Fire the original handler if we replaced one. We fire this - // after the other events to keep stopPropagation/preventDefault - // that happened in the DOM0 handler from touching our DOM2 - // substitute - le = legacyEvents[legacyIndex]; - if (le && le[2]) { - le[2](e); - } - - return ok; - }, - - /** - * Returns the legacy event index that matches the supplied - * signature - * @method getLegacyIndex - * @static - * @private - */ - getLegacyIndex: function(el, sType) { - var key = this.generateId(el) + sType; - if (typeof legacyMap[key] == "undefined") { - return -1; - } else { - return legacyMap[key]; - } - }, - - /** - * Logic that determines when we should automatically use legacy - * events instead of DOM2 events. Currently this is limited to old - * Safari browsers with a broken preventDefault - * @method useLegacyEvent - * @static - * @private - */ - useLegacyEvent: function(el, sType) { - if (this.webkit && ("click"==sType || "dblclick"==sType)) { - var v = parseInt(this.webkit, 10); - if (!isNaN(v) && v<418) { - return true; - } - } - return false; - }, - - /** - * Removes an event handler - * - * @method removeListener - * - * @param {Object} el the html element or the id of the element to - * assign the event to. - * @param {String} sType the type of event to remove. - * @param {Function} fn the method the event invokes. If fn is - * undefined, then all event handlers for the type of event are - * removed. - * @return {boolean} true if the unbind was successful, false - * otherwise. - * @static - */ - removeListener: function(el, sType, fn) { - var i, len; - - // The el argument can be a string - if (typeof el == "string") { - el = this.getEl(el); - // The el argument can be an array of elements or element ids. - } else if ( this._isValidCollection(el)) { - var ok = true; - for (i=0,len=el.length; i<len; ++i) { - ok = ( this.removeListener(el[i], sType, fn) && ok ); - } - return ok; - } - - if (!fn || !fn.call) { - // this.logger.debug("Error, function is not valid " + fn); - //return false; - return this.purgeElement(el, false, sType); - } - - - if ("unload" == sType) { - - for (i=0, len=unloadListeners.length; i<len; i++) { - var li = unloadListeners[i]; - if (li && - li[0] == el && - li[1] == sType && - li[2] == fn) { - unloadListeners.splice(i, 1); - return true; - } - } - - return false; - } - - var cacheItem = null; - - // The index is a hidden parameter; needed to remove it from - // the method signature because it was tempting users to - // try and take advantage of it, which is not possible. - var index = arguments[3]; - - if ("undefined" == typeof index) { - index = this._getCacheIndex(el, sType, fn); - } - - if (index >= 0) { - cacheItem = listeners[index]; - } - - if (!el || !cacheItem) { - // this.logger.debug("cached listener not found"); - return false; - } - - // this.logger.debug("Removing handler: " + el + ", " + sType); - - if (this.useLegacyEvent(el, sType)) { - var legacyIndex = this.getLegacyIndex(el, sType); - var llist = legacyHandlers[legacyIndex]; - if (llist) { - for (i=0, len=llist.length; i<len; ++i) { - li = llist[i]; - if (li && - li[this.EL] == el && - li[this.TYPE] == sType && - li[this.FN] == fn) { - llist.splice(i, 1); - break; - } - } - } - - } else { - try { - this._simpleRemove(el, sType, cacheItem[this.WFN], false); - } catch(ex) { - this.lastError = ex; - return false; - } - } - - // removed the wrapped handler - delete listeners[index][this.WFN]; - delete listeners[index][this.FN]; - listeners.splice(index, 1); - - return true; - - }, - - /** - * Returns the event's target element - * @method getTarget - * @param {Event} ev the event - * @param {boolean} resolveTextNode when set to true the target's - * parent will be returned if the target is a - * text node. @deprecated, the text node is - * now resolved automatically - * @return {HTMLElement} the event's target - * @static - */ - getTarget: function(ev, resolveTextNode) { - var t = ev.target || ev.srcElement; - return this.resolveTextNode(t); - }, - - /** - * In some cases, some browsers will return a text node inside - * the actual element that was targeted. This normalizes the - * return value for getTarget and getRelatedTarget. - * @method resolveTextNode - * @param {HTMLElement} node node to resolve - * @return {HTMLElement} the normized node - * @static - */ - resolveTextNode: function(node) { - // if (node && node.nodeName && - // "#TEXT" == node.nodeName.toUpperCase()) { - if (node && 3 == node.nodeType) { - return node.parentNode; - } else { - return node; - } - }, - - /** - * Returns the event's pageX - * @method getPageX - * @param {Event} ev the event - * @return {int} the event's pageX - * @static - */ - getPageX: function(ev) { - var x = ev.pageX; - if (!x && 0 !== x) { - x = ev.clientX || 0; - - if ( this.isIE ) { - x += this._getScrollLeft(); - } - } - - return x; - }, - - /** - * Returns the event's pageY - * @method getPageY - * @param {Event} ev the event - * @return {int} the event's pageY - * @static - */ - getPageY: function(ev) { - var y = ev.pageY; - if (!y && 0 !== y) { - y = ev.clientY || 0; - - if ( this.isIE ) { - y += this._getScrollTop(); - } - } - - - return y; - }, - - /** - * Returns the pageX and pageY properties as an indexed array. - * @method getXY - * @param {Event} ev the event - * @return {[x, y]} the pageX and pageY properties of the event - * @static - */ - getXY: function(ev) { - return [this.getPageX(ev), this.getPageY(ev)]; - }, - - /** - * Returns the event's related target - * @method getRelatedTarget - * @param {Event} ev the event - * @return {HTMLElement} the event's relatedTarget - * @static - */ - getRelatedTarget: function(ev) { - var t = ev.relatedTarget; - if (!t) { - if (ev.type == "mouseout") { - t = ev.toElement; - } else if (ev.type == "mouseover") { - t = ev.fromElement; - } - } - - return this.resolveTextNode(t); - }, - - /** - * Returns the time of the event. If the time is not included, the - * event is modified using the current time. - * @method getTime - * @param {Event} ev the event - * @return {Date} the time of the event - * @static - */ - getTime: function(ev) { - if (!ev.time) { - var t = new Date().getTime(); - try { - ev.time = t; - } catch(ex) { - this.lastError = ex; - return t; - } - } - - return ev.time; - }, - - /** - * Convenience method for stopPropagation + preventDefault - * @method stopEvent - * @param {Event} ev the event - * @static - */ - stopEvent: function(ev) { - this.stopPropagation(ev); - this.preventDefault(ev); - }, - - /** - * Stops event propagation - * @method stopPropagation - * @param {Event} ev the event - * @static - */ - stopPropagation: function(ev) { - if (ev.stopPropagation) { - ev.stopPropagation(); - } else { - ev.cancelBubble = true; - } - }, - - /** - * Prevents the default behavior of the event - * @method preventDefault - * @param {Event} ev the event - * @static - */ - preventDefault: function(ev) { - if (ev.preventDefault) { - ev.preventDefault(); - } else { - ev.returnValue = false; - } - }, - - /** - * Finds the event in the window object, the caller's arguments, or - * in the arguments of another method in the callstack. This is - * executed automatically for events registered through the event - * manager, so the implementer should not normally need to execute - * this function at all. - * @method getEvent - * @param {Event} e the event parameter from the handler - * @return {Event} the event - * @static - */ - getEvent: function(e) { - var ev = e || window.event; - - if (!ev) { - var c = this.getEvent.caller; - while (c) { - ev = c.arguments[0]; - if (ev && Event == ev.constructor) { - break; - } - c = c.caller; - } - } - - return ev; - }, - - /** - * Returns the charcode for an event - * @method getCharCode - * @param {Event} ev the event - * @return {int} the event's charCode - * @static - */ - getCharCode: function(ev) { - return ev.charCode || ev.keyCode || 0; - }, - - /** - * Locating the saved event handler data by function ref - * - * @method _getCacheIndex - * @static - * @private - */ - _getCacheIndex: function(el, sType, fn) { - for (var i=0,len=listeners.length; i<len; ++i) { - var li = listeners[i]; - if ( li && - li[this.FN] == fn && - li[this.EL] == el && - li[this.TYPE] == sType ) { - return i; - } - } - - return -1; - }, - - /** - * Generates an unique ID for the element if it does not already - * have one. - * @method generateId - * @param el the element to create the id for - * @return {string} the resulting id of the element - * @static - */ - generateId: function(el) { - var id = el.id; - - if (!id) { - id = "yuievtautoid-" + counter; - ++counter; - el.id = id; - } - - return id; - }, - - - /** - * We want to be able to use getElementsByTagName as a collection - * to attach a group of events to. Unfortunately, different - * browsers return different types of collections. This function - * tests to determine if the object is array-like. It will also - * fail if the object is an array, but is empty. - * @method _isValidCollection - * @param o the object to test - * @return {boolean} true if the object is array-like and populated - * @static - * @private - */ - _isValidCollection: function(o) { - return ( o && // o is something - o.length && // o is indexed - typeof o != "string" && // o is not a string - !o.tagName && // o is not an HTML element - !o.alert && // o is not a window - typeof o[0] != "undefined" ); - - }, - - /** - * @private - * @property elCache - * DOM element cache - * @static - */ - elCache: {}, - - /** - * We cache elements bound by id because when the unload event - * fires, we can no longer use document.getElementById - * @method getEl - * @static - * @private - */ - getEl: function(id) { - return document.getElementById(id); - }, - - /** - * Clears the element cache - * @deprecated Elements are not cached any longer - * @method clearCache - * @static - * @private - */ - clearCache: function() { }, - - /** - * hook up any deferred listeners - * @method _load - * @static - * @private - */ - _load: function(e) { - loadComplete = true; - var EU = YAHOO.util.Event; - // Remove the listener to assist with the IE memory issue, but not - // for other browsers because FF 1.0x does not like it. - if (this.isIE) { - EU._simpleRemove(window, "load", EU._load); - } - }, - - /** - * Polling function that runs before the onload event fires, - * attempting to attach to DOM Nodes as soon as they are - * available - * @method _tryPreloadAttach - * @static - * @private - */ - _tryPreloadAttach: function() { - - if (this.locked) { - return false; - } - - this.locked = true; - - // this.logger.debug("tryPreloadAttach"); - - // keep trying until after the page is loaded. We need to - // check the page load state prior to trying to bind the - // elements so that we can be certain all elements have been - // tested appropriately - var tryAgain = !loadComplete; - if (!tryAgain) { - tryAgain = (retryCount > 0); - } - - // onAvailable - var notAvail = []; - for (var i=0,len=onAvailStack.length; i<len ; ++i) { - var item = onAvailStack[i]; - if (item) { - var el = this.getEl(item.id); - - if (el) { - // The element is available, but not necessarily ready - // @todo verify IE7 compatibility - // @todo should we test parentNode.nextSibling? - // @todo re-evaluate global content ready - if ( !item.checkReady || - loadComplete || - el.nextSibling || - (document && document.body) ) { - - var scope = el; - if (item.override) { - if (item.override === true) { - scope = item.obj; - } else { - scope = item.override; - } - } - item.fn.call(scope, item.obj); - //delete onAvailStack[i]; - // null out instead of delete for Opera - onAvailStack[i] = null; - } - } else { - notAvail.push(item); - } - } - } - - retryCount = (notAvail.length === 0) ? 0 : retryCount - 1; - - if (tryAgain) { - // we may need to strip the nulled out items here - this.startInterval(); - } else { - clearInterval(this._interval); - this._interval = null; - } - - this.locked = false; - - return true; - - }, - - /** - * Removes all listeners attached to the given element via addListener. - * Optionally, the node's children can also be purged. - * Optionally, you can specify a specific type of event to remove. - * @method purgeElement - * @param {HTMLElement} el the element to purge - * @param {boolean} recurse recursively purge this element's children - * as well. Use with caution. - * @param {string} sType optional type of listener to purge. If - * left out, all listeners will be removed - * @static - */ - purgeElement: function(el, recurse, sType) { - var elListeners = this.getListeners(el, sType); - if (elListeners) { - for (var i=0,len=elListeners.length; i<len ; ++i) { - var l = elListeners[i]; - // can't use the index on the changing collection - //this.removeListener(el, l.type, l.fn, l.index); - this.removeListener(el, l.type, l.fn); - } - } - - if (recurse && el && el.childNodes) { - for (i=0,len=el.childNodes.length; i<len ; ++i) { - this.purgeElement(el.childNodes[i], recurse, sType); - } - } - }, - - /** - * Returns all listeners attached to the given element via addListener. - * Optionally, you can specify a specific type of event to return. - * @method getListeners - * @param el {HTMLElement} the element to inspect - * @param sType {string} optional type of listener to return. If - * left out, all listeners will be returned - * @return {Object} the listener. Contains the following fields: - * type: (string) the type of event - * fn: (function) the callback supplied to addListener - * obj: (object) the custom object supplied to addListener - * adjust: (boolean) whether or not to adjust the default scope - * index: (int) its position in the Event util listener cache - * @static - */ - getListeners: function(el, sType) { - var results=[], searchLists; - if (!sType) { - searchLists = [listeners, unloadListeners]; - } else if (sType == "unload") { - searchLists = [unloadListeners]; - } else { - searchLists = [listeners]; - } - - for (var j=0;j<searchLists.length; ++j) { - var searchList = searchLists[j]; - if (searchList && searchList.length > 0) { - for (var i=0,len=searchList.length; i<len ; ++i) { - var l = searchList[i]; - if ( l && l[this.EL] === el && - (!sType || sType === l[this.TYPE]) ) { - results.push({ - type: l[this.TYPE], - fn: l[this.FN], - obj: l[this.OBJ], - adjust: l[this.ADJ_SCOPE], - index: i - }); - } - } - } - } - - return (results.length) ? results : null; - }, - - /** - * Removes all listeners registered by pe.event. Called - * automatically during the unload event. - * @method _unload - * @static - * @private - */ - _unload: function(e) { - - var EU = YAHOO.util.Event, i, j, l, len, index; - - for (i=0,len=unloadListeners.length; i<len; ++i) { - l = unloadListeners[i]; - if (l) { - var scope = window; - if (l[EU.ADJ_SCOPE]) { - if (l[EU.ADJ_SCOPE] === true) { - scope = l[EU.OBJ]; - } else { - scope = l[EU.ADJ_SCOPE]; - } - } - l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ] ); - unloadListeners[i] = null; - l=null; - scope=null; - } - } - - unloadListeners = null; - - if (listeners && listeners.length > 0) { - j = listeners.length; - while (j) { - index = j-1; - l = listeners[index]; - if (l) { - EU.removeListener(l[EU.EL], l[EU.TYPE], - l[EU.FN], index); - } - j = j - 1; - } - l=null; - - EU.clearCache(); - } - - for (i=0,len=legacyEvents.length; i<len; ++i) { - // dereference the element - //delete legacyEvents[i][0]; - legacyEvents[i][0] = null; - - // delete the array item - //delete legacyEvents[i]; - legacyEvents[i] = null; - } - - legacyEvents = null; - - EU._simpleRemove(window, "unload", EU._unload); - - }, - - /** - * Returns scrollLeft - * @method _getScrollLeft - * @static - * @private - */ - _getScrollLeft: function() { - return this._getScroll()[1]; - }, - - /** - * Returns scrollTop - * @method _getScrollTop - * @static - * @private - */ - _getScrollTop: function() { - return this._getScroll()[0]; - }, - - /** - * Returns the scrollTop and scrollLeft. Used to calculate the - * pageX and pageY in Internet Explorer - * @method _getScroll - * @static - * @private - */ - _getScroll: function() { - var dd = document.documentElement, db = document.body; - if (dd && (dd.scrollTop || dd.scrollLeft)) { - return [dd.scrollTop, dd.scrollLeft]; - } else if (db) { - return [db.scrollTop, db.scrollLeft]; - } else { - return [0, 0]; - } - }, - - /** - * Used by old versions of CustomEvent, restored for backwards - * compatibility - * @method regCE - * @private - */ - regCE: function() { - // does nothing - }, - - /** - * Adds a DOM event directly without the caching, cleanup, scope adj, etc - * - * @method _simpleAdd - * @param {HTMLElement} el the element to bind the handler to - * @param {string} sType the type of event handler - * @param {function} fn the callback to invoke - * @param {boolen} capture capture or bubble phase - * @static - * @private - */ - _simpleAdd: function () { - if (window.addEventListener) { - return function(el, sType, fn, capture) { - el.addEventListener(sType, fn, (capture)); - }; - } else if (window.attachEvent) { - return function(el, sType, fn, capture) { - el.attachEvent("on" + sType, fn); - }; - } else { - return function(){}; - } - }(), - - /** - * Basic remove listener - * - * @method _simpleRemove - * @param {HTMLElement} el the element to bind the handler to - * @param {string} sType the type of event handler - * @param {function} fn the callback to invoke - * @param {boolen} capture capture or bubble phase - * @static - * @private - */ - _simpleRemove: function() { - if (window.removeEventListener) { - return function (el, sType, fn, capture) { - el.removeEventListener(sType, fn, (capture)); - }; - } else if (window.detachEvent) { - return function (el, sType, fn) { - el.detachEvent("on" + sType, fn); - }; - } else { - return function(){}; - } - }() - }; - - }(); - - (function() { - var EU = YAHOO.util.Event; - - /** - * YAHOO.util.Event.on is an alias for addListener - * @method on - * @see addListener - * @static - */ - EU.on = EU.addListener; - - // YAHOO.mix(EU, YAHOO.util.EventProvider.prototype); - // EU.createEvent("DOMContentReady"); - // EU.subscribe("DOMContentReady", EU._load); - - if (document && document.body) { - EU._load(); - } else { - // EU._simpleAdd(document, "DOMContentLoaded", EU._load); - EU._simpleAdd(window, "load", EU._load); - } - EU._simpleAdd(window, "unload", EU._unload); - EU._tryPreloadAttach(); - })(); -} - -/** - * The CustomEvent class lets you define events for your application - * that can be subscribed to by one or more independent component. - * - * @param {String} type The type of event, which is passed to the callback - * when the event fires - * @param {Object} oScope The context the event will fire from. "this" will - * refer to this object in the callback. Default value: - * the window object. The listener can override this. - * @param {boolean} silent pass true to prevent the event from writing to - * the debugsystem - * @param {int} signature the signature that the custom event subscriber - * will receive. YAHOO.util.CustomEvent.LIST or - * YAHOO.util.CustomEvent.FLAT. The default is - * YAHOO.util.CustomEvent.LIST. - * @namespace YAHOO.util - * @class CustomEvent - * @constructor - */ -YAHOO.util.CustomEvent = function(type, oScope, silent, signature) { - - /** - * The type of event, returned to subscribers when the event fires - * @property type - * @type string - */ - this.type = type; - - /** - * The scope the the event will fire from by default. Defaults to the window - * obj - * @property scope - * @type object - */ - this.scope = oScope || window; - - /** - * By default all custom events are logged in the debug build, set silent - * to true to disable debug outpu for this event. - * @property silent - * @type boolean - */ - this.silent = silent; - - /** - * Custom events support two styles of arguments provided to the event - * subscribers. - * <ul> - * <li>YAHOO.util.CustomEvent.LIST: - * <ul> - * <li>param1: event name</li> - * <li>param2: array of arguments sent to fire</li> - * <li>param3: <optional> a custom object supplied by the subscriber</li> - * </ul> - * </li> - * <li>YAHOO.util.CustomEvent.FLAT - * <ul> - * <li>param1: the first argument passed to fire. If you need to - * pass multiple parameters, use and array or object literal</li> - * <li>param2: <optional> a custom object supplied by the subscriber</li> - * </ul> - * </li> - * </ul> - * @property signature - * @type int - */ - this.signature = signature || YAHOO.util.CustomEvent.LIST; - - /** - * The subscribers to this event - * @property subscribers - * @type Subscriber[] - */ - this.subscribers = []; - - if (!this.silent) { - YAHOO.log( "Creating " + this, "info", "Event" ); - } - - var onsubscribeType = "_YUICEOnSubscribe"; - - // Only add subscribe events for events that are not generated by - // CustomEvent - if (type !== onsubscribeType) { - - /** - * Custom events provide a custom event that fires whenever there is - * a new subscriber to the event. This provides an opportunity to - * handle the case where there is a non-repeating event that has - * already fired has a new subscriber. - * - * @event subscribeEvent - * @type YAHOO.util.CustomEvent - * @param {Function} fn The function to execute - * @param {Object} obj An object to be passed along when the event - * fires - * @param {boolean|Object} override If true, the obj passed in becomes - * the execution scope of the listener. - * if an object, that object becomes the - * the execution scope. - */ - this.subscribeEvent = - new YAHOO.util.CustomEvent(onsubscribeType, this, true); - - } -}; - -/** - * Subscriber listener sigature constant. The LIST type returns three - * parameters: the event type, the array of args passed to fire, and - * the optional custom object - * @property YAHOO.util.CustomEvent.LIST - * @static - * @type int - */ -YAHOO.util.CustomEvent.LIST = 0; - -/** - * Subscriber listener sigature constant. The FLAT type returns two - * parameters: the first argument passed to fire and the optional - * custom object - * @property YAHOO.util.CustomEvent.FLAT - * @static - * @type int - */ -YAHOO.util.CustomEvent.FLAT = 1; - -YAHOO.util.CustomEvent.prototype = { - - /** - * Subscribes the caller to this event - * @method subscribe - * @param {Function} fn The function to execute - * @param {Object} obj An object to be passed along when the event - * fires - * @param {boolean|Object} override If true, the obj passed in becomes - * the execution scope of the listener. - * if an object, that object becomes the - * the execution scope. - */ - subscribe: function(fn, obj, override) { - if (this.subscribeEvent) { - this.subscribeEvent.fire(fn, obj, override); - } - - this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) ); - }, - - /** - * Unsubscribes subscribers. - * @method unsubscribe - * @param {Function} fn The subscribed function to remove, if not supplied - * all will be removed - * @param {Object} obj The custom object passed to subscribe. This is - * optional, but if supplied will be used to - * disambiguate multiple listeners that are the same - * (e.g., you subscribe many object using a function - * that lives on the prototype) - * @return {boolean} True if the subscriber was found and detached. - */ - unsubscribe: function(fn, obj) { - - if (!fn) { - return this.unsubscribeAll(); - } - - var found = false; - for (var i=0, len=this.subscribers.length; i<len; ++i) { - var s = this.subscribers[i]; - if (s && s.contains(fn, obj)) { - this._delete(i); - found = true; - } - } - - return found; - }, - - /** - * Notifies the subscribers. The callback functions will be executed - * from the scope specified when the event was created, and with the - * following parameters: - * <ul> - * <li>The type of event</li> - * <li>All of the arguments fire() was executed with as an array</li> - * <li>The custom object (if any) that was passed into the subscribe() - * method</li> - * </ul> - * @method fire - * @param {Object*} arguments an arbitrary set of parameters to pass to - * the handler. - * @return {boolean} false if one of the subscribers returned false, - * true otherwise - */ - fire: function() { - var len=this.subscribers.length; - if (!len && this.silent) { - return true; - } - - var args=[], ret=true, i; - - for (i=0; i<arguments.length; ++i) { - args.push(arguments[i]); - } - - var argslength = args.length; - - if (!this.silent) { - YAHOO.log( "Firing " + this + ", " + - "args: " + args + ", " + - "subscribers: " + len, - "info", "Event" ); - } - - for (i=0; i<len; ++i) { - var s = this.subscribers[i]; - if (s) { - if (!this.silent) { - YAHOO.log( this.type + "->" + (i+1) + ": " + s, - "info", "Event" ); - } - - var scope = s.getScope(this.scope); - - if (this.signature == YAHOO.util.CustomEvent.FLAT) { - var param = null; - if (args.length > 0) { - param = args[0]; - } - ret = s.fn.call(scope, param, s.obj); - } else { - ret = s.fn.call(scope, this.type, args, s.obj); - } - if (false === ret) { - if (!this.silent) { - YAHOO.log("Event cancelled, subscriber " + i + - " of " + len); - } - - //break; - return false; - } - } - } - - return true; - }, - - /** - * Removes all listeners - * @method unsubscribeAll - * @return {int} The number of listeners unsubscribed - */ - unsubscribeAll: function() { - for (var i=0, len=this.subscribers.length; i<len; ++i) { - this._delete(len - 1 - i); - } - - return i; - }, - - /** - * @method _delete - * @private - */ - _delete: function(index) { - var s = this.subscribers[index]; - if (s) { - delete s.fn; - delete s.obj; - } - - // delete this.subscribers[index]; - this.subscribers.splice(index, 1); - }, - - /** - * @method toString - */ - toString: function() { - return "CustomEvent: " + "'" + this.type + "', " + - "scope: " + this.scope; - - } -}; - -///////////////////////////////////////////////////////////////////// - -/** - * Stores the subscriber information to be used when the event fires. - * @param {Function} fn The function to execute - * @param {Object} obj An object to be passed along when the event fires - * @param {boolean} override If true, the obj passed in becomes the execution - * scope of the listener - * @class Subscriber - * @constructor - */ -YAHOO.util.Subscriber = function(fn, obj, override) { - - /** - * The callback that will be execute when the event fires - * @property fn - * @type function - */ - this.fn = fn; - - /** - * An optional custom object that will passed to the callback when - * the event fires - * @property obj - * @type object - */ - this.obj = obj || null; - - /** - * The default execution scope for the event listener is defined when the - * event is created (usually the object which contains the event). - * By setting override to true, the execution scope becomes the custom - * object passed in by the subscriber. If override is an object, that - * object becomes the scope. - * @property override - * @type boolean|object - */ - this.override = override; - -}; - -/** - * Returns the execution scope for this listener. If override was set to true - * the custom obj will be the scope. If override is an object, that is the - * scope, otherwise the default scope will be used. - * @method getScope - * @param {Object} defaultScope the scope to use if this listener does not - * override it. - */ -YAHOO.util.Subscriber.prototype.getScope = function(defaultScope) { - if (this.override) { - if (this.override === true) { - return this.obj; - } else { - return this.override; - } - } - return defaultScope; -}; - -/** - * Returns true if the fn and obj match this objects properties. - * Used by the unsubscribe method to match the right subscriber. - * - * @method contains - * @param {Function} fn the function to execute - * @param {Object} obj an object to be passed along when the event fires - * @return {boolean} true if the supplied arguments match this - * subscriber's signature. - */ -YAHOO.util.Subscriber.prototype.contains = function(fn, obj) { - if (obj) { - return (this.fn == fn && this.obj == obj); - } else { - return (this.fn == fn); - } -}; - -/** - * @method toString - */ -YAHOO.util.Subscriber.prototype.toString = function() { - return "Subscriber { obj: " + (this.obj || "") + - ", override: " + (this.override || "no") + " }"; -}; - -/** - * EventProvider is designed to be used with YAHOO.augment to wrap - * CustomEvents in an interface that allows events to be subscribed to - * and fired by name. This makes it possible for implementing code to - * subscribe to an event that either has not been created yet, or will - * not be created at all. - * - * @Class EventProvider - */ -YAHOO.util.EventProvider = function() { }; - -YAHOO.util.EventProvider.prototype = { - - /** - * Private storage of custom events - * @property __yui_events - * @type Object[] - * @private - */ - __yui_events: null, - - /** - * Private storage of custom event subscribers - * @property __yui_subscribers - * @type Object[] - * @private - */ - __yui_subscribers: null, - - /** - * Subscribe to a CustomEvent by event type - * - * @method subscribe - * @param p_type {string} the type, or name of the event - * @param p_fn {function} the function to exectute when the event fires - * @param p_obj - * @param p_obj {Object} An object to be passed along when the event - * fires - * @param p_override {boolean} If true, the obj passed in becomes the - * execution scope of the listener - */ - subscribe: function(p_type, p_fn, p_obj, p_override) { - - this.__yui_events = this.__yui_events || {}; - var ce = this.__yui_events[p_type]; - - if (ce) { - ce.subscribe(p_fn, p_obj, p_override); - } else { - this.__yui_subscribers = this.__yui_subscribers || {}; - var subs = this.__yui_subscribers; - if (!subs[p_type]) { - subs[p_type] = []; - } - subs[p_type].push( - { fn: p_fn, obj: p_obj, override: p_override } ); - } - }, - - /** - * Unsubscribes one or more listeners the from the specified event - * @method unsubscribe - * @param p_type {string} The type, or name of the event - * @param p_fn {Function} The subscribed function to unsubscribe, if not - * supplied, all subscribers will be removed. - * @param p_obj {Object} The custom object passed to subscribe. This is - * optional, but if supplied will be used to - * disambiguate multiple listeners that are the same - * (e.g., you subscribe many object using a function - * that lives on the prototype) - * @return {boolean} true if the subscriber was found and detached. - */ - unsubscribe: function(p_type, p_fn, p_obj) { - this.__yui_events = this.__yui_events || {}; - var ce = this.__yui_events[p_type]; - if (ce) { - return ce.unsubscribe(p_fn, p_obj); - } else { - return false; - } - }, - - /** - * Removes all listeners from the specified event - * @method unsubscribeAll - * @param p_type {string} The type, or name of the event - */ - unsubscribeAll: function(p_type) { - return this.unsubscribe(p_type); - }, - - /** - * Creates a new custom event of the specified type. If a custom event - * by that name already exists, it will not be re-created. In either - * case the custom event is returned. - * - * @method createEvent - * - * @param p_type {string} the type, or name of the event - * @param p_config {object} optional config params. Valid properties are: - * - * <ul> - * <li> - * scope: defines the default execution scope. If not defined - * the default scope will be this instance. - * </li> - * <li> - * silent: if true, the custom event will not generate log messages. - * This is false by default. - * </li> - * <li> - * onSubscribeCallback: specifies a callback to execute when the - * event has a new subscriber. This will fire immediately for - * each queued subscriber if any exist prior to the creation of - * the event. - * </li> - * </ul> - * - * @return {CustomEvent} the custom event - * - */ - createEvent: function(p_type, p_config) { - - this.__yui_events = this.__yui_events || {}; - var opts = p_config || {}; - var events = this.__yui_events; - - if (events[p_type]) { - YAHOO.log("EventProvider: error, event already exists"); - } else { - - var scope = opts.scope || this; - var silent = opts.silent || null; - - var ce = new YAHOO.util.CustomEvent(p_type, scope, silent, - YAHOO.util.CustomEvent.FLAT); - events[p_type] = ce; - - if (opts.onSubscribeCallback) { - ce.subscribeEvent.subscribe(opts.onSubscribeCallback); - } - - this.__yui_subscribers = this.__yui_subscribers || {}; - var qs = this.__yui_subscribers[p_type]; - - if (qs) { - for (var i=0; i<qs.length; ++i) { - ce.subscribe(qs[i].fn, qs[i].obj, qs[i].override); - } - } - } - - return events[p_type]; - }, - - - /** - * Fire a custom event by name. The callback functions will be executed - * from the scope specified when the event was created, and with the - * following parameters: - * <ul> - * <li>The first argument fire() was executed with</li> - * <li>The custom object (if any) that was passed into the subscribe() - * method</li> - * </ul> - * @method fireEvent - * @param p_type {string} the type, or name of the event - * @param arguments {Object*} an arbitrary set of parameters to pass to - * the handler. - * @return {boolean} the return value from CustomEvent.fire, or null if - * the custom event does not exist. - */ - fireEvent: function(p_type, arg1, arg2, etc) { - - this.__yui_events = this.__yui_events || {}; - var ce = this.__yui_events[p_type]; - - if (ce) { - var args = []; - for (var i=1; i<arguments.length; ++i) { - args.push(arguments[i]); - } - return ce.fire.apply(ce, args); - } else { - YAHOO.log("EventProvider.fire could not find event: " + p_type); - return null; - } - }, - - /** - * Returns true if the custom event of the provided type has been created - * with createEvent. - * @method hasEvent - * @param type {string} the type, or name of the event - */ - hasEvent: function(type) { - if (this.__yui_events) { - if (this.__yui_events[type]) { - return true; - } - } - return false; - } - -}; - -/** -* KeyListener is a utility that provides an easy interface for listening for -* keydown/keyup events fired against DOM elements. -* @namespace YAHOO.util -* @class KeyListener -* @constructor -* @param {HTMLElement} attachTo The element or element ID to which the key -* event should be attached -* @param {String} attachTo The element or element ID to which the key -* event should be attached -* @param {Object} keyData The object literal representing the key(s) -* to detect. Possible attributes are -* shift(boolean), alt(boolean), ctrl(boolean) -* and keys(either an int or an array of ints -* representing keycodes). -* @param {Function} handler The CustomEvent handler to fire when the -* key event is detected -* @param {Object} handler An object literal representing the handler. -* @param {String} event Optional. The event (keydown or keyup) to -* listen for. Defaults automatically to keydown. -*/ -YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) { - if (!attachTo) { - YAHOO.log("No attachTo element specified", "error"); - } else if (!keyData) { - YAHOO.log("No keyData specified", "error"); - } else if (!handler) { - YAHOO.log("No handler specified", "error"); - } - - if (!event) { - event = YAHOO.util.KeyListener.KEYDOWN; - } - - /** - * The CustomEvent fired internally when a key is pressed - * @event keyEvent - * @private - * @param {Object} keyData The object literal representing the key(s) to - * detect. Possible attributes are shift(boolean), - * alt(boolean), ctrl(boolean) and keys(either an - * int or an array of ints representing keycodes). - */ - var keyEvent = new YAHOO.util.CustomEvent("keyPressed"); - - /** - * The CustomEvent fired when the KeyListener is enabled via the enable() - * function - * @event enabledEvent - * @param {Object} keyData The object literal representing the key(s) to - * detect. Possible attributes are shift(boolean), - * alt(boolean), ctrl(boolean) and keys(either an - * int or an array of ints representing keycodes). - */ - this.enabledEvent = new YAHOO.util.CustomEvent("enabled"); - - /** - * The CustomEvent fired when the KeyListener is disabled via the - * disable() function - * @event disabledEvent - * @param {Object} keyData The object literal representing the key(s) to - * detect. Possible attributes are shift(boolean), - * alt(boolean), ctrl(boolean) and keys(either an - * int or an array of ints representing keycodes). - */ - this.disabledEvent = new YAHOO.util.CustomEvent("disabled"); - - if (typeof attachTo == 'string') { - attachTo = document.getElementById(attachTo); - } - - if (typeof handler == 'function') { - keyEvent.subscribe(handler); - } else { - keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope); - } - - /** - * Handles the key event when a key is pressed. - * @method handleKeyPress - * @param {DOMEvent} e The keypress DOM event - * @param {Object} obj The DOM event scope object - * @private - */ - function handleKeyPress(e, obj) { - if (! keyData.shift) { - keyData.shift = false; - } - if (! keyData.alt) { - keyData.alt = false; - } - if (! keyData.ctrl) { - keyData.ctrl = false; - } - - // check held down modifying keys first - if (e.shiftKey == keyData.shift && - e.altKey == keyData.alt && - e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match - - var dataItem; - var keyPressed; - - if (keyData.keys instanceof Array) { - for (var i=0;i<keyData.keys.length;i++) { - dataItem = keyData.keys[i]; - - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - break; - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - break; - } - } - } else { - dataItem = keyData.keys; - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - } - } - } - } - - /** - * Enables the KeyListener by attaching the DOM event listeners to the - * target DOM element - * @method enable - */ - this.enable = function() { - if (! this.enabled) { - YAHOO.util.Event.addListener(attachTo, event, handleKeyPress); - this.enabledEvent.fire(keyData); - } - /** - * Boolean indicating the enabled/disabled state of the Tooltip - * @property enabled - * @type Boolean - */ - this.enabled = true; - }; - - /** - * Disables the KeyListener by removing the DOM event listeners from the - * target DOM element - * @method disable - */ - this.disable = function() { - if (this.enabled) { - YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress); - this.disabledEvent.fire(keyData); - } - this.enabled = false; - }; - - /** - * Returns a String representation of the object. - * @method toString - * @return {String} The string representation of the KeyListener - */ - this.toString = function() { - return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + - (attachTo.id ? "[" + attachTo.id + "]" : ""); - }; - -}; - -/** -* Constant representing the DOM "keydown" event. -* @property YAHOO.util.KeyListener.KEYDOWN -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYDOWN = "keydown"; - -/** -* Constant representing the DOM "keyup" event. -* @property YAHOO.util.KeyListener.KEYUP -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYUP = "keyup"; -YAHOO.register("event", YAHOO.util.Event, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/event/event-min.js b/interface/web/js/yui/event/event-min.js deleted file mode 100644 index 575a08e154..0000000000 --- a/interface/web/js/yui/event/event-min.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -if(!YAHOO.util.Event){YAHOO.util.Event=function(){var loadComplete=false;var listeners=[];var unloadListeners=[];var legacyEvents=[];var legacyHandlers=[];var retryCount=0;var onAvailStack=[];var legacyMap=[];var counter=0;var lastError=null;return{POLL_RETRYS:200,POLL_INTERVAL:20,EL:0,TYPE:1,FN:2,WFN:3,OBJ:3,ADJ_SCOPE:4,isSafari:(/KHTML/gi).test(navigator.userAgent),webkit:function(){var v=navigator.userAgent.match(/AppleWebKit\/([^ ]*)/);if(v&&v[1]){return v[1];} -return null;}(),isIE:(!this.webkit&&!navigator.userAgent.match(/opera/gi)&&navigator.userAgent.match(/msie/gi)),_interval:null,startInterval:function(){if(!this._interval){var self=this;var callback=function(){self._tryPreloadAttach();};this._interval=setInterval(callback,this.POLL_INTERVAL);}},onAvailable:function(p_id,p_fn,p_obj,p_override){onAvailStack.push({id:p_id,fn:p_fn,obj:p_obj,override:p_override,checkReady:false});retryCount=this.POLL_RETRYS;this.startInterval();},onContentReady:function(p_id,p_fn,p_obj,p_override){onAvailStack.push({id:p_id,fn:p_fn,obj:p_obj,override:p_override,checkReady:true});retryCount=this.POLL_RETRYS;this.startInterval();},addListener:function(el,sType,fn,obj,override){if(!fn||!fn.call){return false;} -if(this._isValidCollection(el)){var ok=true;for(var i=0,len=el.length;i<len;++i){ok=this.on(el[i],sType,fn,obj,override)&&ok;} -return ok;}else if(typeof el=="string"){var oEl=this.getEl(el);if(oEl){el=oEl;}else{this.onAvailable(el,function(){YAHOO.util.Event.on(el,sType,fn,obj,override);});return true;}} -if(!el){return false;} -if("unload"==sType&&obj!==this){unloadListeners[unloadListeners.length]=[el,sType,fn,obj,override];return true;} -var scope=el;if(override){if(override===true){scope=obj;}else{scope=override;}} -var wrappedFn=function(e){return fn.call(scope,YAHOO.util.Event.getEvent(e),obj);};var li=[el,sType,fn,wrappedFn,scope];var index=listeners.length;listeners[index]=li;if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);if(legacyIndex==-1||el!=legacyEvents[legacyIndex][0]){legacyIndex=legacyEvents.length;legacyMap[el.id+sType]=legacyIndex;legacyEvents[legacyIndex]=[el,sType,el["on"+sType]];legacyHandlers[legacyIndex]=[];el["on"+sType]=function(e){YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(e),legacyIndex);};} -legacyHandlers[legacyIndex].push(li);}else{try{this._simpleAdd(el,sType,wrappedFn,false);}catch(ex){this.lastError=ex;this.removeListener(el,sType,fn);return false;}} -return true;},fireLegacyEvent:function(e,legacyIndex){var ok=true,le,lh,li,scope,ret;lh=legacyHandlers[legacyIndex];for(var i=0,len=lh.length;i<len;++i){li=lh[i];if(li&&li[this.WFN]){scope=li[this.ADJ_SCOPE];ret=li[this.WFN].call(scope,e);ok=(ok&&ret);}} -le=legacyEvents[legacyIndex];if(le&&le[2]){le[2](e);} -return ok;},getLegacyIndex:function(el,sType){var key=this.generateId(el)+sType;if(typeof legacyMap[key]=="undefined"){return-1;}else{return legacyMap[key];}},useLegacyEvent:function(el,sType){if(this.webkit&&("click"==sType||"dblclick"==sType)){var v=parseInt(this.webkit,10);if(!isNaN(v)&&v<418){return true;}} -return false;},removeListener:function(el,sType,fn){var i,len;if(typeof el=="string"){el=this.getEl(el);}else if(this._isValidCollection(el)){var ok=true;for(i=0,len=el.length;i<len;++i){ok=(this.removeListener(el[i],sType,fn)&&ok);} -return ok;} -if(!fn||!fn.call){return this.purgeElement(el,false,sType);} -if("unload"==sType){for(i=0,len=unloadListeners.length;i<len;i++){var li=unloadListeners[i];if(li&&li[0]==el&&li[1]==sType&&li[2]==fn){unloadListeners.splice(i,1);return true;}} -return false;} -var cacheItem=null;var index=arguments[3];if("undefined"==typeof index){index=this._getCacheIndex(el,sType,fn);} -if(index>=0){cacheItem=listeners[index];} -if(!el||!cacheItem){return false;} -if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);var llist=legacyHandlers[legacyIndex];if(llist){for(i=0,len=llist.length;i<len;++i){li=llist[i];if(li&&li[this.EL]==el&&li[this.TYPE]==sType&&li[this.FN]==fn){llist.splice(i,1);break;}}}}else{try{this._simpleRemove(el,sType,cacheItem[this.WFN],false);}catch(ex){this.lastError=ex;return false;}} -delete listeners[index][this.WFN];delete listeners[index][this.FN];listeners.splice(index,1);return true;},getTarget:function(ev,resolveTextNode){var t=ev.target||ev.srcElement;return this.resolveTextNode(t);},resolveTextNode:function(node){if(node&&3==node.nodeType){return node.parentNode;}else{return node;}},getPageX:function(ev){var x=ev.pageX;if(!x&&0!==x){x=ev.clientX||0;if(this.isIE){x+=this._getScrollLeft();}} -return x;},getPageY:function(ev){var y=ev.pageY;if(!y&&0!==y){y=ev.clientY||0;if(this.isIE){y+=this._getScrollTop();}} -return y;},getXY:function(ev){return[this.getPageX(ev),this.getPageY(ev)];},getRelatedTarget:function(ev){var t=ev.relatedTarget;if(!t){if(ev.type=="mouseout"){t=ev.toElement;}else if(ev.type=="mouseover"){t=ev.fromElement;}} -return this.resolveTextNode(t);},getTime:function(ev){if(!ev.time){var t=new Date().getTime();try{ev.time=t;}catch(ex){this.lastError=ex;return t;}} -return ev.time;},stopEvent:function(ev){this.stopPropagation(ev);this.preventDefault(ev);},stopPropagation:function(ev){if(ev.stopPropagation){ev.stopPropagation();}else{ev.cancelBubble=true;}},preventDefault:function(ev){if(ev.preventDefault){ev.preventDefault();}else{ev.returnValue=false;}},getEvent:function(e){var ev=e||window.event;if(!ev){var c=this.getEvent.caller;while(c){ev=c.arguments[0];if(ev&&Event==ev.constructor){break;} -c=c.caller;}} -return ev;},getCharCode:function(ev){return ev.charCode||ev.keyCode||0;},_getCacheIndex:function(el,sType,fn){for(var i=0,len=listeners.length;i<len;++i){var li=listeners[i];if(li&&li[this.FN]==fn&&li[this.EL]==el&&li[this.TYPE]==sType){return i;}} -return-1;},generateId:function(el){var id=el.id;if(!id){id="yuievtautoid-"+counter;++counter;el.id=id;} -return id;},_isValidCollection:function(o){return(o&&o.length&&typeof o!="string"&&!o.tagName&&!o.alert&&typeof o[0]!="undefined");},elCache:{},getEl:function(id){return document.getElementById(id);},clearCache:function(){},_load:function(e){loadComplete=true;var EU=YAHOO.util.Event;if(this.isIE){EU._simpleRemove(window,"load",EU._load);}},_tryPreloadAttach:function(){if(this.locked){return false;} -this.locked=true;var tryAgain=!loadComplete;if(!tryAgain){tryAgain=(retryCount>0);} -var notAvail=[];for(var i=0,len=onAvailStack.length;i<len;++i){var item=onAvailStack[i];if(item){var el=this.getEl(item.id);if(el){if(!item.checkReady||loadComplete||el.nextSibling||(document&&document.body)){var scope=el;if(item.override){if(item.override===true){scope=item.obj;}else{scope=item.override;}} -item.fn.call(scope,item.obj);onAvailStack[i]=null;}}else{notAvail.push(item);}}} -retryCount=(notAvail.length===0)?0:retryCount-1;if(tryAgain){this.startInterval();}else{clearInterval(this._interval);this._interval=null;} -this.locked=false;return true;},purgeElement:function(el,recurse,sType){var elListeners=this.getListeners(el,sType);if(elListeners){for(var i=0,len=elListeners.length;i<len;++i){var l=elListeners[i];this.removeListener(el,l.type,l.fn);}} -if(recurse&&el&&el.childNodes){for(i=0,len=el.childNodes.length;i<len;++i){this.purgeElement(el.childNodes[i],recurse,sType);}}},getListeners:function(el,sType){var results=[],searchLists;if(!sType){searchLists=[listeners,unloadListeners];}else if(sType=="unload"){searchLists=[unloadListeners];}else{searchLists=[listeners];} -for(var j=0;j<searchLists.length;++j){var searchList=searchLists[j];if(searchList&&searchList.length>0){for(var i=0,len=searchList.length;i<len;++i){var l=searchList[i];if(l&&l[this.EL]===el&&(!sType||sType===l[this.TYPE])){results.push({type:l[this.TYPE],fn:l[this.FN],obj:l[this.OBJ],adjust:l[this.ADJ_SCOPE],index:i});}}}} -return(results.length)?results:null;},_unload:function(e){var EU=YAHOO.util.Event,i,j,l,len,index;for(i=0,len=unloadListeners.length;i<len;++i){l=unloadListeners[i];if(l){var scope=window;if(l[EU.ADJ_SCOPE]){if(l[EU.ADJ_SCOPE]===true){scope=l[EU.OBJ];}else{scope=l[EU.ADJ_SCOPE];}} -l[EU.FN].call(scope,EU.getEvent(e),l[EU.OBJ]);unloadListeners[i]=null;l=null;scope=null;}} -unloadListeners=null;if(listeners&&listeners.length>0){j=listeners.length;while(j){index=j-1;l=listeners[index];if(l){EU.removeListener(l[EU.EL],l[EU.TYPE],l[EU.FN],index);} -j=j-1;} -l=null;EU.clearCache();} -for(i=0,len=legacyEvents.length;i<len;++i){legacyEvents[i][0]=null;legacyEvents[i]=null;} -legacyEvents=null;EU._simpleRemove(window,"unload",EU._unload);},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var dd=document.documentElement,db=document.body;if(dd&&(dd.scrollTop||dd.scrollLeft)){return[dd.scrollTop,dd.scrollLeft];}else if(db){return[db.scrollTop,db.scrollLeft];}else{return[0,0];}},regCE:function(){},_simpleAdd:function(){if(window.addEventListener){return function(el,sType,fn,capture){el.addEventListener(sType,fn,(capture));};}else if(window.attachEvent){return function(el,sType,fn,capture){el.attachEvent("on"+sType,fn);};}else{return function(){};}}(),_simpleRemove:function(){if(window.removeEventListener){return function(el,sType,fn,capture){el.removeEventListener(sType,fn,(capture));};}else if(window.detachEvent){return function(el,sType,fn){el.detachEvent("on"+sType,fn);};}else{return function(){};}}()};}();(function(){var EU=YAHOO.util.Event;EU.on=EU.addListener;if(document&&document.body){EU._load();}else{EU._simpleAdd(window,"load",EU._load);} -EU._simpleAdd(window,"unload",EU._unload);EU._tryPreloadAttach();})();} -YAHOO.util.CustomEvent=function(type,oScope,silent,signature){this.type=type;this.scope=oScope||window;this.silent=silent;this.signature=signature||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){} -var onsubscribeType="_YUICEOnSubscribe";if(type!==onsubscribeType){this.subscribeEvent=new YAHOO.util.CustomEvent(onsubscribeType,this,true);}};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(fn,obj,override){if(this.subscribeEvent){this.subscribeEvent.fire(fn,obj,override);} -this.subscribers.push(new YAHOO.util.Subscriber(fn,obj,override));},unsubscribe:function(fn,obj){if(!fn){return this.unsubscribeAll();} -var found=false;for(var i=0,len=this.subscribers.length;i<len;++i){var s=this.subscribers[i];if(s&&s.contains(fn,obj)){this._delete(i);found=true;}} -return found;},fire:function(){var len=this.subscribers.length;if(!len&&this.silent){return true;} -var args=[],ret=true,i;for(i=0;i<arguments.length;++i){args.push(arguments[i]);} -var argslength=args.length;if(!this.silent){} -for(i=0;i<len;++i){var s=this.subscribers[i];if(s){if(!this.silent){} -var scope=s.getScope(this.scope);if(this.signature==YAHOO.util.CustomEvent.FLAT){var param=null;if(args.length>0){param=args[0];} -ret=s.fn.call(scope,param,s.obj);}else{ret=s.fn.call(scope,this.type,args,s.obj);} -if(false===ret){if(!this.silent){} -return false;}}} -return true;},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i<len;++i){this._delete(len-1-i);} -return i;},_delete:function(index){var s=this.subscribers[index];if(s){delete s.fn;delete s.obj;} -this.subscribers.splice(index,1);},toString:function(){return"CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(fn,obj,override){this.fn=fn;this.obj=obj||null;this.override=override;};YAHOO.util.Subscriber.prototype.getScope=function(defaultScope){if(this.override){if(this.override===true){return this.obj;}else{return this.override;}} -return defaultScope;};YAHOO.util.Subscriber.prototype.contains=function(fn,obj){if(obj){return(this.fn==fn&&this.obj==obj);}else{return(this.fn==fn);}};YAHOO.util.Subscriber.prototype.toString=function(){return"Subscriber { obj: "+(this.obj||"")+", override: "+(this.override||"no")+" }";};YAHOO.util.EventProvider=function(){};YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(p_type,p_fn,p_obj,p_override){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){ce.subscribe(p_fn,p_obj,p_override);}else{this.__yui_subscribers=this.__yui_subscribers||{};var subs=this.__yui_subscribers;if(!subs[p_type]){subs[p_type]=[];} -subs[p_type].push({fn:p_fn,obj:p_obj,override:p_override});}},unsubscribe:function(p_type,p_fn,p_obj){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){return ce.unsubscribe(p_fn,p_obj);}else{return false;}},unsubscribeAll:function(p_type){return this.unsubscribe(p_type);},createEvent:function(p_type,p_config){this.__yui_events=this.__yui_events||{};var opts=p_config||{};var events=this.__yui_events;if(events[p_type]){}else{var scope=opts.scope||this;var silent=opts.silent||null;var ce=new YAHOO.util.CustomEvent(p_type,scope,silent,YAHOO.util.CustomEvent.FLAT);events[p_type]=ce;if(opts.onSubscribeCallback){ce.subscribeEvent.subscribe(opts.onSubscribeCallback);} -this.__yui_subscribers=this.__yui_subscribers||{};var qs=this.__yui_subscribers[p_type];if(qs){for(var i=0;i<qs.length;++i){ce.subscribe(qs[i].fn,qs[i].obj,qs[i].override);}}} -return events[p_type];},fireEvent:function(p_type,arg1,arg2,etc){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){var args=[];for(var i=1;i<arguments.length;++i){args.push(arguments[i]);} -return ce.fire.apply(ce,args);}else{return null;}},hasEvent:function(type){if(this.__yui_events){if(this.__yui_events[type]){return true;}} -return false;}};YAHOO.util.KeyListener=function(attachTo,keyData,handler,event){if(!attachTo){}else if(!keyData){}else if(!handler){} -if(!event){event=YAHOO.util.KeyListener.KEYDOWN;} -var keyEvent=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof attachTo=='string'){attachTo=document.getElementById(attachTo);} -if(typeof handler=='function'){keyEvent.subscribe(handler);}else{keyEvent.subscribe(handler.fn,handler.scope,handler.correctScope);} -function handleKeyPress(e,obj){if(!keyData.shift){keyData.shift=false;} -if(!keyData.alt){keyData.alt=false;} -if(!keyData.ctrl){keyData.ctrl=false;} -if(e.shiftKey==keyData.shift&&e.altKey==keyData.alt&&e.ctrlKey==keyData.ctrl){var dataItem;var keyPressed;if(keyData.keys instanceof Array){for(var i=0;i<keyData.keys.length;i++){dataItem=keyData.keys[i];if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);break;}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);break;}}}else{dataItem=keyData.keys;if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);}}}} -this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(attachTo,event,handleKeyPress);this.enabledEvent.fire(keyData);} -this.enabled=true;};this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(attachTo,event,handleKeyPress);this.disabledEvent.fire(keyData);} -this.enabled=false;};this.toString=function(){return"KeyListener ["+keyData.keys+"] "+attachTo.tagName+ -(attachTo.id?"["+attachTo.id+"]":"");};};YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.register("event",YAHOO.util.Event,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/event/event.js b/interface/web/js/yui/event/event.js deleted file mode 100644 index 3d8e5dd7af..0000000000 --- a/interface/web/js/yui/event/event.js +++ /dev/null @@ -1,2054 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The Event Utility provides utilities for managing DOM Events and tools - * for building event systems - * - * @module event - * @title Event Utility - * @namespace YAHOO.util - * @requires yahoo - */ - -// The first instance of Event will win if it is loaded more than once. -// @TODO this needs to be changed so that only the state data that needs to -// be preserved is kept, while methods are overwritten/added as needed. -// This means that the module pattern can't be used. -if (!YAHOO.util.Event) { - -/** - * The event utility provides functions to add and remove event listeners, - * event cleansing. It also tries to automatically remove listeners it - * registers during the unload event. - * - * @class Event - * @static - */ - YAHOO.util.Event = function() { - - /** - * True after the onload event has fired - * @property loadComplete - * @type boolean - * @static - * @private - */ - var loadComplete = false; - - /** - * Cache of wrapped listeners - * @property listeners - * @type array - * @static - * @private - */ - var listeners = []; - - /** - * User-defined unload function that will be fired before all events - * are detached - * @property unloadListeners - * @type array - * @static - * @private - */ - var unloadListeners = []; - - /** - * Cache of DOM0 event handlers to work around issues with DOM2 events - * in Safari - * @property legacyEvents - * @static - * @private - */ - var legacyEvents = []; - - /** - * Listener stack for DOM0 events - * @property legacyHandlers - * @static - * @private - */ - var legacyHandlers = []; - - /** - * The number of times to poll after window.onload. This number is - * increased if additional late-bound handlers are requested after - * the page load. - * @property retryCount - * @static - * @private - */ - var retryCount = 0; - - /** - * onAvailable listeners - * @property onAvailStack - * @static - * @private - */ - var onAvailStack = []; - - /** - * Lookup table for legacy events - * @property legacyMap - * @static - * @private - */ - var legacyMap = []; - - /** - * Counter for auto id generation - * @property counter - * @static - * @private - */ - var counter = 0; - - /** - * addListener/removeListener can throw errors in unexpected scenarios. - * These errors are suppressed, the method returns false, and this property - * is set - * @property lastError - * @type Error - */ - var lastError = null; - - return { - - /** - * The number of times we should look for elements that are not - * in the DOM at the time the event is requested after the document - * has been loaded. The default is 200@amp;50 ms, so it will poll - * for 10 seconds or until all outstanding handlers are bound - * (whichever comes first). - * @property POLL_RETRYS - * @type int - * @static - * @final - */ - POLL_RETRYS: 200, - - /** - * The poll interval in milliseconds - * @property POLL_INTERVAL - * @type int - * @static - * @final - */ - POLL_INTERVAL: 20, - - /** - * Element to bind, int constant - * @property EL - * @type int - * @static - * @final - */ - EL: 0, - - /** - * Type of event, int constant - * @property TYPE - * @type int - * @static - * @final - */ - TYPE: 1, - - /** - * Function to execute, int constant - * @property FN - * @type int - * @static - * @final - */ - FN: 2, - - /** - * Function wrapped for scope correction and cleanup, int constant - * @property WFN - * @type int - * @static - * @final - */ - WFN: 3, - - /** - * Object passed in by the user that will be returned as a - * parameter to the callback, int constant - * @property OBJ - * @type int - * @static - * @final - */ - OBJ: 3, - - /** - * Adjusted scope, either the element we are registering the event - * on or the custom object passed in by the listener, int constant - * @property ADJ_SCOPE - * @type int - * @static - * @final - */ - ADJ_SCOPE: 4, - - /** - * Safari detection is necessary to work around the preventDefault - * bug that makes it so you can't cancel a href click from the - * handler. Since this function has been used outside of this - * utility, it was changed to detect all KHTML browser to be more - * friendly towards the non-Safari browsers that share the engine. - * Internally, the preventDefault bug detection now uses the - * webkit property. - * @property isSafari - * @private - * @static - * @deprecated - */ - isSafari: (/KHTML/gi).test(navigator.userAgent), - - /** - * If WebKit is detected, we keep track of the version number of - * the engine. - * Safari 1.3.2 (312.6): 312.8.1 <-- currently the latest - * available on Mac OSX 10.3. - * Safari 2.0.2: 416 <-- hasOwnProperty introduced - * Safari 2.0.4: 418 <-- preventDefault fixed (I believe) - * Safari 2.0.4 (419.3): 418.9.1 <-- current release - * - * http://developer.apple.com/internet/safari/uamatrix.html - * @property webkit - */ - webkit: function() { - var v=navigator.userAgent.match(/AppleWebKit\/([^ ]*)/); - if (v&&v[1]) { - return v[1]; - } - return null; - }(), - - /** - * IE detection needed to properly calculate pageX and pageY. - * capabilities checking didn't seem to work because another - * browser that does not provide the properties have the values - * calculated in a different manner than IE. - * @property isIE - * @private - * @static - */ - isIE: (!this.webkit && !navigator.userAgent.match(/opera/gi) && - navigator.userAgent.match(/msie/gi)), - - /** - * poll handle - * @property _interval - * @private - */ - _interval: null, - - /** - * @method startInterval - * @static - * @private - */ - startInterval: function() { - if (!this._interval) { - var self = this; - var callback = function() { self._tryPreloadAttach(); }; - this._interval = setInterval(callback, this.POLL_INTERVAL); - // this.timeout = setTimeout(callback, i); - } - }, - - /** - * Executes the supplied callback when the item with the supplied - * id is found. This is meant to be used to execute behavior as - * soon as possible as the page loads. If you use this after the - * initial page load it will poll for a fixed time for the element. - * The number of times it will poll and the frequency are - * configurable. By default it will poll for 10 seconds. - * - * @method onAvailable - * - * @param {string} p_id the id of the element to look for. - * @param {function} p_fn what to execute when the element is found. - * @param {object} p_obj an optional object to be passed back as - * a parameter to p_fn. - * @param {boolean} p_override If set to true, p_fn will execute - * in the scope of p_obj - * - * @static - */ - onAvailable: function(p_id, p_fn, p_obj, p_override) { - onAvailStack.push( { id: p_id, - fn: p_fn, - obj: p_obj, - override: p_override, - checkReady: false } ); - - retryCount = this.POLL_RETRYS; - this.startInterval(); - }, - - /** - * Works the same way as onAvailable, but additionally checks the - * state of sibling elements to determine if the content of the - * available element is safe to modify. - * - * @method onContentReady - * - * @param {string} p_id the id of the element to look for. - * @param {function} p_fn what to execute when the element is ready. - * @param {object} p_obj an optional object to be passed back as - * a parameter to p_fn. - * @param {boolean} p_override If set to true, p_fn will execute - * in the scope of p_obj - * - * @static - */ - onContentReady: function(p_id, p_fn, p_obj, p_override) { - onAvailStack.push( { id: p_id, - fn: p_fn, - obj: p_obj, - override: p_override, - checkReady: true } ); - - retryCount = this.POLL_RETRYS; - this.startInterval(); - }, - - /** - * Appends an event handler - * - * @method addListener - * - * @param {Object} el The html element to assign the - * event to - * @param {String} sType The type of event to append - * @param {Function} fn The method the event invokes - * @param {Object} 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 - * @return {boolean} True if the action was successful or defered, - * false if one or more of the elements - * could not have the listener attached, - * or if the operation throws an exception. - * @static - */ - addListener: function(el, sType, fn, obj, override) { - - - if (!fn || !fn.call) { - return false; - } - - // The el argument can be an array of elements or element ids. - if ( this._isValidCollection(el)) { - var ok = true; - for (var i=0,len=el.length; i<len; ++i) { - ok = this.on(el[i], - sType, - fn, - obj, - override) && ok; - } - return ok; - - } else if (typeof el == "string") { - var oEl = this.getEl(el); - // If the el argument is a string, we assume it is - // actually the id of the element. If the page is loaded - // we convert el to the actual element, otherwise we - // defer attaching the event until onload event fires - - // check to see if we need to delay hooking up the event - // until after the page loads. - if (oEl) { - el = oEl; - } else { - // defer adding the event until the element is available - this.onAvailable(el, function() { - YAHOO.util.Event.on(el, sType, fn, obj, override); - }); - - return true; - } - } - - // Element should be an html element or an array if we get - // here. - if (!el) { - return false; - } - - // we need to make sure we fire registered unload events - // prior to automatically unhooking them. So we hang on to - // these instead of attaching them to the window and fire the - // handles explicitly during our one unload event. - if ("unload" == sType && obj !== this) { - unloadListeners[unloadListeners.length] = - [el, sType, fn, obj, override]; - return true; - } - - - // if the user chooses to override the scope, we use the custom - // object passed in, otherwise the executing scope will be the - // HTML element that the event is registered on - var scope = el; - if (override) { - if (override === true) { - scope = obj; - } else { - scope = override; - } - } - - // wrap the function so we can return the obj object when - // the event fires; - var wrappedFn = function(e) { - return fn.call(scope, YAHOO.util.Event.getEvent(e), - obj); - }; - - var li = [el, sType, fn, wrappedFn, scope]; - var index = listeners.length; - // cache the listener so we can try to automatically unload - listeners[index] = li; - - if (this.useLegacyEvent(el, sType)) { - var legacyIndex = this.getLegacyIndex(el, sType); - - // Add a new dom0 wrapper if one is not detected for this - // element - if ( legacyIndex == -1 || - el != legacyEvents[legacyIndex][0] ) { - - legacyIndex = legacyEvents.length; - legacyMap[el.id + sType] = legacyIndex; - - // cache the signature for the DOM0 event, and - // include the existing handler for the event, if any - legacyEvents[legacyIndex] = - [el, sType, el["on" + sType]]; - legacyHandlers[legacyIndex] = []; - - el["on" + sType] = - function(e) { - YAHOO.util.Event.fireLegacyEvent( - YAHOO.util.Event.getEvent(e), legacyIndex); - }; - } - - // add a reference to the wrapped listener to our custom - // stack of events - //legacyHandlers[legacyIndex].push(index); - legacyHandlers[legacyIndex].push(li); - - } else { - try { - this._simpleAdd(el, sType, wrappedFn, false); - } catch(ex) { - // handle an error trying to attach an event. If it fails - // we need to clean up the cache - this.lastError = ex; - this.removeListener(el, sType, fn); - return false; - } - } - - return true; - - }, - - /** - * When using legacy events, the handler is routed to this object - * so we can fire our custom listener stack. - * @method fireLegacyEvent - * @static - * @private - */ - fireLegacyEvent: function(e, legacyIndex) { - var ok=true,le,lh,li,scope,ret; - - lh = legacyHandlers[legacyIndex]; - for (var i=0,len=lh.length; i<len; ++i) { - li = lh[i]; - if ( li && li[this.WFN] ) { - scope = li[this.ADJ_SCOPE]; - ret = li[this.WFN].call(scope, e); - ok = (ok && ret); - } - } - - // Fire the original handler if we replaced one. We fire this - // after the other events to keep stopPropagation/preventDefault - // that happened in the DOM0 handler from touching our DOM2 - // substitute - le = legacyEvents[legacyIndex]; - if (le && le[2]) { - le[2](e); - } - - return ok; - }, - - /** - * Returns the legacy event index that matches the supplied - * signature - * @method getLegacyIndex - * @static - * @private - */ - getLegacyIndex: function(el, sType) { - var key = this.generateId(el) + sType; - if (typeof legacyMap[key] == "undefined") { - return -1; - } else { - return legacyMap[key]; - } - }, - - /** - * Logic that determines when we should automatically use legacy - * events instead of DOM2 events. Currently this is limited to old - * Safari browsers with a broken preventDefault - * @method useLegacyEvent - * @static - * @private - */ - useLegacyEvent: function(el, sType) { - if (this.webkit && ("click"==sType || "dblclick"==sType)) { - var v = parseInt(this.webkit, 10); - if (!isNaN(v) && v<418) { - return true; - } - } - return false; - }, - - /** - * Removes an event handler - * - * @method removeListener - * - * @param {Object} el the html element or the id of the element to - * assign the event to. - * @param {String} sType the type of event to remove. - * @param {Function} fn the method the event invokes. If fn is - * undefined, then all event handlers for the type of event are - * removed. - * @return {boolean} true if the unbind was successful, false - * otherwise. - * @static - */ - removeListener: function(el, sType, fn) { - var i, len; - - // The el argument can be a string - if (typeof el == "string") { - el = this.getEl(el); - // The el argument can be an array of elements or element ids. - } else if ( this._isValidCollection(el)) { - var ok = true; - for (i=0,len=el.length; i<len; ++i) { - ok = ( this.removeListener(el[i], sType, fn) && ok ); - } - return ok; - } - - if (!fn || !fn.call) { - //return false; - return this.purgeElement(el, false, sType); - } - - - if ("unload" == sType) { - - for (i=0, len=unloadListeners.length; i<len; i++) { - var li = unloadListeners[i]; - if (li && - li[0] == el && - li[1] == sType && - li[2] == fn) { - unloadListeners.splice(i, 1); - return true; - } - } - - return false; - } - - var cacheItem = null; - - // The index is a hidden parameter; needed to remove it from - // the method signature because it was tempting users to - // try and take advantage of it, which is not possible. - var index = arguments[3]; - - if ("undefined" == typeof index) { - index = this._getCacheIndex(el, sType, fn); - } - - if (index >= 0) { - cacheItem = listeners[index]; - } - - if (!el || !cacheItem) { - return false; - } - - - if (this.useLegacyEvent(el, sType)) { - var legacyIndex = this.getLegacyIndex(el, sType); - var llist = legacyHandlers[legacyIndex]; - if (llist) { - for (i=0, len=llist.length; i<len; ++i) { - li = llist[i]; - if (li && - li[this.EL] == el && - li[this.TYPE] == sType && - li[this.FN] == fn) { - llist.splice(i, 1); - break; - } - } - } - - } else { - try { - this._simpleRemove(el, sType, cacheItem[this.WFN], false); - } catch(ex) { - this.lastError = ex; - return false; - } - } - - // removed the wrapped handler - delete listeners[index][this.WFN]; - delete listeners[index][this.FN]; - listeners.splice(index, 1); - - return true; - - }, - - /** - * Returns the event's target element - * @method getTarget - * @param {Event} ev the event - * @param {boolean} resolveTextNode when set to true the target's - * parent will be returned if the target is a - * text node. @deprecated, the text node is - * now resolved automatically - * @return {HTMLElement} the event's target - * @static - */ - getTarget: function(ev, resolveTextNode) { - var t = ev.target || ev.srcElement; - return this.resolveTextNode(t); - }, - - /** - * In some cases, some browsers will return a text node inside - * the actual element that was targeted. This normalizes the - * return value for getTarget and getRelatedTarget. - * @method resolveTextNode - * @param {HTMLElement} node node to resolve - * @return {HTMLElement} the normized node - * @static - */ - resolveTextNode: function(node) { - // if (node && node.nodeName && - // "#TEXT" == node.nodeName.toUpperCase()) { - if (node && 3 == node.nodeType) { - return node.parentNode; - } else { - return node; - } - }, - - /** - * Returns the event's pageX - * @method getPageX - * @param {Event} ev the event - * @return {int} the event's pageX - * @static - */ - getPageX: function(ev) { - var x = ev.pageX; - if (!x && 0 !== x) { - x = ev.clientX || 0; - - if ( this.isIE ) { - x += this._getScrollLeft(); - } - } - - return x; - }, - - /** - * Returns the event's pageY - * @method getPageY - * @param {Event} ev the event - * @return {int} the event's pageY - * @static - */ - getPageY: function(ev) { - var y = ev.pageY; - if (!y && 0 !== y) { - y = ev.clientY || 0; - - if ( this.isIE ) { - y += this._getScrollTop(); - } - } - - - return y; - }, - - /** - * Returns the pageX and pageY properties as an indexed array. - * @method getXY - * @param {Event} ev the event - * @return {[x, y]} the pageX and pageY properties of the event - * @static - */ - getXY: function(ev) { - return [this.getPageX(ev), this.getPageY(ev)]; - }, - - /** - * Returns the event's related target - * @method getRelatedTarget - * @param {Event} ev the event - * @return {HTMLElement} the event's relatedTarget - * @static - */ - getRelatedTarget: function(ev) { - var t = ev.relatedTarget; - if (!t) { - if (ev.type == "mouseout") { - t = ev.toElement; - } else if (ev.type == "mouseover") { - t = ev.fromElement; - } - } - - return this.resolveTextNode(t); - }, - - /** - * Returns the time of the event. If the time is not included, the - * event is modified using the current time. - * @method getTime - * @param {Event} ev the event - * @return {Date} the time of the event - * @static - */ - getTime: function(ev) { - if (!ev.time) { - var t = new Date().getTime(); - try { - ev.time = t; - } catch(ex) { - this.lastError = ex; - return t; - } - } - - return ev.time; - }, - - /** - * Convenience method for stopPropagation + preventDefault - * @method stopEvent - * @param {Event} ev the event - * @static - */ - stopEvent: function(ev) { - this.stopPropagation(ev); - this.preventDefault(ev); - }, - - /** - * Stops event propagation - * @method stopPropagation - * @param {Event} ev the event - * @static - */ - stopPropagation: function(ev) { - if (ev.stopPropagation) { - ev.stopPropagation(); - } else { - ev.cancelBubble = true; - } - }, - - /** - * Prevents the default behavior of the event - * @method preventDefault - * @param {Event} ev the event - * @static - */ - preventDefault: function(ev) { - if (ev.preventDefault) { - ev.preventDefault(); - } else { - ev.returnValue = false; - } - }, - - /** - * Finds the event in the window object, the caller's arguments, or - * in the arguments of another method in the callstack. This is - * executed automatically for events registered through the event - * manager, so the implementer should not normally need to execute - * this function at all. - * @method getEvent - * @param {Event} e the event parameter from the handler - * @return {Event} the event - * @static - */ - getEvent: function(e) { - var ev = e || window.event; - - if (!ev) { - var c = this.getEvent.caller; - while (c) { - ev = c.arguments[0]; - if (ev && Event == ev.constructor) { - break; - } - c = c.caller; - } - } - - return ev; - }, - - /** - * Returns the charcode for an event - * @method getCharCode - * @param {Event} ev the event - * @return {int} the event's charCode - * @static - */ - getCharCode: function(ev) { - return ev.charCode || ev.keyCode || 0; - }, - - /** - * Locating the saved event handler data by function ref - * - * @method _getCacheIndex - * @static - * @private - */ - _getCacheIndex: function(el, sType, fn) { - for (var i=0,len=listeners.length; i<len; ++i) { - var li = listeners[i]; - if ( li && - li[this.FN] == fn && - li[this.EL] == el && - li[this.TYPE] == sType ) { - return i; - } - } - - return -1; - }, - - /** - * Generates an unique ID for the element if it does not already - * have one. - * @method generateId - * @param el the element to create the id for - * @return {string} the resulting id of the element - * @static - */ - generateId: function(el) { - var id = el.id; - - if (!id) { - id = "yuievtautoid-" + counter; - ++counter; - el.id = id; - } - - return id; - }, - - - /** - * We want to be able to use getElementsByTagName as a collection - * to attach a group of events to. Unfortunately, different - * browsers return different types of collections. This function - * tests to determine if the object is array-like. It will also - * fail if the object is an array, but is empty. - * @method _isValidCollection - * @param o the object to test - * @return {boolean} true if the object is array-like and populated - * @static - * @private - */ - _isValidCollection: function(o) { - return ( o && // o is something - o.length && // o is indexed - typeof o != "string" && // o is not a string - !o.tagName && // o is not an HTML element - !o.alert && // o is not a window - typeof o[0] != "undefined" ); - - }, - - /** - * @private - * @property elCache - * DOM element cache - * @static - */ - elCache: {}, - - /** - * We cache elements bound by id because when the unload event - * fires, we can no longer use document.getElementById - * @method getEl - * @static - * @private - */ - getEl: function(id) { - return document.getElementById(id); - }, - - /** - * Clears the element cache - * @deprecated Elements are not cached any longer - * @method clearCache - * @static - * @private - */ - clearCache: function() { }, - - /** - * hook up any deferred listeners - * @method _load - * @static - * @private - */ - _load: function(e) { - loadComplete = true; - var EU = YAHOO.util.Event; - // Remove the listener to assist with the IE memory issue, but not - // for other browsers because FF 1.0x does not like it. - if (this.isIE) { - EU._simpleRemove(window, "load", EU._load); - } - }, - - /** - * Polling function that runs before the onload event fires, - * attempting to attach to DOM Nodes as soon as they are - * available - * @method _tryPreloadAttach - * @static - * @private - */ - _tryPreloadAttach: function() { - - if (this.locked) { - return false; - } - - this.locked = true; - - - // keep trying until after the page is loaded. We need to - // check the page load state prior to trying to bind the - // elements so that we can be certain all elements have been - // tested appropriately - var tryAgain = !loadComplete; - if (!tryAgain) { - tryAgain = (retryCount > 0); - } - - // onAvailable - var notAvail = []; - for (var i=0,len=onAvailStack.length; i<len ; ++i) { - var item = onAvailStack[i]; - if (item) { - var el = this.getEl(item.id); - - if (el) { - // The element is available, but not necessarily ready - // @todo verify IE7 compatibility - // @todo should we test parentNode.nextSibling? - // @todo re-evaluate global content ready - if ( !item.checkReady || - loadComplete || - el.nextSibling || - (document && document.body) ) { - - var scope = el; - if (item.override) { - if (item.override === true) { - scope = item.obj; - } else { - scope = item.override; - } - } - item.fn.call(scope, item.obj); - //delete onAvailStack[i]; - // null out instead of delete for Opera - onAvailStack[i] = null; - } - } else { - notAvail.push(item); - } - } - } - - retryCount = (notAvail.length === 0) ? 0 : retryCount - 1; - - if (tryAgain) { - // we may need to strip the nulled out items here - this.startInterval(); - } else { - clearInterval(this._interval); - this._interval = null; - } - - this.locked = false; - - return true; - - }, - - /** - * Removes all listeners attached to the given element via addListener. - * Optionally, the node's children can also be purged. - * Optionally, you can specify a specific type of event to remove. - * @method purgeElement - * @param {HTMLElement} el the element to purge - * @param {boolean} recurse recursively purge this element's children - * as well. Use with caution. - * @param {string} sType optional type of listener to purge. If - * left out, all listeners will be removed - * @static - */ - purgeElement: function(el, recurse, sType) { - var elListeners = this.getListeners(el, sType); - if (elListeners) { - for (var i=0,len=elListeners.length; i<len ; ++i) { - var l = elListeners[i]; - // can't use the index on the changing collection - //this.removeListener(el, l.type, l.fn, l.index); - this.removeListener(el, l.type, l.fn); - } - } - - if (recurse && el && el.childNodes) { - for (i=0,len=el.childNodes.length; i<len ; ++i) { - this.purgeElement(el.childNodes[i], recurse, sType); - } - } - }, - - /** - * Returns all listeners attached to the given element via addListener. - * Optionally, you can specify a specific type of event to return. - * @method getListeners - * @param el {HTMLElement} the element to inspect - * @param sType {string} optional type of listener to return. If - * left out, all listeners will be returned - * @return {Object} the listener. Contains the following fields: - * type: (string) the type of event - * fn: (function) the callback supplied to addListener - * obj: (object) the custom object supplied to addListener - * adjust: (boolean) whether or not to adjust the default scope - * index: (int) its position in the Event util listener cache - * @static - */ - getListeners: function(el, sType) { - var results=[], searchLists; - if (!sType) { - searchLists = [listeners, unloadListeners]; - } else if (sType == "unload") { - searchLists = [unloadListeners]; - } else { - searchLists = [listeners]; - } - - for (var j=0;j<searchLists.length; ++j) { - var searchList = searchLists[j]; - if (searchList && searchList.length > 0) { - for (var i=0,len=searchList.length; i<len ; ++i) { - var l = searchList[i]; - if ( l && l[this.EL] === el && - (!sType || sType === l[this.TYPE]) ) { - results.push({ - type: l[this.TYPE], - fn: l[this.FN], - obj: l[this.OBJ], - adjust: l[this.ADJ_SCOPE], - index: i - }); - } - } - } - } - - return (results.length) ? results : null; - }, - - /** - * Removes all listeners registered by pe.event. Called - * automatically during the unload event. - * @method _unload - * @static - * @private - */ - _unload: function(e) { - - var EU = YAHOO.util.Event, i, j, l, len, index; - - for (i=0,len=unloadListeners.length; i<len; ++i) { - l = unloadListeners[i]; - if (l) { - var scope = window; - if (l[EU.ADJ_SCOPE]) { - if (l[EU.ADJ_SCOPE] === true) { - scope = l[EU.OBJ]; - } else { - scope = l[EU.ADJ_SCOPE]; - } - } - l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ] ); - unloadListeners[i] = null; - l=null; - scope=null; - } - } - - unloadListeners = null; - - if (listeners && listeners.length > 0) { - j = listeners.length; - while (j) { - index = j-1; - l = listeners[index]; - if (l) { - EU.removeListener(l[EU.EL], l[EU.TYPE], - l[EU.FN], index); - } - j = j - 1; - } - l=null; - - EU.clearCache(); - } - - for (i=0,len=legacyEvents.length; i<len; ++i) { - // dereference the element - //delete legacyEvents[i][0]; - legacyEvents[i][0] = null; - - // delete the array item - //delete legacyEvents[i]; - legacyEvents[i] = null; - } - - legacyEvents = null; - - EU._simpleRemove(window, "unload", EU._unload); - - }, - - /** - * Returns scrollLeft - * @method _getScrollLeft - * @static - * @private - */ - _getScrollLeft: function() { - return this._getScroll()[1]; - }, - - /** - * Returns scrollTop - * @method _getScrollTop - * @static - * @private - */ - _getScrollTop: function() { - return this._getScroll()[0]; - }, - - /** - * Returns the scrollTop and scrollLeft. Used to calculate the - * pageX and pageY in Internet Explorer - * @method _getScroll - * @static - * @private - */ - _getScroll: function() { - var dd = document.documentElement, db = document.body; - if (dd && (dd.scrollTop || dd.scrollLeft)) { - return [dd.scrollTop, dd.scrollLeft]; - } else if (db) { - return [db.scrollTop, db.scrollLeft]; - } else { - return [0, 0]; - } - }, - - /** - * Used by old versions of CustomEvent, restored for backwards - * compatibility - * @method regCE - * @private - */ - regCE: function() { - // does nothing - }, - - /** - * Adds a DOM event directly without the caching, cleanup, scope adj, etc - * - * @method _simpleAdd - * @param {HTMLElement} el the element to bind the handler to - * @param {string} sType the type of event handler - * @param {function} fn the callback to invoke - * @param {boolen} capture capture or bubble phase - * @static - * @private - */ - _simpleAdd: function () { - if (window.addEventListener) { - return function(el, sType, fn, capture) { - el.addEventListener(sType, fn, (capture)); - }; - } else if (window.attachEvent) { - return function(el, sType, fn, capture) { - el.attachEvent("on" + sType, fn); - }; - } else { - return function(){}; - } - }(), - - /** - * Basic remove listener - * - * @method _simpleRemove - * @param {HTMLElement} el the element to bind the handler to - * @param {string} sType the type of event handler - * @param {function} fn the callback to invoke - * @param {boolen} capture capture or bubble phase - * @static - * @private - */ - _simpleRemove: function() { - if (window.removeEventListener) { - return function (el, sType, fn, capture) { - el.removeEventListener(sType, fn, (capture)); - }; - } else if (window.detachEvent) { - return function (el, sType, fn) { - el.detachEvent("on" + sType, fn); - }; - } else { - return function(){}; - } - }() - }; - - }(); - - (function() { - var EU = YAHOO.util.Event; - - /** - * YAHOO.util.Event.on is an alias for addListener - * @method on - * @see addListener - * @static - */ - EU.on = EU.addListener; - - // YAHOO.mix(EU, YAHOO.util.EventProvider.prototype); - // EU.createEvent("DOMContentReady"); - // EU.subscribe("DOMContentReady", EU._load); - - if (document && document.body) { - EU._load(); - } else { - // EU._simpleAdd(document, "DOMContentLoaded", EU._load); - EU._simpleAdd(window, "load", EU._load); - } - EU._simpleAdd(window, "unload", EU._unload); - EU._tryPreloadAttach(); - })(); -} - -/** - * The CustomEvent class lets you define events for your application - * that can be subscribed to by one or more independent component. - * - * @param {String} type The type of event, which is passed to the callback - * when the event fires - * @param {Object} oScope The context the event will fire from. "this" will - * refer to this object in the callback. Default value: - * the window object. The listener can override this. - * @param {boolean} silent pass true to prevent the event from writing to - * the debugsystem - * @param {int} signature the signature that the custom event subscriber - * will receive. YAHOO.util.CustomEvent.LIST or - * YAHOO.util.CustomEvent.FLAT. The default is - * YAHOO.util.CustomEvent.LIST. - * @namespace YAHOO.util - * @class CustomEvent - * @constructor - */ -YAHOO.util.CustomEvent = function(type, oScope, silent, signature) { - - /** - * The type of event, returned to subscribers when the event fires - * @property type - * @type string - */ - this.type = type; - - /** - * The scope the the event will fire from by default. Defaults to the window - * obj - * @property scope - * @type object - */ - this.scope = oScope || window; - - /** - * By default all custom events are logged in the debug build, set silent - * to true to disable debug outpu for this event. - * @property silent - * @type boolean - */ - this.silent = silent; - - /** - * Custom events support two styles of arguments provided to the event - * subscribers. - * <ul> - * <li>YAHOO.util.CustomEvent.LIST: - * <ul> - * <li>param1: event name</li> - * <li>param2: array of arguments sent to fire</li> - * <li>param3: <optional> a custom object supplied by the subscriber</li> - * </ul> - * </li> - * <li>YAHOO.util.CustomEvent.FLAT - * <ul> - * <li>param1: the first argument passed to fire. If you need to - * pass multiple parameters, use and array or object literal</li> - * <li>param2: <optional> a custom object supplied by the subscriber</li> - * </ul> - * </li> - * </ul> - * @property signature - * @type int - */ - this.signature = signature || YAHOO.util.CustomEvent.LIST; - - /** - * The subscribers to this event - * @property subscribers - * @type Subscriber[] - */ - this.subscribers = []; - - if (!this.silent) { - } - - var onsubscribeType = "_YUICEOnSubscribe"; - - // Only add subscribe events for events that are not generated by - // CustomEvent - if (type !== onsubscribeType) { - - /** - * Custom events provide a custom event that fires whenever there is - * a new subscriber to the event. This provides an opportunity to - * handle the case where there is a non-repeating event that has - * already fired has a new subscriber. - * - * @event subscribeEvent - * @type YAHOO.util.CustomEvent - * @param {Function} fn The function to execute - * @param {Object} obj An object to be passed along when the event - * fires - * @param {boolean|Object} override If true, the obj passed in becomes - * the execution scope of the listener. - * if an object, that object becomes the - * the execution scope. - */ - this.subscribeEvent = - new YAHOO.util.CustomEvent(onsubscribeType, this, true); - - } -}; - -/** - * Subscriber listener sigature constant. The LIST type returns three - * parameters: the event type, the array of args passed to fire, and - * the optional custom object - * @property YAHOO.util.CustomEvent.LIST - * @static - * @type int - */ -YAHOO.util.CustomEvent.LIST = 0; - -/** - * Subscriber listener sigature constant. The FLAT type returns two - * parameters: the first argument passed to fire and the optional - * custom object - * @property YAHOO.util.CustomEvent.FLAT - * @static - * @type int - */ -YAHOO.util.CustomEvent.FLAT = 1; - -YAHOO.util.CustomEvent.prototype = { - - /** - * Subscribes the caller to this event - * @method subscribe - * @param {Function} fn The function to execute - * @param {Object} obj An object to be passed along when the event - * fires - * @param {boolean|Object} override If true, the obj passed in becomes - * the execution scope of the listener. - * if an object, that object becomes the - * the execution scope. - */ - subscribe: function(fn, obj, override) { - if (this.subscribeEvent) { - this.subscribeEvent.fire(fn, obj, override); - } - - this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, override) ); - }, - - /** - * Unsubscribes subscribers. - * @method unsubscribe - * @param {Function} fn The subscribed function to remove, if not supplied - * all will be removed - * @param {Object} obj The custom object passed to subscribe. This is - * optional, but if supplied will be used to - * disambiguate multiple listeners that are the same - * (e.g., you subscribe many object using a function - * that lives on the prototype) - * @return {boolean} True if the subscriber was found and detached. - */ - unsubscribe: function(fn, obj) { - - if (!fn) { - return this.unsubscribeAll(); - } - - var found = false; - for (var i=0, len=this.subscribers.length; i<len; ++i) { - var s = this.subscribers[i]; - if (s && s.contains(fn, obj)) { - this._delete(i); - found = true; - } - } - - return found; - }, - - /** - * Notifies the subscribers. The callback functions will be executed - * from the scope specified when the event was created, and with the - * following parameters: - * <ul> - * <li>The type of event</li> - * <li>All of the arguments fire() was executed with as an array</li> - * <li>The custom object (if any) that was passed into the subscribe() - * method</li> - * </ul> - * @method fire - * @param {Object*} arguments an arbitrary set of parameters to pass to - * the handler. - * @return {boolean} false if one of the subscribers returned false, - * true otherwise - */ - fire: function() { - var len=this.subscribers.length; - if (!len && this.silent) { - return true; - } - - var args=[], ret=true, i; - - for (i=0; i<arguments.length; ++i) { - args.push(arguments[i]); - } - - var argslength = args.length; - - if (!this.silent) { - } - - for (i=0; i<len; ++i) { - var s = this.subscribers[i]; - if (s) { - if (!this.silent) { - } - - var scope = s.getScope(this.scope); - - if (this.signature == YAHOO.util.CustomEvent.FLAT) { - var param = null; - if (args.length > 0) { - param = args[0]; - } - ret = s.fn.call(scope, param, s.obj); - } else { - ret = s.fn.call(scope, this.type, args, s.obj); - } - if (false === ret) { - if (!this.silent) { - } - - //break; - return false; - } - } - } - - return true; - }, - - /** - * Removes all listeners - * @method unsubscribeAll - * @return {int} The number of listeners unsubscribed - */ - unsubscribeAll: function() { - for (var i=0, len=this.subscribers.length; i<len; ++i) { - this._delete(len - 1 - i); - } - - return i; - }, - - /** - * @method _delete - * @private - */ - _delete: function(index) { - var s = this.subscribers[index]; - if (s) { - delete s.fn; - delete s.obj; - } - - // delete this.subscribers[index]; - this.subscribers.splice(index, 1); - }, - - /** - * @method toString - */ - toString: function() { - return "CustomEvent: " + "'" + this.type + "', " + - "scope: " + this.scope; - - } -}; - -///////////////////////////////////////////////////////////////////// - -/** - * Stores the subscriber information to be used when the event fires. - * @param {Function} fn The function to execute - * @param {Object} obj An object to be passed along when the event fires - * @param {boolean} override If true, the obj passed in becomes the execution - * scope of the listener - * @class Subscriber - * @constructor - */ -YAHOO.util.Subscriber = function(fn, obj, override) { - - /** - * The callback that will be execute when the event fires - * @property fn - * @type function - */ - this.fn = fn; - - /** - * An optional custom object that will passed to the callback when - * the event fires - * @property obj - * @type object - */ - this.obj = obj || null; - - /** - * The default execution scope for the event listener is defined when the - * event is created (usually the object which contains the event). - * By setting override to true, the execution scope becomes the custom - * object passed in by the subscriber. If override is an object, that - * object becomes the scope. - * @property override - * @type boolean|object - */ - this.override = override; - -}; - -/** - * Returns the execution scope for this listener. If override was set to true - * the custom obj will be the scope. If override is an object, that is the - * scope, otherwise the default scope will be used. - * @method getScope - * @param {Object} defaultScope the scope to use if this listener does not - * override it. - */ -YAHOO.util.Subscriber.prototype.getScope = function(defaultScope) { - if (this.override) { - if (this.override === true) { - return this.obj; - } else { - return this.override; - } - } - return defaultScope; -}; - -/** - * Returns true if the fn and obj match this objects properties. - * Used by the unsubscribe method to match the right subscriber. - * - * @method contains - * @param {Function} fn the function to execute - * @param {Object} obj an object to be passed along when the event fires - * @return {boolean} true if the supplied arguments match this - * subscriber's signature. - */ -YAHOO.util.Subscriber.prototype.contains = function(fn, obj) { - if (obj) { - return (this.fn == fn && this.obj == obj); - } else { - return (this.fn == fn); - } -}; - -/** - * @method toString - */ -YAHOO.util.Subscriber.prototype.toString = function() { - return "Subscriber { obj: " + (this.obj || "") + - ", override: " + (this.override || "no") + " }"; -}; - -/** - * EventProvider is designed to be used with YAHOO.augment to wrap - * CustomEvents in an interface that allows events to be subscribed to - * and fired by name. This makes it possible for implementing code to - * subscribe to an event that either has not been created yet, or will - * not be created at all. - * - * @Class EventProvider - */ -YAHOO.util.EventProvider = function() { }; - -YAHOO.util.EventProvider.prototype = { - - /** - * Private storage of custom events - * @property __yui_events - * @type Object[] - * @private - */ - __yui_events: null, - - /** - * Private storage of custom event subscribers - * @property __yui_subscribers - * @type Object[] - * @private - */ - __yui_subscribers: null, - - /** - * Subscribe to a CustomEvent by event type - * - * @method subscribe - * @param p_type {string} the type, or name of the event - * @param p_fn {function} the function to exectute when the event fires - * @param p_obj - * @param p_obj {Object} An object to be passed along when the event - * fires - * @param p_override {boolean} If true, the obj passed in becomes the - * execution scope of the listener - */ - subscribe: function(p_type, p_fn, p_obj, p_override) { - - this.__yui_events = this.__yui_events || {}; - var ce = this.__yui_events[p_type]; - - if (ce) { - ce.subscribe(p_fn, p_obj, p_override); - } else { - this.__yui_subscribers = this.__yui_subscribers || {}; - var subs = this.__yui_subscribers; - if (!subs[p_type]) { - subs[p_type] = []; - } - subs[p_type].push( - { fn: p_fn, obj: p_obj, override: p_override } ); - } - }, - - /** - * Unsubscribes one or more listeners the from the specified event - * @method unsubscribe - * @param p_type {string} The type, or name of the event - * @param p_fn {Function} The subscribed function to unsubscribe, if not - * supplied, all subscribers will be removed. - * @param p_obj {Object} The custom object passed to subscribe. This is - * optional, but if supplied will be used to - * disambiguate multiple listeners that are the same - * (e.g., you subscribe many object using a function - * that lives on the prototype) - * @return {boolean} true if the subscriber was found and detached. - */ - unsubscribe: function(p_type, p_fn, p_obj) { - this.__yui_events = this.__yui_events || {}; - var ce = this.__yui_events[p_type]; - if (ce) { - return ce.unsubscribe(p_fn, p_obj); - } else { - return false; - } - }, - - /** - * Removes all listeners from the specified event - * @method unsubscribeAll - * @param p_type {string} The type, or name of the event - */ - unsubscribeAll: function(p_type) { - return this.unsubscribe(p_type); - }, - - /** - * Creates a new custom event of the specified type. If a custom event - * by that name already exists, it will not be re-created. In either - * case the custom event is returned. - * - * @method createEvent - * - * @param p_type {string} the type, or name of the event - * @param p_config {object} optional config params. Valid properties are: - * - * <ul> - * <li> - * scope: defines the default execution scope. If not defined - * the default scope will be this instance. - * </li> - * <li> - * silent: if true, the custom event will not generate log messages. - * This is false by default. - * </li> - * <li> - * onSubscribeCallback: specifies a callback to execute when the - * event has a new subscriber. This will fire immediately for - * each queued subscriber if any exist prior to the creation of - * the event. - * </li> - * </ul> - * - * @return {CustomEvent} the custom event - * - */ - createEvent: function(p_type, p_config) { - - this.__yui_events = this.__yui_events || {}; - var opts = p_config || {}; - var events = this.__yui_events; - - if (events[p_type]) { - } else { - - var scope = opts.scope || this; - var silent = opts.silent || null; - - var ce = new YAHOO.util.CustomEvent(p_type, scope, silent, - YAHOO.util.CustomEvent.FLAT); - events[p_type] = ce; - - if (opts.onSubscribeCallback) { - ce.subscribeEvent.subscribe(opts.onSubscribeCallback); - } - - this.__yui_subscribers = this.__yui_subscribers || {}; - var qs = this.__yui_subscribers[p_type]; - - if (qs) { - for (var i=0; i<qs.length; ++i) { - ce.subscribe(qs[i].fn, qs[i].obj, qs[i].override); - } - } - } - - return events[p_type]; - }, - - - /** - * Fire a custom event by name. The callback functions will be executed - * from the scope specified when the event was created, and with the - * following parameters: - * <ul> - * <li>The first argument fire() was executed with</li> - * <li>The custom object (if any) that was passed into the subscribe() - * method</li> - * </ul> - * @method fireEvent - * @param p_type {string} the type, or name of the event - * @param arguments {Object*} an arbitrary set of parameters to pass to - * the handler. - * @return {boolean} the return value from CustomEvent.fire, or null if - * the custom event does not exist. - */ - fireEvent: function(p_type, arg1, arg2, etc) { - - this.__yui_events = this.__yui_events || {}; - var ce = this.__yui_events[p_type]; - - if (ce) { - var args = []; - for (var i=1; i<arguments.length; ++i) { - args.push(arguments[i]); - } - return ce.fire.apply(ce, args); - } else { - return null; - } - }, - - /** - * Returns true if the custom event of the provided type has been created - * with createEvent. - * @method hasEvent - * @param type {string} the type, or name of the event - */ - hasEvent: function(type) { - if (this.__yui_events) { - if (this.__yui_events[type]) { - return true; - } - } - return false; - } - -}; - -/** -* KeyListener is a utility that provides an easy interface for listening for -* keydown/keyup events fired against DOM elements. -* @namespace YAHOO.util -* @class KeyListener -* @constructor -* @param {HTMLElement} attachTo The element or element ID to which the key -* event should be attached -* @param {String} attachTo The element or element ID to which the key -* event should be attached -* @param {Object} keyData The object literal representing the key(s) -* to detect. Possible attributes are -* shift(boolean), alt(boolean), ctrl(boolean) -* and keys(either an int or an array of ints -* representing keycodes). -* @param {Function} handler The CustomEvent handler to fire when the -* key event is detected -* @param {Object} handler An object literal representing the handler. -* @param {String} event Optional. The event (keydown or keyup) to -* listen for. Defaults automatically to keydown. -*/ -YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) { - if (!attachTo) { - } else if (!keyData) { - } else if (!handler) { - } - - if (!event) { - event = YAHOO.util.KeyListener.KEYDOWN; - } - - /** - * The CustomEvent fired internally when a key is pressed - * @event keyEvent - * @private - * @param {Object} keyData The object literal representing the key(s) to - * detect. Possible attributes are shift(boolean), - * alt(boolean), ctrl(boolean) and keys(either an - * int or an array of ints representing keycodes). - */ - var keyEvent = new YAHOO.util.CustomEvent("keyPressed"); - - /** - * The CustomEvent fired when the KeyListener is enabled via the enable() - * function - * @event enabledEvent - * @param {Object} keyData The object literal representing the key(s) to - * detect. Possible attributes are shift(boolean), - * alt(boolean), ctrl(boolean) and keys(either an - * int or an array of ints representing keycodes). - */ - this.enabledEvent = new YAHOO.util.CustomEvent("enabled"); - - /** - * The CustomEvent fired when the KeyListener is disabled via the - * disable() function - * @event disabledEvent - * @param {Object} keyData The object literal representing the key(s) to - * detect. Possible attributes are shift(boolean), - * alt(boolean), ctrl(boolean) and keys(either an - * int or an array of ints representing keycodes). - */ - this.disabledEvent = new YAHOO.util.CustomEvent("disabled"); - - if (typeof attachTo == 'string') { - attachTo = document.getElementById(attachTo); - } - - if (typeof handler == 'function') { - keyEvent.subscribe(handler); - } else { - keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope); - } - - /** - * Handles the key event when a key is pressed. - * @method handleKeyPress - * @param {DOMEvent} e The keypress DOM event - * @param {Object} obj The DOM event scope object - * @private - */ - function handleKeyPress(e, obj) { - if (! keyData.shift) { - keyData.shift = false; - } - if (! keyData.alt) { - keyData.alt = false; - } - if (! keyData.ctrl) { - keyData.ctrl = false; - } - - // check held down modifying keys first - if (e.shiftKey == keyData.shift && - e.altKey == keyData.alt && - e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match - - var dataItem; - var keyPressed; - - if (keyData.keys instanceof Array) { - for (var i=0;i<keyData.keys.length;i++) { - dataItem = keyData.keys[i]; - - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - break; - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - break; - } - } - } else { - dataItem = keyData.keys; - if (dataItem == e.charCode ) { - keyEvent.fire(e.charCode, e); - } else if (dataItem == e.keyCode) { - keyEvent.fire(e.keyCode, e); - } - } - } - } - - /** - * Enables the KeyListener by attaching the DOM event listeners to the - * target DOM element - * @method enable - */ - this.enable = function() { - if (! this.enabled) { - YAHOO.util.Event.addListener(attachTo, event, handleKeyPress); - this.enabledEvent.fire(keyData); - } - /** - * Boolean indicating the enabled/disabled state of the Tooltip - * @property enabled - * @type Boolean - */ - this.enabled = true; - }; - - /** - * Disables the KeyListener by removing the DOM event listeners from the - * target DOM element - * @method disable - */ - this.disable = function() { - if (this.enabled) { - YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress); - this.disabledEvent.fire(keyData); - } - this.enabled = false; - }; - - /** - * Returns a String representation of the object. - * @method toString - * @return {String} The string representation of the KeyListener - */ - this.toString = function() { - return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + - (attachTo.id ? "[" + attachTo.id + "]" : ""); - }; - -}; - -/** -* Constant representing the DOM "keydown" event. -* @property YAHOO.util.KeyListener.KEYDOWN -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYDOWN = "keydown"; - -/** -* Constant representing the DOM "keyup" event. -* @property YAHOO.util.KeyListener.KEYUP -* @static -* @final -* @type String -*/ -YAHOO.util.KeyListener.KEYUP = "keyup"; -YAHOO.register("event", YAHOO.util.Event, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/fonts/README b/interface/web/js/yui/fonts/README deleted file mode 100644 index eebc48b136..0000000000 --- a/interface/web/js/yui/fonts/README +++ /dev/null @@ -1,13 +0,0 @@ -YUI Library - Fonts - Release Notes - -Version 2.2.0 - - * No changes. - -Version 0.10.1 - 0.12.2 - - * No changes. - -Version 0.10.0 - - * Initial release. diff --git a/interface/web/js/yui/fonts/fonts-min.css b/interface/web/js/yui/fonts/fonts-min.css deleted file mode 100644 index 40930b6656..0000000000 --- a/interface/web/js/yui/fonts/fonts-min.css +++ /dev/null @@ -1,7 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;} diff --git a/interface/web/js/yui/fonts/fonts.css b/interface/web/js/yui/fonts/fonts.css deleted file mode 100644 index 90b12648dd..0000000000 --- a/interface/web/js/yui/fonts/fonts.css +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * Percents could work for IE, but for backCompat purposes, we are using keywords. - * x-small is for IE6/7 quirks mode. - * - */ -body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;} -table {font-size:inherit;font:100%;} - -/** - * 99% for safari; 100% is too large - */ -select, input, textarea {font:99% arial,helvetica,clean,sans-serif;} - -/** - * Bump up !IE to get to 13px equivalent - */ -pre, code {font:115% monospace;*font-size:100%;} - -/** - * Default line-height based on font-size rather than "computed-value" - * see: http://www.w3.org/TR/CSS21/visudet.html#line-height - */ -body * {line-height:1.22em;} diff --git a/interface/web/js/yui/grids/README b/interface/web/js/yui/grids/README deleted file mode 100644 index 9550af4296..0000000000 --- a/interface/web/js/yui/grids/README +++ /dev/null @@ -1,48 +0,0 @@ -YUI Library - Grids - Release Notes - -Version 2.2.0 - - * No changes. - -Version 0.12.1 - 0.12.2 - - * No changes. - -Version 0.12.0 - - * Removed redundant "text-align:left" from nodes below #doc. - - * Removed small-font treatment on #ft. - - * Removed margin-bottom from #hd,#bd. - - * Added two new #doc definitions (#doc2 and #doc3) that provide - 950px centered and 100% page width presets to supplement the - original 750px centered page width. - - * Made ".first" selectors more precise by binding to divs, to - make it less likely that our .first definitions will impact - nested content elements wishing to use this nomenclature. - - * Fixed "nested yui-gc" bug. - - * Fixed build-process whitespace bug with .yui-t2 and .yui-t5. - - * Migrated .yui-t's technique to "negative margins" technique - from "floated ems". - - * The "negative margins" technique caused z-index issues, so - position:relative was added to the secondary yui-b to enable - correct z-index. - - * Make optimization benefits from inheritence wins via code - reorganizations. - -Version 0.11.0 - - * Removed line #43 because it set an already-set value. - Was: ".yui-t7 #main .yui-b{min-width:750px;}" - -Version 0.10.0 - - * Initial release. \ No newline at end of file diff --git a/interface/web/js/yui/grids/grids-min.css b/interface/web/js/yui/grids/grids-min.css deleted file mode 100644 index 5783459881..0000000000 --- a/interface/web/js/yui/grids/grids-min.css +++ /dev/null @@ -1,7 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -body{text-align:center;}#ft{clear:both;}#doc,#doc2,#doc3,.yui-t1,.yui-t2,.yui-t3,.yui-t4,.yui-t5,.yui-t6,.yui-t7{margin:auto;text-align:left;width:57.69em;*width:56.3em;min-width:750px;}#doc2{width:73.074em;*width:71.313em;min-width:950px;}#doc3{margin:auto 10px;width:auto;}.yui-b{position:relative;}.yui-b{_position:static;}#yui-main .yui-b{position:static;}#yui-main{width:100%;}.yui-t1 #yui-main,.yui-t2 #yui-main,.yui-t3 #yui-main{float:right;margin-left:-25em;}.yui-t4 #yui-main,.yui-t5 #yui-main,.yui-t6 #yui-main{float:left;margin-right:-25em;}.yui-t1 .yui-b{float:left;width:12.3207em;*width:12.0106em;}.yui-t1 #yui-main .yui-b{margin-left:13.3207em;*margin-left:13.0106em;}.yui-t2 .yui-b{float:left;width:13.8456em;*width:13.512em;}.yui-t2 #yui-main .yui-b{margin-left:14.8456em;*margin-left:14.512em;}.yui-t3 .yui-b{float:left;width:23.0759em;*width:22.52em;}.yui-t3 #yui-main .yui-b{margin-left:24.0759em;*margin-left:23.52em;}.yui-t4 .yui-b{float:right;width:13.8456em;*width:13.512em;}.yui-t4 #yui-main .yui-b{margin-right:14.8456em;*margin-right:14.512em;}.yui-t5 .yui-b{float:right;width:18.4608em;*width:18.016em;}.yui-t5 #yui-main .yui-b{margin-right:19.4608em;*margin-right:19.016em;}.yui-t6 .yui-b{float:right;width:23.0759em;*width:22.52em;}.yui-t6 #yui-main .yui-b{margin-right:24.0759em;*margin-right:23.52em;}.yui-t7 #yui-main .yui-b{display:block;margin:0 0 1em 0;}#yui-main .yui-b{float:none;width:auto;}.yui-g .yui-u,.yui-g .yui-g,.yui-gc .yui-u,.yui-gc .yui-g .yui-u,.yui-ge .yui-u,.yui-gf .yui-u{float:right;display:inline;}.yui-g div.first,.yui-gc div.first,.yui-gc div.first div.first,.yui-gd div.first,.yui-ge div.first,.yui-gf div.first{float:left;}.yui-g .yui-u,.yui-g .yui-g{width:49.1%;}.yui-g .yui-g .yui-u,.yui-gc .yui-g .yui-u{width:48.1%;}.yui-gb .yui-u,.yui-gc .yui-u,.yui-gd .yui-u{float:left;margin-left:2%;*margin-left:1.895%;width:32%;}.yui-gb div.first,.yui-gc div.first,.yui-gd div.first{margin-left:0;}.yui-gc div.first,.yui-gd .yui-u{width:66%;}.yui-gd div.first{width:32%;}.yui-ge .yui-u{width:24%;}.yui-ge div.first,.yui-gf .yui-u{width:74.2%;}.yui-gf div.first{width:24%;}.yui-ge div.first{width:74.2%;}#bd:after,.yui-g:after,.yui-gb:after,.yui-gc:after,.yui-gd:after,.yui-ge:after,.yui-gf:after{content:".";display:block;height:0;clear:both;visibility:hidden;}#bd,.yui-g,.yui-gb,.yui-gc,.yui-gd,.yui-ge,.yui-gf{zoom:1;} \ No newline at end of file diff --git a/interface/web/js/yui/grids/grids.css b/interface/web/js/yui/grids/grids.css deleted file mode 100644 index 67fe5bdc23..0000000000 --- a/interface/web/js/yui/grids/grids.css +++ /dev/null @@ -1,129 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/* for all templates and grids */ -body{text-align:center;} -#ft{clear:both;} -/**/ -/* 750 centered, and backward compatibility */ -#doc,#doc2,#doc3,.yui-t1,.yui-t2,.yui-t3,.yui-t4,.yui-t5,.yui-t6,.yui-t7 { - margin:auto;text-align:left; - width:57.69em;*width:56.3em;min-width:750px;} -/* 950 centered */ -#doc2 { - width:73.074em;*width:71.313em;min-width:950px;} -/* 100% with 10px viewport side matting */ -#doc3 { - margin:auto 10px; /* not for structure, but so content doesn't bleed to edge */ - width:auto;} - -/* below required for all fluid grids; adjust widths and margins above accordingly */ - - /* to preserve source-order independence for Gecko */ - .yui-b{position:relative;} - .yui-b{_position:static;} /* for IE < 7 */ - #yui-main .yui-b{position:static;} - -#yui-main {width:100%;} -.yui-t1 #yui-main, -.yui-t2 #yui-main, -.yui-t3 #yui-main{float:right;margin-left:-25em;/* IE: preserve layout at narrow widths */} - -.yui-t4 #yui-main, -.yui-t5 #yui-main, -.yui-t6 #yui-main{float:left;margin-right:-25em;/* IE: preserve layout at narrow widths */} - -.yui-t1 .yui-b { - float:left; - width:12.3207em;*width:12.0106em;} -.yui-t1 #yui-main .yui-b{ - margin-left:13.3207em;*margin-left:13.0106em; -} - -.yui-t2 .yui-b { - float:left; - width:13.8456em;*width:13.512em;} -.yui-t2 #yui-main .yui-b { - margin-left:14.8456em;*margin-left:14.512em; -} - -.yui-t3 .yui-b { - float:left; - width:23.0759em;*width:22.52em;} -.yui-t3 #yui-main .yui-b { - margin-left:24.0759em;*margin-left:23.52em; -} - -.yui-t4 .yui-b { - float:right; - width:13.8456em;*width:13.512em;} -.yui-t4 #yui-main .yui-b { - margin-right:14.8456em;*margin-right:14.512em; -} - -.yui-t5 .yui-b { - float:right; - width:18.4608em;*width:18.016em;} -.yui-t5 #yui-main .yui-b { - margin-right:19.4608em;*margin-right:19.016em; -} - -.yui-t6 .yui-b { - float:right; - width:23.0759em;*width:22.52em;} -.yui-t6 #yui-main .yui-b { - margin-right:24.0759em;*margin-right:23.52em; -} - -.yui-t7 #yui-main .yui-b { - display:block;margin:0 0 1em 0; -} -#yui-main .yui-b {float:none;width:auto;} -/* GRIDS (not TEMPLATES) */ -.yui-g .yui-u, -.yui-g .yui-g, -.yui-gc .yui-u, -.yui-gc .yui-g .yui-u, -.yui-ge .yui-u, -.yui-gf .yui-u{float:right;display:inline;} -.yui-g div.first, -.yui-gc div.first, -.yui-gc div.first div.first, -.yui-gd div.first, -.yui-ge div.first, -.yui-gf div.first{float:left;} -.yui-g .yui-u, -.yui-g .yui-g{width:49.1%;} -.yui-g .yui-g .yui-u, -.yui-gc .yui-g .yui-u {width:48.1%;} -.yui-gb .yui-u, -.yui-gc .yui-u, -.yui-gd .yui-u{float:left;margin-left:2%;*margin-left:1.895%;width:32%;} -.yui-gb div.first, -.yui-gc div.first, -.yui-gd div.first{margin-left:0;} -.yui-gc div.first, -.yui-gd .yui-u{width:66%;} -.yui-gd div.first{width:32%;} -.yui-ge .yui-u{width:24%;} -.yui-ge div.first, -.yui-gf .yui-u{width:74.2%;} -.yui-gf div.first{width:24%;} -.yui-ge div.first{width:74.2%;} -#bd:after, -.yui-g:after, -.yui-gb:after, -.yui-gc:after, -.yui-gd:after, -.yui-ge:after, -.yui-gf:after{content:".";display:block;height:0;clear:both;visibility:hidden;} -#bd, -.yui-g, -.yui-gb, -.yui-gc, -.yui-gd, -.yui-ge, -.yui-gf{zoom:1;} \ No newline at end of file diff --git a/interface/web/js/yui/history/README b/interface/web/js/yui/history/README deleted file mode 100644 index 7a4dbde524..0000000000 --- a/interface/web/js/yui/history/README +++ /dev/null @@ -1,11 +0,0 @@ -YUI Library - History - Release Notes - -2.2.0 - - * This is the initial release of the browser history manager. - This component is considered experimental. Experimental components - are released for community experimentation and feedback; they - are not considered appropriate for implementation in mission- - critical applications. Please see the YUI FAQ at - http://developer.yahoo.com/yui/articles/faq/#experimental - for more information about the "experimental" designation. \ No newline at end of file diff --git a/interface/web/js/yui/history/assets/blank.html b/interface/web/js/yui/history/assets/blank.html deleted file mode 100644 index 42682b4746..0000000000 --- a/interface/web/js/yui/history/assets/blank.html +++ /dev/null @@ -1 +0,0 @@ -<html><body></body></html> \ No newline at end of file diff --git a/interface/web/js/yui/history/history-experimental-debug.js b/interface/web/js/yui/history/history-experimental-debug.js deleted file mode 100644 index 17f27627f3..0000000000 --- a/interface/web/js/yui/history/history-experimental-debug.js +++ /dev/null @@ -1,649 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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() { - - /** - * String identifying which browser we are in. - * Different code is run depending on which browser you are using. - * - * @property _browser - * @type string - * @default "unknown" - * @private - */ - var _browser = "unknown"; - - /** - * 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 = top.location.href; - var idx = href.indexOf( "#" ); - return idx >= 0 ? href.substr( idx+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 initialStates = []; - var currentStates = []; - for ( var moduleName in _modules ) { - var moduleObj = _modules[moduleName]; - initialStates.push( moduleName + "=" + moduleObj.initialState ); - currentStates.push( moduleName + "=" + moduleObj.currentState ); - } - _storageField.value = initialStates.join( "&" ) + "|" + currentStates.join( "&" ); - if ( _browser == "safari" ) { - _storageField.value += "|" + _fqstates.join( "," ); - } - } - - /** - * Periodically checks whether our internal IFrame is ready to be used. - * - * @method _checkIframeLoaded - * @private - */ - function _checkIframeLoaded() { - 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. - - var doc = _iframe.contentWindow.document; - var 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... - var fqstate = elem ? elem.innerText : null; - - setInterval( function() { - doc = _iframe.contentWindow.document; - elem = doc.getElementById( "state" ); - // See my comment above about using innerText instead of innerHTML... - var newfqstate = elem ? elem.innerText : null; - if ( newfqstate != fqstate ) { - fqstate = newfqstate; - _handleFQStateChange( fqstate ); - - var hash; - if ( !fqstate ) { - var states = []; - for ( var moduleName in _modules ) { - var moduleObj = _modules[moduleName]; - states.push( moduleName + "=" + moduleObj.initialState ); - } - hash = states.join( "&" ); - } else { - hash = fqstate; - } - - // Allow the state to be bookmarked without messing up the browser history... - top.location.replace( "#" + hash ); - - _storeStates(); - } - }, 50 ); - - _bhmReady = true; - - YAHOO.util.History.onLoadEvent.fire(); - } - - /** - * 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 moduleName, moduleObj, currentState; - - if ( !fqstate ) { - // Notifies all modules - for ( moduleName in _modules ) { - moduleObj = _modules[moduleName]; - moduleObj.currentState = moduleObj.initialState; - moduleObj.onStateChange( moduleObj.currentState ); - } - return; - } - - var modules = []; - var states = fqstate.split( "&" ); - for ( var idx=0, len=states.length ; idx<len ; idx++ ) { - var tokens = states[idx].split( "=" ); - if ( tokens.length == 2 ) { - moduleName = tokens[0]; - currentState = tokens[1]; - modules[moduleName] = currentState; - } - } - - for ( moduleName in _modules ) { - moduleObj = _modules[moduleName]; - currentState = modules[moduleName]; - if ( !currentState || moduleObj.currentState != currentState ) { - moduleObj.currentState = currentState || moduleObj.initialState; - moduleObj.onStateChange( moduleObj.currentState ); - } - } - } - - /** - * Finish up the initialization of the Browser History Manager. - * - * @method _initialize - * @private - */ - function _initialize() { - - _storageField = document.getElementById( "yui_hist_field" ); - - // Decode the content of our storage field... - var parts = _storageField.value.split( "|" ); - - if ( parts.length > 1 ) { - - var idx, len, tokens, moduleName, moduleObj; - - var initialStates = parts[0].split( "&" ); - for ( idx=0, len=initialStates.length ; idx<len ; idx++ ) { - tokens = initialStates[idx].split( "=" ); - if ( tokens.length == 2 ) { - moduleName = tokens[0]; - var initialState = tokens[1]; - moduleObj = _modules[moduleName]; - if ( moduleObj ) { - moduleObj.initialState = initialState; - } - } - } - - var currentStates = parts[1].split( "&" ); - for ( idx=0, len=currentStates.length ; idx<len ; idx++ ) { - tokens = currentStates[idx].split( "=" ); - if ( tokens.length >= 2 ) { - moduleName = tokens[0]; - var currentState = tokens[1]; - moduleObj = _modules[moduleName]; - if ( moduleObj ) { - moduleObj.currentState = currentState; - } - } - } - } - - if ( parts.length > 2 ) { - _fqstates = parts[2].split( "," ); - } - - _storageFieldReady = true; - - if ( _browser == "msie" ) { - - _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! - var counter = history.length; - - // On Gecko and Opera, we just need to watch the hash... - var hash = _getHash(); - - setInterval( function() { - var state; - var newHash = _getHash(); - var 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(); - } - } - - // Simple browser detection code - // After talking with Matt Sweeney, I moved back to using the - // user agent string instead of doing browser detection. - var ua = navigator.userAgent.toLowerCase(); - if ( ua.indexOf( "opera" ) != -1 ) { - // Opera (check first in case of spoof) - _browser = "opera"; - } else if ( ua.indexOf( "msie" ) != -1 ) { - // Microsoft Internet Explorer and derivatives... - _browser = "msie"; - } else if ( ua.indexOf( "safari" ) != -1 ) { - // Safari (check before Gecko because it includes "like Gecko") - _browser = "safari"; - } else if ( ua.indexOf( "gecko" ) != -1 ) { - // Gecko - _browser = "gecko"; - } - - 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. - */ - register : function( module, initialState, onStateChange ) { - 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] ) { - throw new Error( "A module cannot be registered twice" ); - } - - // 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 ); - - _modules[module] = { - name : module, - initialState : initialState, - currentState : initialState, - onStateChange : onStateChange - }; - }, - - /** - * 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" - * @public - */ - initialize : function( iframeTarget ) { - // Return if the browser history manager has already been initialized - if ( _initialized ) { - return; - } - - if ( _browser == "unknown" ) { - throw new Error( "Your web browser is not supported by the Browser History Manager" ); - } - - if ( !iframeTarget ) { - iframeTarget = "blank.html"; - } - - if ( typeof iframeTarget != "string" || _trim( iframeTarget ) === "" ) { - throw new Error( "Invalid argument passed to YAHOO.util.History.initialize" ); - } - - document.write( '<input type="hidden" id="yui_hist_field">' ); - if ( _browser == "msie" ) { - // Pointing the IFrame to a file on the server is absolutely - // essential. I tried to point it to nothing (by setting - // src="") and create the initial entry in the browser - // history (by using document.write) but it did not work - // when coming back to the page... Also, the file must exist - // on the server! - document.write( '<iframe id="yui_hist_iframe" src="' + iframeTarget + '" style="position:absolute;visibility:hidden;"></iframe>' ); - } - - // 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 ) { - if ( typeof module != "string" || typeof state != "string" ) { - throw new Error( "Missing or invalid argument passed to YAHOO.util.History.navigate" ); - } - - if ( !_bhmReady ) { - throw new Error( "The Browser History Manager is not initialized" ); - } - - if ( !_modules[module] ) { - throw new Error( "The following module has not been registered: " + module ); - } - - // Make sure the strings passed in do not contain our separators "," and "|" - module = escape( module ); - state = escape( state ); - - // Generate our new full state string mod1=xxx&mod2=yyy - var currentStates = []; - for ( var moduleName in _modules ) { - var moduleObj = _modules[moduleName]; - var currentState = ( moduleName == module ) ? state : moduleObj.currentState; - currentStates.push( moduleName + "=" + currentState ); - } - - var fqstate = currentStates.join( "&" ); - - if ( _browser == "msie" ) { - - // Add a new entry to the browser's history... - var html = '<html><body><div id="state">' + fqstate + '</div></body></html>'; - try { - var 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 ( _browser == "safari" ) { - // 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 ) { - 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" ); - } - - var 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 ) { - if ( typeof module != "string" ) { - throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState" ); - } - - var hash = top.location.hash.substr(1); - var states = hash.split( "&" ); - for ( var idx=0, len=states.length ; idx<len ; idx++ ) { - var tokens = states[idx].split( "=" ); - if ( tokens.length == 2 ) { - var moduleName = tokens[0]; - if ( moduleName == module ) { - return 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 ) { - url = url || top.location.href; - var idx = url.indexOf( "?" ); - var queryString = idx >= 0 ? url.substr( idx+1 ) : url; - var params = queryString.split( "&" ); - for ( var i=0, len=params.length ; i<len ; i++ ) { - var tokens = params[i].split( "=" ); - if ( tokens.length >= 2 ) { - if ( tokens[0] == paramName ) { - return tokens[1]; - } - } - } - return null; - } - - }; - -} )(); -YAHOO.register("history", YAHOO.util.History, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/history/history-experimental-min.js b/interface/web/js/yui/history/history-experimental-min.js deleted file mode 100644 index 218ead8900..0000000000 --- a/interface/web/js/yui/history/history-experimental-min.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -YAHOO.util.History=(function(){var _browser="unknown";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=top.location.href;var idx=href.indexOf("#");return idx>=0?href.substr(idx+1):null;} -function _storeStates(){var initialStates=[];var currentStates=[];for(var moduleName in _modules){var moduleObj=_modules[moduleName];initialStates.push(moduleName+"="+moduleObj.initialState);currentStates.push(moduleName+"="+moduleObj.currentState);} -_storageField.value=initialStates.join("&")+"|"+currentStates.join("&");if(_browser=="safari"){_storageField.value+="|"+_fqstates.join(",");}} -function _checkIframeLoaded(){if(!_iframe.contentWindow||!_iframe.contentWindow.document){setTimeout(_checkIframeLoaded,10);return;} -var doc=_iframe.contentWindow.document;var elem=doc.getElementById("state");var fqstate=elem?elem.innerText:null;setInterval(function(){doc=_iframe.contentWindow.document;elem=doc.getElementById("state");var newfqstate=elem?elem.innerText:null;if(newfqstate!=fqstate){fqstate=newfqstate;_handleFQStateChange(fqstate);var hash;if(!fqstate){var states=[];for(var moduleName in _modules){var moduleObj=_modules[moduleName];states.push(moduleName+"="+moduleObj.initialState);} -hash=states.join("&");}else{hash=fqstate;} -top.location.replace("#"+hash);_storeStates();}},50);_bhmReady=true;YAHOO.util.History.onLoadEvent.fire();} -function _handleFQStateChange(fqstate){var moduleName,moduleObj,currentState;if(!fqstate){for(moduleName in _modules){moduleObj=_modules[moduleName];moduleObj.currentState=moduleObj.initialState;moduleObj.onStateChange(moduleObj.currentState);} -return;} -var modules=[];var states=fqstate.split("&");for(var idx=0,len=states.length;idx<len;idx++){var tokens=states[idx].split("=");if(tokens.length==2){moduleName=tokens[0];currentState=tokens[1];modules[moduleName]=currentState;}} -for(moduleName in _modules){moduleObj=_modules[moduleName];currentState=modules[moduleName];if(!currentState||moduleObj.currentState!=currentState){moduleObj.currentState=currentState||moduleObj.initialState;moduleObj.onStateChange(moduleObj.currentState);}}} -function _initialize(){_storageField=document.getElementById("yui_hist_field");var parts=_storageField.value.split("|");if(parts.length>1){var idx,len,tokens,moduleName,moduleObj;var initialStates=parts[0].split("&");for(idx=0,len=initialStates.length;idx<len;idx++){tokens=initialStates[idx].split("=");if(tokens.length==2){moduleName=tokens[0];var initialState=tokens[1];moduleObj=_modules[moduleName];if(moduleObj){moduleObj.initialState=initialState;}}} -var currentStates=parts[1].split("&");for(idx=0,len=currentStates.length;idx<len;idx++){tokens=currentStates[idx].split("=");if(tokens.length>=2){moduleName=tokens[0];var currentState=tokens[1];moduleObj=_modules[moduleName];if(moduleObj){moduleObj.currentState=currentState;}}}} -if(parts.length>2){_fqstates=parts[2].split(",");} -_storageFieldReady=true;if(_browser=="msie"){_iframe=document.getElementById("yui_hist_iframe");_checkIframeLoaded();}else{var counter=history.length;var hash=_getHash();setInterval(function(){var state;var newHash=_getHash();var 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();}} -var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("opera")!=-1){_browser="opera";}else if(ua.indexOf("msie")!=-1){_browser="msie";}else if(ua.indexOf("safari")!=-1){_browser="safari";}else if(ua.indexOf("gecko")!=-1){_browser="gecko";} -return{onLoadEvent:new YAHOO.util.CustomEvent("onLoad"),register:function(module,initialState,onStateChange){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]){throw new Error("A module cannot be registered twice");} -if(_initialized){throw new Error("All modules must be registered before calling YAHOO.util.History.initialize");} -module=escape(module);initialState=escape(initialState);_modules[module]={name:module,initialState:initialState,currentState:initialState,onStateChange:onStateChange};},initialize:function(iframeTarget){if(_initialized){return;} -if(_browser=="unknown"){throw new Error("Your web browser is not supported by the Browser History Manager");} -if(!iframeTarget){iframeTarget="blank.html";} -if(typeof iframeTarget!="string"||_trim(iframeTarget)===""){throw new Error("Invalid argument passed to YAHOO.util.History.initialize");} -document.write('<input type="hidden" id="yui_hist_field">');if(_browser=="msie"){document.write('<iframe id="yui_hist_iframe" src="'+iframeTarget+'" style="position:absolute;visibility:hidden;"></iframe>');} -YAHOO.util.Event.addListener(window,"load",_initialize);_initialized=true;},navigate:function(module,state){if(typeof module!="string"||typeof state!="string"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.navigate");} -if(!_bhmReady){throw new Error("The Browser History Manager is not initialized");} -if(!_modules[module]){throw new Error("The following module has not been registered: "+module);} -module=escape(module);state=escape(state);var currentStates=[];for(var moduleName in _modules){var moduleObj=_modules[moduleName];var currentState=(moduleName==module)?state:moduleObj.currentState;currentStates.push(moduleName+"="+currentState);} -var fqstate=currentStates.join("&");if(_browser=="msie"){var html='<html><body><div id="state">'+fqstate+'</div></body></html>';try{var doc=_iframe.contentWindow.document;doc.open();doc.write(html);doc.close();}catch(e){return false;}}else{top.location.hash=fqstate;if(_browser=="safari"){_fqstates[history.length]=fqstate;_storeStates();}} -return true;},getCurrentState:function(module){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");} -var moduleObj=_modules[module];if(!moduleObj){throw new Error("No such registered module: "+module);} -return unescape(moduleObj.currentState);},getBookmarkedState:function(module){if(typeof module!="string"){throw new Error("Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState");} -var hash=top.location.hash.substr(1);var states=hash.split("&");for(var idx=0,len=states.length;idx<len;idx++){var tokens=states[idx].split("=");if(tokens.length==2){var moduleName=tokens[0];if(moduleName==module){return tokens[1];}}} -return null;},getQueryStringParameter:function(paramName,url){url=url||top.location.href;var idx=url.indexOf("?");var queryString=idx>=0?url.substr(idx+1):url;var params=queryString.split("&");for(var i=0,len=params.length;i<len;i++){var tokens=params[i].split("=");if(tokens.length>=2){if(tokens[0]==paramName){return tokens[1];}}} -return null;}};})();YAHOO.register("history",YAHOO.util.History,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/history/history-experimental.js b/interface/web/js/yui/history/history-experimental.js deleted file mode 100644 index 17f27627f3..0000000000 --- a/interface/web/js/yui/history/history-experimental.js +++ /dev/null @@ -1,649 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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() { - - /** - * String identifying which browser we are in. - * Different code is run depending on which browser you are using. - * - * @property _browser - * @type string - * @default "unknown" - * @private - */ - var _browser = "unknown"; - - /** - * 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 = top.location.href; - var idx = href.indexOf( "#" ); - return idx >= 0 ? href.substr( idx+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 initialStates = []; - var currentStates = []; - for ( var moduleName in _modules ) { - var moduleObj = _modules[moduleName]; - initialStates.push( moduleName + "=" + moduleObj.initialState ); - currentStates.push( moduleName + "=" + moduleObj.currentState ); - } - _storageField.value = initialStates.join( "&" ) + "|" + currentStates.join( "&" ); - if ( _browser == "safari" ) { - _storageField.value += "|" + _fqstates.join( "," ); - } - } - - /** - * Periodically checks whether our internal IFrame is ready to be used. - * - * @method _checkIframeLoaded - * @private - */ - function _checkIframeLoaded() { - 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. - - var doc = _iframe.contentWindow.document; - var 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... - var fqstate = elem ? elem.innerText : null; - - setInterval( function() { - doc = _iframe.contentWindow.document; - elem = doc.getElementById( "state" ); - // See my comment above about using innerText instead of innerHTML... - var newfqstate = elem ? elem.innerText : null; - if ( newfqstate != fqstate ) { - fqstate = newfqstate; - _handleFQStateChange( fqstate ); - - var hash; - if ( !fqstate ) { - var states = []; - for ( var moduleName in _modules ) { - var moduleObj = _modules[moduleName]; - states.push( moduleName + "=" + moduleObj.initialState ); - } - hash = states.join( "&" ); - } else { - hash = fqstate; - } - - // Allow the state to be bookmarked without messing up the browser history... - top.location.replace( "#" + hash ); - - _storeStates(); - } - }, 50 ); - - _bhmReady = true; - - YAHOO.util.History.onLoadEvent.fire(); - } - - /** - * 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 moduleName, moduleObj, currentState; - - if ( !fqstate ) { - // Notifies all modules - for ( moduleName in _modules ) { - moduleObj = _modules[moduleName]; - moduleObj.currentState = moduleObj.initialState; - moduleObj.onStateChange( moduleObj.currentState ); - } - return; - } - - var modules = []; - var states = fqstate.split( "&" ); - for ( var idx=0, len=states.length ; idx<len ; idx++ ) { - var tokens = states[idx].split( "=" ); - if ( tokens.length == 2 ) { - moduleName = tokens[0]; - currentState = tokens[1]; - modules[moduleName] = currentState; - } - } - - for ( moduleName in _modules ) { - moduleObj = _modules[moduleName]; - currentState = modules[moduleName]; - if ( !currentState || moduleObj.currentState != currentState ) { - moduleObj.currentState = currentState || moduleObj.initialState; - moduleObj.onStateChange( moduleObj.currentState ); - } - } - } - - /** - * Finish up the initialization of the Browser History Manager. - * - * @method _initialize - * @private - */ - function _initialize() { - - _storageField = document.getElementById( "yui_hist_field" ); - - // Decode the content of our storage field... - var parts = _storageField.value.split( "|" ); - - if ( parts.length > 1 ) { - - var idx, len, tokens, moduleName, moduleObj; - - var initialStates = parts[0].split( "&" ); - for ( idx=0, len=initialStates.length ; idx<len ; idx++ ) { - tokens = initialStates[idx].split( "=" ); - if ( tokens.length == 2 ) { - moduleName = tokens[0]; - var initialState = tokens[1]; - moduleObj = _modules[moduleName]; - if ( moduleObj ) { - moduleObj.initialState = initialState; - } - } - } - - var currentStates = parts[1].split( "&" ); - for ( idx=0, len=currentStates.length ; idx<len ; idx++ ) { - tokens = currentStates[idx].split( "=" ); - if ( tokens.length >= 2 ) { - moduleName = tokens[0]; - var currentState = tokens[1]; - moduleObj = _modules[moduleName]; - if ( moduleObj ) { - moduleObj.currentState = currentState; - } - } - } - } - - if ( parts.length > 2 ) { - _fqstates = parts[2].split( "," ); - } - - _storageFieldReady = true; - - if ( _browser == "msie" ) { - - _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! - var counter = history.length; - - // On Gecko and Opera, we just need to watch the hash... - var hash = _getHash(); - - setInterval( function() { - var state; - var newHash = _getHash(); - var 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(); - } - } - - // Simple browser detection code - // After talking with Matt Sweeney, I moved back to using the - // user agent string instead of doing browser detection. - var ua = navigator.userAgent.toLowerCase(); - if ( ua.indexOf( "opera" ) != -1 ) { - // Opera (check first in case of spoof) - _browser = "opera"; - } else if ( ua.indexOf( "msie" ) != -1 ) { - // Microsoft Internet Explorer and derivatives... - _browser = "msie"; - } else if ( ua.indexOf( "safari" ) != -1 ) { - // Safari (check before Gecko because it includes "like Gecko") - _browser = "safari"; - } else if ( ua.indexOf( "gecko" ) != -1 ) { - // Gecko - _browser = "gecko"; - } - - 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. - */ - register : function( module, initialState, onStateChange ) { - 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] ) { - throw new Error( "A module cannot be registered twice" ); - } - - // 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 ); - - _modules[module] = { - name : module, - initialState : initialState, - currentState : initialState, - onStateChange : onStateChange - }; - }, - - /** - * 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" - * @public - */ - initialize : function( iframeTarget ) { - // Return if the browser history manager has already been initialized - if ( _initialized ) { - return; - } - - if ( _browser == "unknown" ) { - throw new Error( "Your web browser is not supported by the Browser History Manager" ); - } - - if ( !iframeTarget ) { - iframeTarget = "blank.html"; - } - - if ( typeof iframeTarget != "string" || _trim( iframeTarget ) === "" ) { - throw new Error( "Invalid argument passed to YAHOO.util.History.initialize" ); - } - - document.write( '<input type="hidden" id="yui_hist_field">' ); - if ( _browser == "msie" ) { - // Pointing the IFrame to a file on the server is absolutely - // essential. I tried to point it to nothing (by setting - // src="") and create the initial entry in the browser - // history (by using document.write) but it did not work - // when coming back to the page... Also, the file must exist - // on the server! - document.write( '<iframe id="yui_hist_iframe" src="' + iframeTarget + '" style="position:absolute;visibility:hidden;"></iframe>' ); - } - - // 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 ) { - if ( typeof module != "string" || typeof state != "string" ) { - throw new Error( "Missing or invalid argument passed to YAHOO.util.History.navigate" ); - } - - if ( !_bhmReady ) { - throw new Error( "The Browser History Manager is not initialized" ); - } - - if ( !_modules[module] ) { - throw new Error( "The following module has not been registered: " + module ); - } - - // Make sure the strings passed in do not contain our separators "," and "|" - module = escape( module ); - state = escape( state ); - - // Generate our new full state string mod1=xxx&mod2=yyy - var currentStates = []; - for ( var moduleName in _modules ) { - var moduleObj = _modules[moduleName]; - var currentState = ( moduleName == module ) ? state : moduleObj.currentState; - currentStates.push( moduleName + "=" + currentState ); - } - - var fqstate = currentStates.join( "&" ); - - if ( _browser == "msie" ) { - - // Add a new entry to the browser's history... - var html = '<html><body><div id="state">' + fqstate + '</div></body></html>'; - try { - var 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 ( _browser == "safari" ) { - // 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 ) { - 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" ); - } - - var 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 ) { - if ( typeof module != "string" ) { - throw new Error( "Missing or invalid argument passed to YAHOO.util.History.getBookmarkedState" ); - } - - var hash = top.location.hash.substr(1); - var states = hash.split( "&" ); - for ( var idx=0, len=states.length ; idx<len ; idx++ ) { - var tokens = states[idx].split( "=" ); - if ( tokens.length == 2 ) { - var moduleName = tokens[0]; - if ( moduleName == module ) { - return 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 ) { - url = url || top.location.href; - var idx = url.indexOf( "?" ); - var queryString = idx >= 0 ? url.substr( idx+1 ) : url; - var params = queryString.split( "&" ); - for ( var i=0, len=params.length ; i<len ; i++ ) { - var tokens = params[i].split( "=" ); - if ( tokens.length >= 2 ) { - if ( tokens[0] == paramName ) { - return tokens[1]; - } - } - } - return null; - } - - }; - -} )(); -YAHOO.register("history", YAHOO.util.History, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/logger/README b/interface/web/js/yui/logger/README deleted file mode 100644 index 21d952150b..0000000000 --- a/interface/web/js/yui/logger/README +++ /dev/null @@ -1,51 +0,0 @@ -Logger Release Notes - -*** version 2.2.0 *** - -* Implemented expand() and collapse() in LogReader class. -* Better internal browser detection. - - - -*** version 0.12.2 *** - -* No changes. - - - -**** version 0.12.1 *** - -* Fixed issues with setting LogReader's "bottom" property. - - - -*** version 0.12.0 *** - -* Added method formatMsg(oLogMsg) to support custom formatting of log messages -for output to a LogReader. - - - -*** version 0.11.3 *** - -* 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. - - - -*** version 0.11.0 *** - -* Initial release diff --git a/interface/web/js/yui/logger/assets/logger.css b/interface/web/js/yui/logger/assets/logger.css deleted file mode 100644 index bca6e0b6c7..0000000000 --- a/interface/web/js/yui/logger/assets/logger.css +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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;} -.yui-log p {margin:1px;padding:.1em;} -.yui-log button {font-family:monospace;} -.yui-log .yui-log-hd {margin-top:1em;padding:.5em;background-color:#575757;color:#FFF;} -/* height is controlled here: default 20em*/ -.yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;} -.yui-log .yui-log-ft {margin-top:.5em;margin-bottom:1em;} -.yui-log .yui-log-ft .yui-log-categoryfilters {} -.yui-log .yui-log-ft .yui-log-sourcefilters {width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;} -.yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;} -.yui-log .yui-log-filtergrp {margin-right:.5em;} -.yui-log .info {background-color:#A7CC25;} /* A7CC25 green */ -.yui-log .warn {background-color:#F58516;} /* F58516 orange */ -.yui-log .error {background-color:#E32F0B;} /* E32F0B red */ -.yui-log .time {background-color:#A6C9D7;} /* A6C9D7 blue */ -.yui-log .window {background-color:#F2E886;} /* F2E886 tan */ diff --git a/interface/web/js/yui/logger/logger-debug.js b/interface/web/js/yui/logger/logger-debug.js deleted file mode 100644 index b0340a7c6b..0000000000 --- a/interface/web/js/yui/logger/logger-debug.js +++ /dev/null @@ -1,1597 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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; - } - // For Opera - if(navigator.userAgent.toLowerCase().indexOf("opera") != -1) { - 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 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; - -/** - * 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; - -///////////////////////////////////////////////////////////////////////////// -// -// 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._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 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; -}; - -/** - * 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) ? - ["<p><span class='", category, "'>", label, "</span> ", - totalTime, "ms (+", elapsedTime, ") ", - localTime, ": ", - "</p><p>", - sourceAndDetail, - ": </p><p>", - msg, - "</p>"] : - - ["<p><span class='", category, "'>", label, "</span> ", - totalTime, "ms (+", elapsedTime, ") ", - localTime, ": ", - sourceAndDetail, ": ", - msg,"</p>"]; - - 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, "<").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; - -/** - * 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; - -/** - * 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 -// -///////////////////////////////////////////////////////////////////////////// - -/** - * 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 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 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 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._buffer.length; i++) { - entries[i] = this._buffer[i]; - } - this._buffer = []; - this._printToConsole(entries); - } - else { - this._filterLogs(); - } - - if(!this.newestOnTop) { - this._elConsole.scrollTop = this._elConsole.scrollHeight; - } - } -}; - -/** - * Cycles through an array of log messages, and outputs each one to the console - * if its category has not been filtered out. - * - * @method _printToConsole - * @param aEntries {Object[]} Array of LogMsg objects to output to console. - * @private - */ -YAHOO.widget.LogReader.prototype._printToConsole = function(aEntries) { - // Manage the number of messages displayed in the console - var entriesLen = aEntries.length; - var thresholdMin = this.thresholdMin; - if(isNaN(thresholdMin) || (thresholdMin > 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<entriesLen; i++) { - // Print only the ones that filter through - var okToPrint = false; - var okToFilterCats = false; - - // Get log message details - var entry = aEntries[i]; - var source = entry.source; - var category = entry.category; - - for(var j=0; j<sourceFiltersLen; j++) { - if(source == this._sourceFilters[j]) { - okToFilterCats = true; - break; - } - } - if(okToFilterCats) { - for(var k=0; k<categoryFiltersLen; k++) { - if(category == this._categoryFilters[k]) { - okToPrint = true; - break; - } - } - } - if(okToPrint) { - var output = this.formatMsg(entry); - - // Verbose output uses <code> tag instead of <pre> 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<filtersArray.length; i++) { - if(newFilter == filtersArray[i]) { - filtersArray.splice(i, 1); - break; - } - } - } - else { // Add category to filters - filtersArray.push(newFilter); - } - oSelf._filterLogs(); -}; - -/** - * Handles check events on the category filter checkboxes. - * - * @method _onCheckSource - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onCheckSource = function(v, oSelf) { - var newFilter = this.source; - var filtersArray = oSelf._sourceFilters; - - if(!this.checked) { // Remove category from filters - for(var i=0; i<filtersArray.length; i++) { - if(newFilter == filtersArray[i]) { - filtersArray.splice(i, 1); - break; - } - } - } - else { // Add category to filters - filtersArray.push(newFilter); - } - oSelf._filterLogs(); -}; - -/** - * Handles click events on the collapse button. - * - * @method _onClickCollapseBtn - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The LogReader instance - * @private - */ -YAHOO.widget.LogReader.prototype._onClickCollapseBtn = function(v, oSelf) { - if(!oSelf.isCollapsed) { - oSelf.collapse(); - } - else { - oSelf.expand(); - } -}; - -/** - * Handles click events on the pause button. - * - * @method _onClickPauseBtn - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onClickPauseBtn = function(v, oSelf) { - var btn = oSelf._btnPause; - if(btn.value == "Resume") { - oSelf.resume(); - btn.value = "Pause"; - } - else { - oSelf.pause(); - btn.value = "Resume"; - } -}; - -/** - * Handles click events on the clear button. - * - * @method _onClickClearBtn - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onClickClearBtn = function(v, oSelf) { - oSelf._clearConsole(); -}; - -/** - * Handles Logger's newLogEvent. - * - * @method _onNewLog - * @param sType {String} The event. - * @param aArgs {Object[]} Data passed from event firer. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onNewLog = function(sType, aArgs, oSelf) { - var logEntry = aArgs[0]; - oSelf._buffer.push(logEntry); - - if (oSelf.logReaderEnabled === true && oSelf._timeout === null) { - oSelf._timeout = setTimeout(function(){oSelf._printBuffer();}, 100); - } -}; - -/** - * Handles Logger's resetEvent. - * - * @method _onReset - * @param sType {String} The event. - * @param aArgs {Object[]} Data passed from event firer. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onReset = function(sType, aArgs, oSelf) { - oSelf._filterLogs(); -}; - - /** - * The Logger widget provides a simple way to read or write log messages in - * JavaScript code. Integration with the YUI Library's debug builds allow - * implementers to access under-the-hood events, errors, and debugging messages. - * Output may be read through a LogReader console and/or output to a browser - * console. - * - * @module logger - * @requires yahoo, event, dom - * @optional dragdrop - * @namespace YAHOO.widget - * @title Logger Widget - */ - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The singleton Logger class provides core log management functionality. Saves - * logs written through the global YAHOO.log function or written by a LogWriter - * instance. Provides access to logs for reading by a LogReader instance or - * native browser console such as the Firebug extension to Firefox or Safari's - * JavaScript console through integration with the console.log() method. - * - * @class Logger - * @static - */ -YAHOO.widget.Logger = { - // Initialize members - loggerEnabled: true, - _browserConsoleEnabled: false, - categories: ["info","warn","error","time","window"], - sources: ["global"], - _stack: [], // holds all log msgs - maxStackEntries: 2500, - _startTime: new Date().getTime(), // static start timestamp - _lastTime: null // timestamp of last logged message -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// -/** - * Saves a log message to the stack and fires newLogEvent. If the log message is - * assigned to an unknown category, creates a new category. If the log message is - * from an unknown source, creates a new source. If browser console is enabled, - * outputs the log message to browser console. - * - * @method log - * @param sMsg {String} The log message. - * @param sCategory {String} Category of log message, or null. - * @param sSource {String} Source of LogWriter, or null if global. - */ -YAHOO.widget.Logger.log = function(sMsg, sCategory, sSource) { - if(this.loggerEnabled) { - if(!sCategory) { - sCategory = "info"; // default category - } - else { - sCategory = sCategory.toLocaleLowerCase(); - if(this._isNewCategory(sCategory)) { - this._createNewCategory(sCategory); - } - } - var sClass = "global"; // default source - var sDetail = null; - if(sSource) { - var spaceIndex = sSource.indexOf(" "); - if(spaceIndex > 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.2.0", build: "127"}); diff --git a/interface/web/js/yui/logger/logger-min.js b/interface/web/js/yui/logger/logger-min.js deleted file mode 100644 index e54a2efe36..0000000000 --- a/interface/web/js/yui/logger/logger-min.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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(navigator.userAgent.toLowerCase().indexOf("opera")!=-1){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<catsLen;i++){this._createCategoryCheckbox(YAHOO.widget.Logger.categories[i]);}} -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());};YAHOO.widget.LogReader.prototype.logReaderEnabled=true;YAHOO.widget.LogReader.prototype.width=null;YAHOO.widget.LogReader.prototype.height=null;YAHOO.widget.LogReader.prototype.top=null;YAHOO.widget.LogReader.prototype.left=null;YAHOO.widget.LogReader.prototype.right=null;YAHOO.widget.LogReader.prototype.bottom=null;YAHOO.widget.LogReader.prototype.fontSize=null;YAHOO.widget.LogReader.prototype.footerEnabled=true;YAHOO.widget.LogReader.prototype.verboseOutput=true;YAHOO.widget.LogReader.prototype.newestOnTop=true;YAHOO.widget.LogReader.prototype.thresholdMax=500;YAHOO.widget.LogReader.prototype.thresholdMin=100;YAHOO.widget.LogReader.prototype.isCollapsed=false;YAHOO.widget.LogReader.prototype.toString=function(){return"LogReader instance"+this._sName;};YAHOO.widget.LogReader.prototype.pause=function(){this._timeout=null;this.logReaderEnabled=false;};YAHOO.widget.LogReader.prototype.resume=function(){this.logReaderEnabled=true;this._printBuffer();};YAHOO.widget.LogReader.prototype.hide=function(){this._elContainer.style.display="none";};YAHOO.widget.LogReader.prototype.show=function(){this._elContainer.style.display="block";};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;};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;};YAHOO.widget.LogReader.prototype.setTitle=function(sTitle){this._title.innerHTML=this.html2Text(sTitle);};YAHOO.widget.LogReader.prototype.getLastTime=function(){return this._lastTime;};YAHOO.widget.LogReader.prototype.formatMsg=function(oLogMsg){var category=oLogMsg.category;var label=category.substring(0,4).toUpperCase();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;var msg=this.html2Text(oLogMsg.msg);var output=(this.verboseOutput)?["<p><span class='",category,"'>",label,"</span> ",totalTime,"ms (+",elapsedTime,") ",localTime,": ","</p><p>",sourceAndDetail,": </p><p>",msg,"</p>"]:["<p><span class='",category,"'>",label,"</span> ",totalTime,"ms (+",elapsedTime,") ",localTime,": ",sourceAndDetail,": ",msg,"</p>"];return output.join("");};YAHOO.widget.LogReader.prototype.html2Text=function(sHtml){if(sHtml){sHtml+="";return sHtml.replace(/&/g,"&").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._consoleMsgCount<thresholdMax){var entries=[];for(var i=0;i<this._buffer.length;i++){entries[i]=this._buffer[i];} -this._buffer=[];this._printToConsole(entries);} -else{this._filterLogs();} -if(!this.newestOnTop){this._elConsole.scrollTop=this._elConsole.scrollHeight;}}};YAHOO.widget.LogReader.prototype._printToConsole=function(aEntries){var entriesLen=aEntries.length;var thresholdMin=this.thresholdMin;if(isNaN(thresholdMin)||(thresholdMin>this.thresholdMax)){thresholdMin=0;} -var entriesStartIndex=(entriesLen>thresholdMin)?(entriesLen-thresholdMin):0;var sourceFiltersLen=this._sourceFilters.length;var categoryFiltersLen=this._categoryFilters.length;for(var i=entriesStartIndex;i<entriesLen;i++){var okToPrint=false;var okToFilterCats=false;var entry=aEntries[i];var source=entry.source;var category=entry.category;for(var j=0;j<sourceFiltersLen;j++){if(source==this._sourceFilters[j]){okToFilterCats=true;break;}} -if(okToFilterCats){for(var k=0;k<categoryFiltersLen;k++){if(category==this._categoryFilters[k]){okToPrint=true;break;}}} -if(okToPrint){var output=this.formatMsg(entry);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();}}};YAHOO.widget.LogReader.prototype._onCategoryCreate=function(sType,aArgs,oSelf){var category=aArgs[0];if(oSelf._elFt){oSelf._createCategoryCheckbox(category);}};YAHOO.widget.LogReader.prototype._onSourceCreate=function(sType,aArgs,oSelf){var source=aArgs[0];if(oSelf._elFt){oSelf._createSourceCheckbox(source);}};YAHOO.widget.LogReader.prototype._onCheckCategory=function(v,oSelf){var newFilter=this.category;var filtersArray=oSelf._categoryFilters;if(!this.checked){for(var i=0;i<filtersArray.length;i++){if(newFilter==filtersArray[i]){filtersArray.splice(i,1);break;}}} -else{filtersArray.push(newFilter);} -oSelf._filterLogs();};YAHOO.widget.LogReader.prototype._onCheckSource=function(v,oSelf){var newFilter=this.source;var filtersArray=oSelf._sourceFilters;if(!this.checked){for(var i=0;i<filtersArray.length;i++){if(newFilter==filtersArray[i]){filtersArray.splice(i,1);break;}}} -else{filtersArray.push(newFilter);} -oSelf._filterLogs();};YAHOO.widget.LogReader.prototype._onClickCollapseBtn=function(v,oSelf){if(!oSelf.isCollapsed){oSelf.collapse();} -else{oSelf.expand();}};YAHOO.widget.LogReader.prototype._onClickPauseBtn=function(v,oSelf){var btn=oSelf._btnPause;if(btn.value=="Resume"){oSelf.resume();btn.value="Pause";} -else{oSelf.pause();btn.value="Resume";}};YAHOO.widget.LogReader.prototype._onClickClearBtn=function(v,oSelf){oSelf._clearConsole();};YAHOO.widget.LogReader.prototype._onNewLog=function(sType,aArgs,oSelf){var logEntry=aArgs[0];oSelf._buffer.push(logEntry);if(oSelf.logReaderEnabled===true&&oSelf._timeout===null){oSelf._timeout=setTimeout(function(){oSelf._printBuffer();},100);}};YAHOO.widget.LogReader.prototype._onReset=function(sType,aArgs,oSelf){oSelf._filterLogs();};YAHOO.widget.Logger={loggerEnabled:true,_browserConsoleEnabled:false,categories:["info","warn","error","time","window"],sources:["global"],_stack:[],maxStackEntries:2500,_startTime:new Date().getTime(),_lastTime:null};YAHOO.widget.Logger.log=function(sMsg,sCategory,sSource){if(this.loggerEnabled){if(!sCategory){sCategory="info";} -else{sCategory=sCategory.toLocaleLowerCase();if(this._isNewCategory(sCategory)){this._createNewCategory(sCategory);}} -var sClass="global";var sDetail=null;if(sSource){var spaceIndex=sSource.indexOf(" ");if(spaceIndex>0){sClass=sSource.substring(0,spaceIndex);sDetail=sSource.substring(spaceIndex,sSource.length);} -else{sClass=sSource;} -if(this._isNewSource(sClass)){this._createNewSource(sClass);}} -var timestamp=new Date();var logEntry=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<this.categories.length;i++){if(sCategory==this.categories[i]){return false;}} -return true;};YAHOO.widget.Logger._createNewSource=function(sSource){this.sources.push(sSource);this.sourceCreateEvent.fire(sSource);};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;}};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);}};YAHOO.widget.Logger._onWindowError=function(sMsg,sUrl,sLine){try{YAHOO.widget.Logger.log(sMsg+' ('+sUrl+', line '+sLine+')',"window");if(YAHOO.widget.Logger._origOnWindowError){YAHOO.widget.Logger._origOnWindowError();}} -catch(e){return false;}};if(window.onerror){YAHOO.widget.Logger._origOnWindowError=window.onerror;} -window.onerror=YAHOO.widget.Logger._onWindowError;YAHOO.widget.Logger.log("Logger initialized");YAHOO.register("logger",YAHOO.widget.Logger,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/logger/logger.js b/interface/web/js/yui/logger/logger.js deleted file mode 100644 index b0340a7c6b..0000000000 --- a/interface/web/js/yui/logger/logger.js +++ /dev/null @@ -1,1597 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.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; - } - // For Opera - if(navigator.userAgent.toLowerCase().indexOf("opera") != -1) { - 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 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; - -/** - * 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; - -///////////////////////////////////////////////////////////////////////////// -// -// 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._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 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; -}; - -/** - * 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) ? - ["<p><span class='", category, "'>", label, "</span> ", - totalTime, "ms (+", elapsedTime, ") ", - localTime, ": ", - "</p><p>", - sourceAndDetail, - ": </p><p>", - msg, - "</p>"] : - - ["<p><span class='", category, "'>", label, "</span> ", - totalTime, "ms (+", elapsedTime, ") ", - localTime, ": ", - sourceAndDetail, ": ", - msg,"</p>"]; - - 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, "<").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; - -/** - * 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; - -/** - * 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 -// -///////////////////////////////////////////////////////////////////////////// - -/** - * 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 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 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 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._buffer.length; i++) { - entries[i] = this._buffer[i]; - } - this._buffer = []; - this._printToConsole(entries); - } - else { - this._filterLogs(); - } - - if(!this.newestOnTop) { - this._elConsole.scrollTop = this._elConsole.scrollHeight; - } - } -}; - -/** - * Cycles through an array of log messages, and outputs each one to the console - * if its category has not been filtered out. - * - * @method _printToConsole - * @param aEntries {Object[]} Array of LogMsg objects to output to console. - * @private - */ -YAHOO.widget.LogReader.prototype._printToConsole = function(aEntries) { - // Manage the number of messages displayed in the console - var entriesLen = aEntries.length; - var thresholdMin = this.thresholdMin; - if(isNaN(thresholdMin) || (thresholdMin > 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<entriesLen; i++) { - // Print only the ones that filter through - var okToPrint = false; - var okToFilterCats = false; - - // Get log message details - var entry = aEntries[i]; - var source = entry.source; - var category = entry.category; - - for(var j=0; j<sourceFiltersLen; j++) { - if(source == this._sourceFilters[j]) { - okToFilterCats = true; - break; - } - } - if(okToFilterCats) { - for(var k=0; k<categoryFiltersLen; k++) { - if(category == this._categoryFilters[k]) { - okToPrint = true; - break; - } - } - } - if(okToPrint) { - var output = this.formatMsg(entry); - - // Verbose output uses <code> tag instead of <pre> 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<filtersArray.length; i++) { - if(newFilter == filtersArray[i]) { - filtersArray.splice(i, 1); - break; - } - } - } - else { // Add category to filters - filtersArray.push(newFilter); - } - oSelf._filterLogs(); -}; - -/** - * Handles check events on the category filter checkboxes. - * - * @method _onCheckSource - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onCheckSource = function(v, oSelf) { - var newFilter = this.source; - var filtersArray = oSelf._sourceFilters; - - if(!this.checked) { // Remove category from filters - for(var i=0; i<filtersArray.length; i++) { - if(newFilter == filtersArray[i]) { - filtersArray.splice(i, 1); - break; - } - } - } - else { // Add category to filters - filtersArray.push(newFilter); - } - oSelf._filterLogs(); -}; - -/** - * Handles click events on the collapse button. - * - * @method _onClickCollapseBtn - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The LogReader instance - * @private - */ -YAHOO.widget.LogReader.prototype._onClickCollapseBtn = function(v, oSelf) { - if(!oSelf.isCollapsed) { - oSelf.collapse(); - } - else { - oSelf.expand(); - } -}; - -/** - * Handles click events on the pause button. - * - * @method _onClickPauseBtn - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onClickPauseBtn = function(v, oSelf) { - var btn = oSelf._btnPause; - if(btn.value == "Resume") { - oSelf.resume(); - btn.value = "Pause"; - } - else { - oSelf.pause(); - btn.value = "Resume"; - } -}; - -/** - * Handles click events on the clear button. - * - * @method _onClickClearBtn - * @param v {HTMLEvent} The click event. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onClickClearBtn = function(v, oSelf) { - oSelf._clearConsole(); -}; - -/** - * Handles Logger's newLogEvent. - * - * @method _onNewLog - * @param sType {String} The event. - * @param aArgs {Object[]} Data passed from event firer. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onNewLog = function(sType, aArgs, oSelf) { - var logEntry = aArgs[0]; - oSelf._buffer.push(logEntry); - - if (oSelf.logReaderEnabled === true && oSelf._timeout === null) { - oSelf._timeout = setTimeout(function(){oSelf._printBuffer();}, 100); - } -}; - -/** - * Handles Logger's resetEvent. - * - * @method _onReset - * @param sType {String} The event. - * @param aArgs {Object[]} Data passed from event firer. - * @param oSelf {Object} The LogReader instance. - * @private - */ -YAHOO.widget.LogReader.prototype._onReset = function(sType, aArgs, oSelf) { - oSelf._filterLogs(); -}; - - /** - * The Logger widget provides a simple way to read or write log messages in - * JavaScript code. Integration with the YUI Library's debug builds allow - * implementers to access under-the-hood events, errors, and debugging messages. - * Output may be read through a LogReader console and/or output to a browser - * console. - * - * @module logger - * @requires yahoo, event, dom - * @optional dragdrop - * @namespace YAHOO.widget - * @title Logger Widget - */ - -/****************************************************************************/ -/****************************************************************************/ -/****************************************************************************/ - -/** - * The singleton Logger class provides core log management functionality. Saves - * logs written through the global YAHOO.log function or written by a LogWriter - * instance. Provides access to logs for reading by a LogReader instance or - * native browser console such as the Firebug extension to Firefox or Safari's - * JavaScript console through integration with the console.log() method. - * - * @class Logger - * @static - */ -YAHOO.widget.Logger = { - // Initialize members - loggerEnabled: true, - _browserConsoleEnabled: false, - categories: ["info","warn","error","time","window"], - sources: ["global"], - _stack: [], // holds all log msgs - maxStackEntries: 2500, - _startTime: new Date().getTime(), // static start timestamp - _lastTime: null // timestamp of last logged message -}; - -///////////////////////////////////////////////////////////////////////////// -// -// Public methods -// -///////////////////////////////////////////////////////////////////////////// -/** - * Saves a log message to the stack and fires newLogEvent. If the log message is - * assigned to an unknown category, creates a new category. If the log message is - * from an unknown source, creates a new source. If browser console is enabled, - * outputs the log message to browser console. - * - * @method log - * @param sMsg {String} The log message. - * @param sCategory {String} Category of log message, or null. - * @param sSource {String} Source of LogWriter, or null if global. - */ -YAHOO.widget.Logger.log = function(sMsg, sCategory, sSource) { - if(this.loggerEnabled) { - if(!sCategory) { - sCategory = "info"; // default category - } - else { - sCategory = sCategory.toLocaleLowerCase(); - if(this._isNewCategory(sCategory)) { - this._createNewCategory(sCategory); - } - } - var sClass = "global"; // default source - var sDetail = null; - if(sSource) { - var spaceIndex = sSource.indexOf(" "); - if(spaceIndex > 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.2.0", build: "127"}); diff --git a/interface/web/js/yui/menu/README b/interface/web/js/yui/menu/README deleted file mode 100644 index 34689ef959..0000000000 --- a/interface/web/js/yui/menu/README +++ /dev/null @@ -1,385 +0,0 @@ -*** 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 <div> 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 - <em> element used for the submenu arrow indicator. - - * EXPANDED_SUBMENU_INDICATOR_TEXT - String representing the text for the - submenu arrow indicator element (<em>) when the submenu is visible. - - * DISABLED_SUBMENU_INDICATOR_ALT_TEXT - String representing the text for - the submenu arrow indicator element (<em>) when the menu item is disabled. - - * CHECKED_TEXT - String representing the text to be used for the checked - indicator element (<em>). - - * DISABLED_CHECKED_TEXT - String representing the text to be used for the - checked indicator element (<em>) 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 <li> - 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 <li> 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 *** - -Fixed the following bugs: -------------------------- - -* Placed the call to the DOM "focus" method used by the MenuItem class inside - a zero-second timeout to resolve a race condition between menu positioning - and focusing of a menu item that resulted in the browser viewport - scrolling unnecessarily. - -* Switched to JSMin for JavaScript compression to resolve issues with the - minified version. - -* Disabled menu item instances will no longer display a submenu if the item is - clicked or moused over. - -* Can no longer select more than one item in a menu if using the keyboard and - mouse simultaneously. - -* Calling the "destory" method on a menu will now unregister all of the menu's - submenus from the MenuManager. - - - -*** version 0.12 *** - -Added the following features: ------------------------------ - -* Added the YAHOO.widget.MenuManager singleton class. - -* Added two new methods to YAHOO.widget.Menu: - - * "addItems" - Adds an array of items to a menu. - - * "getRoot" - Returns the root menu in a menu hierarchy. - -* Added two new events to YAHOO.widget.Menu: - - * "itemAddedEvent" - Fires when an item is added to a menu. - - * "itemRemovedEvent" - Fires when an item is removed from a menu. - -* Added two new properties to YAHOO.widget.Menu: - - * "itemData" - Array of items to be added to the menu. - - * "lazyLoad" - Boolean indicating if the menu's "lazy load" feature - is enabled. - -* Added new configuration properties to YAHOO.widget.Menu: - - * "hidedelay" - Hides the menu after the specified number of milliseconds. - - * "showdelay" - Shows the menu after the specified number of milliseconds. - - * "container" - The containing element the menu should be rendered into. - - * "clicktohide" - Boolean indicating if the menu will automatically be - hidden if the user clicks outside of it. - - * "autosubmenudisplay" - Boolean indicating if submenus are automatically - made visible when the user mouses over the menu's items. - -* Added a "toString" method to YAHOO.widget.MenuItem, YAHOO.widget.MenuBarItem - and YAHOO.widget.ContextMenuItem that returns the class name followed by the - value of the item's "text" configuration property. - - -Fixed the following bugs: -------------------------- - -* Setting a YAHOO.widget.ContextMenu instance's "trigger" configuration - property will remove all previous triggers before setting up the new ones. - -* "destroy" method of YAHOO.widget.ContextMenu cleans up all DOM event handlers. - -* Clicking on a menu item with a submenu no longer hides/collapses the - entire menu. - -* Clicking an item's submenu indicator image no longer collapses the - entire menu. - - -Changes: --------- - -* Deprecated the YAHOO.widget.MenuModule and YAHOO.widget.MenuModuleItem - classes. The Base classes are now YAHOO.widget.Menu and - YAHOO.widget.MenuItem. - -* "addItem" and "insertItem" methods of YAHOO.widget.Menu now accept an - object literal representing YAHOO.widget.MenuItem configuration properties. - -* "clearActiveItem" now takes an argument: flag indicating if the Menu - instance's active item should be blurred. - -* Switched the default value of the "visible" configuration property for - YAHOO.widget.Menu to "false." - -* Switched the default value of the "constraintoviewport" configuration - property for YAHOO.widget.Menu to "true." - -* Overloaded the "submenu" configuration property for YAHOO.widget.MenuItem - so that it now can accept any of the following: - - * YAHOO.widget.Menu instance - * Object literal representation of a menu - * Element id - * Element reference - -* "hide" and "show" methods of statically positioned menus now toggle the their - element's "display" style property between "block" and "none." - - - -*** version 0.10.0 *** - -* Initial release - -* Known issues: - - * Some Firefox extensions disable the ability for JavaScript to prevent - the display of the browser's default context menu. These extensions - can cause the YUI ContextMenu to stop working. If you encounter this - problem, you can reset the context menu preference in Firefox back to - the default by making sure the "Disable or replace context menus" - preference is checked: - - Mac Firefox 1.0: - ------------------- - Preferences > Web Features > - Advanced... > Disable or replace context menus - - Mac Firefox 1.5 - ------------------- - Preferences > Context > - Advanced... > Disable or replace context menus - - Windows Firefox 1.0 - ------------------- - Tools > Options > Web Features > - Advanced... > Disable or replace context menus - - Windows Firefox 1.5 - ------------------- - Tools > Options > Context > - Advanced... > Disable or replace context menus - - - -*** version 0.11.3 *** - -Added the following features: ------------------------------ - -* Added a "target" configuration property to the MenuModuleItem object that - allows the user to specify the target of an item's anchor element. Items - that make use of the "target" configuration property will require the user - to click exactly on the item's anchor element to navigate to the specified - URL. - -* Items without a "url" property set will automatically hide their parent - menu instance(s) when clicked. - - -Fixed the following bugs: -------------------------- - -* Items in a submenu should now navigate to their specified URL when clicked. - -* Removed MenuBar's use of "overflow:hidden." This fixes an issue in Firefox - 1.5 in which submenus of a Menubar instance cannot overlay other absolutely - positioned elements on the page. - -* Submenus of a Menubar instance will now automatically have their iframe shim - enabled in IE<7. - -* Statically positioned Menubar and Menu instances will now render with the - correct position and dimensions in Safari. - -* MenuModuleItem's "focus" method now checks to make sure that an item's - "display" style property is not "none" before trying to set focus to its - anchor element. - -* A ContextMenu instance will now hide all other ContextMenu instances before - displaying itself. - -* Removed the dead space in front of an item's submenu indicator image in IE. - This space was causing an item's submenu to flicker when the user hovered - over it. - - -Changes: --------- - -* Moved the DOM event handlers for every menu from the root DIV node of each - instance to the document object. This change reduces the number of DOM event - handlers used by Menu to eight, improving the cleanup time required by the - Event utility. - - - -*** version 0.11.0 *** - -Added the following features: ------------------------------ -* Overloaded the "addItem" and "insertItem" methods of MenuModule to accept a - string or a MenuModuleItem instance - -* Added the ability to define a MenuItem instance as being "checked" - - -Fixed the following bugs: -------------------------- -* Changing the path for the submenu indicator image of one MenuModuleItem - subclass will no longer affect other subclasses - -* MenuItem instances built from existing markup without anchor tags will no - longer trigger a JavaScript error when clicked - -* Modified the implementation of the "imageRoot" property for the - MenuModuleItem class so that it is set to a secure/non-secure path when the - object is instantiated - -* Menu instances now resize in response to changes to the browser's font size - -* Modified the propagation of the MenuModule class's "submenualignment" - configuration property so that it only applies to instances of the same type - -* Adjusted the specificity of the style rule that controls the position of a - MenuItem instance's submenu indicator image to prevent it from wrapping in IE - -* Specified a width and height for submenu indicator images in the Menu - stylesheet to ensure that Menu instances are always rendered at the correct - width - -* Clicking a MenuItem instance will no longer trigger two HTTP GET requests - -* Users can now control or shift-click on MenuItem links - - -Changes: --------- -* In the Menu stylesheet (menu.css), switched from using "first" class to - "first-of-type" class - -* Changed case of MenuModuleItem class's "subMenuIndicator" property - to "submenuIndicator" \ No newline at end of file diff --git a/interface/web/js/yui/menu/assets/map.gif b/interface/web/js/yui/menu/assets/map.gif deleted file mode 100644 index 715859aa8b7e006cce52c4533c659e0bc022b868..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 264 zcmZ?wbhEHb<Y4Gv*v!FDUtizb+p}xu&g$x_n>TNsJ9jQJGU7iNFkl0UKUo+V7&sVo zK$0Lc7+AInC?+qN`sLP|^s9Hibw0?Db#Gswb$h3{&dF@4+u?yLtoE1N`d%=aA|mKM z)#%8{78|vmBColJVss?A%2!qGKb)|B#qX#4G929*E^J_AFn#3Psr*2mStj9<yLu># zEK3YWi$+tMh6sC8w?uR;dwsoBr#Q=Wp_y}L&tznr*~Y>sv~a%o!lhEo8SB=EO!4=t vRQBJnW9P2j9u6tiNok&YjvU?NvsF%9WXiE~=l3MqC#QLMUcInOkii-N{U~MY diff --git a/interface/web/js/yui/menu/assets/menu.css b/interface/web/js/yui/menu/assets/menu.css deleted file mode 100644 index 656dec9fc0..0000000000 --- a/interface/web/js/yui/menu/assets/menu.css +++ /dev/null @@ -1,384 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/* Menu styles */ - -div.yuimenu { - - background-color:#f6f7ee; - border:solid 1px #c4c4be; - padding:1px; - -} - -/* Submenus are positioned absolute and hidden by default */ - -div.yuimenu div.yuimenu, -div.yuimenubar div.yuimenu { - - position:absolute; - visibility:hidden; - -} - -/* MenuBar Styles */ - -div.yuimenubar { - - background-color:#f6f7ee; - -} - -/* - Applying a width triggers "haslayout" in IE so that the module's - body clears its floated elements -*/ -div.yuimenubar div.bd { - - width:100%; - -} - -/* - Clear the module body for other browsers -*/ -div.yuimenubar div.bd:after { - - content:'.'; - display:block; - clear:both; - visibility:hidden; - height:0; - -} - -/* Matches the group title (H6) inside a Menu or MenuBar instance */ - -div.yuimenu h6, -div.yuimenubar h6 { - - font-size:100%; - font-weight:normal; - margin:0; - border:solid 1px #c4c4be; - color:#b9b9b9; - -} - -div.yuimenubar h6 { - - float:left; - display:inline; /* Prevent margin doubling in IE */ - padding:4px 12px; - border-width:0 1px 0 0; - -} - -div.yuimenu h6 { - - float:none; - display:block; - border-width:1px 0 0 0; - padding:5px 10px 0 10px; - -} - -/* Matches the UL inside a Menu or MenuBar instance */ - -div.yuimenubar ul { - - list-style-type:none; - margin:0; - padding:0; - -} - -div.yuimenu ul { - - list-style-type:none; - border:solid 1px #c4c4be; - border-width:1px 0 0 0; - margin:0; - padding:10px 0; - -} - -div.yuimenu ul.first-of-type, -div.yuimenu ul.hastitle, -div.yuimenu h6.first-of-type { - - border-width:0; - -} - -/* - Styles for the menu's header and footer elements that are used as controls - to scroll the menu's body element when the menu's height exceeds the - value of the "maxheight" configuration property. -*/ - -div.yuimenu div.topscrollbar, -div.yuimenu div.bottomscrollbar { - - height:16px; - background-image:url(map.gif); - background-repeat:no-repeat; - -} - - -div.yuimenu div.topscrollbar { - - background-image:url(map.gif); - background-position:center -72px; - -} - - -div.yuimenu div.topscrollbar_disabled { - - background-image:url(map.gif); - background-position:center -88px; - -} - - -div.yuimenu div.bottomscrollbar { - - background-image:url(map.gif); - background-position:center -104px; - -} - - -div.yuimenu div.bottomscrollbar_disabled { - - background-image:url(map.gif); - background-position:center -120px; - -} - - -/* MenuItem and MenuBarItem styles */ - -div.yuimenu li, -div.yuimenubar li { - - font-size:85%; - cursor:pointer; - cursor:hand; - white-space:nowrap; - text-align:left; - -} - -div.yuimenu li.yuimenuitem { - - padding:2px 24px; - -} - -div.yuimenu li li, -div.yuimenubar li li { - - font-size:100%; - -} - - -/* Matches the help text for a menu item */ - -div.yuimenu li.hashelptext em.helptext { - - font-style:normal; - margin:0 0 0 40px; - -} - -div.yuimenu li a, -div.yuimenubar li a { - - /* - "zoom:1" triggers "haslayout" in IE to ensure that the mouseover and - mouseout events bubble to the parent LI in IE. - */ - zoom:1; - color:#000; - text-decoration:none; - -} - -div.yuimenu li.hassubmenu, -div.yuimenu li.hashelptext { - - text-align:right; - -} - -div.yuimenu li.hassubmenu a.hassubmenu, -div.yuimenu li.hashelptext a.hashelptext { - - float:left; - display:inline; /* Prevent margin doubling in IE */ - text-align:left; - -} - - -/* Matches selected menu items */ - -div.yuimenu li.selected, -div.yuimenubar li.selected { - - background-color:#8c8ad0; - -} - -div.yuimenu li.selected a.selected, -div.yuimenubar li.selected a.selected { - - text-decoration:underline; - -} - -div.yuimenu li.selected a.selected, -div.yuimenu li.selected em.selected, -div.yuimenubar li.selected a.selected { - - color:#fff; - -} - - -/* Matches disabled menu items */ - -div.yuimenu li.disabled, -div.yuimenubar li.disabled { - - cursor:default; - -} - -div.yuimenu li.disabled a.disabled, -div.yuimenu li.disabled em.disabled, -div.yuimenubar li.disabled a.disabled { - - color:#b9b9b9; - cursor:default; - -} - -div.yuimenubar li.yuimenubaritem { - - float:left; - display:inline; /* Prevent margin doubling in IE */ - border-width:0 0 0 1px; - border-style:solid; - border-color:#c4c4be; - padding:4px 24px; - margin:0; - -} - -div.yuimenubar li.yuimenubaritem.first-of-type { - - border-width:0; - -} - - -/* Styles for the the submenu indicator for menu items */ - -div.yuimenu li.hassubmenu em.submenuindicator, -div.yuimenubar li.hassubmenu em.submenuindicator { - - display:-moz-inline-box; /* Mozilla */ - display:inline-block; /* IE, Opera and Safari */ - vertical-align:middle; - height:8px; - width:8px; - text-indent:9px; - font:0/0 arial; - overflow:hidden; - background-image:url(map.gif); - background-repeat:no-repeat; - -} - -div.yuimenubar li.hassubmenu em.submenuindicator { - - background-position:0 -24px; - margin:0 0 0 10px; - -} - -div.yuimenubar li.hassubmenu em.submenuindicator.selected { - - background-position:0 -32px; - -} - -div.yuimenubar li.hassubmenu em.submenuindicator.disabled { - - background-position:0 -40px; - -} - -div.yuimenu li.hassubmenu em.submenuindicator { - - background-position:0 0; - margin:0 -16px 0 10px; - -} - -div.yuimenu li.hassubmenu em.submenuindicator.selected { - - background-position:0 -8px; - -} - -div.yuimenu li.hassubmenu em.submenuindicator.disabled { - - background-position:0 -16px; - -} - - -/* Styles for a menu item's "checked" state */ - -div.yuimenu li.checked { - - position:relative; - -} - -div.yuimenu li.checked em.checkedindicator { - - height:8px; - width:8px; - text-indent:9px; - overflow:hidden; - background-image:url(map.gif); - background-position:0 -48px; - background-repeat:no-repeat; - position:absolute; - left:6px; - _left:-16px; /* Underscore hack b/c this is for IE 6 only */ - top:.5em; - -} - -div.yuimenu li.checked em.checkedindicator.selected { - - background-position:0 -56px; - -} - -div.yuimenu li.checked em.checkedindicator.disabled { - - background-position:0 -64px; - -} \ No newline at end of file diff --git a/interface/web/js/yui/menu/assets/menuarodwn8_dim_1.gif b/interface/web/js/yui/menu/assets/menuarodwn8_dim_1.gif deleted file mode 100644 index 60b38365a203237a6cfd8b95002bbd0b4322fe99..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53 zcmZ?wbhEHb<Y3@nXkcVGckUbm1B2pE7DfgJMg|=q8z|1fz`(@Q(=W+z{M)?AD^{-N HVz34PDe??) diff --git a/interface/web/js/yui/menu/assets/menuarodwn8_hov_1.gif b/interface/web/js/yui/menu/assets/menuarodwn8_hov_1.gif deleted file mode 100644 index 66632e83e2b62c42823147c76e3ae64f89d147ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53 zcmZ?wbhEHb<Y3@nXkcXc|NlP&1B2pE7DfgJMg|=q8z|1fz`(@Q(=W+z{M)?AD^{-N HVz34PKvxX} diff --git a/interface/web/js/yui/menu/assets/menuarodwn8_nrm_1.gif b/interface/web/js/yui/menu/assets/menuarodwn8_nrm_1.gif deleted file mode 100644 index bf5d3f1d2de98f703b472b6b9d212e456e18ba8b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53 zcmZ?wbhEHb<Y3@nXkcWBjErDlU{L(Y!pOkD$e;sc1I0NQ7?^l^`Xw2Tf15XX#md!O G4AubjL<<oB diff --git a/interface/web/js/yui/menu/assets/menuarorght8_dim_1.gif b/interface/web/js/yui/menu/assets/menuarorght8_dim_1.gif deleted file mode 100644 index 0780b662115465ffcd5a5fc6f781dc6908b21a6a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmZ?wbhEHb<Y3@nXkcVGckUbm1B2pE7DfgJMg|=q8z|1fz`(@o!?3Jv^;^H955C^{ H8VuF|GOY|b diff --git a/interface/web/js/yui/menu/assets/menuarorght8_hov_1.gif b/interface/web/js/yui/menu/assets/menuarorght8_hov_1.gif deleted file mode 100644 index 0d87f1a35587240de1e1f3528de894859cc5ba4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmZ?wbhEHb<Y3@nXkcXc|NlP&1B2pE7DfgJMg|=q8z|1fz`(@o!?3Jv^;^H955C^{ H8VuF|Nu><T diff --git a/interface/web/js/yui/menu/assets/menuarorght8_nrm_1.gif b/interface/web/js/yui/menu/assets/menuarorght8_nrm_1.gif deleted file mode 100644 index 3cdc2a9d18fe9b4eb72e764869e64f37c777b906..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 zcmZ?wbhEHb<Y3@nXkcWBjErDlU{L(Y!pOkD$e;sc1I0NQ7?^l{7?!oIe(P8C!Ph%q HgTWdA`=1Kg diff --git a/interface/web/js/yui/menu/assets/menuaroup8_dim_1.gif b/interface/web/js/yui/menu/assets/menuaroup8_dim_1.gif deleted file mode 100644 index 1acaeecf1447e32179a9027b4420527987a1dc5f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53 zcmZ?wbhEHb<Y3@nXkcJCckUbm1B2pE7DfgJMg|=q8z|1fz`(@Q)8Dz^!RfdOlUG)A HF<1itG7Jpn diff --git a/interface/web/js/yui/menu/assets/menuaroup8_nrm_1.gif b/interface/web/js/yui/menu/assets/menuaroup8_nrm_1.gif deleted file mode 100644 index ee44529ace0b46009fca271d0b0e9bb08fda07b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53 zcmZ?wbhEHb<Y3@nXkcK7jErDlU{L(Y!pOkD$e;sc1I0NQ7?^l^`a2gqI2|`(^2%y1 G25SKPUJHf* diff --git a/interface/web/js/yui/menu/assets/menuchk8_dim_1.gif b/interface/web/js/yui/menu/assets/menuchk8_dim_1.gif deleted file mode 100644 index d282a6c06ac7f43aeafbcb8208765c9b508bb99b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 65 zcmZ?wbhEHb<Y3@nn8?gfU0v1N+jH~gO$G)A#h)yU3=GT+IzTp1mV<$TNobCJlUf&V TB=<s9L7%xRp0O&hGFSru5~2^0 diff --git a/interface/web/js/yui/menu/assets/menuchk8_hov_1.gif b/interface/web/js/yui/menu/assets/menuchk8_hov_1.gif deleted file mode 100644 index 2fabaef59b00950cd4f25dc9a9abee998eafc8ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 67 zcmZ?wbhEHb<Y3@nn8?g<^XARS$cX>{|1&T!DE?$&WME)s&;hc6vK$NyOd@ma8`w7K Vws;w`SgzXn>&^zA2Z0O>)&O?c6EFY( diff --git a/interface/web/js/yui/menu/assets/menuchk8_nrm_1.gif b/interface/web/js/yui/menu/assets/menuchk8_nrm_1.gif deleted file mode 100644 index 9732837a7755b6bee23b95f32eb998c487daa53c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 67 zcmZ?wbhEHb<Y3@nn8?hqYv<0$$cXy-dIkmt#h)yU3=GT+IzTp1mV<$TNo0<F1KTFu V7B52<%T+sn-PyqNAdrE<8UP%w5m5jD diff --git a/interface/web/js/yui/menu/menu-debug.js b/interface/web/js/yui/menu/menu-debug.js deleted file mode 100644 index aa1dceebe9..0000000000 --- a/interface/web/js/yui/menu/menu-debug.js +++ /dev/null @@ -1,8317 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - - -/** -* @module menu -* @description <p>The Menu family of components features a collection of -* controls that make it easy to add menus to your website or web application. -* With the Menu Controls you can create website fly-out menus, customized -* context menus, or application-style menu bars with just a small amount of -* scripting.</p><p>The Menu family of controls features:</p> -* <ul> -* <li>Screen-reader accessibility.</li> -* <li>Keyboard and mouse navigation.</li> -* <li>A rich event model that provides access to all of a menu's -* interesting moments.</li> -* <li>Support for -* <a href="http://en.wikipedia.org/wiki/Progressive_Enhancement">Progressive -* Enhancement</a>; Menus can be created from simple, -* semantic markup on the page or purely through JavaScript.</li> -* </ul> -* @title Menu -* @namespace YAHOO.widget -* @requires Event, Dom, Container -*/ -(function() { - -var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event; - -/** -* Singleton that manages a collection of all menus and menu items. Listens for -* DOM events at the document level and dispatches the events to the -* corresponding menu or menu item. -* -* @namespace YAHOO.widget -* @class MenuManager -* @static -*/ -YAHOO.widget.MenuManager = function() { - - // Private member variables - - - // Flag indicating if the DOM event handlers have been attached - - var m_bInitializedEventHandlers = false, - - - // Collection of menus - - m_oMenus = {}, - - - // Collection of menu items - - m_oItems = {}, - - - // Collection of visible menus - - m_oVisibleMenus = {}, - - me = this; - - - var m_oLogger = new YAHOO.widget.LogWriter(this.toString()); - - - // Private methods - - - /** - * @method addItem - * @description Adds an item to the collection of known menu items. - * @private - * @param {YAHOO.widget.MenuItem} p_oItem Object specifying the MenuItem - * instance to be added. - */ - function addItem(p_oItem) { - - var sId = p_oItem.id; - - if(p_oItem && m_oItems[sId] != p_oItem) { - - m_oItems[sId] = p_oItem; - - p_oItem.destroyEvent.subscribe(onItemDestroy, p_oItem); - - m_oLogger.log("Item: " + - p_oItem.toString() + " successfully registered."); - - } - - } - - - /** - * @method removeItem - * @description Removes an item from the collection of known menu items. - * @private - * @param {YAHOO.widget.MenuItem} p_oItem Object specifying the MenuItem - * instance to be removed. - */ - function removeItem(p_oItem) { - - var sId = p_oItem.id; - - if(sId && m_oItems[sId]) { - - delete m_oItems[sId]; - - m_oLogger.log("Item: " + - p_oItem.toString() + " successfully unregistered."); - - } - - } - - - /** - * @method getMenuRootElement - * @description Finds the root DIV node of a menu or the root LI node of a - * menu item. - * @private - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-58190037">HTMLElement</a>} p_oElement Object specifying - * an HTML element. - */ - function getMenuRootElement(p_oElement) { - - var oParentNode; - - if(p_oElement && p_oElement.tagName) { - - switch(p_oElement.tagName.toUpperCase()) { - - case "DIV": - - oParentNode = p_oElement.parentNode; - - // Check if the DIV is the inner "body" node of a menu - - if( - ( - Dom.hasClass(p_oElement, "hd") || - Dom.hasClass(p_oElement, "bd") || - Dom.hasClass(p_oElement, "ft") - ) - && - oParentNode && - oParentNode.tagName && - oParentNode.tagName.toUpperCase() == "DIV" - ) { - - return oParentNode; - - } - else { - - return p_oElement; - - } - - break; - - case "LI": - - return p_oElement; - - default: - - oParentNode = p_oElement.parentNode; - - if(oParentNode) { - - return getMenuRootElement(oParentNode); - - } - - break; - - } - - } - - } - - - - // Private event handlers - - - /** - * @method onDOMEvent - * @description Generic, global event handler for all of a menu's DOM-based - * events. This listens for events against the document object. If the - * target of a given event is a member of a menu or menu item's DOM, the - * instance's corresponding Custom Event is fired. - * @private - * @param {Event} p_oEvent Object representing the DOM event object passed - * back by the event utility (YAHOO.util.Event). - */ - function onDOMEvent(p_oEvent) { - - // Get the target node of the DOM event - - var oTarget = Event.getTarget(p_oEvent), - - - // See if the target of the event was a menu, or a menu item - - oElement = getMenuRootElement(oTarget), - oMenuItem, - oMenu; - - - if(oElement) { - - var sTagName = oElement.tagName.toUpperCase(); - - if(sTagName == "LI") { - - var sId = oElement.id; - - if(sId && m_oItems[sId]) { - - oMenuItem = m_oItems[sId]; - oMenu = oMenuItem.parent; - - } - - } - else if(sTagName == "DIV") { - - if(oElement.id) { - - oMenu = m_oMenus[oElement.id]; - - } - - } - - } - - if(oMenu) { - - // Map of DOM event names to CustomEvent names - - var oEventTypes = { - "click": "clickEvent", - "mousedown": "mouseDownEvent", - "mouseup": "mouseUpEvent", - "mouseover": "mouseOverEvent", - "mouseout": "mouseOutEvent", - "keydown": "keyDownEvent", - "keyup": "keyUpEvent", - "keypress": "keyPressEvent" - }, - - sCustomEventType = oEventTypes[p_oEvent.type]; - - - // Fire the Custom Even that corresponds the current DOM event - - if(oMenuItem && !oMenuItem.cfg.getProperty("disabled")) { - - oMenuItem[sCustomEventType].fire(p_oEvent); - - } - - oMenu[sCustomEventType].fire(p_oEvent, oMenuItem); - - } - else if(p_oEvent.type == "mousedown") { - - - /* - If the target of the event wasn't a menu, hide all - dynamically positioned menus - */ - - var oActiveItem; - - for(var i in m_oMenus) { - - if(m_oMenus.hasOwnProperty(i)) { - - oMenu = m_oMenus[i]; - - if( - oMenu.cfg.getProperty("clicktohide") && - oMenu.cfg.getProperty("position") == "dynamic" - ) { - - oMenu.hide(); - - } - else { - - oMenu.clearActiveItem(true); - - } - - } - - } - - } - - } - - - /** - * @method onMenuDestroy - * @description "destroy" event handler for a 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.Menu} p_oMenu Object representing the menu that - * fired the event. - */ - function onMenuDestroy(p_sType, p_aArgs, p_oMenu) { - - if(p_oMenu && m_oMenus[p_oMenu.id]) { - - delete m_oMenus[p_oMenu.id]; - - m_oLogger.log("Menu: " + - p_oMenu.toString() + " successfully unregistered."); - - } - - } - - - /** - * @method onItemDestroy - * @description "destroy" event handler for a MenuItem instance. - * @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 fired the event. - */ - function onItemDestroy(p_sType, p_aArgs, p_oItem) { - - var sId = p_oItem.id; - - if(sId && m_oItems[sId]) { - - delete m_oItems[sId]; - - } - - } - - - /** - * @method onMenuVisibleConfigChange - * @description Event handler for when the "visible" configuration property - * of a Menu instance changes. - * @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.Menu} p_oMenu Object representing the menu that - * fired the event. - */ - function onMenuVisibleConfigChange(p_sType, p_aArgs, p_oMenu) { - - var bVisible = p_aArgs[0]; - - if(bVisible) { - - m_oVisibleMenus[p_oMenu.id] = p_oMenu; - - m_oLogger.log("Menu: " + - p_oMenu.toString() + - " registered with the collection of visible menus."); - - } - else if(m_oVisibleMenus[p_oMenu.id]) { - - delete m_oVisibleMenus[p_oMenu.id]; - - m_oLogger.log("Menu: " + - p_oMenu.toString() + - " unregistered from the collection of visible menus."); - - } - - } - - - /** - * @method onItemAdded - * @description "itemadded" event handler for a Menu instance. - * @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. - */ - function onItemAdded(p_sType, p_aArgs) { - - addItem(p_aArgs[0]); - - } - - - /** - * @method onItemRemoved - * @description "itemremoved" event handler for a Menu instance. - * @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. - */ - function onItemRemoved(p_sType, p_aArgs) { - - removeItem(p_aArgs[0]); - - } - - - - return { - - // Privileged methods - - - /** - * @method addMenu - * @description Adds a menu to the collection of known menus. - * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu - * instance to be added. - */ - addMenu: function(p_oMenu) { - - if(p_oMenu && p_oMenu.id && !m_oMenus[p_oMenu.id]) { - - m_oMenus[p_oMenu.id] = p_oMenu; - - - if(!m_bInitializedEventHandlers) { - - var oDoc = document; - - Event.addListener(oDoc, "mouseover", onDOMEvent, me, true); - Event.addListener(oDoc, "mouseout", onDOMEvent, me, true); - Event.addListener(oDoc, "mousedown", onDOMEvent, me, true); - Event.addListener(oDoc, "mouseup", onDOMEvent, me, true); - Event.addListener(oDoc, "click", onDOMEvent, me, true); - Event.addListener(oDoc, "keydown", onDOMEvent, me, true); - Event.addListener(oDoc, "keyup", onDOMEvent, me, true); - Event.addListener(oDoc, "keypress", onDOMEvent, me, true); - - m_bInitializedEventHandlers = true; - - m_oLogger.log("DOM event handlers initialized."); - - } - - p_oMenu.destroyEvent.subscribe(onMenuDestroy, p_oMenu, me); - - p_oMenu.cfg.subscribeToConfigEvent( - "visible", - onMenuVisibleConfigChange, - p_oMenu - ); - - p_oMenu.itemAddedEvent.subscribe(onItemAdded); - p_oMenu.itemRemovedEvent.subscribe(onItemRemoved); - - m_oLogger.log("Menu: " + - p_oMenu.toString() + " successfully registered."); - - } - - }, - - - /** - * @method removeMenu - * @description Removes a menu from the collection of known menus. - * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu - * instance to be removed. - */ - removeMenu: function(p_oMenu) { - - if(p_oMenu && m_oMenus[p_oMenu.id]) { - - delete m_oMenus[p_oMenu.id]; - - m_oLogger.log("Menu: " + - p_oMenu.toString() + " successfully unregistered."); - - } - - }, - - - /** - * @method hideVisible - * @description Hides all visible, dynamically positioned menus. - */ - hideVisible: function() { - - var oMenu; - - for(var i in m_oVisibleMenus) { - - if(m_oVisibleMenus.hasOwnProperty(i)) { - - oMenu = m_oVisibleMenus[i]; - - if(oMenu.cfg.getProperty("position") == "dynamic") { - - oMenu.hide(); - - } - - } - - } - - }, - - - /** - * @method getMenus - * @description Returns an array of all menus registered with the - * menu manger. - * @return {Array} - */ - getMenus: function() { - - return m_oMenus; - - }, - - - /** - * @method getMenu - * @description Returns a menu with the specified id. - * @param {String} p_sId String specifying the id of the menu to - * be retrieved. - * @return {YAHOO.widget.Menu} - */ - getMenu: function(p_sId) { - - if(m_oMenus[p_sId]) { - - return m_oMenus[p_sId]; - - } - - }, - - - /** - * @method toString - * @description Returns a string representing the menu manager. - * @return {String} - */ - toString: function() { - - return ("MenuManager"); - - } - - }; - -}(); - -})(); - - - -/** -* The Menu class creates a container that holds a vertical list representing -* a set of options or commands. Menu is the base class for all -* menu containers. -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the menu. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source -* for the menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object -* specifying the <code><div></code> element of the menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement -* Object specifying the <code><select></code> element to be used as -* the data source for the menu. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu. See configuration class documentation for -* more details. -* @namespace YAHOO.widget -* @class Menu -* @constructor -* @extends YAHOO.widget.Overlay -*/ -(function() { - -var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event, - Lang = YAHOO.lang; - - -YAHOO.widget.Menu = function(p_oElement, p_oConfig) { - - if(p_oConfig) { - - this.parent = p_oConfig.parent; - this.lazyLoad = p_oConfig.lazyLoad || p_oConfig.lazyload; - this.itemData = p_oConfig.itemData || p_oConfig.itemdata; - - } - - - YAHOO.widget.Menu.superclass.constructor.call( - this, - p_oElement, - p_oConfig - ); - -}; - - -YAHOO.lang.extend(YAHOO.widget.Menu, YAHOO.widget.Overlay, { - - -// Constants - - -/** -* @property CSS_CLASS_NAME -* @description String representing the CSS class(es) to be applied to the -* menu's <code><div></code> element. -* @default "yuimenu" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuimenu", - - -/** -* @property ITEM_TYPE -* @description Object representing the type of menu item to instantiate and -* add when parsing the child nodes (either <code><li></code> element, -* <code><optgroup></code> element or <code><option></code>) -* of the menu's source HTML element. -* @default YAHOO.widget.MenuItem -* @final -* @type YAHOO.widget.MenuItem -*/ -ITEM_TYPE: null, - - -/** -* @property GROUP_TITLE_TAG_NAME -* @description String representing the tagname of the HTML element used to -* title the menu's item groups. -* @default H6 -* @final -* @type String -*/ -GROUP_TITLE_TAG_NAME: "h6", - - - -// Private properties - - -/** -* @property _nHideDelayId -* @description Number representing the time-out setting used to cancel the -* hiding of a menu. -* @default null -* @private -* @type Number -*/ -_nHideDelayId: null, - - -/** -* @property _nShowDelayId -* @description Number representing the time-out setting used to cancel the -* showing of a menu. -* @default null -* @private -* @type Number -*/ -_nShowDelayId: null, - - -/** -* @property _nSubmenuHideDelayId -* @description Number representing the time-out setting used to cancel the -* hiding of a submenu. -* @default null -* @private -* @type Number -*/ -_nSubmenuHideDelayId: null, - - -/** -* @property _nBodyScrollId -* @description Number representing the time-out setting used to cancel the -* scrolling of the menu's body element. -* @default null -* @private -* @type Number -*/ -_nBodyScrollId: null, - - -/** -* @property _bHideDelayEventHandlersAssigned -* @description Boolean indicating if the "mouseover" and "mouseout" event -* handlers used for hiding the menu via a call to "window.setTimeout" have -* already been assigned. -* @default false -* @private -* @type Boolean -*/ -_bHideDelayEventHandlersAssigned: false, - - -/** -* @property _bHandledMouseOverEvent -* @description Boolean indicating the current state of the menu's -* "mouseover" event. -* @default false -* @private -* @type Boolean -*/ -_bHandledMouseOverEvent: false, - - -/** -* @property _bHandledMouseOutEvent -* @description Boolean indicating the current state of the menu's -* "mouseout" event. -* @default false -* @private -* @type Boolean -*/ -_bHandledMouseOutEvent: false, - - -/** -* @property _aGroupTitleElements -* @description Array of HTML element used to title groups of menu items. -* @default [] -* @private -* @type Array -*/ -_aGroupTitleElements: null, - - -/** -* @property _aItemGroups -* @description Multi-dimensional Array representing the menu items as they -* are grouped in the menu. -* @default [] -* @private -* @type Array -*/ -_aItemGroups: null, - - -/** -* @property _aListElements -* @description Array of <code><ul></code> elements, each of which is -* the parent node for each item's <code><li></code> element. -* @default [] -* @private -* @type Array -*/ -_aListElements: null, - - -/** -* @property _nCurrentMouseX -* @description The current x coordinate of the mouse inside the area of -* the menu. -* @default 0 -* @private -* @type Number -*/ -_nCurrentMouseX: 0, - - -/** -* @property _nMaxHeight -* @description The original value of the "maxheight" configuration property -* as set by the user. -* @default -1 -* @private -* @type Number -*/ -_nMaxHeight: -1, - - -/** -* @property _bStopMouseEventHandlers -* @description Stops "mouseover," "mouseout," and "mousemove" event handlers -* from executing. -* @default false -* @private -* @type Boolean -*/ -_bStopMouseEventHandlers: false, - - -/** -* @property _sClassName -* @description The current value of the "classname" configuration attribute. -* @default null -* @private -* @type String -*/ -_sClassName: null, - - - -// Public properties - - -/** -* @property lazyLoad -* @description Boolean indicating if the menu's "lazy load" feature is -* enabled. If set to "true," initialization and rendering of the menu's -* items will be deferred until the first time it is made visible. This -* property should be set via the constructor using the configuration -* object literal. -* @default false -* @type Boolean -*/ -lazyLoad: false, - - -/** -* @property itemData -* @description Array of items to be added to the menu. The array can contain -* strings representing the text for each item to be created, object literals -* representing the menu item configuration properties, or MenuItem instances. -* This property should be set via the constructor using the configuration -* object literal. -* @default null -* @type Array -*/ -itemData: null, - - -/** -* @property activeItem -* @description Object reference to the item in the menu that has focus. -* @default null -* @type YAHOO.widget.MenuItem -*/ -activeItem: null, - - -/** -* @property parent -* @description Object reference to the menu's parent menu or menu item. -* This property can be set via the constructor using the configuration -* object literal. -* @default null -* @type YAHOO.widget.MenuItem -*/ -parent: null, - - -/** -* @property srcElement -* @description Object reference to the HTML element (either -* <code><select></code> or <code><div></code>) used to -* create the menu. -* @default null -* @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-94282980">HTMLSelectElement</a>|<a -* href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html. -* html#ID-22445964">HTMLDivElement</a> -*/ -srcElement: null, - - - -// Events - - -/** -* @event mouseOverEvent -* @description Fires when the mouse has entered the menu. Passes back -* the DOM Event object as an argument. -*/ -mouseOverEvent: null, - - -/** -* @event mouseOutEvent -* @description Fires when the mouse has left the menu. Passes back the DOM -* Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -mouseOutEvent: null, - - -/** -* @event mouseDownEvent -* @description Fires when the user mouses down on the menu. Passes back the -* DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -mouseDownEvent: null, - - -/** -* @event mouseUpEvent -* @description Fires when the user releases a mouse button while the mouse is -* over the menu. Passes back the DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -mouseUpEvent: null, - - -/** -* @event clickEvent -* @description Fires when the user clicks the on the menu. Passes back the -* DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -clickEvent: null, - - -/** -* @event keyPressEvent -* @description Fires when the user presses an alphanumeric key when one of the -* menu's items has focus. Passes back the DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -keyPressEvent: null, - - -/** -* @event keyDownEvent -* @description Fires when the user presses a key when one of the menu's items -* has focus. Passes back the DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -keyDownEvent: null, - - -/** -* @event keyUpEvent -* @description Fires when the user releases a key when one of the menu's items -* has focus. Passes back the DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -keyUpEvent: null, - - -/** -* @event itemAddedEvent -* @description Fires when an item is added to the menu. -* @type YAHOO.util.CustomEvent -*/ -itemAddedEvent: null, - - -/** -* @event itemRemovedEvent -* @description Fires when an item is removed to the menu. -* @type YAHOO.util.CustomEvent -*/ -itemRemovedEvent: null, - - -/** -* @method init -* @description The Menu class's initialization method. This method is -* automatically called by the constructor, and sets up all DOM references -* for pre-existing markup, and creates required markup if it is not -* already present. -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the menu. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source -* for the menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object -* specifying the <code><div></code> element of the menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement -* Object specifying the <code><select></code> element to be used as -* the data source for the menu. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu. See configuration class documentation for -* more details. -*/ -init: function(p_oElement, p_oConfig) { - - this._aItemGroups = []; - this._aListElements = []; - this._aGroupTitleElements = []; - - - if(!this.ITEM_TYPE) { - - this.ITEM_TYPE = YAHOO.widget.MenuItem; - - } - - - var oElement; - - if(typeof p_oElement == "string") { - - oElement = document.getElementById(p_oElement); - - } - else if(p_oElement.tagName) { - - oElement = p_oElement; - - } - - - if(oElement && oElement.tagName) { - - switch(oElement.tagName.toUpperCase()) { - - case "DIV": - - this.srcElement = oElement; - - if(!oElement.id) { - - oElement.setAttribute("id", Dom.generateId()); - - } - - - /* - Note: we don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.Menu.superclass.init.call(this, oElement); - - this.beforeInitEvent.fire(YAHOO.widget.Menu); - - this.logger = new YAHOO.widget.LogWriter(this.toString()); - - this.logger.log("Source element: " + this.srcElement.tagName); - - break; - - case "SELECT": - - this.srcElement = oElement; - - - /* - The source element is not something that we can use - outright, so we need to create a new Overlay - - Note: we don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.Menu.superclass.init.call(this, Dom.generateId()); - - this.beforeInitEvent.fire(YAHOO.widget.Menu); - - this.logger = new YAHOO.widget.LogWriter(this.toString()); - - this.logger.log("Source element: " + this.srcElement.tagName); - - break; - - } - - } - else { - - /* - Note: we don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.Menu.superclass.init.call(this, p_oElement); - - this.beforeInitEvent.fire(YAHOO.widget.Menu); - - this.logger = new YAHOO.widget.LogWriter(this.toString()); - - this.logger.log("No source element found. " + - "Created element with id: " + this.id); - - } - - - if(this.element) { - - var oEl = this.element; - - Dom.addClass(oEl, this.CSS_CLASS_NAME); - - - // Subscribe to Custom Events - - this.initEvent.subscribe(this._onInit, this, true); - this.beforeRenderEvent.subscribe(this._onBeforeRender, this, true); - this.renderEvent.subscribe(this._setWidth, this, true); - this.beforeShowEvent.subscribe(this._onBeforeShow, this, true); - this.showEvent.subscribe(this._onShow, this, true); - this.beforeHideEvent.subscribe(this._onBeforeHide, this, true); - this.hideEvent.subscribe(this._onHide, this, true); - this.mouseOverEvent.subscribe(this._onMouseOver, this, true); - this.mouseOutEvent.subscribe(this._onMouseOut, this, true); - this.clickEvent.subscribe(this._onClick, this, true); - this.keyDownEvent.subscribe(this._onKeyDown, this, true); - this.keyPressEvent.subscribe(this._onKeyPress, this, true); - - YAHOO.widget.Module.textResizeEvent.subscribe( - this._onTextResize, - this, - true - ); - - - if(p_oConfig) { - - this.cfg.applyConfig(p_oConfig, true); - - } - - - // Register the Menu instance with the MenuManager - - YAHOO.widget.MenuManager.addMenu(this); - - - this.initEvent.fire(YAHOO.widget.Menu); - - } - -}, - - - -// Private methods - - -/** -* @method _initSubTree -* @description Iterates the childNodes of the source element to find nodes -* used to instantiate menu and menu items. -* @private -*/ -_initSubTree: function() { - - var oNode; - - if(this.srcElement.tagName.toUpperCase() == "DIV") { - - /* - Populate the collection of item groups and item - group titles - */ - - oNode = this.body.firstChild; - - var nGroup = 0, - sGroupTitleTagName = this.GROUP_TITLE_TAG_NAME.toUpperCase(); - - do { - - if(oNode && oNode.tagName) { - - switch(oNode.tagName.toUpperCase()) { - - case sGroupTitleTagName: - - this._aGroupTitleElements[nGroup] = oNode; - - break; - - case "UL": - - this._aListElements[nGroup] = oNode; - this._aItemGroups[nGroup] = []; - nGroup++; - - break; - - } - - } - - } - while((oNode = oNode.nextSibling)); - - - /* - Apply the "first-of-type" class to the first UL to mimic - the "first-of-type" CSS3 psuedo class. - */ - - if(this._aListElements[0]) { - - Dom.addClass(this._aListElements[0], "first-of-type"); - - } - - } - - - oNode = null; - - this.logger.log("Searching DOM for items to initialize."); - - if(this.srcElement.tagName) { - - var sSrcElementTagName = this.srcElement.tagName.toUpperCase(); - - - switch(sSrcElementTagName) { - - case "DIV": - - if(this._aListElements.length > 0) { - - this.logger.log("Found " + - this._aListElements.length + - " item groups to initialize."); - - var i = this._aListElements.length - 1; - - do { - - oNode = this._aListElements[i].firstChild; - - this.logger.log("Scanning " + - this._aListElements[i].childNodes.length + - " child nodes for items to initialize."); - - do { - - if( - oNode && - oNode.tagName && - oNode.tagName.toUpperCase() == "LI" - ) { - - this.logger.log("Initializing " + - oNode.tagName + " node."); - - this.addItem( - new this.ITEM_TYPE( - oNode, - { parent: this } - ), - i - ); - - } - - } - while((oNode = oNode.nextSibling)); - - } - while(i--); - - } - - break; - - case "SELECT": - - this.logger.log("Scanning " + - this.srcElement.childNodes.length + - " child nodes for items to initialize."); - - oNode = this.srcElement.firstChild; - - do { - - if(oNode && oNode.tagName) { - - switch(oNode.tagName.toUpperCase()) { - - case "OPTGROUP": - case "OPTION": - - this.logger.log("Initializing " + - oNode.tagName + " node."); - - this.addItem( - new this.ITEM_TYPE( - oNode, - { parent: this } - ) - ); - - break; - - } - - } - - } - while((oNode = oNode.nextSibling)); - - break; - - } - - } - -}, - - -/** -* @method _getFirstEnabledItem -* @description Returns the first enabled item in the menu. -* @return {YAHOO.widget.MenuItem} -* @private -*/ -_getFirstEnabledItem: function() { - - var aItems = this.getItems(), - nItems = aItems.length, - oItem; - - for(var i=0; i<nItems; i++) { - - oItem = aItems[i]; - - if( - oItem && - !oItem.cfg.getProperty("disabled") && - oItem.element.style.display != "none" - ) { - - return oItem; - - } - - } - -}, - - -/** -* @method _checkPosition -* @description Checks to make sure that the value of the "position" property -* is one of the supported strings. Returns true if the position is supported. -* @private -* @param {Object} p_sPosition String specifying the position of the menu. -* @return {Boolean} -*/ -_checkPosition: function(p_sPosition) { - - if(typeof p_sPosition == "string") { - - var sPosition = p_sPosition.toLowerCase(); - - return ("dynamic,static".indexOf(sPosition) != -1); - - } - -}, - - -/** -* @method _addItemToGroup -* @description Adds a menu item to a group. -* @private -* @param {Number} p_nGroupIndex Number indicating the group to which the -* item belongs. -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance to be added to the menu. -* @param {String} p_oItem String specifying the text of the item to be added -* to the menu. -* @param {Object} p_oItem Object literal containing a set of menu item -* configuration properties. -* @param {Number} p_nItemIndex Optional. Number indicating the index at -* which the menu item should be added. -* @return {YAHOO.widget.MenuItem} -*/ -_addItemToGroup: function(p_nGroupIndex, p_oItem, p_nItemIndex) { - - var oItem; - - if(p_oItem instanceof this.ITEM_TYPE) { - - oItem = p_oItem; - oItem.parent = this; - - } - else if(typeof p_oItem == "string") { - - oItem = new this.ITEM_TYPE(p_oItem, { parent: this }); - - } - else if(typeof p_oItem == "object") { - - p_oItem.parent = this; - - oItem = new this.ITEM_TYPE(p_oItem.text, p_oItem); - - } - - - if(oItem) { - - var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0, - aGroup = this._getItemGroup(nGroupIndex), - oGroupItem; - - - if(!aGroup) { - - aGroup = this._createItemGroup(nGroupIndex); - - } - - - if(typeof p_nItemIndex == "number") { - - var bAppend = (p_nItemIndex >= aGroup.length); - - - if(aGroup[p_nItemIndex]) { - - aGroup.splice(p_nItemIndex, 0, oItem); - - } - else { - - aGroup[p_nItemIndex] = oItem; - - } - - - oGroupItem = aGroup[p_nItemIndex]; - - if(oGroupItem) { - - if( - bAppend && - ( - !oGroupItem.element.parentNode || - oGroupItem.element.parentNode.nodeType == 11 - ) - ) { - - this._aListElements[nGroupIndex].appendChild( - oGroupItem.element - ); - - } - else { - - function getNextItemSibling(p_aArray, p_nStartIndex) { - - return ( - p_aArray[p_nStartIndex] || - getNextItemSibling( - p_aArray, - (p_nStartIndex+1) - ) - ); - - } - - - var oNextItemSibling = - getNextItemSibling(aGroup, (p_nItemIndex+1)); - - if( - oNextItemSibling && - ( - !oGroupItem.element.parentNode || - oGroupItem.element.parentNode.nodeType == 11 - ) - ) { - - this._aListElements[nGroupIndex].insertBefore( - oGroupItem.element, - oNextItemSibling.element - ); - - } - - } - - - oGroupItem.parent = this; - - this._subscribeToItemEvents(oGroupItem); - - this._configureSubmenu(oGroupItem); - - this._updateItemProperties(nGroupIndex); - - this.logger.log("Item inserted." + - " Text: " + oGroupItem.cfg.getProperty("text") + ", " + - " Index: " + oGroupItem.index + ", " + - " Group Index: " + oGroupItem.groupIndex); - - this.itemAddedEvent.fire(oGroupItem); - - return oGroupItem; - - } - - } - else { - - var nItemIndex = aGroup.length; - - aGroup[nItemIndex] = oItem; - - oGroupItem = aGroup[nItemIndex]; - - - if(oGroupItem) { - - if( - !Dom.isAncestor( - this._aListElements[nGroupIndex], - oGroupItem.element - ) - ) { - - this._aListElements[nGroupIndex].appendChild( - oGroupItem.element - ); - - } - - oGroupItem.element.setAttribute("groupindex", nGroupIndex); - oGroupItem.element.setAttribute("index", nItemIndex); - - oGroupItem.parent = this; - - oGroupItem.index = nItemIndex; - oGroupItem.groupIndex = nGroupIndex; - - this._subscribeToItemEvents(oGroupItem); - - this._configureSubmenu(oGroupItem); - - if(nItemIndex === 0) { - - Dom.addClass(oGroupItem.element, "first-of-type"); - - } - - this.logger.log("Item added." + - " Text: " + oGroupItem.cfg.getProperty("text") + ", " + - " Index: " + oGroupItem.index + ", " + - " Group Index: " + oGroupItem.groupIndex); - - - this.itemAddedEvent.fire(oGroupItem); - - return oGroupItem; - - } - - } - - } - -}, - - -/** -* @method _removeItemFromGroupByIndex -* @description Removes a menu item from a group by index. Returns the menu -* item that was removed. -* @private -* @param {Number} p_nGroupIndex Number indicating the group to which the menu -* item belongs. -* @param {Number} p_nItemIndex Number indicating the index of the menu item -* to be removed. -* @return {YAHOO.widget.MenuItem} -*/ -_removeItemFromGroupByIndex: function(p_nGroupIndex, p_nItemIndex) { - - var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0, - aGroup = this._getItemGroup(nGroupIndex); - - if(aGroup) { - - var aArray = aGroup.splice(p_nItemIndex, 1), - oItem = aArray[0]; - - if(oItem) { - - // Update the index and className properties of each member - - this._updateItemProperties(nGroupIndex); - - if(aGroup.length === 0) { - - // Remove the UL - - var oUL = this._aListElements[nGroupIndex]; - - if(this.body && oUL) { - - this.body.removeChild(oUL); - - } - - // Remove the group from the array of items - - this._aItemGroups.splice(nGroupIndex, 1); - - - // Remove the UL from the array of ULs - - this._aListElements.splice(nGroupIndex, 1); - - - /* - Assign the "first-of-type" class to the new first UL - in the collection - */ - - oUL = this._aListElements[0]; - - if(oUL) { - - Dom.addClass(oUL, "first-of-type"); - - } - - } - - - this.itemRemovedEvent.fire(oItem); - - - // Return a reference to the item that was removed - - return oItem; - - } - - } - -}, - - -/** -* @method _removeItemFromGroupByValue -* @description Removes a menu item from a group by reference. Returns the -* menu item that was removed. -* @private -* @param {Number} p_nGroupIndex Number indicating the group to which the -* menu item belongs. -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance to be removed. -* @return {YAHOO.widget.MenuItem} -*/ -_removeItemFromGroupByValue: function(p_nGroupIndex, p_oItem) { - - var aGroup = this._getItemGroup(p_nGroupIndex); - - if(aGroup) { - - var nItems = aGroup.length, - nItemIndex = -1; - - if(nItems > 0) { - - var i = nItems-1; - - do { - - if(aGroup[i] == p_oItem) { - - nItemIndex = i; - break; - - } - - } - while(i--); - - if(nItemIndex > -1) { - - return this._removeItemFromGroupByIndex( - p_nGroupIndex, - nItemIndex - ); - - } - - } - - } - -}, - - -/** -* @method _updateItemProperties -* @description Updates the "index," "groupindex," and "className" properties -* of the menu items in the specified group. -* @private -* @param {Number} p_nGroupIndex Number indicating the group of items to update. -*/ -_updateItemProperties: function(p_nGroupIndex) { - - var aGroup = this._getItemGroup(p_nGroupIndex), - nItems = aGroup.length; - - if(nItems > 0) { - - var i = nItems - 1, - oItem, - oLI; - - // Update the index and className properties of each member - - do { - - oItem = aGroup[i]; - - if(oItem) { - - oLI = oItem.element; - - oItem.index = i; - oItem.groupIndex = p_nGroupIndex; - - oLI.setAttribute("groupindex", p_nGroupIndex); - oLI.setAttribute("index", i); - - Dom.removeClass(oLI, "first-of-type"); - - } - - } - while(i--); - - - if(oLI) { - - Dom.addClass(oLI, "first-of-type"); - - } - - } - -}, - - -/** -* @method _createItemGroup -* @description Creates a new menu item group (array) and its associated -* <code><ul></code> element. Returns an aray of menu item groups. -* @private -* @param {Number} p_nIndex Number indicating the group to create. -* @return {Array} -*/ -_createItemGroup: function(p_nIndex) { - - if(!this._aItemGroups[p_nIndex]) { - - this._aItemGroups[p_nIndex] = []; - - var oUL = document.createElement("ul"); - - this._aListElements[p_nIndex] = oUL; - - return this._aItemGroups[p_nIndex]; - - } - -}, - - -/** -* @method _getItemGroup -* @description Returns the menu item group at the specified index. -* @private -* @param {Number} p_nIndex Number indicating the index of the menu item group -* to be retrieved. -* @return {Array} -*/ -_getItemGroup: function(p_nIndex) { - - var nIndex = ((typeof p_nIndex == "number") ? p_nIndex : 0); - - return this._aItemGroups[nIndex]; - -}, - - -/** -* @method _configureSubmenu -* @description Subscribes the menu item's submenu to its parent menu's events. -* @private -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance with the submenu to be configured. -*/ -_configureSubmenu: function(p_oItem) { - - var oSubmenu = p_oItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - /* - Listen for configuration changes to the parent menu - so they they can be applied to the submenu. - */ - - this.cfg.configChangedEvent.subscribe( - this._onParentMenuConfigChange, - oSubmenu, - true - ); - - this.renderEvent.subscribe( - this._onParentMenuRender, - oSubmenu, - true - ); - - oSubmenu.beforeShowEvent.subscribe( - this._onSubmenuBeforeShow, - oSubmenu, - true - ); - - oSubmenu.showEvent.subscribe( - this._onSubmenuShow, - oSubmenu, - true - ); - - oSubmenu.hideEvent.subscribe( - this._onSubmenuHide, - oSubmenu, - true - ); - - } - -}, - - -/** -* @method _subscribeToItemEvents -* @description Subscribes a menu to a menu item's event. -* @private -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance whose events should be subscribed to. -*/ -_subscribeToItemEvents: function(p_oItem) { - - p_oItem.focusEvent.subscribe(this._onMenuItemFocus, p_oItem, this); - - p_oItem.blurEvent.subscribe(this._onMenuItemBlur, this, true); - - p_oItem.cfg.configChangedEvent.subscribe( - this._onMenuItemConfigChange, - p_oItem, - this - ); - -}, - - -/** -* @method _getOffsetWidth -* @description Returns the offset width of the menu's -* <code><div></code> element. -* @private -*/ -_getOffsetWidth: function() { - - var oClone = this.element.cloneNode(true); - - Dom.setStyle(oClone, "width", ""); - - document.body.appendChild(oClone); - - var sWidth = oClone.offsetWidth; - - document.body.removeChild(oClone); - - return sWidth; - -}, - - -/** -* @method _setWidth -* @description Sets the width of the menu's root <code><div></code> -* element to its offsetWidth. -* @private -*/ -_setWidth: function() { - - if(this.cfg.getProperty("position") == "dynamic") { - - var sWidth; - - if(this.element.parentNode.tagName.toUpperCase() == "BODY") { - - if(this.browser == "opera") { - - sWidth = this._getOffsetWidth(); - - } - else { - - Dom.setStyle(this.element, "width", "auto"); - - sWidth = this.element.offsetWidth; - - } - - } - else { - - sWidth = this._getOffsetWidth(); - - } - - this.cfg.setProperty("width", (sWidth + "px")); - - } - -}, - - -/** -* @method _cancelHideDelay -* @description Cancels the call to "hideMenu." -* @private -*/ -_cancelHideDelay: function() { - - var oRoot = this.getRoot(); - - if(oRoot._nHideDelayId) { - - window.clearTimeout(oRoot._nHideDelayId); - - } - -}, - - -/** -* @method _execHideDelay -* @description Hides the menu after the number of milliseconds specified by -* the "hidedelay" configuration property. -* @private -*/ -_execHideDelay: function() { - - this._cancelHideDelay(); - - var oRoot = this.getRoot(), - me = this; - - function hideMenu() { - - if(oRoot.activeItem) { - - oRoot.clearActiveItem(); - - } - - if(oRoot == me && me.cfg.getProperty("position") == "dynamic") { - - me.hide(); - - } - - } - - - oRoot._nHideDelayId = - window.setTimeout(hideMenu, oRoot.cfg.getProperty("hidedelay")); - -}, - - -/** -* @method _cancelShowDelay -* @description Cancels the call to the "showMenu." -* @private -*/ -_cancelShowDelay: function() { - - var oRoot = this.getRoot(); - - if(oRoot._nShowDelayId) { - - window.clearTimeout(oRoot._nShowDelayId); - - } - -}, - - -/** -* @method _execShowDelay -* @description Shows the menu after the number of milliseconds specified by -* the "showdelay" configuration property have ellapsed. -* @private -* @param {YAHOO.widget.Menu} p_oMenu Object specifying the menu that should -* be made visible. -*/ -_execShowDelay: function(p_oMenu) { - - var oRoot = this.getRoot(); - - function showMenu() { - - if(p_oMenu.parent.cfg.getProperty("selected")) { - - p_oMenu.show(); - - } - - } - - - oRoot._nShowDelayId = - window.setTimeout(showMenu, oRoot.cfg.getProperty("showdelay")); - -}, - - -/** -* @method _execSubmenuHideDelay -* @description Hides a submenu after the number of milliseconds specified by -* the "submenuhidedelay" configuration property have ellapsed. -* @private -* @param {YAHOO.widget.Menu} p_oSubmenu Object specifying the submenu that -* should be hidden. -* @param {Number} p_nMouseX The x coordinate of the mouse when it left -* the specified submenu's parent menu item. -* @param {Number} p_nHideDelay The number of milliseconds that should ellapse -* before the submenu is hidden. -*/ -_execSubmenuHideDelay: function(p_oSubmenu, p_nMouseX, p_nHideDelay) { - - var me = this; - - p_oSubmenu._nSubmenuHideDelayId = window.setTimeout(function () { - - if(me._nCurrentMouseX > (p_nMouseX + 10)) { - - p_oSubmenu._nSubmenuHideDelayId = window.setTimeout(function () { - - p_oSubmenu.hide(); - - }, p_nHideDelay); - - } - else { - - p_oSubmenu.hide(); - - } - - }, 50); - -}, - - - -// Protected methods - - -/** -* @method _disableScrollHeader -* @description Disables the header used for scrolling the body of the menu. -* @protected -*/ -_disableScrollHeader: function() { - - if(!this._bHeaderDisabled) { - - Dom.addClass(this.header, "topscrollbar_disabled"); - this._bHeaderDisabled = true; - - } - -}, - - -/** -* @method _disableScrollFooter -* @description Disables the footer used for scrolling the body of the menu. -* @protected -*/ -_disableScrollFooter: function() { - - if(!this._bFooterDisabled) { - - Dom.addClass(this.footer, "bottomscrollbar_disabled"); - this._bFooterDisabled = true; - - } - -}, - - -/** -* @method _enableScrollHeader -* @description Enables the header used for scrolling the body of the menu. -* @protected -*/ -_enableScrollHeader: function() { - - if(this._bHeaderDisabled) { - - Dom.removeClass(this.header, "topscrollbar_disabled"); - this._bHeaderDisabled = false; - - } - -}, - - -/** -* @method _enableScrollFooter -* @description Enables the footer used for scrolling the body of the menu. -* @protected -*/ -_enableScrollFooter: function() { - - if(this._bFooterDisabled) { - - Dom.removeClass(this.footer, "bottomscrollbar_disabled"); - this._bFooterDisabled = false; - - } - -}, - - - -/** -* @method _onMouseOver -* @description "mouseover" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onMouseOver: function(p_sType, p_aArgs, p_oMenu) { - - if(this._bStopMouseEventHandlers) { - - return false; - - } - - - var oEvent = p_aArgs[0], - oItem = p_aArgs[1], - oTarget = Event.getTarget(oEvent); - - - if( - !this._bHandledMouseOverEvent && - (oTarget == this.element || Dom.isAncestor(this.element, oTarget)) - ) { - - // Menu mouseover logic - - this._nCurrentMouseX = 0; - - Event.addListener( - this.element, - "mousemove", - this._onMouseMove, - this, - true - ); - - - this.clearActiveItem(); - - - if(this.parent && this._nSubmenuHideDelayId) { - - window.clearTimeout(this._nSubmenuHideDelayId); - - this.parent.cfg.setProperty("selected", true); - - var oParentMenu = this.parent.parent; - - oParentMenu.activeItem = this.parent; - - oParentMenu._bHandledMouseOutEvent = true; - oParentMenu._bHandledMouseOverEvent = false; - - } - - - this._bHandledMouseOverEvent = true; - this._bHandledMouseOutEvent = false; - - } - - - if( - oItem && !oItem.handledMouseOverEvent && - !oItem.cfg.getProperty("disabled") && - (oTarget == oItem.element || Dom.isAncestor(oItem.element, oTarget)) - ) { - - // Menu Item mouseover logic - - var nShowDelay = this.cfg.getProperty("showdelay"), - bShowDelay = (nShowDelay > 0); - - - if(bShowDelay) { - - this._cancelShowDelay(); - - } - - - var oActiveItem = this.activeItem; - - if(oActiveItem) { - - oActiveItem.cfg.setProperty("selected", false); - - } - - - var oItemCfg = oItem.cfg; - - // Select and focus the current menu item - - oItemCfg.setProperty("selected", true); - oItem.focus(); - - - if(this.cfg.getProperty("autosubmenudisplay")) { - - // Show the submenu this menu item - - var oSubmenu = oItemCfg.getProperty("submenu"); - - if(oSubmenu) { - - if(bShowDelay) { - - this._execShowDelay(oSubmenu); - - } - else { - - oSubmenu.show(); - - } - - } - - } - - oItem.handledMouseOverEvent = true; - oItem.handledMouseOutEvent = false; - - } - -}, - - -/** -* @method _onMouseOut -* @description "mouseout" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onMouseOut: function(p_sType, p_aArgs, p_oMenu) { - - if(this._bStopMouseEventHandlers) { - - return false; - - } - - - var oEvent = p_aArgs[0], - oItem = p_aArgs[1], - oRelatedTarget = Event.getRelatedTarget(oEvent), - bMovingToSubmenu = false; - - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var oItemCfg = oItem.cfg, - oSubmenu = oItemCfg.getProperty("submenu"); - - - if( - oSubmenu && - ( - oRelatedTarget == oSubmenu.element || - Dom.isAncestor(oSubmenu.element, oRelatedTarget) - ) - ) { - - bMovingToSubmenu = true; - - } - - - if( - !oItem.handledMouseOutEvent && - ( - ( - oRelatedTarget != oItem.element && - !Dom.isAncestor(oItem.element, oRelatedTarget) - ) || bMovingToSubmenu - ) - ) { - - // Menu Item mouseout logic - - if(!bMovingToSubmenu) { - - oItem.cfg.setProperty("selected", false); - - - if(oSubmenu) { - - var nSubmenuHideDelay = - this.cfg.getProperty("submenuhidedelay"), - - nShowDelay = this.cfg.getProperty("showdelay"); - - if( - !(this instanceof YAHOO.widget.MenuBar) && - nSubmenuHideDelay > 0 && - nShowDelay >= nSubmenuHideDelay - ) { - - this._execSubmenuHideDelay( - oSubmenu, - Event.getPageX(oEvent), - nSubmenuHideDelay - ); - - } - else { - - oSubmenu.hide(); - - } - - } - - } - - - oItem.handledMouseOutEvent = true; - oItem.handledMouseOverEvent = false; - - } - - } - - - if( - !this._bHandledMouseOutEvent && - ( - ( - oRelatedTarget != this.element && - !Dom.isAncestor(this.element, oRelatedTarget) - ) - || bMovingToSubmenu - ) - ) { - - // Menu mouseout logic - - Event.removeListener(this.element, "mousemove", this._onMouseMove); - - this._nCurrentMouseX = Event.getPageX(oEvent); - - this._bHandledMouseOutEvent = true; - this._bHandledMouseOverEvent = false; - - } - -}, - - -/** -* @method _onMouseMove -* @description "click" event handler for the menu. -* @protected -* @param {Event} p_oEvent Object representing the DOM event object passed -* back by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onMouseMove: function(p_oEvent, p_oMenu) { - - if(this._bStopMouseEventHandlers) { - - return false; - - } - - this._nCurrentMouseX = Event.getPageX(p_oEvent); - -}, - - -/** -* @method _onClick -* @description "click" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onClick: function(p_sType, p_aArgs, p_oMenu) { - - var oEvent = p_aArgs[0], - oItem = p_aArgs[1], - oTarget = Event.getTarget(oEvent); - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var oItemCfg = oItem.cfg, - oSubmenu = oItemCfg.getProperty("submenu"); - - - /* - ACCESSIBILITY FEATURE FOR SCREEN READERS: - Expand/collapse the submenu when the user clicks - on the submenu indicator image. - */ - - if(oTarget == oItem.submenuIndicator && oSubmenu) { - - if(oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.hide(); - - oSubmenu.parent.focus(); - - } - else { - - this.clearActiveItem(); - - this.activeItem = oItem; - - oItem.cfg.setProperty("selected", true); - - oSubmenu.show(); - - } - - } - else { - - var sURL = oItemCfg.getProperty("url"), - bCurrentPageURL = (sURL.substr((sURL.length-1),1) == "#"), - sTarget = oItemCfg.getProperty("target"), - bHasTarget = (sTarget && sTarget.length > 0); - - /* - Prevent the browser from following links - equal to "#" - */ - - if( - oTarget.tagName.toUpperCase() == "A" && - bCurrentPageURL && !bHasTarget - ) { - - Event.preventDefault(oEvent); - - } - - if( - oTarget.tagName.toUpperCase() != "A" && - !bCurrentPageURL && !bHasTarget - ) { - - /* - Follow the URL of the item regardless of - whether or not the user clicked specifically - on the anchor element. - */ - - document.location = sURL; - - } - - - /* - If the item doesn't navigate to a URL and it doesn't have - a submenu, then collapse the menu tree. - */ - - if(bCurrentPageURL && !oSubmenu) { - - var oRoot = this.getRoot(); - - if(oRoot.cfg.getProperty("position") == "static") { - - oRoot.clearActiveItem(); - - } - else if(oRoot.cfg.getProperty("clicktohide")) { - - oRoot.hide(); - - } - - } - - } - - } - -}, - - -/** -* @method _onKeyDown -* @description "keydown" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onKeyDown: function(p_sType, p_aArgs, p_oMenu) { - - var oEvent = p_aArgs[0], - oItem = p_aArgs[1], - me = this, - oSubmenu; - - - /* - This function is called to prevent a bug in Firefox. In Firefox, - moving a DOM element into a stationary mouse pointer will cause the - browser to fire mouse events. This can result in the menu mouse - event handlers being called uncessarily, especially when menus are - moved into a stationary mouse pointer as a result of a - key event handler. - */ - function stopMouseEventHandlers() { - - me._bStopMouseEventHandlers = true; - - window.setTimeout(function() { - - me._bStopMouseEventHandlers = false; - - }, 10); - - } - - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var oItemCfg = oItem.cfg, - oParentItem = this.parent, - oRoot, - oNextItem; - - - switch(oEvent.keyCode) { - - case 38: // Up arrow - case 40: // Down arrow - - if( - oItem == this.activeItem && - !oItemCfg.getProperty("selected") - ) { - - oItemCfg.setProperty("selected", true); - - } - else { - - oNextItem = (oEvent.keyCode == 38) ? - oItem.getPreviousEnabledSibling() : - oItem.getNextEnabledSibling(); - - if(oNextItem) { - - this.clearActiveItem(); - - oNextItem.cfg.setProperty("selected", true); - oNextItem.focus(); - - - if(this.cfg.getProperty("maxheight") > 0) { - - var oBody = this.body; - - oBody.scrollTop = - - ( - oNextItem.element.offsetTop + - oNextItem.element.offsetHeight - ) - oBody.offsetHeight; - - - var nScrollTop = oBody.scrollTop, - nScrollTarget = - oBody.scrollHeight - oBody.offsetHeight; - - if(nScrollTop === 0) { - - this._disableScrollHeader(); - this._enableScrollFooter(); - - } - else if(nScrollTop == nScrollTarget) { - - this._enableScrollHeader(); - this._disableScrollFooter(); - - } - else { - - this._enableScrollHeader(); - this._enableScrollFooter(); - - } - - } - - } - - } - - Event.preventDefault(oEvent); - - stopMouseEventHandlers(); - - break; - - - case 39: // Right arrow - - oSubmenu = oItemCfg.getProperty("submenu"); - - if(oSubmenu) { - - if(!oItemCfg.getProperty("selected")) { - - oItemCfg.setProperty("selected", true); - - } - - oSubmenu.show(); - - oSubmenu.setInitialSelection(); - - } - else { - - oRoot = this.getRoot(); - - if(oRoot instanceof YAHOO.widget.MenuBar) { - - oNextItem = oRoot.activeItem.getNextEnabledSibling(); - - if(oNextItem) { - - oRoot.clearActiveItem(); - - oNextItem.cfg.setProperty("selected", true); - - oSubmenu = oNextItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.show(); - - } - - oNextItem.focus(); - - } - - } - - } - - - Event.preventDefault(oEvent); - - stopMouseEventHandlers(); - - break; - - - case 37: // Left arrow - - if(oParentItem) { - - var oParentMenu = oParentItem.parent; - - if(oParentMenu instanceof YAHOO.widget.MenuBar) { - - oNextItem = - oParentMenu.activeItem.getPreviousEnabledSibling(); - - if(oNextItem) { - - oParentMenu.clearActiveItem(); - - oNextItem.cfg.setProperty("selected", true); - - oSubmenu = oNextItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.show(); - - } - - oNextItem.focus(); - - } - - } - else { - - this.hide(); - - oParentItem.focus(); - - } - - } - - Event.preventDefault(oEvent); - - stopMouseEventHandlers(); - - break; - - } - - - } - - - if(oEvent.keyCode == 27) { // Esc key - - if(this.cfg.getProperty("position") == "dynamic") { - - this.hide(); - - if(this.parent) { - - this.parent.focus(); - - } - - } - else if(this.activeItem) { - - oSubmenu = this.activeItem.cfg.getProperty("submenu"); - - if(oSubmenu && oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.hide(); - this.activeItem.focus(); - - } - else { - - this.activeItem.cfg.setProperty("selected", false); - this.activeItem.blur(); - - } - - } - - - Event.preventDefault(oEvent); - - } - -}, - - -/** -* @method _onKeyPress -* @description "keypress" event handler for a Menu instance. -* @protected -* @param {String} p_sType The name of the event that was fired. -* @param {Array} p_aArgs Collection of arguments sent when the event -* was fired. -* @param {YAHOO.widget.Menu} p_oMenu The Menu instance that fired the event. -*/ -_onKeyPress: function(p_sType, p_aArgs, p_oMenu) { - - var oEvent = p_aArgs[0]; - - - if(oEvent.keyCode == 40 || oEvent.keyCode == 38) { - - YAHOO.util.Event.preventDefault(oEvent); - - } - -}, - - -/** -* @method _onTextResize -* @description "textresize" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onTextResize: function(p_sType, p_aArgs, p_oMenu) { - - if(this.browser == "gecko" && !this._handleResize) { - - this._handleResize = true; - return; - - } - - - var oConfig = this.cfg; - - if(oConfig.getProperty("position") == "dynamic") { - - oConfig.setProperty("width", (this._getOffsetWidth() + "px")); - - } - -}, - - -/** -* @method _onScrollTargetMouseOver -* @description "mouseover" event handler for the menu's "header" and "footer" -* elements. Used to scroll the body of the menu up and down when the -* menu's "maxheight" configuration property is set to a value greater than 0. -* @protected -* @param {Event} p_oEvent Object representing the DOM event object passed -* back by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onScrollTargetMouseOver: function(p_oEvent, p_oMenu) { - - this._cancelHideDelay(); - - var oTarget = Event.getTarget(p_oEvent), - oBody = this.body, - me = this, - nScrollTarget, - fnScrollFunction; - - - function scrollBodyDown() { - - var nScrollTop = oBody.scrollTop; - - - if(nScrollTop < nScrollTarget) { - - oBody.scrollTop = (nScrollTop + 1); - - me._enableScrollHeader(); - - } - else { - - oBody.scrollTop = nScrollTarget; - - window.clearInterval(me._nBodyScrollId); - - me._disableScrollFooter(); - - } - - } - - - function scrollBodyUp() { - - var nScrollTop = oBody.scrollTop; - - - if(nScrollTop > 0) { - - oBody.scrollTop = (nScrollTop - 1); - - me._enableScrollFooter(); - - } - else { - - oBody.scrollTop = 0; - - window.clearInterval(me._nBodyScrollId); - - me._disableScrollHeader(); - - } - - } - - - if(Dom.hasClass(oTarget, "hd")) { - - fnScrollFunction = scrollBodyUp; - - } - else { - - nScrollTarget = oBody.scrollHeight - oBody.offsetHeight; - - fnScrollFunction = scrollBodyDown; - - } - - - this._nBodyScrollId = window.setInterval(fnScrollFunction, 10); - -}, - - -/** -* @method _onScrollTargetMouseOut -* @description "mouseout" event handler for the menu's "header" and "footer" -* elements. Used to stop scrolling the body of the menu up and down when the -* menu's "maxheight" configuration property is set to a value greater than 0. -* @protected -* @param {Event} p_oEvent Object representing the DOM event object passed -* back by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onScrollTargetMouseOut: function(p_oEvent, p_oMenu) { - - window.clearInterval(this._nBodyScrollId); - - this._cancelHideDelay(); - -}, - - - -// Private methods - - -/** -* @method _onInit -* @description "init" event handler for the 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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onInit: function(p_sType, p_aArgs, p_oMenu) { - - if( - ( - (this.parent && !this.lazyLoad) || - (!this.parent && this.cfg.getProperty("position") == "static") || - ( - !this.parent && - !this.lazyLoad && - this.cfg.getProperty("position") == "dynamic" - ) - ) && - this.getItemGroups().length === 0 - ) { - - if(this.srcElement) { - - this._initSubTree(); - - } - - - if(this.itemData) { - - this.addItems(this.itemData); - - } - - } - else if(this.lazyLoad) { - - this.cfg.fireQueue(); - - } - -}, - - -/** -* @method _onBeforeRender -* @description "beforerender" event handler for the menu. Appends all of the -* <code><ul></code>, <code><li></code> and their accompanying -* title elements to the body element of the 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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onBeforeRender: function(p_sType, p_aArgs, p_oMenu) { - - var oConfig = this.cfg, - oEl = this.element, - nListElements = this._aListElements.length; - - - if(nListElements > 0) { - - var i = 0, - bFirstList = true, - oUL, - oGroupTitle; - - - do { - - oUL = this._aListElements[i]; - - if(oUL) { - - if(bFirstList) { - - Dom.addClass(oUL, "first-of-type"); - bFirstList = false; - - } - - - if(!Dom.isAncestor(oEl, oUL)) { - - this.appendToBody(oUL); - - } - - - oGroupTitle = this._aGroupTitleElements[i]; - - if(oGroupTitle) { - - if(!Dom.isAncestor(oEl, oGroupTitle)) { - - oUL.parentNode.insertBefore(oGroupTitle, oUL); - - } - - - Dom.addClass(oUL, "hastitle"); - - } - - } - - i++; - - } - while(i < nListElements); - - } - -}, - - -/** -* @method _onBeforeShow -* @description "beforeshow" event handler for the 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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onBeforeShow: function(p_sType, p_aArgs, p_oMenu) { - - if(this.lazyLoad && this.getItemGroups().length === 0) { - - if(this.srcElement) { - - this._initSubTree(); - - } - - - if(this.itemData) { - - if( - this.parent && this.parent.parent && - this.parent.parent.srcElement && - this.parent.parent.srcElement.tagName.toUpperCase() == "SELECT" - ) { - - var nOptions = this.itemData.length; - - for(var n=0; n<nOptions; n++) { - - if(this.itemData[n].tagName) { - - this.addItem((new this.ITEM_TYPE(this.itemData[n]))); - - } - - } - - } - else { - - this.addItems(this.itemData); - - } - - } - - - var oSrcElement = this.srcElement; - - if(oSrcElement) { - - if(oSrcElement.tagName.toUpperCase() == "SELECT") { - - if(Dom.inDocument(oSrcElement)) { - - this.render(oSrcElement.parentNode); - - } - else { - - this.render(this.cfg.getProperty("container")); - - } - - } - else { - - this.render(); - - } - - } - else { - - if(this.parent) { - - this.render(this.parent.element); - - } - else { - - this.render(this.cfg.getProperty("container")); - - } - - } - - } - - - - if(this.cfg.getProperty("position") == "dynamic") { - - var nViewportHeight = Dom.getViewportHeight(); - - if(this.element.offsetHeight >= nViewportHeight) { - - var nMaxHeight = this.cfg.getProperty("maxheight"); - - /* - Cache the original value for the "maxheight" configuration - property so that we can set it back when the menu is hidden. - */ - - this._nMaxHeight = nMaxHeight; - - this.cfg.setProperty("maxheight", (nViewportHeight - 20)); - - } - - - if(this.cfg.getProperty("maxheight") > 0) { - - var oBody = this.body; - - if(oBody.scrollTop > 0) { - - oBody.scrollTop = 0; - - } - - this._disableScrollHeader(); - this._enableScrollFooter(); - - } - - } - - -}, - - -/** -* @method _onShow -* @description "show" event handler for the 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.Menu} p_oMenu Object representing the menu that fired -* the event. -*/ -_onShow: function(p_sType, p_aArgs, p_oMenu) { - - this.setInitialFocus(); - - var oParent = this.parent; - - if(oParent) { - - var oParentMenu = oParent.parent, - aParentAlignment = oParentMenu.cfg.getProperty("submenualignment"), - aAlignment = this.cfg.getProperty("submenualignment"); - - - if( - (aParentAlignment[0] != aAlignment[0]) && - (aParentAlignment[1] != aAlignment[1]) - ) { - - this.cfg.setProperty( - "submenualignment", - [ aParentAlignment[0], aParentAlignment[1] ] - ); - - } - - - if( - !oParentMenu.cfg.getProperty("autosubmenudisplay") && - oParentMenu.cfg.getProperty("position") == "static" - ) { - - oParentMenu.cfg.setProperty("autosubmenudisplay", true); - - - function disableAutoSubmenuDisplay(p_oEvent) { - - if( - p_oEvent.type == "mousedown" || - (p_oEvent.type == "keydown" && p_oEvent.keyCode == 27) - ) { - - /* - Set the "autosubmenudisplay" to "false" if the user - clicks outside the menu bar. - */ - - var oTarget = Event.getTarget(p_oEvent); - - if( - oTarget != oParentMenu.element || - !YAHOO.util.Dom.isAncestor(oParentMenu.element, oTarget) - ) { - - oParentMenu.cfg.setProperty( - "autosubmenudisplay", - false - ); - - Event.removeListener( - document, - "mousedown", - disableAutoSubmenuDisplay - ); - - Event.removeListener( - document, - "keydown", - disableAutoSubmenuDisplay - ); - - } - - } - - } - - Event.addListener(document, "mousedown", disableAutoSubmenuDisplay); - Event.addListener(document, "keydown", disableAutoSubmenuDisplay); - - } - - } - else if(!oParent && this.lazyLoad) { - - this.cfg.refireEvent("xy"); - - } - -}, - - -/** -* @method _onBeforeHide -* @description "beforehide" event handler for the 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.Menu} p_oMenu Object representing the menu that fired -* the event. -*/ -_onBeforeHide: function(p_sType, p_aArgs, p_oMenu) { - - var oActiveItem = this.activeItem; - - if(oActiveItem) { - - var oConfig = oActiveItem.cfg; - - oConfig.setProperty("selected", false); - - var oSubmenu = oConfig.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.hide(); - - } - - oActiveItem.blur(); - - } - -}, - - -/** -* @method _onHide -* @description "hide" event handler for the 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.Menu} p_oMenu Object representing the menu that fired -* the event. -*/ -_onHide: function(p_sType, p_aArgs, p_oMenu) { - - if(this._nMaxHeight != -1) { - - this.cfg.setProperty("maxheight", this._nMaxHeight); - - this._nMaxHeight = -1; - - } - -}, - - -/** -* @method _onParentMenuConfigChange -* @description "configchange" event handler for a submenu. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onParentMenuConfigChange: function(p_sType, p_aArgs, p_oSubmenu) { - - var sPropertyName = p_aArgs[0][0], - oPropertyValue = p_aArgs[0][1]; - - switch(sPropertyName) { - - case "iframe": - case "constraintoviewport": - case "hidedelay": - case "showdelay": - case "submenuhidedelay": - case "clicktohide": - case "effect": - case "classname": - - p_oSubmenu.cfg.setProperty(sPropertyName, oPropertyValue); - - break; - - } - -}, - - -/** -* @method _onParentMenuRender -* @description "render" event handler for a submenu. Renders a -* submenu in response to the firing of its parent's "render" event. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onParentMenuRender: function(p_sType, p_aArgs, p_oSubmenu) { - - var oParentMenu = p_oSubmenu.parent.parent, - - oConfig = { - - constraintoviewport: - oParentMenu.cfg.getProperty("constraintoviewport"), - - xy: [0,0], - - clicktohide: oParentMenu.cfg.getProperty("clicktohide"), - - effect: oParentMenu.cfg.getProperty("effect"), - - showdelay: oParentMenu.cfg.getProperty("showdelay"), - - hidedelay: oParentMenu.cfg.getProperty("hidedelay"), - - submenuhidedelay: oParentMenu.cfg.getProperty("submenuhidedelay"), - - classname: oParentMenu.cfg.getProperty("classname") - - }; - - - /* - Only sync the "iframe" configuration property if the parent - menu's "position" configuration is the same. - */ - - if( - this.cfg.getProperty("position") == - oParentMenu.cfg.getProperty("position") - ) { - - oConfig.iframe = oParentMenu.cfg.getProperty("iframe"); - - } - - - p_oSubmenu.cfg.applyConfig(oConfig); - - - if(!this.lazyLoad) { - - var oLI = this.parent.element; - - if(this.element.parentNode == oLI) { - - this.render(); - - } - else { - - this.render(oLI); - - } - - } - -}, - - -/** -* @method _onSubmenuBeforeShow -* @description "beforeshow" event handler for a submenu. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onSubmenuBeforeShow: function(p_sType, p_aArgs, p_oSubmenu) { - - var oParent = this.parent, - aAlignment = oParent.parent.cfg.getProperty("submenualignment"); - - this.cfg.setProperty( - "context", - [oParent.element, aAlignment[0], aAlignment[1]] - ); - - - var nScrollTop = oParent.parent.body.scrollTop; - - if( - (this.browser == "gecko" || this.browser == "safari") - && nScrollTop > 0 - ) { - - this.cfg.setProperty("y", (this.cfg.getProperty("y") - nScrollTop)); - - } - -}, - - -/** -* @method _onSubmenuShow -* @description "show" event handler for a submenu. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onSubmenuShow: function(p_sType, p_aArgs, p_oSubmenu) { - - var oParent = this.parent; - - oParent.submenuIndicator.firstChild.nodeValue = - oParent.EXPANDED_SUBMENU_INDICATOR_TEXT; - -}, - - -/** -* @method _onSubmenuHide -* @description "hide" Custom Event handler for a submenu. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onSubmenuHide: function(p_sType, p_aArgs, p_oSubmenu) { - - var oParent = this.parent; - - oParent.submenuIndicator.firstChild.nodeValue = - oParent.COLLAPSED_SUBMENU_INDICATOR_TEXT; - -}, - - -/** -* @method _onMenuItemFocus -* @description "focus" event handler for the menu's items. -* @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 fired the event. -*/ -_onMenuItemFocus: function(p_sType, p_aArgs, p_oItem) { - - this.activeItem = p_oItem; - -}, - - -/** -* @method _onMenuItemBlur -* @description "blur" event handler for the menu's items. -* @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. -*/ -_onMenuItemBlur: function(p_sType, p_aArgs) { - - this.activeItem = null; - -}, - - -/** -* @method _onMenuItemConfigChange -* @description "configchange" event handler for the menu's items. -* @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 fired the event. -*/ -_onMenuItemConfigChange: function(p_sType, p_aArgs, p_oItem) { - - var sProperty = p_aArgs[0][0]; - - switch(sProperty) { - - case "submenu": - - var oSubmenu = p_aArgs[0][1]; - - if(oSubmenu) { - - this._configureSubmenu(p_oItem); - - } - - break; - - case "text": - case "helptext": - - /* - A change to an item's "text" or "helptext" - configuration properties requires the width of the parent - menu to be recalculated. - */ - - if(this.element.style.width) { - - var sWidth = this._getOffsetWidth() + "px"; - - Dom.setStyle(this.element, "width", sWidth); - - } - - break; - - } - -}, - - - -// Public event handlers for configuration properties - - -/** -* @method enforceConstraints -* @description The default event handler executed when the moveEvent is fired, -* if the "constraintoviewport" configuration property is set to true. -* @param {String} type The name of the event that was fired. -* @param {Array} args Collection of arguments sent when the -* event was fired. -* @param {Array} obj Array containing the current Menu instance -* and the item that fired the event. -*/ -enforceConstraints: function(type, args, obj) { - - var oConfig = this.cfg, - pos = args[0], - - x = pos[0], - y = pos[1], - - offsetHeight = this.element.offsetHeight, - offsetWidth = this.element.offsetWidth, - - viewPortWidth = YAHOO.util.Dom.getViewportWidth(), - viewPortHeight = YAHOO.util.Dom.getViewportHeight(), - - scrollX = Math.max( - document.documentElement.scrollLeft, - document.body.scrollLeft - ), - - scrollY = Math.max( - document.documentElement.scrollTop, - document.body.scrollTop - ), - - nPadding = ( - this.parent && - this.parent.parent instanceof YAHOO.widget.MenuBar - ) ? 0 : 10, - - topConstraint = scrollY + nPadding, - leftConstraint = scrollX + nPadding, - bottomConstraint = scrollY + viewPortHeight - offsetHeight - nPadding, - rightConstraint = scrollX + viewPortWidth - offsetWidth - nPadding, - - aContext = oConfig.getProperty("context"), - oContextElement = aContext ? aContext[0] : null; - - - if (x < 10) { - - x = leftConstraint; - - } else if ((x + offsetWidth) > viewPortWidth) { - - if( - oContextElement && - ((x - oContextElement.offsetWidth) > offsetWidth) - ) { - - x = (x - (oContextElement.offsetWidth + offsetWidth)); - - } - else { - - x = rightConstraint; - - } - - } - - if (y < 10) { - - y = topConstraint; - - } else if (y > bottomConstraint) { - - if(oContextElement && (y > offsetHeight)) { - - y = ((y + oContextElement.offsetHeight) - offsetHeight); - - } - else { - - y = bottomConstraint; - - } - - } - - oConfig.setProperty("x", x, true); - oConfig.setProperty("y", y, true); - oConfig.setProperty("xy", [x,y], true); - -}, - - -/** -* @method configVisible -* @description Event handler for when the "visible" configuration property -* the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configVisible: function(p_sType, p_aArgs, p_oMenu) { - - if(this.cfg.getProperty("position") == "dynamic") { - - YAHOO.widget.Menu.superclass.configVisible.call( - this, - p_sType, - p_aArgs, - p_oMenu - ); - - } - else { - - var bVisible = p_aArgs[0], - sDisplay = Dom.getStyle(this.element, "display"); - - if(bVisible) { - - if(sDisplay != "block") { - this.beforeShowEvent.fire(); - Dom.setStyle(this.element, "display", "block"); - this.showEvent.fire(); - } - - } - else { - - if(sDisplay == "block") { - this.beforeHideEvent.fire(); - Dom.setStyle(this.element, "display", "none"); - this.hideEvent.fire(); - } - - } - - } - -}, - - -/** -* @method configPosition -* @description Event handler for when the "position" configuration property -* of the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configPosition: function(p_sType, p_aArgs, p_oMenu) { - - var sCSSPosition = p_aArgs[0] == "static" ? "static" : "absolute", - oCfg = this.cfg; - - Dom.setStyle(this.element, "position", sCSSPosition); - - - if(sCSSPosition == "static") { - - /* - Remove the iframe for statically positioned menus since it will - intercept mouse events. - */ - - oCfg.setProperty("iframe", false); - - - // Statically positioned menus are visible by default - - Dom.setStyle(this.element, "display", "block"); - - oCfg.setProperty("visible", true); - - } - else { - - /* - Even though the "visible" property is queued to - "false" by default, we need to set the "visibility" property to - "hidden" since Overlay's "configVisible" implementation checks the - element's "visibility" style property before deciding whether - or not to show an Overlay instance. - */ - - Dom.setStyle(this.element, "visibility", "hidden"); - - } - - - if(sCSSPosition == "absolute") { - - var nZIndex = oCfg.getProperty("zindex"); - - if(!nZIndex || nZIndex === 0) { - - nZIndex = this.parent ? - (this.parent.parent.cfg.getProperty("zindex") + 1) : 1; - - oCfg.setProperty("zindex", nZIndex); - - } - - } - -}, - - -/** -* @method configIframe -* @description Event handler for when the "iframe" configuration property of -* the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configIframe: function(p_sType, p_aArgs, p_oMenu) { - - if(this.cfg.getProperty("position") == "dynamic") { - - YAHOO.widget.Menu.superclass.configIframe.call( - this, - p_sType, - p_aArgs, - p_oMenu - ); - - } - -}, - - -/** -* @method configHideDelay -* @description Event handler for when the "hidedelay" configuration property -* of the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configHideDelay: function(p_sType, p_aArgs, p_oMenu) { - - var nHideDelay = p_aArgs[0], - oMouseOutEvent = this.mouseOutEvent, - oMouseOverEvent = this.mouseOverEvent, - oKeyDownEvent = this.keyDownEvent; - - if(nHideDelay > 0) { - - /* - Only assign event handlers once. This way the user change - the value for the hidedelay as many times as they want. - */ - - if(!this._bHideDelayEventHandlersAssigned) { - - oMouseOutEvent.subscribe(this._execHideDelay, true); - oMouseOverEvent.subscribe(this._cancelHideDelay, this, true); - oKeyDownEvent.subscribe(this._cancelHideDelay, this, true); - - this._bHideDelayEventHandlersAssigned = true; - - } - - } - else { - - oMouseOutEvent.unsubscribe(this._execHideDelay, this); - oMouseOverEvent.unsubscribe(this._cancelHideDelay, this); - oKeyDownEvent.unsubscribe(this._cancelHideDelay, this); - - this._bHideDelayEventHandlersAssigned = false; - - } - -}, - - -/** -* @method configContainer -* @description Event handler for when the "container" configuration property -of the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configContainer: function(p_sType, p_aArgs, p_oMenu) { - - var oElement = p_aArgs[0]; - - if(typeof oElement == 'string') { - - this.cfg.setProperty( - "container", - document.getElementById(oElement), - true - ); - - } - -}, - - -/** -* @method configMaxHeight -* @description Event handler for when the "maxheight" configuration property of -* a Menu changes. -* @param {String} p_sType The name of the event that was fired. -* @param {Array} p_aArgs Collection of arguments sent when the event -* was fired. -* @param {YAHOO.widget.Menu} p_oMenu The Menu instance fired -* the event. -*/ -configMaxHeight: function(p_sType, p_aArgs, p_oMenu) { - - var nMaxHeight = p_aArgs[0], - oBody = this.body, - oHeader = this.header, - oFooter = this.footer, - fnMouseOver = this._onScrollTargetMouseOver, - fnMouseOut = this._onScrollTargetMouseOut; - - - if((nMaxHeight > 0) && (oBody.offsetHeight > nMaxHeight)) { - - if(!this.cfg.getProperty("width")) { - - this._setWidth(); - - } - - if(!oHeader && !oFooter) { - - this.setHeader(" "); - this.setFooter(" "); - - oHeader = this.header; - oFooter = this.footer; - - Dom.addClass(oHeader, "topscrollbar"); - Dom.addClass(oFooter, "bottomscrollbar"); - - this.element.insertBefore(oHeader, oBody); - this.element.appendChild(oFooter); - - Event.addListener(oHeader, "mouseover", fnMouseOver, this, true); - Event.addListener(oHeader, "mouseout", fnMouseOut, this, true); - Event.addListener(oFooter, "mouseover", fnMouseOver, this, true); - Event.addListener(oFooter, "mouseout", fnMouseOut, this, true); - - } - - var nHeight = - - ( - nMaxHeight - - (this.footer.offsetHeight + this.header.offsetHeight) - ); - - Dom.setStyle(oBody, "height", (nHeight + "px")); - Dom.setStyle(oBody, "overflow", "hidden"); - - } - else if(oHeader && oFooter) { - - Dom.setStyle(oBody, "height", "auto"); - Dom.setStyle(oBody, "overflow", "visible"); - - Event.removeListener(oHeader, "mouseover", fnMouseOver); - Event.removeListener(oHeader, "mouseout", fnMouseOut); - Event.removeListener(oFooter, "mouseover", fnMouseOver); - Event.removeListener(oFooter, "mouseout", fnMouseOut); - - this.element.removeChild(oHeader); - this.element.removeChild(oFooter); - - this.header = null; - this.footer = null; - - } - -}, - - -/** -* @method configClassName -* @description Event handler for when the "classname" configuration property of -* a menu changes. -* @param {String} p_sType The name of the event that was fired. -* @param {Array} p_aArgs Collection of arguments sent when the event was fired. -* @param {YAHOO.widget.Menu} p_oMenu The Menu instance fired the event. -*/ -configClassName: function(p_sType, p_aArgs, p_oMenu) { - - var sClassName = p_aArgs[0]; - - if(this._sClassName) { - - Dom.removeClass(this.element, this._sClassName); - - } - - Dom.addClass(this.element, sClassName); - this._sClassName = sClassName; - -}, - - -// Public methods - - -/** -* @method initEvents -* @description Initializes the custom events for the menu. -*/ -initEvents: function() { - - YAHOO.widget.Menu.superclass.initEvents.call(this); - - // Create custom events - - var CustomEvent = YAHOO.util.CustomEvent; - - this.mouseOverEvent = new CustomEvent("mouseOverEvent", this); - this.mouseOutEvent = new CustomEvent("mouseOutEvent", this); - this.mouseDownEvent = new CustomEvent("mouseDownEvent", this); - this.mouseUpEvent = new CustomEvent("mouseUpEvent", this); - this.clickEvent = new CustomEvent("clickEvent", this); - this.keyPressEvent = new CustomEvent("keyPressEvent", this); - this.keyDownEvent = new CustomEvent("keyDownEvent", this); - this.keyUpEvent = new CustomEvent("keyUpEvent", this); - this.itemAddedEvent = new CustomEvent("itemAddedEvent", this); - this.itemRemovedEvent = new CustomEvent("itemRemovedEvent", this); - -}, - - -/** -* @method getRoot -* @description Finds the menu's root menu. -*/ -getRoot: function() { - - var oItem = this.parent; - - if(oItem) { - - var oParentMenu = oItem.parent; - - return oParentMenu ? oParentMenu.getRoot() : this; - - } - else { - - return this; - - } - -}, - - -/** -* @method toString -* @description Returns a string representing the menu. -* @return {String} -*/ -toString: function() { - - return ("Menu " + this.id); - -}, - - -/** -* @method setItemGroupTitle -* @description Sets the title of a group of menu items. -* @param {String} p_sGroupTitle String specifying the title of the group. -* @param {Number} p_nGroupIndex Optional. Number specifying the group to which -* the title belongs. -*/ -setItemGroupTitle: function(p_sGroupTitle, p_nGroupIndex) { - - if(typeof p_sGroupTitle == "string" && p_sGroupTitle.length > 0) { - - var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0, - oTitle = this._aGroupTitleElements[nGroupIndex]; - - - if(oTitle) { - - oTitle.innerHTML = p_sGroupTitle; - - } - else { - - oTitle = document.createElement(this.GROUP_TITLE_TAG_NAME); - - oTitle.innerHTML = p_sGroupTitle; - - this._aGroupTitleElements[nGroupIndex] = oTitle; - - } - - - var i = this._aGroupTitleElements.length - 1, - nFirstIndex; - - do { - - if(this._aGroupTitleElements[i]) { - - Dom.removeClass(this._aGroupTitleElements[i], "first-of-type"); - - nFirstIndex = i; - - } - - } - while(i--); - - - if(nFirstIndex !== null) { - - Dom.addClass( - this._aGroupTitleElements[nFirstIndex], - "first-of-type" - ); - - } - - } - -}, - - - -/** -* @method addItem -* @description Appends an item to the menu. -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance to be added to the menu. -* @param {String} p_oItem String specifying the text of the item to be added -* to the menu. -* @param {Object} p_oItem Object literal containing a set of menu item -* configuration properties. -* @param {Number} p_nGroupIndex Optional. Number indicating the group to -* which the item belongs. -* @return {YAHOO.widget.MenuItem} -*/ -addItem: function(p_oItem, p_nGroupIndex) { - - if(p_oItem) { - - return this._addItemToGroup(p_nGroupIndex, p_oItem); - - } - -}, - - -/** -* @method addItems -* @description Adds an array of items to the menu. -* @param {Array} p_aItems Array of items to be added to the menu. The array -* can contain strings specifying the text for each item to be created, object -* literals specifying each of the menu item configuration properties, -* or MenuItem instances. -* @param {Number} p_nGroupIndex Optional. Number specifying the group to -* which the items belongs. -* @return {Array} -*/ -addItems: function(p_aItems, p_nGroupIndex) { - - if(Lang.isArray(p_aItems)) { - - var nItems = p_aItems.length, - aItems = [], - oItem; - - - for(var i=0; i<nItems; i++) { - - oItem = p_aItems[i]; - - if(oItem) { - - if(Lang.isArray(oItem)) { - - aItems[aItems.length] = this.addItems(oItem, i); - - } - else { - - aItems[aItems.length] = - this._addItemToGroup(p_nGroupIndex, oItem); - - } - - } - - } - - - if(aItems.length) { - - return aItems; - - } - - } - -}, - - -/** -* @method insertItem -* @description Inserts an item into the menu at the specified index. -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance to be added to the menu. -* @param {String} p_oItem String specifying the text of the item to be added -* to the menu. -* @param {Object} p_oItem Object literal containing a set of menu item -* configuration properties. -* @param {Number} p_nItemIndex Number indicating the ordinal position at which -* the item should be added. -* @param {Number} p_nGroupIndex Optional. Number indicating the group to which -* the item belongs. -* @return {YAHOO.widget.MenuItem} -*/ -insertItem: function(p_oItem, p_nItemIndex, p_nGroupIndex) { - - if(p_oItem) { - - return this._addItemToGroup(p_nGroupIndex, p_oItem, p_nItemIndex); - - } - -}, - - -/** -* @method removeItem -* @description Removes the specified item from the menu. -* @param {YAHOO.widget.MenuItem} p_oObject Object reference for the MenuItem -* instance to be removed from the menu. -* @param {Number} p_oObject Number specifying the index of the item -* to be removed. -* @param {Number} p_nGroupIndex Optional. Number specifying the group to -* which the item belongs. -* @return {YAHOO.widget.MenuItem} -*/ -removeItem: function(p_oObject, p_nGroupIndex) { - - if(typeof p_oObject != "undefined") { - - var oItem; - - if(p_oObject instanceof YAHOO.widget.MenuItem) { - - oItem = this._removeItemFromGroupByValue(p_nGroupIndex, p_oObject); - - } - else if(typeof p_oObject == "number") { - - oItem = this._removeItemFromGroupByIndex(p_nGroupIndex, p_oObject); - - } - - if(oItem) { - - oItem.destroy(); - - this.logger.log("Item removed." + - " Text: " + oItem.cfg.getProperty("text") + ", " + - " Index: " + oItem.index + ", " + - " Group Index: " + oItem.groupIndex); - - return oItem; - - } - - } - -}, - - -/** -* @method getItems -* @description Returns an array of all of the items in the menu. -* @return {Array} -*/ -getItems: function() { - - var aGroups = this._aItemGroups, - nGroups = aGroups.length; - - return ( - (nGroups == 1) ? aGroups[0] : - (Array.prototype.concat.apply([], aGroups)) - ); - -}, - - -/** -* @method getItemGroups -* @description Multi-dimensional Array representing the menu items as they -* are grouped in the menu. -* @return {Array} -*/ -getItemGroups: function() { - - return this._aItemGroups; - -}, - - -/** -* @method getItem -* @description Returns the item at the specified index. -* @param {Number} p_nItemIndex Number indicating the ordinal position of the -* item to be retrieved. -* @param {Number} p_nGroupIndex Optional. Number indicating the group to which -* the item belongs. -* @return {YAHOO.widget.MenuItem} -*/ -getItem: function(p_nItemIndex, p_nGroupIndex) { - - if(typeof p_nItemIndex == "number") { - - var aGroup = this._getItemGroup(p_nGroupIndex); - - if(aGroup) { - - return aGroup[p_nItemIndex]; - - } - - } - -}, - - -/** -* @method clearContent -* @description Removes all of the content from the menu, including the menu -* items, group titles, header and footer. -*/ -clearContent: function() { - - var aItems = this.getItems(), - nItems = aItems.length, - oElement = this.element, - oBody = this.body, - oHeader = this.header, - oFooter = this.footer; - - - if(nItems > 0) { - - var i = nItems - 1, - oItem, - oSubmenu; - - do { - - oItem = aItems[i]; - - if(oItem) { - - oSubmenu = oItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - this.cfg.configChangedEvent.unsubscribe( - this._onParentMenuConfigChange, - oSubmenu - ); - - this.renderEvent.unsubscribe( - this._onParentMenuRender, - oSubmenu - ); - - } - - oItem.destroy(); - - } - - } - while(i--); - - } - - - if(oHeader) { - - Event.purgeElement(oHeader); - oElement.removeChild(oHeader); - - } - - - if(oFooter) { - - Event.purgeElement(oFooter); - oElement.removeChild(oFooter); - } - - - if(oBody) { - - Event.purgeElement(oBody); - - oBody.innerHTML = ""; - - } - - - this._aItemGroups = []; - this._aListElements = []; - this._aGroupTitleElements = []; - -}, - - -/** -* @method destroy -* @description Removes the menu's <code><div></code> element -* (and accompanying child nodes) from the document. -*/ -destroy: function() { - - // Remove all DOM event listeners - - Event.purgeElement(this.element); - - - // Remove Custom Event listeners - - this.mouseOverEvent.unsubscribeAll(); - this.mouseOutEvent.unsubscribeAll(); - this.mouseDownEvent.unsubscribeAll(); - this.mouseUpEvent.unsubscribeAll(); - this.clickEvent.unsubscribeAll(); - this.keyPressEvent.unsubscribeAll(); - this.keyDownEvent.unsubscribeAll(); - this.keyUpEvent.unsubscribeAll(); - this.itemAddedEvent.unsubscribeAll(); - this.itemRemovedEvent.unsubscribeAll(); - - YAHOO.widget.Module.textResizeEvent.unsubscribe(this._onTextResize, this); - - - // Remove all items - - this.clearContent(); - - - this._aItemGroups = null; - this._aListElements = null; - this._aGroupTitleElements = null; - - - // Continue with the superclass implementation of this method - - YAHOO.widget.Menu.superclass.destroy.call(this); - - this.logger.log("Destroyed."); - -}, - - -/** -* @method setInitialFocus -* @description Sets focus to the menu's first enabled item. -*/ -setInitialFocus: function() { - - var oItem = this._getFirstEnabledItem(); - - if(oItem) { - - oItem.focus(); - } - -}, - - -/** -* @method setInitialSelection -* @description Sets the "selected" configuration property of the menu's first -* enabled item to "true." -*/ -setInitialSelection: function() { - - var oItem = this._getFirstEnabledItem(); - - if(oItem) { - - oItem.cfg.setProperty("selected", true); - } - -}, - - -/** -* @method clearActiveItem -* @description Sets the "selected" configuration property of the menu's active -* item to "false" and hides the item's submenu. -* @param {Boolean} p_bBlur Boolean indicating if the menu's active item -* should be blurred. -*/ -clearActiveItem: function(p_bBlur) { - - if(this.cfg.getProperty("showdelay") > 0) { - - this._cancelShowDelay(); - - } - - - var oActiveItem = this.activeItem; - - if(oActiveItem) { - - var oConfig = oActiveItem.cfg; - - oConfig.setProperty("selected", false); - - var oSubmenu = oConfig.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.hide(); - - } - - if(p_bBlur) { - - oActiveItem.blur(); - - } - - } - -}, - - -/** -* @description Initializes the class's configurable properties which can be -* changed using the menu's Config object ("cfg"). -* @method initDefaultConfig -*/ -initDefaultConfig: function() { - - YAHOO.widget.Menu.superclass.initDefaultConfig.call(this); - - var oConfig = this.cfg; - - // Add configuration attributes - - /* - Change the default value for the "visible" configuration - property to "false" by re-adding the property. - */ - - /** - * @config visible - * @description Boolean indicating whether or not the menu is visible. If - * the menu's "position" configuration property is set to "dynamic" (the - * default), this property toggles the menu's <code><div></code> - * element's "visibility" style property between "visible" (true) or - * "hidden" (false). If the menu's "position" configuration property is - * set to "static" this property toggles the menu's - * <code><div></code> element's "display" style property - * between "block" (true) or "none" (false). - * @default false - * @type Boolean - */ - oConfig.addProperty( - "visible", - { - value:false, - handler:this.configVisible, - validator:this.cfg.checkBoolean - } - ); - - - /* - Change the default value for the "constraintoviewport" configuration - property to "true" by re-adding the property. - */ - - /** - * @config constraintoviewport - * @description Boolean indicating if the menu will try to remain inside - * the boundaries of the size of viewport. - * @default true - * @type Boolean - */ - oConfig.addProperty( - "constraintoviewport", - { - value:true, - handler:this.configConstrainToViewport, - validator:this.cfg.checkBoolean, - supercedes:["iframe","x","y","xy"] - } - ); - - - /** - * @config position - * @description String indicating how a menu should be positioned on the - * screen. Possible values are "static" and "dynamic." Static menus are - * visible by default and reside in the normal flow of the document - * (CSS position: static). Dynamic menus are hidden by default, reside - * out of the normal flow of the document (CSS position: absolute), and - * can overlay other elements on the screen. - * @default dynamic - * @type String - */ - oConfig.addProperty( - "position", - { - value: "dynamic", - handler: this.configPosition, - validator: this._checkPosition, - supercedes: ["visible"] - } - ); - - - /** - * @config submenualignment - * @description Array defining how submenus should be aligned to their - * parent menu item. The format is: [itemCorner, submenuCorner]. By default - * a submenu's top left corner is aligned to its parent menu item's top - * right corner. - * @default ["tl","tr"] - * @type Array - */ - oConfig.addProperty("submenualignment", { value: ["tl","tr"] } ); - - - /** - * @config autosubmenudisplay - * @description Boolean indicating if submenus are automatically made - * visible when the user mouses over the menu's items. - * @default true - * @type Boolean - */ - oConfig.addProperty( - "autosubmenudisplay", - { - value: true, - validator: oConfig.checkBoolean - } - ); - - - /** - * @config showdelay - * @description Number indicating the time (in milliseconds) that should - * expire before a submenu is made visible when the user mouses over - * the menu's items. - * @default 250 - * @type Number - */ - oConfig.addProperty( - "showdelay", - { - value: 250, - validator: oConfig.checkNumber - } - ); - - - /** - * @config hidedelay - * @description Number indicating the time (in milliseconds) that should - * expire before the menu is hidden. - * @default 0 - * @type Number - */ - oConfig.addProperty( - "hidedelay", - { - value: 0, - validator: oConfig.checkNumber, - handler: this.configHideDelay, - suppressEvent: true - } - ); - - - /** - * @config submenuhidedelay - * @description 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. - * @default 250 - * @type Number - */ - oConfig.addProperty( - "submenuhidedelay", - { - value: 250, - validator: oConfig.checkNumber - } - ); - - - /** - * @config clicktohide - * @description Boolean indicating if the menu will automatically be - * hidden if the user clicks outside of it. - * @default true - * @type Boolean - */ - oConfig.addProperty( - "clicktohide", - { - value: true, - validator: oConfig.checkBoolean - } - ); - - - /** - * @config container - * @description HTML element reference or string specifying the id - * attribute of the HTML element that the menu's markup should be - * rendered into. - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|String - * @default document.body - */ - oConfig.addProperty( - "container", - { - value:document.body, - handler:this.configContainer - } - ); - - - /** - * @config maxheight - * @description Defines the maximum height (in pixels) for a menu before the - * contents of the body are scrolled. - * @default 0 - * @type Number - */ - oConfig.addProperty( - "maxheight", - { - value: 0, - validator: oConfig.checkNumber, - handler: this.configMaxHeight - } - ); - - - /** - * @config classname - * @description CSS class to be applied to the menu's root - * <code><div></code> element. The specified class(es) are - * appended in addition to the default class as specified by the menu's - * CSS_CLASS_NAME constant. - * @default null - * @type String - */ - oConfig.addProperty( - "classname", - { - value: null, - handler: this.configClassName, - validator: this._checkString - } - ); - -} - -}); // END YAHOO.lang.extend - -})(); - - - -(function() { - -var Dom = YAHOO.util.Dom, - Module = YAHOO.widget.Module, - Menu = YAHOO.widget.Menu, - - m_oMenuItemElement = null, - m_oSubmenuIndicator = null, - m_oCheckedIndicator = null; - - -/** -* Creates an item for a menu. -* -* @param {String} p_oObject String specifying the text of the menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying -* the <code><li></code> element of the menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object -* specifying the <code><option></code> element of the menu item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu item. See configuration class documentation -* for more details. -* @class MenuItem -* @constructor -*/ -YAHOO.widget.MenuItem = function(p_oObject, p_oConfig) { - - if(p_oObject) { - - if(p_oConfig) { - - this.parent = p_oConfig.parent; - this.value = p_oConfig.value; - this.id = p_oConfig.id; - - } - - this.init(p_oObject, p_oConfig); - - } - -}; - - -YAHOO.widget.MenuItem.prototype = { - - // Constants - - - /** - * @property SUBMENU_INDICATOR_IMAGE_PATH - * @description String representing the path to the image to be used for the - * menu item's submenu arrow indicator. - * @default "nt/ic/ut/alt1/menuarorght8_nrm_1.gif" - * @final - * @type String - * @deprecated All submenu indicator images are applied via a CSS - * background image. See "submenuindicator" class name in menu.css. - */ - SUBMENU_INDICATOR_IMAGE_PATH: "nt/ic/ut/alt1/menuarorght8_nrm_1.gif", - - - /** - * @property SELECTED_SUBMENU_INDICATOR_IMAGE_PATH - * @description String representing the path to the image to be used for the - * submenu arrow indicator when the menu item is selected. - * @default "nt/ic/ut/alt1/menuarorght8_hov_1.gif" - * @final - * @type String - * @deprecated All submenu indicator images are applied via a CSS - * background image. See "submenuindicator" class name in menu.css. - */ - SELECTED_SUBMENU_INDICATOR_IMAGE_PATH: - "nt/ic/ut/alt1/menuarorght8_hov_1.gif", - - - /** - * @property DISABLED_SUBMENU_INDICATOR_IMAGE_PATH - * @description String representing the path to the image to be used for the - * submenu arrow indicator when the menu item is disabled. - * @default "nt/ic/ut/alt1/menuarorght8_dim_1.gif" - * @final - * @type String - * @deprecated All submenu indicator images are applied via a CSS - * background image. See "submenuindicator" class name in menu.css. - */ - DISABLED_SUBMENU_INDICATOR_IMAGE_PATH: - "nt/ic/ut/alt1/menuarorght8_dim_1.gif", - - - /** - * @property COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the submenu arrow indicator. - * @default "Collapsed. Click to expand." - * @final - * @type String - * @deprecated Use COLLAPSED_SUBMENU_INDICATOR_TEXT. - */ - COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT: "Collapsed. Click to expand.", - - - /** - * @property EXPANDED_SUBMENU_INDICATOR_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the submenu arrow indicator when the submenu is visible. - * @default "Expanded. Click to collapse." - * @final - * @type String - * @deprecated Use EXPANDED_SUBMENU_INDICATOR_TEXT. - */ - EXPANDED_SUBMENU_INDICATOR_ALT_TEXT: "Expanded. Click to collapse.", - - - /** - * @property DISABLED_SUBMENU_INDICATOR_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the submenu arrow indicator when the menu item is disabled. - * @default "Disabled." - * @final - * @type String - * @deprecated Use DISABLED_SUBMENU_INDICATOR_TEXT. - */ - DISABLED_SUBMENU_INDICATOR_ALT_TEXT: "Disabled.", - - - /** - * @property COLLAPSED_SUBMENU_INDICATOR_TEXT - * @description String representing the text for the <code><em><code> - * element used for the submenu arrow indicator. - * @default "Submenu collapsed. Click to expand submenu." - * @final - * @type String - */ - COLLAPSED_SUBMENU_INDICATOR_TEXT: - "Submenu collapsed. Click to expand submenu.", - - - /** - * @property EXPANDED_SUBMENU_INDICATOR_TEXT - * @description String representing the text for the submenu arrow indicator - * element (<code><em><code>) when the submenu is visible. - * @default "Submenu expanded. Click to collapse submenu." - * @final - * @type String - */ - EXPANDED_SUBMENU_INDICATOR_TEXT: - "Submenu expanded. Click to collapse submenu.", - - - /** - * @property DISABLED_SUBMENU_INDICATOR_TEXT - * @description String representing the text for the submenu arrow indicator - * element (<code><em><code>) when the menu item is disabled. - * @default "Submenu collapsed. (Item disabled.)." - * @final - * @type String - */ - DISABLED_SUBMENU_INDICATOR_TEXT: "Submenu collapsed. (Item disabled.)", - - - /** - * @property CHECKED_IMAGE_PATH - * @description String representing the path to the image to be used for - * the checked state. - * @default "nt/ic/ut/bsc/menuchk8_nrm_1.gif" - * @final - * @type String - * @deprecated All checked indicator images are applied via a CSS - * background image. See "checkedindicator" class name in menu.css. - */ - CHECKED_IMAGE_PATH: "nt/ic/ut/bsc/menuchk8_nrm_1.gif", - - - /** - * @property SELECTED_CHECKED_IMAGE_PATH - * @description String representing the path to the image to be used for - * the selected checked state. - * @default "nt/ic/ut/bsc/menuchk8_hov_1.gif" - * @final - * @type String - * @deprecated All checked indicator images are applied via a CSS - * background image. See "checkedindicator" class name in menu.css. - */ - SELECTED_CHECKED_IMAGE_PATH: "nt/ic/ut/bsc/menuchk8_hov_1.gif", - - - /** - * @property DISABLED_CHECKED_IMAGE_PATH - * @description String representing the path to the image to be used for - * the disabled checked state. - * @default "nt/ic/ut/bsc/menuchk8_dim_1.gif" - * @final - * @type String - * @deprecated All checked indicator images are applied via a CSS - * background image. - */ - DISABLED_CHECKED_IMAGE_PATH: "nt/ic/ut/bsc/menuchk8_dim_1.gif", - - - /** - * @property CHECKED_IMAGE_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the checked image. - * @default "Checked." - * @final - * @type String - * @deprecated Use CHECKED_TEXT. - */ - CHECKED_IMAGE_ALT_TEXT: "Checked.", - - - /** - * @property DISABLED_CHECKED_IMAGE_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the checked image when the item is disabled. - * @default "Checked. (Item disabled.)" - * @final - * @type String - * @deprecated Use DISABLED_CHECKED_TEXT. - */ - DISABLED_CHECKED_IMAGE_ALT_TEXT: "Checked. (Item disabled.)", - - - /** - * @property CHECKED_TEXT - * @description String representing the text to be used for the checked - * indicator element (<code><em><code>). - * @default "Checked." - * @final - * @type String - */ - CHECKED_TEXT: "Menu item checked.", - - - /** - * @property DISABLED_CHECKED_TEXT - * @description String representing the text to be used for the checked - * indicator element (<code><em><code>) when the menu item - * is disabled. - * @default "Checked. (Item disabled.)" - * @final - * @type String - */ - DISABLED_CHECKED_TEXT: "Checked. (Item disabled.)", - - - /** - * @property CSS_CLASS_NAME - * @description String representing the CSS class(es) to be applied to the - * <code><li></code> element of the menu item. - * @default "yuimenuitem" - * @final - * @type String - */ - CSS_CLASS_NAME: "yuimenuitem", - - - /** - * @property SUBMENU_TYPE - * @description Object representing the type of menu to instantiate and - * add when parsing the child nodes of the menu item's source HTML element. - * @final - * @type YAHOO.widget.Menu - */ - SUBMENU_TYPE: null, - - - /** - * @property IMG_ROOT - * @description String representing the prefix path to use for - * non-secure images. - * @default "http://us.i1.yimg.com/us.yimg.com/i/" - * @type String - * @deprecated All menu item images are now applied via CSS - * background images. - */ - IMG_ROOT: "http://us.i1.yimg.com/us.yimg.com/i/", - - - /** - * @property IMG_ROOT_SSL - * @description String representing the prefix path to use for securely - * served images. - * @default "https://a248.e.akamai.net/sec.yimg.com/i/" - * @type String - * @deprecated All menu item images are now applied via CSS - * background images. - */ - IMG_ROOT_SSL: "https://a248.e.akamai.net/sec.yimg.com/i/", - - - - // Private member variables - - - /** - * @property _oAnchor - * @description Object reference to the menu item's - * <code><a></code> element. - * @default null - * @private - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-48250443">HTMLAnchorElement</a> - */ - _oAnchor: null, - - - /** - * @property _oText - * @description Object reference to the menu item's text node. - * @default null - * @private - * @type TextNode - */ - _oText: null, - - - /** - * @property _oHelpTextEM - * @description Object reference to the menu item's help text - * <code><em></code> element. - * @default null - * @private - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-58190037">HTMLElement</a> - */ - _oHelpTextEM: null, - - - /** - * @property _oSubmenu - * @description Object reference to the menu item's submenu. - * @default null - * @private - * @type YAHOO.widget.Menu - */ - _oSubmenu: null, - - - /** - * @property _checkImage - * @description Object reference to the menu item's checkmark image. - * @default null - * @private - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-17701901">HTMLImageElement</a> - * @deprecated Use _oCheckedIndicator. - */ - _checkImage: null, - - - /** - * @property _oCheckedIndicator - * @description Object reference to the menu item's checkmark image. - * @default <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a> - * @private - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a> - */ - _oCheckedIndicator: null, - - - /** - * @property _oOnclickAttributeValue - * @description Object reference to the menu item's current value for the - * "onclick" configuration attribute. - * @default null - * @private - * @type Object - */ - _oOnclickAttributeValue: null, - - - /** - * @property _sClassName - * @description The current value of the "classname" configuration attribute. - * @default null - * @private - * @type String - */ - _sClassName: null, - - - - // Public properties - - - /** - * @property constructor - * @description Object reference to the menu item's constructor function. - * @default YAHOO.widget.MenuItem - * @type YAHOO.widget.MenuItem - */ - constructor: YAHOO.widget.MenuItem, - - - /** - * @property imageRoot - * @description String representing the root path for all of the menu - * item's images. - * @type String - * @deprecated All menu item images are now applied via CSS - * background images. - */ - imageRoot: null, - - - /** - * @property isSecure - * @description Boolean representing whether or not the current browsing - * context is secure (HTTPS). - * @type Boolean - * @deprecated All menu item images are now applied via CSS - * background images. - */ - isSecure: Module.prototype.isSecure, - - - /** - * @property index - * @description Number indicating the ordinal position of the menu item in - * its group. - * @default null - * @type Number - */ - index: null, - - - /** - * @property groupIndex - * @description Number indicating the index of the group to which the menu - * item belongs. - * @default null - * @type Number - */ - groupIndex: null, - - - /** - * @property parent - * @description Object reference to the menu item's parent menu. - * @default null - * @type YAHOO.widget.Menu - */ - parent: null, - - - /** - * @property element - * @description Object reference to the menu item's - * <code><li></code> element. - * @default <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level - * -one-html.html#ID-74680021">HTMLLIElement</a> - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-74680021">HTMLLIElement</a> - */ - element: null, - - - /** - * @property srcElement - * @description Object reference to the HTML element (either - * <code><li></code>, <code><optgroup></code> or - * <code><option></code>) used create the menu item. - * @default <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-74680021">HTMLLIElement</a>|<a href="http://www. - * w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-38450247" - * >HTMLOptGroupElement</a>|<a href="http://www.w3.org/TR/2000/WD-DOM- - * Level-1-20000929/level-one-html.html#ID-70901257">HTMLOptionElement</a> - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-74680021">HTMLLIElement</a>|<a href="http://www.w3. - * org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-38450247"> - * HTMLOptGroupElement</a>|<a href="http://www.w3.org/TR/2000/WD-DOM- - * Level-1-20000929/level-one-html.html#ID-70901257">HTMLOptionElement</a> - */ - srcElement: null, - - - /** - * @property value - * @description Object reference to the menu item's value. - * @default null - * @type Object - */ - value: null, - - - /** - * @property submenuIndicator - * @description Object reference to the <code><em></code> element - * used to create the submenu indicator for the menu item. - * @default <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a> - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a> - */ - submenuIndicator: null, - - - /** - * @property browser - * @description String representing the browser. - * @type String - */ - browser: Module.prototype.browser, - - - /** - * @property id - * @description Id of the menu item's root <code><li></code> - * element. This property should be set via the constructor using the - * configuration object literal. If an id is not specified, then one will - * be created using the "generateId" method of the Dom utility. - * @default null - * @type String - */ - id: null, - - - - // Events - - - /** - * @event destroyEvent - * @description Fires when the menu item's <code><li></code> - * element is removed from its parent <code><ul></code> element. - * @type YAHOO.util.CustomEvent - */ - destroyEvent: null, - - - /** - * @event mouseOverEvent - * @description Fires when the mouse has entered the menu item. Passes - * back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - mouseOverEvent: null, - - - /** - * @event mouseOutEvent - * @description Fires when the mouse has left the menu item. Passes back - * the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - mouseOutEvent: null, - - - /** - * @event mouseDownEvent - * @description Fires when the user mouses down on the menu item. Passes - * back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - mouseDownEvent: null, - - - /** - * @event mouseUpEvent - * @description Fires when the user releases a mouse button while the mouse - * is over the menu item. Passes back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - mouseUpEvent: null, - - - /** - * @event clickEvent - * @description Fires when the user clicks the on the menu item. Passes - * back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - clickEvent: null, - - - /** - * @event keyPressEvent - * @description Fires when the user presses an alphanumeric key when the - * menu item has focus. Passes back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - keyPressEvent: null, - - - /** - * @event keyDownEvent - * @description Fires when the user presses a key when the menu item has - * focus. Passes back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - keyDownEvent: null, - - - /** - * @event keyUpEvent - * @description Fires when the user releases a key when the menu item has - * focus. Passes back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - keyUpEvent: null, - - - /** - * @event focusEvent - * @description Fires when the menu item receives focus. - * @type YAHOO.util.CustomEvent - */ - focusEvent: null, - - - /** - * @event blurEvent - * @description Fires when the menu item loses the input focus. - * @type YAHOO.util.CustomEvent - */ - blurEvent: null, - - - /** - * @method init - * @description The MenuItem class's initialization method. This method is - * automatically called by the constructor, and sets up all DOM references - * for pre-existing markup, and creates required markup if it is not - * already present. - * @param {String} p_oObject String specifying the text of the menu item. - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying - * the <code><li></code> element of the menu item. - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object - * specifying the <code><optgroup></code> element of the menu item. - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object - * specifying the <code><option></code> element of the menu item. - * @param {Object} p_oConfig Optional. Object literal specifying the - * configuration for the menu item. See configuration class documentation - * for more details. - */ - init: function(p_oObject, p_oConfig) { - - - if(!this.SUBMENU_TYPE) { - - this.SUBMENU_TYPE = Menu; - - } - - - // Create the config object - - this.cfg = new YAHOO.util.Config(this); - - this.initDefaultConfig(); - - var oConfig = this.cfg; - - - if(this._checkString(p_oObject)) { - - this._createRootNodeStructure(); - - oConfig.setProperty("text", p_oObject); - - } - else if(this._checkDOMNode(p_oObject)) { - - switch(p_oObject.tagName.toUpperCase()) { - - case "OPTION": - - this._createRootNodeStructure(); - - oConfig.setProperty("text", p_oObject.text); - - this.srcElement = p_oObject; - - break; - - case "OPTGROUP": - - this._createRootNodeStructure(); - - oConfig.setProperty("text", p_oObject.label); - - this.srcElement = p_oObject; - - this._initSubTree(); - - break; - - case "LI": - - // Get the anchor node (if it exists) - - var oAnchor = this._getFirstElement(p_oObject, "A"), - sURL = "#", - sTarget, - sText; - - - // Capture the "text" and/or the "URL" - - if(oAnchor) { - - sURL = oAnchor.getAttribute("href"); - sTarget = oAnchor.getAttribute("target"); - - if(oAnchor.innerText) { - - sText = oAnchor.innerText; - - } - else { - - var oRange = oAnchor.ownerDocument.createRange(); - - oRange.selectNodeContents(oAnchor); - - sText = oRange.toString(); - - } - - } - else { - - var oText = p_oObject.firstChild; - - sText = oText.nodeValue; - - oAnchor = document.createElement("a"); - - oAnchor.setAttribute("href", sURL); - - p_oObject.replaceChild(oAnchor, oText); - - oAnchor.appendChild(oText); - - } - - - this.srcElement = p_oObject; - this.element = p_oObject; - this._oAnchor = oAnchor; - - - // Check if emphasis has been applied to the MenuItem - - var oEmphasisNode = this._getFirstElement(oAnchor), - bEmphasis = false, - bStrongEmphasis = false; - - if(oEmphasisNode) { - - // Set a reference to the text node - - this._oText = oEmphasisNode.firstChild; - - switch(oEmphasisNode.tagName.toUpperCase()) { - - case "EM": - - bEmphasis = true; - - break; - - case "STRONG": - - bStrongEmphasis = true; - - break; - - } - - } - else { - - // Set a reference to the text node - - this._oText = oAnchor.firstChild; - - } - - - /* - Set these properties silently to sync up the - configuration object without making changes to the - element's DOM - */ - - oConfig.setProperty("text", sText, true); - oConfig.setProperty("url", sURL, true); - oConfig.setProperty("target", sTarget, true); - oConfig.setProperty("emphasis", bEmphasis, true); - oConfig.setProperty( - "strongemphasis", - bStrongEmphasis, - true - ); - - this._initSubTree(); - - break; - - } - - } - - - if(this.element) { - - var sId = this.element.id; - - if(!sId) { - - sId = this.id || Dom.generateId(); - - this.element.id = sId; - - } - - this.id = sId; - - - Dom.addClass(this.element, this.CSS_CLASS_NAME); - - - // Create custom events - - var CustomEvent = YAHOO.util.CustomEvent; - - this.destroyEvent = new CustomEvent("destroyEvent", this); - this.mouseOverEvent = new CustomEvent("mouseOverEvent", this); - this.mouseOutEvent = new CustomEvent("mouseOutEvent", this); - this.mouseDownEvent = new CustomEvent("mouseDownEvent", this); - this.mouseUpEvent = new CustomEvent("mouseUpEvent", this); - this.clickEvent = new CustomEvent("clickEvent", this); - this.keyPressEvent = new CustomEvent("keyPressEvent", this); - this.keyDownEvent = new CustomEvent("keyDownEvent", this); - this.keyUpEvent = new CustomEvent("keyUpEvent", this); - this.focusEvent = new CustomEvent("focusEvent", this); - this.blurEvent = new CustomEvent("blurEvent", this); - - - if(p_oConfig) { - - oConfig.applyConfig(p_oConfig); - - } - - oConfig.fireQueue(); - - - - - } - - }, - - - - // Private methods - - - /** - * @method _getFirstElement - * @description Returns an HTML element's first HTML element node. - * @private - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>} p_oElement Object - * reference specifying the element to be evaluated. - * @param {String} p_sTagName Optional. String specifying the tagname of - * the element to be retrieved. - * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>} - */ - _getFirstElement: function(p_oElement, p_sTagName) { - - var oFirstChild = p_oElement.firstChild, - oElement; - - if(oFirstChild) { - - if(oFirstChild.nodeType == 1) { - - oElement = oFirstChild; - - } - else { - - var oNextSibling = oFirstChild.nextSibling; - - if(oNextSibling && oNextSibling.nodeType == 1) { - - oElement = oNextSibling; - - } - - } - - } - - - if(p_sTagName) { - - return (oElement && oElement.tagName.toUpperCase() == p_sTagName) ? - oElement : false; - - } - - return oElement; - - }, - - - /** - * @method _checkString - * @description Determines if an object is a string. - * @private - * @param {Object} p_oObject Object to be evaluated. - * @return {Boolean} - */ - _checkString: function(p_oObject) { - - return (typeof p_oObject == "string"); - - }, - - - /** - * @method _checkDOMNode - * @description Determines if an object is an HTML element. - * @private - * @param {Object} p_oObject Object to be evaluated. - * @return {Boolean} - */ - _checkDOMNode: function(p_oObject) { - - return (p_oObject && p_oObject.tagName); - - }, - - - /** - * @method _createRootNodeStructure - * @description Creates the core DOM structure for the menu item. - * @private - */ - _createRootNodeStructure: function () { - - if(!m_oMenuItemElement) { - - m_oMenuItemElement = document.createElement("li"); - m_oMenuItemElement.innerHTML = "<a href=\"#\">s</a>"; - - } - - this.element = m_oMenuItemElement.cloneNode(true); - this._oAnchor = this.element.firstChild; - this._oText = this._oAnchor.firstChild; - - this.element.appendChild(this._oAnchor); - - }, - - - /** - * @method _initSubTree - * @description Iterates the source element's childNodes collection and uses - * the child nodes to instantiate other menus. - * @private - */ - _initSubTree: function() { - - var oSrcEl = this.srcElement, - oConfig = this.cfg; - - - if(oSrcEl.childNodes.length > 0) { - - if( - this.parent.lazyLoad && - this.parent.srcElement && - this.parent.srcElement.tagName.toUpperCase() == "SELECT" - ) { - - oConfig.setProperty( - "submenu", - { id: Dom.generateId(), itemdata: oSrcEl.childNodes } - ); - - } - else { - - var oNode = oSrcEl.firstChild, - aOptions = []; - - do { - - if(oNode && oNode.tagName) { - - switch(oNode.tagName.toUpperCase()) { - - case "DIV": - - oConfig.setProperty("submenu", oNode); - - break; - - case "OPTION": - - aOptions[aOptions.length] = oNode; - - break; - - } - - } - - } - while((oNode = oNode.nextSibling)); - - - var nOptions = aOptions.length; - - if(nOptions > 0) { - - var oMenu = new this.SUBMENU_TYPE(Dom.generateId()); - - oConfig.setProperty("submenu", oMenu); - - for(var n=0; n<nOptions; n++) { - - oMenu.addItem((new oMenu.ITEM_TYPE(aOptions[n]))); - - } - - } - - } - - } - - }, - - - /** - * @method _preloadImage - * @description Preloads an image by creating an image element from the - * specified path and appending the image to the body of the document. - * @private - * @param {String} p_sPath String specifying the path to the image. - * @deprecated All menu item images are now applied via CSS - * background images. - */ - _preloadImage: function(p_sPath) { - - var sPath = this.imageRoot + p_sPath; - - if(!document.images[sPath]) { - - var oImage = document.createElement("img"); - oImage.src = sPath; - oImage.name = sPath; - oImage.id = sPath; - oImage.style.display = "none"; - - document.body.appendChild(oImage); - - } - - }, - - - - // Event handlers for configuration properties - - - /** - * @method configText - * @description Event handler for when the "text" configuration property of - * the menu item changes. - * @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 fired the event. - */ - configText: function(p_sType, p_aArgs, p_oItem) { - - var sText = p_aArgs[0]; - - - if(this._oText) { - - this._oText.nodeValue = sText; - - } - - }, - - - /** - * @method configHelpText - * @description Event handler for when the "helptext" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configHelpText: function(p_sType, p_aArgs, p_oItem) { - - var me = this, - oHelpText = p_aArgs[0], - oEl = this.element, - oConfig = this.cfg, - aNodes = [oEl, this._oAnchor], - oSubmenuIndicator = this.submenuIndicator; - - - function initHelpText() { - - Dom.addClass(aNodes, "hashelptext"); - - if(oConfig.getProperty("disabled")) { - - oConfig.refireEvent("disabled"); - - } - - if(oConfig.getProperty("selected")) { - - oConfig.refireEvent("selected"); - - } - - } - - - function removeHelpText() { - - Dom.removeClass(aNodes, "hashelptext"); - - oEl.removeChild(me._oHelpTextEM); - me._oHelpTextEM = null; - - } - - - if(this._checkDOMNode(oHelpText)) { - - oHelpText.className = "helptext"; - - if(this._oHelpTextEM) { - - this._oHelpTextEM.parentNode.replaceChild( - oHelpText, - this._oHelpTextEM - ); - - } - else { - - this._oHelpTextEM = oHelpText; - - oEl.insertBefore(this._oHelpTextEM, oSubmenuIndicator); - - } - - initHelpText(); - - } - else if(this._checkString(oHelpText)) { - - if(oHelpText.length === 0) { - - removeHelpText(); - - } - else { - - if(!this._oHelpTextEM) { - - this._oHelpTextEM = document.createElement("em"); - this._oHelpTextEM.className = "helptext"; - - oEl.insertBefore(this._oHelpTextEM, oSubmenuIndicator); - - } - - this._oHelpTextEM.innerHTML = oHelpText; - - initHelpText(); - - } - - } - else if(!oHelpText && this._oHelpTextEM) { - - removeHelpText(); - - } - - }, - - - /** - * @method configURL - * @description Event handler for when the "url" configuration property of - * the menu item changes. - * @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 fired the event. - */ - configURL: function(p_sType, p_aArgs, p_oItem) { - - var sURL = p_aArgs[0]; - - if(!sURL) { - - sURL = "#"; - - } - - this._oAnchor.setAttribute("href", sURL); - - }, - - - /** - * @method configTarget - * @description Event handler for when the "target" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configTarget: function(p_sType, p_aArgs, p_oItem) { - - var sTarget = p_aArgs[0], - oAnchor = this._oAnchor; - - if(sTarget && sTarget.length > 0) { - - oAnchor.setAttribute("target", sTarget); - - } - else { - - oAnchor.removeAttribute("target"); - - } - - }, - - - /** - * @method configEmphasis - * @description Event handler for when the "emphasis" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configEmphasis: function(p_sType, p_aArgs, p_oItem) { - - var bEmphasis = p_aArgs[0], - oAnchor = this._oAnchor, - oText = this._oText, - oConfig = this.cfg, - oEM; - - - if(bEmphasis && oConfig.getProperty("strongemphasis")) { - - oConfig.setProperty("strongemphasis", false); - - } - - - if(oAnchor) { - - if(bEmphasis) { - - oEM = document.createElement("em"); - oEM.appendChild(oText); - - oAnchor.appendChild(oEM); - - } - else { - - oEM = this._getFirstElement(oAnchor, "EM"); - - if(oEM) { - - oAnchor.removeChild(oEM); - oAnchor.appendChild(oText); - - } - - } - - } - - }, - - - /** - * @method configStrongEmphasis - * @description Event handler for when the "strongemphasis" configuration - * property of the menu item changes. - * @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 fired the event. - */ - configStrongEmphasis: function(p_sType, p_aArgs, p_oItem) { - - var bStrongEmphasis = p_aArgs[0], - oAnchor = this._oAnchor, - oText = this._oText, - oConfig = this.cfg, - oStrong; - - if(bStrongEmphasis && oConfig.getProperty("emphasis")) { - - oConfig.setProperty("emphasis", false); - - } - - if(oAnchor) { - - if(bStrongEmphasis) { - - oStrong = document.createElement("strong"); - oStrong.appendChild(oText); - - oAnchor.appendChild(oStrong); - - } - else { - - oStrong = this._getFirstElement(oAnchor, "STRONG"); - - if(oStrong) { - - oAnchor.removeChild(oStrong); - oAnchor.appendChild(oText); - - } - - } - - } - - }, - - - /** - * @method configChecked - * @description Event handler for when the "checked" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configChecked: function(p_sType, p_aArgs, p_oItem) { - - var bChecked = p_aArgs[0], - oEl = this.element, - oConfig = this.cfg, - oEM; - - - if(bChecked) { - - if(!m_oCheckedIndicator) { - - m_oCheckedIndicator = document.createElement("em"); - m_oCheckedIndicator.innerHTML = this.CHECKED_TEXT; - m_oCheckedIndicator.className = "checkedindicator"; - - } - - oEM = m_oCheckedIndicator.cloneNode(true); - - var oSubmenu = this.cfg.getProperty("submenu"); - - if(oSubmenu && oSubmenu.element) { - - oEl.insertBefore(oEM, oSubmenu.element); - - } - else { - - oEl.appendChild(oEM); - - } - - - Dom.addClass(oEl, "checked"); - - this._oCheckedIndicator = oEM; - - if(oConfig.getProperty("disabled")) { - - oConfig.refireEvent("disabled"); - - } - - if(oConfig.getProperty("selected")) { - - oConfig.refireEvent("selected"); - - } - - } - else { - - oEM = this._oCheckedIndicator; - - Dom.removeClass(oEl, "checked"); - - if(oEM) { - - oEl.removeChild(oEM); - - } - - this._oCheckedIndicator = null; - - } - - }, - - - - /** - * @method configDisabled - * @description Event handler for when the "disabled" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configDisabled: function(p_sType, p_aArgs, p_oItem) { - - var bDisabled = p_aArgs[0], - oConfig = this.cfg, - oAnchor = this._oAnchor, - aNodes = [this.element, oAnchor], - oHelpText = this._oHelpTextEM, - oCheckedIndicator = this._oCheckedIndicator, - oSubmenuIndicator = this.submenuIndicator, - i = 1; - - - if(oHelpText) { - - i++; - aNodes[i] = oHelpText; - - } - - - if(oCheckedIndicator) { - - oCheckedIndicator.firstChild.nodeValue = bDisabled ? - this.DISABLED_CHECKED_TEXT : - this.CHECKED_TEXT; - - i++; - aNodes[i] = oCheckedIndicator; - - } - - - if(oSubmenuIndicator) { - - oSubmenuIndicator.firstChild.nodeValue = bDisabled ? - this.DISABLED_SUBMENU_INDICATOR_TEXT : - this.COLLAPSED_SUBMENU_INDICATOR_TEXT; - - i++; - aNodes[i] = oSubmenuIndicator; - - } - - - if(bDisabled) { - - if(oConfig.getProperty("selected")) { - - oConfig.setProperty("selected", false); - - } - - oAnchor.removeAttribute("href"); - - Dom.addClass(aNodes, "disabled"); - - } - else { - - oAnchor.setAttribute("href", oConfig.getProperty("url")); - - Dom.removeClass(aNodes, "disabled"); - - } - - }, - - - /** - * @method configSelected - * @description Event handler for when the "selected" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configSelected: function(p_sType, p_aArgs, p_oItem) { - - if(!this.cfg.getProperty("disabled")) { - - var bSelected = p_aArgs[0], - oHelpText = this._oHelpTextEM, - oSubmenuIndicator = this.submenuIndicator, - oCheckedIndicator = this._oCheckedIndicator, - aNodes = [this.element, this._oAnchor], - i = 1; - - - if(oHelpText) { - - i++; - aNodes[i] = oHelpText; - - } - - - if(oSubmenuIndicator) { - - i++; - aNodes[i] = oSubmenuIndicator; - - } - - - if(oCheckedIndicator) { - - i++; - aNodes[i] = oCheckedIndicator; - - } - - - if(bSelected) { - - Dom.addClass(aNodes, "selected"); - - } - else { - - Dom.removeClass(aNodes, "selected"); - - } - - } - - }, - - - /** - * @method configSubmenu - * @description Event handler for when the "submenu" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configSubmenu: function(p_sType, p_aArgs, p_oItem) { - - var oEl = this.element, - oSubmenu = p_aArgs[0], - oSubmenuIndicator = this.submenuIndicator, - oConfig = this.cfg, - aNodes = [this.element, this._oAnchor], - bLazyLoad = this.parent && this.parent.lazyLoad, - oMenu; - - - if(oSubmenu) { - - if(oSubmenu instanceof Menu) { - - oMenu = oSubmenu; - oMenu.parent = this; - oMenu.lazyLoad = bLazyLoad; - - } - else if( - typeof oSubmenu == "object" && - oSubmenu.id && - !oSubmenu.nodeType - ) { - - var sSubmenuId = oSubmenu.id, - oSubmenuConfig = oSubmenu; - - oSubmenuConfig.lazyload = bLazyLoad; - oSubmenuConfig.parent = this; - - oMenu = new this.SUBMENU_TYPE(sSubmenuId, oSubmenuConfig); - - - // Set the value of the property to the Menu instance - - this.cfg.setProperty("submenu", oMenu, true); - - } - else { - - oMenu = new this.SUBMENU_TYPE( - oSubmenu, - { lazyload: bLazyLoad, parent: this } - ); - - - // Set the value of the property to the Menu instance - - this.cfg.setProperty("submenu", oMenu, true); - - } - - - if(oMenu) { - - this._oSubmenu = oMenu; - - - if(!oSubmenuIndicator) { - - - if(!m_oSubmenuIndicator) { - - m_oSubmenuIndicator = document.createElement("em"); - m_oSubmenuIndicator.innerHTML = - this.COLLAPSED_SUBMENU_INDICATOR_TEXT; - m_oSubmenuIndicator.className = "submenuindicator"; - - } - - - oSubmenuIndicator = m_oSubmenuIndicator.cloneNode(true); - - - if(oMenu.element.parentNode == oEl) { - - if(this.browser == "opera") { - - oEl.appendChild(oSubmenuIndicator); - - oMenu.renderEvent.subscribe(function() { - - oSubmenuIndicator.parentNode.insertBefore( - oSubmenuIndicator, - oMenu.element - ); - - }); - - } - else { - - oEl.insertBefore(oSubmenuIndicator, oMenu.element); - - } - - } - else { - - oEl.appendChild(oSubmenuIndicator); - - } - - this.submenuIndicator = oSubmenuIndicator; - - } - - - Dom.addClass(aNodes, "hassubmenu"); - - - if(oConfig.getProperty("disabled")) { - - oConfig.refireEvent("disabled"); - - } - - if(oConfig.getProperty("selected")) { - - oConfig.refireEvent("selected"); - - } - - } - - } - else { - - Dom.removeClass(aNodes, "hassubmenu"); - - if(oSubmenuIndicator) { - - oEl.removeChild(oSubmenuIndicator); - - } - - if(this._oSubmenu) { - - this._oSubmenu.destroy(); - - } - - } - - }, - - - /** - * @method configOnClick - * @description Event handler for when the "onclick" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configOnClick: function(p_sType, p_aArgs, p_oItem) { - - var oObject = p_aArgs[0]; - - /* - Remove any existing listeners if a "click" event handler has - already been specified. - */ - - if( - this._oOnclickAttributeValue && - (this._oOnclickAttributeValue != oObject) - ) { - - this.clickEvent.unsubscribe( - this._oOnclickAttributeValue.fn, - this._oOnclickAttributeValue.obj - ); - - this._oOnclickAttributeValue = null; - - } - - - if( - !this._oOnclickAttributeValue && - typeof oObject == "object" && - typeof oObject.fn == "function" - ) { - - this.clickEvent.subscribe( - oObject.fn, - (oObject.obj || this), - oObject.scope - ); - - this._oOnclickAttributeValue = oObject; - - } - - }, - - - /** - * @method configClassName - * @description Event handler for when the "classname" configuration - * property of a menu item changes. - * @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 fired the event. - */ - configClassName: function(p_sType, p_aArgs, p_oItem) { - - var sClassName = p_aArgs[0]; - - if(this._sClassName) { - - Dom.removeClass(this.element, this._sClassName); - - } - - Dom.addClass(this.element, sClassName); - this._sClassName = sClassName; - - }, - - - - // Public methods - - - /** - * @method initDefaultConfig - * @description Initializes an item's configurable properties. - */ - initDefaultConfig : function() { - - var oConfig = this.cfg, - CheckBoolean = oConfig.checkBoolean; - - - // Define the configuration attributes - - /** - * @config text - * @description String specifying the text label for the menu item. - * When building a menu from existing HTML the value of this property - * will be interpreted from the menu's markup. - * @default "" - * @type String - */ - oConfig.addProperty( - "text", - { - value: "", - handler: this.configText, - validator: this._checkString, - suppressEvent: true - } - ); - - - /** - * @config helptext - * @description String specifying additional instructional text to - * accompany the text for the nenu item. - * @default null - * @type String|<a href="http://www.w3.org/TR/ - * 2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-58190037"> - * HTMLElement</a> - */ - oConfig.addProperty("helptext", { handler: this.configHelpText }); - - - /** - * @config url - * @description String specifying the URL for the menu item's anchor's - * "href" attribute. When building a menu from existing HTML the value - * of this property will be interpreted from the menu's markup. - * @default "#" - * @type String - */ - oConfig.addProperty( - "url", - { value: "#", handler: this.configURL, suppressEvent: true } - ); - - - /** - * @config target - * @description String specifying the value for the "target" attribute - * of the menu item's anchor element. <strong>Specifying a target will - * require the user to click directly on the menu item's anchor node in - * order to cause the browser to navigate to the specified URL.</strong> - * When building a menu from existing HTML the value of this property - * will be interpreted from the menu's markup. - * @default null - * @type String - */ - oConfig.addProperty( - "target", - { handler: this.configTarget, suppressEvent: true } - ); - - - /** - * @config emphasis - * @description Boolean indicating if the text of the menu item will be - * rendered with emphasis. When building a menu from existing HTML the - * value of this property will be interpreted from the menu's markup. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "emphasis", - { - value: false, - handler: this.configEmphasis, - validator: CheckBoolean, - suppressEvent: true - } - ); - - - /** - * @config strongemphasis - * @description Boolean indicating if the text of the menu item will be - * rendered with strong emphasis. When building a menu from existing - * HTML the value of this property will be interpreted from the - * menu's markup. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "strongemphasis", - { - value: false, - handler: this.configStrongEmphasis, - validator: CheckBoolean, - suppressEvent: true - } - ); - - - /** - * @config checked - * @description Boolean indicating if the menu item should be rendered - * with a checkmark. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "checked", - { - value: false, - handler: this.configChecked, - validator: this.cfg.checkBoolean, - suppressEvent: true, - supercedes:["disabled"] - } - ); - - - /** - * @config disabled - * @description Boolean indicating if the menu item should be disabled. - * (Disabled menu items are dimmed and will not respond to user input - * or fire events.) - * @default false - * @type Boolean - */ - oConfig.addProperty( - "disabled", - { - value: false, - handler: this.configDisabled, - validator: CheckBoolean, - suppressEvent: true - } - ); - - - /** - * @config selected - * @description Boolean indicating if the menu item should - * be highlighted. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "selected", - { - value: false, - handler: this.configSelected, - validator: CheckBoolean, - suppressEvent: true - } - ); - - - /** - * @config submenu - * @description Object specifying the submenu to be appended to the - * menu item. The value can be one of the following: <ul><li>Object - * specifying a Menu instance.</li><li>Object literal specifying the - * menu to be created. Format: <code>{ id: [menu id], itemdata: - * [<a href="YAHOO.widget.Menu.html#itemData">array of values for - * items</a>] }</code>.</li><li>String specifying the id attribute - * of the <code><div></code> element of the menu.</li><li> - * Object specifying the <code><div></code> element of the - * menu.</li></ul> - * @default null - * @type Menu|String|Object|<a href="http://www.w3.org/TR/2000/ - * WD-DOM-Level-1-20000929/level-one-html.html#ID-58190037"> - * HTMLElement</a> - */ - oConfig.addProperty("submenu", { handler: this.configSubmenu }); - - - /** - * @config onclick - * @description Object literal representing the code to be executed when - * the button is clicked. Format:<br> <code> {<br> - * <strong>fn:</strong> Function, // The handler to call when - * the event fires.<br> <strong>obj:</strong> Object, // An - * object to pass back to the handler.<br> <strong>scope:</strong> - * Object // The object to use for the scope of the handler. - * <br> } </code> - * @type Object - * @default null - */ - oConfig.addProperty("onclick", { handler: this.configOnClick }); - - - /** - * @config classname - * @description CSS class to be applied to the menu item's root - * <code><li></code> element. The specified class(es) are - * appended in addition to the default class as specified by the menu - * item's CSS_CLASS_NAME constant. - * @default null - * @type String - */ - oConfig.addProperty( - "classname", - { - value: null, - handler: this.configClassName, - validator: this._checkString - } - ); - - }, - - - /** - * @method getNextEnabledSibling - * @description Finds the menu item's next enabled sibling. - * @return YAHOO.widget.MenuItem - */ - getNextEnabledSibling: function() { - - if(this.parent instanceof Menu) { - - var nGroupIndex = this.groupIndex; - - function getNextArrayItem(p_aArray, p_nStartIndex) { - - return p_aArray[p_nStartIndex] || - getNextArrayItem(p_aArray, (p_nStartIndex+1)); - - } - - - var aItemGroups = this.parent.getItemGroups(), - oNextItem; - - - if(this.index < (aItemGroups[nGroupIndex].length - 1)) { - - oNextItem = getNextArrayItem( - aItemGroups[nGroupIndex], - (this.index+1) - ); - - } - else { - - var nNextGroupIndex; - - if(nGroupIndex < (aItemGroups.length - 1)) { - - nNextGroupIndex = nGroupIndex + 1; - - } - else { - - nNextGroupIndex = 0; - - } - - var aNextGroup = getNextArrayItem(aItemGroups, nNextGroupIndex); - - // Retrieve the first menu item in the next group - - oNextItem = getNextArrayItem(aNextGroup, 0); - - } - - return ( - oNextItem.cfg.getProperty("disabled") || - oNextItem.element.style.display == "none" - ) ? - oNextItem.getNextEnabledSibling() : oNextItem; - - } - - }, - - - /** - * @method getPreviousEnabledSibling - * @description Finds the menu item's previous enabled sibling. - * @return {YAHOO.widget.MenuItem} - */ - getPreviousEnabledSibling: function() { - - if(this.parent instanceof Menu) { - - var nGroupIndex = this.groupIndex; - - function getPreviousArrayItem(p_aArray, p_nStartIndex) { - - return p_aArray[p_nStartIndex] || - getPreviousArrayItem(p_aArray, (p_nStartIndex-1)); - - } - - function getFirstItemIndex(p_aArray, p_nStartIndex) { - - return p_aArray[p_nStartIndex] ? - p_nStartIndex : - getFirstItemIndex(p_aArray, (p_nStartIndex+1)); - - } - - var aItemGroups = this.parent.getItemGroups(), - oPreviousItem; - - if( - this.index > getFirstItemIndex(aItemGroups[nGroupIndex], 0) - ) { - - oPreviousItem = - getPreviousArrayItem( - aItemGroups[nGroupIndex], - (this.index-1) - ); - - } - else { - - var nPreviousGroupIndex; - - if(nGroupIndex > getFirstItemIndex(aItemGroups, 0)) { - - nPreviousGroupIndex = nGroupIndex - 1; - - } - else { - - nPreviousGroupIndex = aItemGroups.length - 1; - - } - - var aPreviousGroup = - getPreviousArrayItem(aItemGroups, nPreviousGroupIndex); - - oPreviousItem = - getPreviousArrayItem( - aPreviousGroup, - (aPreviousGroup.length - 1) - ); - - } - - return ( - oPreviousItem.cfg.getProperty("disabled") || - oPreviousItem.element.style.display == "none" - ) ? - oPreviousItem.getPreviousEnabledSibling() : oPreviousItem; - - } - - }, - - - /** - * @method focus - * @description Causes the menu item to receive the focus and fires the - * focus event. - */ - focus: function() { - - var oParent = this.parent, - oAnchor = this._oAnchor, - oActiveItem = oParent.activeItem; - - - function setFocus() { - - try { - - oAnchor.focus(); - - } - catch(e) { - - } - - } - - - if( - !this.cfg.getProperty("disabled") && - oParent && - oParent.cfg.getProperty("visible") && - this.element.style.display != "none" - ) { - - if(oActiveItem) { - - oActiveItem.blur(); - - } - - - /* - Setting focus via a timer fixes a race condition in Firefox, IE - and Opera where the browser viewport jumps as it trys to - position and focus the menu. - */ - - window.setTimeout(setFocus, 0); - - this.focusEvent.fire(); - - } - - }, - - - /** - * @method blur - * @description Causes the menu item to lose focus and fires the - * onblur event. - */ - blur: function() { - - var oParent = this.parent; - - if( - !this.cfg.getProperty("disabled") && - oParent && - Dom.getStyle(oParent.element, "visibility") == "visible" - ) { - - this._oAnchor.blur(); - - this.blurEvent.fire(); - - } - - }, - - - /** - * @method destroy - * @description Removes the menu item's <code><li></code> element - * from its parent <code><ul></code> element. - */ - destroy: function() { - - var oEl = this.element; - - if(oEl) { - - - // If the item has a submenu, destroy it first - - var oSubmenu = this.cfg.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.destroy(); - - } - - - // Remove CustomEvent listeners - - this.mouseOverEvent.unsubscribeAll(); - this.mouseOutEvent.unsubscribeAll(); - this.mouseDownEvent.unsubscribeAll(); - this.mouseUpEvent.unsubscribeAll(); - this.clickEvent.unsubscribeAll(); - this.keyPressEvent.unsubscribeAll(); - this.keyDownEvent.unsubscribeAll(); - this.keyUpEvent.unsubscribeAll(); - this.focusEvent.unsubscribeAll(); - this.blurEvent.unsubscribeAll(); - this.cfg.configChangedEvent.unsubscribeAll(); - - - // Remove the element from the parent node - - var oParentNode = oEl.parentNode; - - if(oParentNode) { - - oParentNode.removeChild(oEl); - - this.destroyEvent.fire(); - - } - - this.destroyEvent.unsubscribeAll(); - - } - - }, - - - /** - * @method toString - * @description Returns a string representing the menu item. - * @return {String} - */ - toString: function() { - - return ("MenuItem: " + this.cfg.getProperty("text")); - - } - -}; - -})(); - - - -/** -* Creates a list of options or commands which are made visible in response to -* an HTML element's "contextmenu" event ("mousedown" for Opera). -* -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the context menu. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source for the -* context menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object specifying the -* <code><div></code> element of the context menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-94282980">HTMLSelectElement</a>} p_oElement Object specifying -* the <code><select></code> element to be used as the data source for -* the context menu. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the context menu. See configuration class documentation -* for more details. -* @class ContextMenu -* @constructor -* @extends YAHOO.widget.Menu -* @namespace YAHOO.widget -*/ -YAHOO.widget.ContextMenu = function(p_oElement, p_oConfig) { - - YAHOO.widget.ContextMenu.superclass.constructor.call( - this, - p_oElement, - p_oConfig - ); - -}; - - -YAHOO.lang.extend(YAHOO.widget.ContextMenu, YAHOO.widget.Menu, { - - - -// Private properties - - -/** -* @property _oTrigger -* @description Object reference to the current value of the "trigger" -* configuration property. -* @default null -* @private -* @type String|<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/leve -* l-one-html.html#ID-58190037">HTMLElement</a>|Array -*/ -_oTrigger: null, - - -/** -* @property _bCancelled -* @description Boolean indicating if the display of the context menu should -* be cancelled. -* @default false -* @private -* @type Boolean -*/ -_bCancelled: false, - - -// Public properties - - -/** -* @property contextEventTarget -* @description Object reference for the HTML element that was the target of the -* "contextmenu" DOM event ("mousedown" for Opera) that triggered the display of -* the context menu. -* @default null -* @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-58190037">HTMLElement</a> -*/ -contextEventTarget: null, - - - -// Events - - -/** -* @event triggerContextMenuEvent -* @description Custom Event wrapper for the "contextmenu" DOM event -* ("mousedown" for Opera) fired by the element(s) that trigger the display of -* the context menu. -*/ -triggerContextMenuEvent: null, - - - - - -/** -* @method init -* @description The ContextMenu class's initialization method. This method is -* automatically called by the constructor, and sets up all DOM references for -* pre-existing markup, and creates required markup if it is not already present. -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the context menu. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source for -* the context menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object specifying the -* <code><div></code> element of the context menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-94282980">HTMLSelectElement</a>} p_oElement Object specifying -* the <code><select></code> element to be used as the data source for -* the context menu. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the context menu. See configuration class documentation -* for more details. -*/ -init: function(p_oElement, p_oConfig) { - - if(!this.ITEM_TYPE) { - - this.ITEM_TYPE = YAHOO.widget.ContextMenuItem; - - } - - - // Call the init of the superclass (YAHOO.widget.Menu) - - YAHOO.widget.ContextMenu.superclass.init.call(this, p_oElement); - - - this.beforeInitEvent.fire(YAHOO.widget.ContextMenu); - - - if(p_oConfig) { - - this.cfg.applyConfig(p_oConfig, true); - - } - - - this.initEvent.fire(YAHOO.widget.ContextMenu); - -}, - - -/** -* @method initEvents -* @description Initializes the custom events for the context menu. -*/ -initEvents: function() { - - YAHOO.widget.ContextMenu.superclass.initEvents.call(this); - - // Create custom events - - this.triggerContextMenuEvent = - new YAHOO.util.CustomEvent("triggerContextMenuEvent", this); - -}, - - -/** -* @method cancel -* @description Cancels the display of the context menu. -*/ -cancel: function() { - - this._bCancelled = true; - -}, - - - -// Private methods - - -/** -* @method _removeEventHandlers -* @description Removes all of the DOM event handlers from the HTML element(s) -* whose "context menu" event ("click" for Opera) trigger the display of -* the context menu. -* @private -*/ -_removeEventHandlers: function() { - - var Event = YAHOO.util.Event, - oTrigger = this._oTrigger, - bOpera = (this.browser == "opera"); - - - // Remove the event handlers from the trigger(s) - - Event.removeListener( - oTrigger, - (bOpera ? "mousedown" : "contextmenu"), - this._onTriggerContextMenu - ); - - if(bOpera) { - - Event.removeListener(oTrigger, "click", this._onTriggerClick); - - } - -}, - - - -// Private event handlers - - -/** -* @method _onTriggerClick -* @description "click" event handler for the HTML element(s) identified as the -* "trigger" for the context menu. Used to cancel default behaviors in Opera. -* @private -* @param {Event} p_oEvent Object representing the DOM event object passed back -* by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.ContextMenu} p_oMenu Object representing the context -* menu that is handling the event. -*/ -_onTriggerClick: function(p_oEvent, p_oMenu) { - - if(p_oEvent.ctrlKey) { - - YAHOO.util.Event.stopEvent(p_oEvent); - - } - -}, - - -/** -* @method _onTriggerContextMenu -* @description "contextmenu" event handler ("mousedown" for Opera) for the HTML -* element(s) that trigger the display of the context menu. -* @private -* @param {Event} p_oEvent Object representing the DOM event object passed back -* by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.ContextMenu} p_oMenu Object representing the context -* menu that is handling the event. -*/ -_onTriggerContextMenu: function(p_oEvent, p_oMenu) { - - var Event = YAHOO.util.Event; - - if(p_oEvent.type == "mousedown" && !p_oEvent.ctrlKey) { - - return; - - } - - - /* - Prevent the browser's default context menu from appearing and - stop the propagation of the "contextmenu" event so that - other ContextMenu instances are not displayed. - */ - - Event.stopEvent(p_oEvent); - - - // Hide any other ContextMenu instances that might be visible - - YAHOO.widget.MenuManager.hideVisible(); - - - this.contextEventTarget = Event.getTarget(p_oEvent); - - this.triggerContextMenuEvent.fire(p_oEvent); - - - if(!this._bCancelled) { - - // Position and display the context menu - - this.cfg.setProperty("xy", Event.getXY(p_oEvent)); - - this.show(); - - } - - this._bCancelled = false; - -}, - - - -// Public methods - - -/** -* @method toString -* @description Returns a string representing the context menu. -* @return {String} -*/ -toString: function() { - - return ("ContextMenu " + this.id); - -}, - - -/** -* @method initDefaultConfig -* @description Initializes the class's configurable properties which can be -* changed using the context menu's Config object ("cfg"). -*/ -initDefaultConfig: function() { - - YAHOO.widget.ContextMenu.superclass.initDefaultConfig.call(this); - - /** - * @config trigger - * @description The HTML element(s) whose "contextmenu" event ("mousedown" - * for Opera) trigger the display of the context menu. Can be a string - * representing the id attribute of the HTML element, an object reference - * for the HTML element, or an array of strings or HTML element references. - * @default null - * @type String|<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|Array - */ - this.cfg.addProperty("trigger", { handler: this.configTrigger }); - -}, - - -/** -* @method destroy -* @description Removes the context menu's <code><div></code> element -* (and accompanying child nodes) from the document. -*/ -destroy: function() { - - // Remove the DOM event handlers from the current trigger(s) - - this._removeEventHandlers(); - - - // Continue with the superclass implementation of this method - - YAHOO.widget.ContextMenu.superclass.destroy.call(this); - -}, - - - -// Public event handlers for configuration properties - - -/** -* @method configTrigger -* @description Event handler for when the value of the "trigger" configuration -* property changes. -* @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.ContextMenu} p_oMenu Object representing the context -* menu that fired the event. -*/ -configTrigger: function(p_sType, p_aArgs, p_oMenu) { - - var Event = YAHOO.util.Event, - oTrigger = p_aArgs[0]; - - if(oTrigger) { - - /* - If there is a current "trigger" - remove the event handlers - from that element(s) before assigning new ones - */ - - if(this._oTrigger) { - - this._removeEventHandlers(); - - } - - this._oTrigger = oTrigger; - - - /* - Listen for the "mousedown" event in Opera b/c it does not - support the "contextmenu" event - */ - - var bOpera = (this.browser == "opera"); - - Event.addListener( - oTrigger, - (bOpera ? "mousedown" : "contextmenu"), - this._onTriggerContextMenu, - this, - true - ); - - - /* - Assign a "click" event handler to the trigger element(s) for - Opera to prevent default browser behaviors. - */ - - if(bOpera) { - - Event.addListener( - oTrigger, - "click", - this._onTriggerClick, - this, - true - ); - - } - - } - else { - - this._removeEventHandlers(); - - } - -} - -}); // END YAHOO.lang.extend - - - -/** -* Creates an item for a context menu. -* -* @param {String} p_oObject String specifying the text of the context menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying the -* <code><li></code> element of the context menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the context -* menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object specifying -* the <code><option></code> element of the context menu item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the context menu item. See configuration class -* documentation for more details. -* @class ContextMenuItem -* @constructor -* @extends YAHOO.widget.MenuItem -*/ -YAHOO.widget.ContextMenuItem = function(p_oObject, p_oConfig) { - - YAHOO.widget.ContextMenuItem.superclass.constructor.call( - this, - p_oObject, - p_oConfig - ); - -}; - -YAHOO.lang.extend(YAHOO.widget.ContextMenuItem, YAHOO.widget.MenuItem, { - - -/** -* @method init -* @description The ContextMenuItem class's initialization method. This method -* is automatically called by the constructor, and sets up all DOM references -* for pre-existing markup, and creates required markup if it is not -* already present. -* @param {String} p_oObject String specifying the text of the context menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying the -* <code><li></code> element of the context menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the context -* menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object specifying -* the <code><option></code> element of the context menu item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the context menu item. See configuration class -* documentation for more details. -*/ -init: function(p_oObject, p_oConfig) { - - if(!this.SUBMENU_TYPE) { - - this.SUBMENU_TYPE = YAHOO.widget.ContextMenu; - - } - - - /* - Call the init of the superclass (YAHOO.widget.MenuItem) - Note: We don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.ContextMenuItem.superclass.init.call(this, p_oObject); - - var oConfig = this.cfg; - - if(p_oConfig) { - - oConfig.applyConfig(p_oConfig, true); - - } - - oConfig.fireQueue(); - -}, - - - -// Public methods - - -/** -* @method toString -* @description Returns a string representing the context menu item. -* @return {String} -*/ -toString: function() { - - return ("ContextMenuItem: " + this.cfg.getProperty("text")); - -} - -}); // END YAHOO.lang.extend - - - -/** -* Horizontal collection of items, each of which can contain a submenu. -* -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the menu bar. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source for the -* menu bar. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object specifying -* the <code><div></code> element of the menu bar. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement Object -* specifying the <code><select></code> element to be used as the data -* source for the menu bar. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu bar. See configuration class documentation for -* more details. -* @class Menubar -* @constructor -* @extends YAHOO.widget.Menu -* @namespace YAHOO.widget -*/ -YAHOO.widget.MenuBar = function(p_oElement, p_oConfig) { - - YAHOO.widget.MenuBar.superclass.constructor.call( - this, - p_oElement, - p_oConfig - ); - -}; - -YAHOO.lang.extend(YAHOO.widget.MenuBar, YAHOO.widget.Menu, { - -/** -* @method init -* @description The MenuBar class's initialization method. This method is -* automatically called by the constructor, and sets up all DOM references for -* pre-existing markup, and creates required markup if it is not already present. -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the menu bar. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source for the -* menu bar. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object specifying -* the <code><div></code> element of the menu bar. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement Object -* specifying the <code><select></code> element to be used as the data -* source for the menu bar. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu bar. See configuration class documentation for -* more details. -*/ -init: function(p_oElement, p_oConfig) { - - if(!this.ITEM_TYPE) { - - this.ITEM_TYPE = YAHOO.widget.MenuBarItem; - - } - - - // Call the init of the superclass (YAHOO.widget.Menu) - - YAHOO.widget.MenuBar.superclass.init.call(this, p_oElement); - - - this.beforeInitEvent.fire(YAHOO.widget.MenuBar); - - - if(p_oConfig) { - - this.cfg.applyConfig(p_oConfig, true); - - } - - this.initEvent.fire(YAHOO.widget.MenuBar); - -}, - - - -// Constants - - -/** -* @property CSS_CLASS_NAME -* @description String representing the CSS class(es) to be applied to the menu -* bar's <code><div></code> element. -* @default "yuimenubar" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuimenubar", - - - -// Protected event handlers - - -/** -* @method _onKeyDown -* @description "keydown" Custom Event handler for the menu bar. -* @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.MenuBar} p_oMenuBar Object representing the menu bar -* that fired the event. -*/ -_onKeyDown: function(p_sType, p_aArgs, p_oMenuBar) { - - var Event = YAHOO.util.Event, - oEvent = p_aArgs[0], - oItem = p_aArgs[1], - oSubmenu; - - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var oItemCfg = oItem.cfg; - - switch(oEvent.keyCode) { - - case 37: // Left arrow - case 39: // Right arrow - - if( - oItem == this.activeItem && - !oItemCfg.getProperty("selected") - ) { - - oItemCfg.setProperty("selected", true); - - } - else { - - var oNextItem = (oEvent.keyCode == 37) ? - oItem.getPreviousEnabledSibling() : - oItem.getNextEnabledSibling(); - - if(oNextItem) { - - this.clearActiveItem(); - - oNextItem.cfg.setProperty("selected", true); - - - if(this.cfg.getProperty("autosubmenudisplay")) { - - oSubmenu = oNextItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.show(); - oSubmenu.activeItem.blur(); - oSubmenu.activeItem = null; - - } - - } - - oNextItem.focus(); - - } - - } - - Event.preventDefault(oEvent); - - break; - - case 40: // Down arrow - - if(this.activeItem != oItem) { - - this.clearActiveItem(); - - oItemCfg.setProperty("selected", true); - oItem.focus(); - - } - - oSubmenu = oItemCfg.getProperty("submenu"); - - if(oSubmenu) { - - if(oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.setInitialSelection(); - oSubmenu.setInitialFocus(); - - } - else { - - oSubmenu.show(); - - } - - } - - Event.preventDefault(oEvent); - - break; - - } - - } - - - if(oEvent.keyCode == 27 && this.activeItem) { // Esc key - - oSubmenu = this.activeItem.cfg.getProperty("submenu"); - - if(oSubmenu && oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.hide(); - this.activeItem.focus(); - - } - else { - - this.activeItem.cfg.setProperty("selected", false); - this.activeItem.blur(); - - } - - Event.preventDefault(oEvent); - - } - -}, - - -/** -* @method _onClick -* @description "click" event handler for the menu bar. -* @protected -* @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.MenuBar} p_oMenuBar Object representing the menu bar -* that fired the event. -*/ -_onClick: function(p_sType, p_aArgs, p_oMenuBar) { - - YAHOO.widget.MenuBar.superclass._onClick.call( - this, - p_sType, - p_aArgs, - p_oMenuBar - ); - - - var oItem = p_aArgs[1]; - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var Event = YAHOO.util.Event, - Dom = YAHOO.util.Dom, - - oEvent = p_aArgs[0], - oTarget = Event.getTarget(oEvent), - - oActiveItem = this.activeItem, - oConfig = this.cfg; - - - // Hide any other submenus that might be visible - - if(oActiveItem && oActiveItem != oItem) { - - this.clearActiveItem(); - - } - - - // Select and focus the current item - - oItem.cfg.setProperty("selected", true); - oItem.focus(); - - - // Show the submenu for the item - - var oSubmenu = oItem.cfg.getProperty("submenu"); - - - if(oSubmenu && oTarget != oItem.submenuIndicator) { - - if(oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.hide(); - - } - else { - - oSubmenu.show(); - - } - - } - - } - -}, - - - -// Public methods - - -/** -* @method toString -* @description Returns a string representing the menu bar. -* @return {String} -*/ -toString: function() { - - return ("MenuBar " + this.id); - -}, - - -/** -* @description Initializes the class's configurable properties which can be -* changed using the menu bar's Config object ("cfg"). -* @method initDefaultConfig -*/ -initDefaultConfig: function() { - - YAHOO.widget.MenuBar.superclass.initDefaultConfig.call(this); - - var oConfig = this.cfg; - - // Add configuration properties - - - /* - Set the default value for the "position" configuration property - to "static" by re-adding the property. - */ - - /** - * @config position - * @description String indicating how a menu bar should be positioned on the - * screen. Possible values are "static" and "dynamic." Static menu bars - * are visible by default and reside in the normal flow of the document - * (CSS position: static). Dynamic menu bars are hidden by default, reside - * out of the normal flow of the document (CSS position: absolute), and can - * overlay other elements on the screen. - * @default static - * @type String - */ - oConfig.addProperty( - "position", - { - value: "static", - handler: this.configPosition, - validator: this._checkPosition, - supercedes: ["visible"] - } - ); - - - /* - Set the default value for the "submenualignment" configuration property - to ["tl","bl"] by re-adding the property. - */ - - /** - * @config submenualignment - * @description Array defining how submenus should be aligned to their - * parent menu bar item. The format is: [itemCorner, submenuCorner]. - * @default ["tl","bl"] - * @type Array - */ - oConfig.addProperty("submenualignment", { value: ["tl","bl"] } ); - - - /* - Change the default value for the "autosubmenudisplay" configuration - property to "false" by re-adding the property. - */ - - /** - * @config autosubmenudisplay - * @description Boolean indicating if submenus are automatically made - * visible when the user mouses over the menu bar's items. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "autosubmenudisplay", - { value: false, validator: oConfig.checkBoolean } - ); - -} - -}); // END YAHOO.lang.extend - - - -/** -* Creates an item for a menu bar. -* -* @param {String} p_oObject String specifying the text of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying the -* <code><li></code> element of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object specifying -* the <code><option></code> element of the menu bar item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu bar item. See configuration class documentation -* for more details. -* @class MenuBarItem -* @constructor -* @extends YAHOO.widget.MenuItem -*/ -YAHOO.widget.MenuBarItem = function(p_oObject, p_oConfig) { - - YAHOO.widget.MenuBarItem.superclass.constructor.call( - this, - p_oObject, - p_oConfig - ); - -}; - -YAHOO.lang.extend(YAHOO.widget.MenuBarItem, YAHOO.widget.MenuItem, { - - -/** -* @method init -* @description The MenuBarItem class's initialization method. This method is -* automatically called by the constructor, and sets up all DOM references for -* pre-existing markup, and creates required markup if it is not already present. -* @param {String} p_oObject String specifying the text of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying the -* <code><li></code> element of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object specifying -* the <code><option></code> element of the menu bar item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu bar item. See configuration class documentation -* for more details. -*/ -init: function(p_oObject, p_oConfig) { - - if(!this.SUBMENU_TYPE) { - - this.SUBMENU_TYPE = YAHOO.widget.Menu; - - } - - - /* - Call the init of the superclass (YAHOO.widget.MenuItem) - Note: We don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.MenuBarItem.superclass.init.call(this, p_oObject); - - - var oConfig = this.cfg; - - if(p_oConfig) { - - oConfig.applyConfig(p_oConfig, true); - - } - - oConfig.fireQueue(); - -}, - - - -// Constants - -/** -* @property CSS_CLASS_NAME -* @description String representing the CSS class(es) to be applied to the -* <code><li></code> element of the menu bar item. -* @default "yuimenubaritem" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuimenubaritem", - - - -// Public methods - - -/** -* @method toString -* @description Returns a string representing the menu bar item. -* @return {String} -*/ -toString: function() { - - return ("MenuBarItem: " + this.cfg.getProperty("text")); - -} - -}); // END YAHOO.lang.extend -YAHOO.register("menu", YAHOO.widget.Menu, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/menu/menu-min.js b/interface/web/js/yui/menu/menu-min.js deleted file mode 100644 index e74783e2d0..0000000000 --- a/interface/web/js/yui/menu/menu-min.js +++ /dev/null @@ -1,260 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event;YAHOO.widget.MenuManager=function(){var m_bInitializedEventHandlers=false,m_oMenus={},m_oItems={},m_oVisibleMenus={},me=this;function addItem(p_oItem){var sId=p_oItem.id;if(p_oItem&&m_oItems[sId]!=p_oItem){m_oItems[sId]=p_oItem;p_oItem.destroyEvent.subscribe(onItemDestroy,p_oItem);}} -function removeItem(p_oItem){var sId=p_oItem.id;if(sId&&m_oItems[sId]){delete m_oItems[sId];}} -function getMenuRootElement(p_oElement){var oParentNode;if(p_oElement&&p_oElement.tagName){switch(p_oElement.tagName.toUpperCase()){case"DIV":oParentNode=p_oElement.parentNode;if((Dom.hasClass(p_oElement,"hd")||Dom.hasClass(p_oElement,"bd")||Dom.hasClass(p_oElement,"ft"))&&oParentNode&&oParentNode.tagName&&oParentNode.tagName.toUpperCase()=="DIV"){return oParentNode;} -else{return p_oElement;} -break;case"LI":return p_oElement;default:oParentNode=p_oElement.parentNode;if(oParentNode){return getMenuRootElement(oParentNode);} -break;}}} -function onDOMEvent(p_oEvent){var oTarget=Event.getTarget(p_oEvent),oElement=getMenuRootElement(oTarget),oMenuItem,oMenu;if(oElement){var sTagName=oElement.tagName.toUpperCase();if(sTagName=="LI"){var sId=oElement.id;if(sId&&m_oItems[sId]){oMenuItem=m_oItems[sId];oMenu=oMenuItem.parent;}} -else if(sTagName=="DIV"){if(oElement.id){oMenu=m_oMenus[oElement.id];}}} -if(oMenu){var oEventTypes={"click":"clickEvent","mousedown":"mouseDownEvent","mouseup":"mouseUpEvent","mouseover":"mouseOverEvent","mouseout":"mouseOutEvent","keydown":"keyDownEvent","keyup":"keyUpEvent","keypress":"keyPressEvent"},sCustomEventType=oEventTypes[p_oEvent.type];if(oMenuItem&&!oMenuItem.cfg.getProperty("disabled")){oMenuItem[sCustomEventType].fire(p_oEvent);} -oMenu[sCustomEventType].fire(p_oEvent,oMenuItem);} -else if(p_oEvent.type=="mousedown"){var oActiveItem;for(var i in m_oMenus){if(m_oMenus.hasOwnProperty(i)){oMenu=m_oMenus[i];if(oMenu.cfg.getProperty("clicktohide")&&oMenu.cfg.getProperty("position")=="dynamic"){oMenu.hide();} -else{oMenu.clearActiveItem(true);}}}}} -function onMenuDestroy(p_sType,p_aArgs,p_oMenu){if(p_oMenu&&m_oMenus[p_oMenu.id]){delete m_oMenus[p_oMenu.id];}} -function onItemDestroy(p_sType,p_aArgs,p_oItem){var sId=p_oItem.id;if(sId&&m_oItems[sId]){delete m_oItems[sId];}} -function onMenuVisibleConfigChange(p_sType,p_aArgs,p_oMenu){var bVisible=p_aArgs[0];if(bVisible){m_oVisibleMenus[p_oMenu.id]=p_oMenu;} -else if(m_oVisibleMenus[p_oMenu.id]){delete m_oVisibleMenus[p_oMenu.id];}} -function onItemAdded(p_sType,p_aArgs){addItem(p_aArgs[0]);} -function onItemRemoved(p_sType,p_aArgs){removeItem(p_aArgs[0]);} -return{addMenu:function(p_oMenu){if(p_oMenu&&p_oMenu.id&&!m_oMenus[p_oMenu.id]){m_oMenus[p_oMenu.id]=p_oMenu;if(!m_bInitializedEventHandlers){var oDoc=document;Event.addListener(oDoc,"mouseover",onDOMEvent,me,true);Event.addListener(oDoc,"mouseout",onDOMEvent,me,true);Event.addListener(oDoc,"mousedown",onDOMEvent,me,true);Event.addListener(oDoc,"mouseup",onDOMEvent,me,true);Event.addListener(oDoc,"click",onDOMEvent,me,true);Event.addListener(oDoc,"keydown",onDOMEvent,me,true);Event.addListener(oDoc,"keyup",onDOMEvent,me,true);Event.addListener(oDoc,"keypress",onDOMEvent,me,true);m_bInitializedEventHandlers=true;} -p_oMenu.destroyEvent.subscribe(onMenuDestroy,p_oMenu,me);p_oMenu.cfg.subscribeToConfigEvent("visible",onMenuVisibleConfigChange,p_oMenu);p_oMenu.itemAddedEvent.subscribe(onItemAdded);p_oMenu.itemRemovedEvent.subscribe(onItemRemoved);}},removeMenu:function(p_oMenu){if(p_oMenu&&m_oMenus[p_oMenu.id]){delete m_oMenus[p_oMenu.id];}},hideVisible:function(){var oMenu;for(var i in m_oVisibleMenus){if(m_oVisibleMenus.hasOwnProperty(i)){oMenu=m_oVisibleMenus[i];if(oMenu.cfg.getProperty("position")=="dynamic"){oMenu.hide();}}}},getMenus:function(){return m_oMenus;},getMenu:function(p_sId){if(m_oMenus[p_sId]){return m_oMenus[p_sId];}},toString:function(){return("MenuManager");}};}();})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event,Lang=YAHOO.lang;YAHOO.widget.Menu=function(p_oElement,p_oConfig){if(p_oConfig){this.parent=p_oConfig.parent;this.lazyLoad=p_oConfig.lazyLoad||p_oConfig.lazyload;this.itemData=p_oConfig.itemData||p_oConfig.itemdata;} -YAHOO.widget.Menu.superclass.constructor.call(this,p_oElement,p_oConfig);};YAHOO.lang.extend(YAHOO.widget.Menu,YAHOO.widget.Overlay,{CSS_CLASS_NAME:"yuimenu",ITEM_TYPE:null,GROUP_TITLE_TAG_NAME:"h6",_nHideDelayId:null,_nShowDelayId:null,_nSubmenuHideDelayId:null,_nBodyScrollId:null,_bHideDelayEventHandlersAssigned:false,_bHandledMouseOverEvent:false,_bHandledMouseOutEvent:false,_aGroupTitleElements:null,_aItemGroups:null,_aListElements:null,_nCurrentMouseX:0,_nMaxHeight:-1,_bStopMouseEventHandlers:false,_sClassName:null,lazyLoad:false,itemData:null,activeItem:null,parent:null,srcElement:null,mouseOverEvent:null,mouseOutEvent:null,mouseDownEvent:null,mouseUpEvent:null,clickEvent:null,keyPressEvent:null,keyDownEvent:null,keyUpEvent:null,itemAddedEvent:null,itemRemovedEvent:null,init:function(p_oElement,p_oConfig){this._aItemGroups=[];this._aListElements=[];this._aGroupTitleElements=[];if(!this.ITEM_TYPE){this.ITEM_TYPE=YAHOO.widget.MenuItem;} -var oElement;if(typeof p_oElement=="string"){oElement=document.getElementById(p_oElement);} -else if(p_oElement.tagName){oElement=p_oElement;} -if(oElement&&oElement.tagName){switch(oElement.tagName.toUpperCase()){case"DIV":this.srcElement=oElement;if(!oElement.id){oElement.setAttribute("id",Dom.generateId());} -YAHOO.widget.Menu.superclass.init.call(this,oElement);this.beforeInitEvent.fire(YAHOO.widget.Menu);break;case"SELECT":this.srcElement=oElement;YAHOO.widget.Menu.superclass.init.call(this,Dom.generateId());this.beforeInitEvent.fire(YAHOO.widget.Menu);break;}} -else{YAHOO.widget.Menu.superclass.init.call(this,p_oElement);this.beforeInitEvent.fire(YAHOO.widget.Menu);} -if(this.element){var oEl=this.element;Dom.addClass(oEl,this.CSS_CLASS_NAME);this.initEvent.subscribe(this._onInit,this,true);this.beforeRenderEvent.subscribe(this._onBeforeRender,this,true);this.renderEvent.subscribe(this._setWidth,this,true);this.beforeShowEvent.subscribe(this._onBeforeShow,this,true);this.showEvent.subscribe(this._onShow,this,true);this.beforeHideEvent.subscribe(this._onBeforeHide,this,true);this.hideEvent.subscribe(this._onHide,this,true);this.mouseOverEvent.subscribe(this._onMouseOver,this,true);this.mouseOutEvent.subscribe(this._onMouseOut,this,true);this.clickEvent.subscribe(this._onClick,this,true);this.keyDownEvent.subscribe(this._onKeyDown,this,true);this.keyPressEvent.subscribe(this._onKeyPress,this,true);YAHOO.widget.Module.textResizeEvent.subscribe(this._onTextResize,this,true);if(p_oConfig){this.cfg.applyConfig(p_oConfig,true);} -YAHOO.widget.MenuManager.addMenu(this);this.initEvent.fire(YAHOO.widget.Menu);}},_initSubTree:function(){var oNode;if(this.srcElement.tagName.toUpperCase()=="DIV"){oNode=this.body.firstChild;var nGroup=0,sGroupTitleTagName=this.GROUP_TITLE_TAG_NAME.toUpperCase();do{if(oNode&&oNode.tagName){switch(oNode.tagName.toUpperCase()){case sGroupTitleTagName:this._aGroupTitleElements[nGroup]=oNode;break;case"UL":this._aListElements[nGroup]=oNode;this._aItemGroups[nGroup]=[];nGroup++;break;}}} -while((oNode=oNode.nextSibling));if(this._aListElements[0]){Dom.addClass(this._aListElements[0],"first-of-type");}} -oNode=null;if(this.srcElement.tagName){var sSrcElementTagName=this.srcElement.tagName.toUpperCase();switch(sSrcElementTagName){case"DIV":if(this._aListElements.length>0){var i=this._aListElements.length-1;do{oNode=this._aListElements[i].firstChild;do{if(oNode&&oNode.tagName&&oNode.tagName.toUpperCase()=="LI"){this.addItem(new this.ITEM_TYPE(oNode,{parent:this}),i);}} -while((oNode=oNode.nextSibling));} -while(i--);} -break;case"SELECT":oNode=this.srcElement.firstChild;do{if(oNode&&oNode.tagName){switch(oNode.tagName.toUpperCase()){case"OPTGROUP":case"OPTION":this.addItem(new this.ITEM_TYPE(oNode,{parent:this}));break;}}} -while((oNode=oNode.nextSibling));break;}}},_getFirstEnabledItem:function(){var aItems=this.getItems(),nItems=aItems.length,oItem;for(var i=0;i<nItems;i++){oItem=aItems[i];if(oItem&&!oItem.cfg.getProperty("disabled")&&oItem.element.style.display!="none"){return oItem;}}},_checkPosition:function(p_sPosition){if(typeof p_sPosition=="string"){var sPosition=p_sPosition.toLowerCase();return("dynamic,static".indexOf(sPosition)!=-1);}},_addItemToGroup:function(p_nGroupIndex,p_oItem,p_nItemIndex){var oItem;if(p_oItem instanceof this.ITEM_TYPE){oItem=p_oItem;oItem.parent=this;} -else if(typeof p_oItem=="string"){oItem=new this.ITEM_TYPE(p_oItem,{parent:this});} -else if(typeof p_oItem=="object"){p_oItem.parent=this;oItem=new this.ITEM_TYPE(p_oItem.text,p_oItem);} -if(oItem){var nGroupIndex=typeof p_nGroupIndex=="number"?p_nGroupIndex:0,aGroup=this._getItemGroup(nGroupIndex),oGroupItem;if(!aGroup){aGroup=this._createItemGroup(nGroupIndex);} -if(typeof p_nItemIndex=="number"){var bAppend=(p_nItemIndex>=aGroup.length);if(aGroup[p_nItemIndex]){aGroup.splice(p_nItemIndex,0,oItem);} -else{aGroup[p_nItemIndex]=oItem;} -oGroupItem=aGroup[p_nItemIndex];if(oGroupItem){if(bAppend&&(!oGroupItem.element.parentNode||oGroupItem.element.parentNode.nodeType==11)){this._aListElements[nGroupIndex].appendChild(oGroupItem.element);} -else{function getNextItemSibling(p_aArray,p_nStartIndex){return(p_aArray[p_nStartIndex]||getNextItemSibling(p_aArray,(p_nStartIndex+1)));} -var oNextItemSibling=getNextItemSibling(aGroup,(p_nItemIndex+1));if(oNextItemSibling&&(!oGroupItem.element.parentNode||oGroupItem.element.parentNode.nodeType==11)){this._aListElements[nGroupIndex].insertBefore(oGroupItem.element,oNextItemSibling.element);}} -oGroupItem.parent=this;this._subscribeToItemEvents(oGroupItem);this._configureSubmenu(oGroupItem);this._updateItemProperties(nGroupIndex);this.itemAddedEvent.fire(oGroupItem);return oGroupItem;}} -else{var nItemIndex=aGroup.length;aGroup[nItemIndex]=oItem;oGroupItem=aGroup[nItemIndex];if(oGroupItem){if(!Dom.isAncestor(this._aListElements[nGroupIndex],oGroupItem.element)){this._aListElements[nGroupIndex].appendChild(oGroupItem.element);} -oGroupItem.element.setAttribute("groupindex",nGroupIndex);oGroupItem.element.setAttribute("index",nItemIndex);oGroupItem.parent=this;oGroupItem.index=nItemIndex;oGroupItem.groupIndex=nGroupIndex;this._subscribeToItemEvents(oGroupItem);this._configureSubmenu(oGroupItem);if(nItemIndex===0){Dom.addClass(oGroupItem.element,"first-of-type");} -this.itemAddedEvent.fire(oGroupItem);return oGroupItem;}}}},_removeItemFromGroupByIndex:function(p_nGroupIndex,p_nItemIndex){var nGroupIndex=typeof p_nGroupIndex=="number"?p_nGroupIndex:0,aGroup=this._getItemGroup(nGroupIndex);if(aGroup){var aArray=aGroup.splice(p_nItemIndex,1),oItem=aArray[0];if(oItem){this._updateItemProperties(nGroupIndex);if(aGroup.length===0){var oUL=this._aListElements[nGroupIndex];if(this.body&&oUL){this.body.removeChild(oUL);} -this._aItemGroups.splice(nGroupIndex,1);this._aListElements.splice(nGroupIndex,1);oUL=this._aListElements[0];if(oUL){Dom.addClass(oUL,"first-of-type");}} -this.itemRemovedEvent.fire(oItem);return oItem;}}},_removeItemFromGroupByValue:function(p_nGroupIndex,p_oItem){var aGroup=this._getItemGroup(p_nGroupIndex);if(aGroup){var nItems=aGroup.length,nItemIndex=-1;if(nItems>0){var i=nItems-1;do{if(aGroup[i]==p_oItem){nItemIndex=i;break;}} -while(i--);if(nItemIndex>-1){return this._removeItemFromGroupByIndex(p_nGroupIndex,nItemIndex);}}}},_updateItemProperties:function(p_nGroupIndex){var aGroup=this._getItemGroup(p_nGroupIndex),nItems=aGroup.length;if(nItems>0){var i=nItems-1,oItem,oLI;do{oItem=aGroup[i];if(oItem){oLI=oItem.element;oItem.index=i;oItem.groupIndex=p_nGroupIndex;oLI.setAttribute("groupindex",p_nGroupIndex);oLI.setAttribute("index",i);Dom.removeClass(oLI,"first-of-type");}} -while(i--);if(oLI){Dom.addClass(oLI,"first-of-type");}}},_createItemGroup:function(p_nIndex){if(!this._aItemGroups[p_nIndex]){this._aItemGroups[p_nIndex]=[];var oUL=document.createElement("ul");this._aListElements[p_nIndex]=oUL;return this._aItemGroups[p_nIndex];}},_getItemGroup:function(p_nIndex){var nIndex=((typeof p_nIndex=="number")?p_nIndex:0);return this._aItemGroups[nIndex];},_configureSubmenu:function(p_oItem){var oSubmenu=p_oItem.cfg.getProperty("submenu");if(oSubmenu){this.cfg.configChangedEvent.subscribe(this._onParentMenuConfigChange,oSubmenu,true);this.renderEvent.subscribe(this._onParentMenuRender,oSubmenu,true);oSubmenu.beforeShowEvent.subscribe(this._onSubmenuBeforeShow,oSubmenu,true);oSubmenu.showEvent.subscribe(this._onSubmenuShow,oSubmenu,true);oSubmenu.hideEvent.subscribe(this._onSubmenuHide,oSubmenu,true);}},_subscribeToItemEvents:function(p_oItem){p_oItem.focusEvent.subscribe(this._onMenuItemFocus,p_oItem,this);p_oItem.blurEvent.subscribe(this._onMenuItemBlur,this,true);p_oItem.cfg.configChangedEvent.subscribe(this._onMenuItemConfigChange,p_oItem,this);},_getOffsetWidth:function(){var oClone=this.element.cloneNode(true);Dom.setStyle(oClone,"width","");document.body.appendChild(oClone);var sWidth=oClone.offsetWidth;document.body.removeChild(oClone);return sWidth;},_setWidth:function(){if(this.cfg.getProperty("position")=="dynamic"){var sWidth;if(this.element.parentNode.tagName.toUpperCase()=="BODY"){if(this.browser=="opera"){sWidth=this._getOffsetWidth();} -else{Dom.setStyle(this.element,"width","auto");sWidth=this.element.offsetWidth;}} -else{sWidth=this._getOffsetWidth();} -this.cfg.setProperty("width",(sWidth+"px"));}},_cancelHideDelay:function(){var oRoot=this.getRoot();if(oRoot._nHideDelayId){window.clearTimeout(oRoot._nHideDelayId);}},_execHideDelay:function(){this._cancelHideDelay();var oRoot=this.getRoot(),me=this;function hideMenu(){if(oRoot.activeItem){oRoot.clearActiveItem();} -if(oRoot==me&&me.cfg.getProperty("position")=="dynamic"){me.hide();}} -oRoot._nHideDelayId=window.setTimeout(hideMenu,oRoot.cfg.getProperty("hidedelay"));},_cancelShowDelay:function(){var oRoot=this.getRoot();if(oRoot._nShowDelayId){window.clearTimeout(oRoot._nShowDelayId);}},_execShowDelay:function(p_oMenu){var oRoot=this.getRoot();function showMenu(){if(p_oMenu.parent.cfg.getProperty("selected")){p_oMenu.show();}} -oRoot._nShowDelayId=window.setTimeout(showMenu,oRoot.cfg.getProperty("showdelay"));},_execSubmenuHideDelay:function(p_oSubmenu,p_nMouseX,p_nHideDelay){var me=this;p_oSubmenu._nSubmenuHideDelayId=window.setTimeout(function(){if(me._nCurrentMouseX>(p_nMouseX+10)){p_oSubmenu._nSubmenuHideDelayId=window.setTimeout(function(){p_oSubmenu.hide();},p_nHideDelay);} -else{p_oSubmenu.hide();}},50);},_disableScrollHeader:function(){if(!this._bHeaderDisabled){Dom.addClass(this.header,"topscrollbar_disabled");this._bHeaderDisabled=true;}},_disableScrollFooter:function(){if(!this._bFooterDisabled){Dom.addClass(this.footer,"bottomscrollbar_disabled");this._bFooterDisabled=true;}},_enableScrollHeader:function(){if(this._bHeaderDisabled){Dom.removeClass(this.header,"topscrollbar_disabled");this._bHeaderDisabled=false;}},_enableScrollFooter:function(){if(this._bFooterDisabled){Dom.removeClass(this.footer,"bottomscrollbar_disabled");this._bFooterDisabled=false;}},_onMouseOver:function(p_sType,p_aArgs,p_oMenu){if(this._bStopMouseEventHandlers){return false;} -var oEvent=p_aArgs[0],oItem=p_aArgs[1],oTarget=Event.getTarget(oEvent);if(!this._bHandledMouseOverEvent&&(oTarget==this.element||Dom.isAncestor(this.element,oTarget))){this._nCurrentMouseX=0;Event.addListener(this.element,"mousemove",this._onMouseMove,this,true);this.clearActiveItem();if(this.parent&&this._nSubmenuHideDelayId){window.clearTimeout(this._nSubmenuHideDelayId);this.parent.cfg.setProperty("selected",true);var oParentMenu=this.parent.parent;oParentMenu.activeItem=this.parent;oParentMenu._bHandledMouseOutEvent=true;oParentMenu._bHandledMouseOverEvent=false;} -this._bHandledMouseOverEvent=true;this._bHandledMouseOutEvent=false;} -if(oItem&&!oItem.handledMouseOverEvent&&!oItem.cfg.getProperty("disabled")&&(oTarget==oItem.element||Dom.isAncestor(oItem.element,oTarget))){var nShowDelay=this.cfg.getProperty("showdelay"),bShowDelay=(nShowDelay>0);if(bShowDelay){this._cancelShowDelay();} -var oActiveItem=this.activeItem;if(oActiveItem){oActiveItem.cfg.setProperty("selected",false);} -var oItemCfg=oItem.cfg;oItemCfg.setProperty("selected",true);oItem.focus();if(this.cfg.getProperty("autosubmenudisplay")){var oSubmenu=oItemCfg.getProperty("submenu");if(oSubmenu){if(bShowDelay){this._execShowDelay(oSubmenu);} -else{oSubmenu.show();}}} -oItem.handledMouseOverEvent=true;oItem.handledMouseOutEvent=false;}},_onMouseOut:function(p_sType,p_aArgs,p_oMenu){if(this._bStopMouseEventHandlers){return false;} -var oEvent=p_aArgs[0],oItem=p_aArgs[1],oRelatedTarget=Event.getRelatedTarget(oEvent),bMovingToSubmenu=false;if(oItem&&!oItem.cfg.getProperty("disabled")){var oItemCfg=oItem.cfg,oSubmenu=oItemCfg.getProperty("submenu");if(oSubmenu&&(oRelatedTarget==oSubmenu.element||Dom.isAncestor(oSubmenu.element,oRelatedTarget))){bMovingToSubmenu=true;} -if(!oItem.handledMouseOutEvent&&((oRelatedTarget!=oItem.element&&!Dom.isAncestor(oItem.element,oRelatedTarget))||bMovingToSubmenu)){if(!bMovingToSubmenu){oItem.cfg.setProperty("selected",false);if(oSubmenu){var nSubmenuHideDelay=this.cfg.getProperty("submenuhidedelay"),nShowDelay=this.cfg.getProperty("showdelay");if(!(this instanceof YAHOO.widget.MenuBar)&&nSubmenuHideDelay>0&&nShowDelay>=nSubmenuHideDelay){this._execSubmenuHideDelay(oSubmenu,Event.getPageX(oEvent),nSubmenuHideDelay);} -else{oSubmenu.hide();}}} -oItem.handledMouseOutEvent=true;oItem.handledMouseOverEvent=false;}} -if(!this._bHandledMouseOutEvent&&((oRelatedTarget!=this.element&&!Dom.isAncestor(this.element,oRelatedTarget))||bMovingToSubmenu)){Event.removeListener(this.element,"mousemove",this._onMouseMove);this._nCurrentMouseX=Event.getPageX(oEvent);this._bHandledMouseOutEvent=true;this._bHandledMouseOverEvent=false;}},_onMouseMove:function(p_oEvent,p_oMenu){if(this._bStopMouseEventHandlers){return false;} -this._nCurrentMouseX=Event.getPageX(p_oEvent);},_onClick:function(p_sType,p_aArgs,p_oMenu){var oEvent=p_aArgs[0],oItem=p_aArgs[1],oTarget=Event.getTarget(oEvent);if(oItem&&!oItem.cfg.getProperty("disabled")){var oItemCfg=oItem.cfg,oSubmenu=oItemCfg.getProperty("submenu");if(oTarget==oItem.submenuIndicator&&oSubmenu){if(oSubmenu.cfg.getProperty("visible")){oSubmenu.hide();oSubmenu.parent.focus();} -else{this.clearActiveItem();this.activeItem=oItem;oItem.cfg.setProperty("selected",true);oSubmenu.show();}} -else{var sURL=oItemCfg.getProperty("url"),bCurrentPageURL=(sURL.substr((sURL.length-1),1)=="#"),sTarget=oItemCfg.getProperty("target"),bHasTarget=(sTarget&&sTarget.length>0);if(oTarget.tagName.toUpperCase()=="A"&&bCurrentPageURL&&!bHasTarget){Event.preventDefault(oEvent);} -if(oTarget.tagName.toUpperCase()!="A"&&!bCurrentPageURL&&!bHasTarget){document.location=sURL;} -if(bCurrentPageURL&&!oSubmenu){var oRoot=this.getRoot();if(oRoot.cfg.getProperty("position")=="static"){oRoot.clearActiveItem();} -else if(oRoot.cfg.getProperty("clicktohide")){oRoot.hide();}}}}},_onKeyDown:function(p_sType,p_aArgs,p_oMenu){var oEvent=p_aArgs[0],oItem=p_aArgs[1],me=this,oSubmenu;function stopMouseEventHandlers(){me._bStopMouseEventHandlers=true;window.setTimeout(function(){me._bStopMouseEventHandlers=false;},10);} -if(oItem&&!oItem.cfg.getProperty("disabled")){var oItemCfg=oItem.cfg,oParentItem=this.parent,oRoot,oNextItem;switch(oEvent.keyCode){case 38:case 40:if(oItem==this.activeItem&&!oItemCfg.getProperty("selected")){oItemCfg.setProperty("selected",true);} -else{oNextItem=(oEvent.keyCode==38)?oItem.getPreviousEnabledSibling():oItem.getNextEnabledSibling();if(oNextItem){this.clearActiveItem();oNextItem.cfg.setProperty("selected",true);oNextItem.focus();if(this.cfg.getProperty("maxheight")>0){var oBody=this.body;oBody.scrollTop=(oNextItem.element.offsetTop+ -oNextItem.element.offsetHeight)-oBody.offsetHeight;var nScrollTop=oBody.scrollTop,nScrollTarget=oBody.scrollHeight-oBody.offsetHeight;if(nScrollTop===0){this._disableScrollHeader();this._enableScrollFooter();} -else if(nScrollTop==nScrollTarget){this._enableScrollHeader();this._disableScrollFooter();} -else{this._enableScrollHeader();this._enableScrollFooter();}}}} -Event.preventDefault(oEvent);stopMouseEventHandlers();break;case 39:oSubmenu=oItemCfg.getProperty("submenu");if(oSubmenu){if(!oItemCfg.getProperty("selected")){oItemCfg.setProperty("selected",true);} -oSubmenu.show();oSubmenu.setInitialSelection();} -else{oRoot=this.getRoot();if(oRoot instanceof YAHOO.widget.MenuBar){oNextItem=oRoot.activeItem.getNextEnabledSibling();if(oNextItem){oRoot.clearActiveItem();oNextItem.cfg.setProperty("selected",true);oSubmenu=oNextItem.cfg.getProperty("submenu");if(oSubmenu){oSubmenu.show();} -oNextItem.focus();}}} -Event.preventDefault(oEvent);stopMouseEventHandlers();break;case 37:if(oParentItem){var oParentMenu=oParentItem.parent;if(oParentMenu instanceof YAHOO.widget.MenuBar){oNextItem=oParentMenu.activeItem.getPreviousEnabledSibling();if(oNextItem){oParentMenu.clearActiveItem();oNextItem.cfg.setProperty("selected",true);oSubmenu=oNextItem.cfg.getProperty("submenu");if(oSubmenu){oSubmenu.show();} -oNextItem.focus();}} -else{this.hide();oParentItem.focus();}} -Event.preventDefault(oEvent);stopMouseEventHandlers();break;}} -if(oEvent.keyCode==27){if(this.cfg.getProperty("position")=="dynamic"){this.hide();if(this.parent){this.parent.focus();}} -else if(this.activeItem){oSubmenu=this.activeItem.cfg.getProperty("submenu");if(oSubmenu&&oSubmenu.cfg.getProperty("visible")){oSubmenu.hide();this.activeItem.focus();} -else{this.activeItem.cfg.setProperty("selected",false);this.activeItem.blur();}} -Event.preventDefault(oEvent);}},_onKeyPress:function(p_sType,p_aArgs,p_oMenu){var oEvent=p_aArgs[0];if(oEvent.keyCode==40||oEvent.keyCode==38){YAHOO.util.Event.preventDefault(oEvent);}},_onTextResize:function(p_sType,p_aArgs,p_oMenu){if(this.browser=="gecko"&&!this._handleResize){this._handleResize=true;return;} -var oConfig=this.cfg;if(oConfig.getProperty("position")=="dynamic"){oConfig.setProperty("width",(this._getOffsetWidth()+"px"));}},_onScrollTargetMouseOver:function(p_oEvent,p_oMenu){this._cancelHideDelay();var oTarget=Event.getTarget(p_oEvent),oBody=this.body,me=this,nScrollTarget,fnScrollFunction;function scrollBodyDown(){var nScrollTop=oBody.scrollTop;if(nScrollTop<nScrollTarget){oBody.scrollTop=(nScrollTop+1);me._enableScrollHeader();} -else{oBody.scrollTop=nScrollTarget;window.clearInterval(me._nBodyScrollId);me._disableScrollFooter();}} -function scrollBodyUp(){var nScrollTop=oBody.scrollTop;if(nScrollTop>0){oBody.scrollTop=(nScrollTop-1);me._enableScrollFooter();} -else{oBody.scrollTop=0;window.clearInterval(me._nBodyScrollId);me._disableScrollHeader();}} -if(Dom.hasClass(oTarget,"hd")){fnScrollFunction=scrollBodyUp;} -else{nScrollTarget=oBody.scrollHeight-oBody.offsetHeight;fnScrollFunction=scrollBodyDown;} -this._nBodyScrollId=window.setInterval(fnScrollFunction,10);},_onScrollTargetMouseOut:function(p_oEvent,p_oMenu){window.clearInterval(this._nBodyScrollId);this._cancelHideDelay();},_onInit:function(p_sType,p_aArgs,p_oMenu){if(((this.parent&&!this.lazyLoad)||(!this.parent&&this.cfg.getProperty("position")=="static")||(!this.parent&&!this.lazyLoad&&this.cfg.getProperty("position")=="dynamic"))&&this.getItemGroups().length===0){if(this.srcElement){this._initSubTree();} -if(this.itemData){this.addItems(this.itemData);}} -else if(this.lazyLoad){this.cfg.fireQueue();}},_onBeforeRender:function(p_sType,p_aArgs,p_oMenu){var oConfig=this.cfg,oEl=this.element,nListElements=this._aListElements.length;if(nListElements>0){var i=0,bFirstList=true,oUL,oGroupTitle;do{oUL=this._aListElements[i];if(oUL){if(bFirstList){Dom.addClass(oUL,"first-of-type");bFirstList=false;} -if(!Dom.isAncestor(oEl,oUL)){this.appendToBody(oUL);} -oGroupTitle=this._aGroupTitleElements[i];if(oGroupTitle){if(!Dom.isAncestor(oEl,oGroupTitle)){oUL.parentNode.insertBefore(oGroupTitle,oUL);} -Dom.addClass(oUL,"hastitle");}} -i++;} -while(i<nListElements);}},_onBeforeShow:function(p_sType,p_aArgs,p_oMenu){if(this.lazyLoad&&this.getItemGroups().length===0){if(this.srcElement){this._initSubTree();} -if(this.itemData){if(this.parent&&this.parent.parent&&this.parent.parent.srcElement&&this.parent.parent.srcElement.tagName.toUpperCase()=="SELECT"){var nOptions=this.itemData.length;for(var n=0;n<nOptions;n++){if(this.itemData[n].tagName){this.addItem((new this.ITEM_TYPE(this.itemData[n])));}}} -else{this.addItems(this.itemData);}} -var oSrcElement=this.srcElement;if(oSrcElement){if(oSrcElement.tagName.toUpperCase()=="SELECT"){if(Dom.inDocument(oSrcElement)){this.render(oSrcElement.parentNode);} -else{this.render(this.cfg.getProperty("container"));}} -else{this.render();}} -else{if(this.parent){this.render(this.parent.element);} -else{this.render(this.cfg.getProperty("container"));}}} -if(this.cfg.getProperty("position")=="dynamic"){var nViewportHeight=Dom.getViewportHeight();if(this.element.offsetHeight>=nViewportHeight){var nMaxHeight=this.cfg.getProperty("maxheight");this._nMaxHeight=nMaxHeight;this.cfg.setProperty("maxheight",(nViewportHeight-20));} -if(this.cfg.getProperty("maxheight")>0){var oBody=this.body;if(oBody.scrollTop>0){oBody.scrollTop=0;} -this._disableScrollHeader();this._enableScrollFooter();}}},_onShow:function(p_sType,p_aArgs,p_oMenu){this.setInitialFocus();var oParent=this.parent;if(oParent){var oParentMenu=oParent.parent,aParentAlignment=oParentMenu.cfg.getProperty("submenualignment"),aAlignment=this.cfg.getProperty("submenualignment");if((aParentAlignment[0]!=aAlignment[0])&&(aParentAlignment[1]!=aAlignment[1])){this.cfg.setProperty("submenualignment",[aParentAlignment[0],aParentAlignment[1]]);} -if(!oParentMenu.cfg.getProperty("autosubmenudisplay")&&oParentMenu.cfg.getProperty("position")=="static"){oParentMenu.cfg.setProperty("autosubmenudisplay",true);function disableAutoSubmenuDisplay(p_oEvent){if(p_oEvent.type=="mousedown"||(p_oEvent.type=="keydown"&&p_oEvent.keyCode==27)){var oTarget=Event.getTarget(p_oEvent);if(oTarget!=oParentMenu.element||!YAHOO.util.Dom.isAncestor(oParentMenu.element,oTarget)){oParentMenu.cfg.setProperty("autosubmenudisplay",false);Event.removeListener(document,"mousedown",disableAutoSubmenuDisplay);Event.removeListener(document,"keydown",disableAutoSubmenuDisplay);}}} -Event.addListener(document,"mousedown",disableAutoSubmenuDisplay);Event.addListener(document,"keydown",disableAutoSubmenuDisplay);}} -else if(!oParent&&this.lazyLoad){this.cfg.refireEvent("xy");}},_onBeforeHide:function(p_sType,p_aArgs,p_oMenu){var oActiveItem=this.activeItem;if(oActiveItem){var oConfig=oActiveItem.cfg;oConfig.setProperty("selected",false);var oSubmenu=oConfig.getProperty("submenu");if(oSubmenu){oSubmenu.hide();} -oActiveItem.blur();}},_onHide:function(p_sType,p_aArgs,p_oMenu){if(this._nMaxHeight!=-1){this.cfg.setProperty("maxheight",this._nMaxHeight);this._nMaxHeight=-1;}},_onParentMenuConfigChange:function(p_sType,p_aArgs,p_oSubmenu){var sPropertyName=p_aArgs[0][0],oPropertyValue=p_aArgs[0][1];switch(sPropertyName){case"iframe":case"constraintoviewport":case"hidedelay":case"showdelay":case"submenuhidedelay":case"clicktohide":case"effect":case"classname":p_oSubmenu.cfg.setProperty(sPropertyName,oPropertyValue);break;}},_onParentMenuRender:function(p_sType,p_aArgs,p_oSubmenu){var oParentMenu=p_oSubmenu.parent.parent,oConfig={constraintoviewport:oParentMenu.cfg.getProperty("constraintoviewport"),xy:[0,0],clicktohide:oParentMenu.cfg.getProperty("clicktohide"),effect:oParentMenu.cfg.getProperty("effect"),showdelay:oParentMenu.cfg.getProperty("showdelay"),hidedelay:oParentMenu.cfg.getProperty("hidedelay"),submenuhidedelay:oParentMenu.cfg.getProperty("submenuhidedelay"),classname:oParentMenu.cfg.getProperty("classname")};if(this.cfg.getProperty("position")==oParentMenu.cfg.getProperty("position")){oConfig.iframe=oParentMenu.cfg.getProperty("iframe");} -p_oSubmenu.cfg.applyConfig(oConfig);if(!this.lazyLoad){var oLI=this.parent.element;if(this.element.parentNode==oLI){this.render();} -else{this.render(oLI);}}},_onSubmenuBeforeShow:function(p_sType,p_aArgs,p_oSubmenu){var oParent=this.parent,aAlignment=oParent.parent.cfg.getProperty("submenualignment");this.cfg.setProperty("context",[oParent.element,aAlignment[0],aAlignment[1]]);var nScrollTop=oParent.parent.body.scrollTop;if((this.browser=="gecko"||this.browser=="safari")&&nScrollTop>0){this.cfg.setProperty("y",(this.cfg.getProperty("y")-nScrollTop));}},_onSubmenuShow:function(p_sType,p_aArgs,p_oSubmenu){var oParent=this.parent;oParent.submenuIndicator.firstChild.nodeValue=oParent.EXPANDED_SUBMENU_INDICATOR_TEXT;},_onSubmenuHide:function(p_sType,p_aArgs,p_oSubmenu){var oParent=this.parent;oParent.submenuIndicator.firstChild.nodeValue=oParent.COLLAPSED_SUBMENU_INDICATOR_TEXT;},_onMenuItemFocus:function(p_sType,p_aArgs,p_oItem){this.activeItem=p_oItem;},_onMenuItemBlur:function(p_sType,p_aArgs){this.activeItem=null;},_onMenuItemConfigChange:function(p_sType,p_aArgs,p_oItem){var sProperty=p_aArgs[0][0];switch(sProperty){case"submenu":var oSubmenu=p_aArgs[0][1];if(oSubmenu){this._configureSubmenu(p_oItem);} -break;case"text":case"helptext":if(this.element.style.width){var sWidth=this._getOffsetWidth()+"px";Dom.setStyle(this.element,"width",sWidth);} -break;}},enforceConstraints:function(type,args,obj){var oConfig=this.cfg,pos=args[0],x=pos[0],y=pos[1],offsetHeight=this.element.offsetHeight,offsetWidth=this.element.offsetWidth,viewPortWidth=YAHOO.util.Dom.getViewportWidth(),viewPortHeight=YAHOO.util.Dom.getViewportHeight(),scrollX=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),scrollY=Math.max(document.documentElement.scrollTop,document.body.scrollTop),nPadding=(this.parent&&this.parent.parent instanceof YAHOO.widget.MenuBar)?0:10,topConstraint=scrollY+nPadding,leftConstraint=scrollX+nPadding,bottomConstraint=scrollY+viewPortHeight-offsetHeight-nPadding,rightConstraint=scrollX+viewPortWidth-offsetWidth-nPadding,aContext=oConfig.getProperty("context"),oContextElement=aContext?aContext[0]:null;if(x<10){x=leftConstraint;}else if((x+offsetWidth)>viewPortWidth){if(oContextElement&&((x-oContextElement.offsetWidth)>offsetWidth)){x=(x-(oContextElement.offsetWidth+offsetWidth));} -else{x=rightConstraint;}} -if(y<10){y=topConstraint;}else if(y>bottomConstraint){if(oContextElement&&(y>offsetHeight)){y=((y+oContextElement.offsetHeight)-offsetHeight);} -else{y=bottomConstraint;}} -oConfig.setProperty("x",x,true);oConfig.setProperty("y",y,true);oConfig.setProperty("xy",[x,y],true);},configVisible:function(p_sType,p_aArgs,p_oMenu){if(this.cfg.getProperty("position")=="dynamic"){YAHOO.widget.Menu.superclass.configVisible.call(this,p_sType,p_aArgs,p_oMenu);} -else{var bVisible=p_aArgs[0],sDisplay=Dom.getStyle(this.element,"display");if(bVisible){if(sDisplay!="block"){this.beforeShowEvent.fire();Dom.setStyle(this.element,"display","block");this.showEvent.fire();}} -else{if(sDisplay=="block"){this.beforeHideEvent.fire();Dom.setStyle(this.element,"display","none");this.hideEvent.fire();}}}},configPosition:function(p_sType,p_aArgs,p_oMenu){var sCSSPosition=p_aArgs[0]=="static"?"static":"absolute",oCfg=this.cfg;Dom.setStyle(this.element,"position",sCSSPosition);if(sCSSPosition=="static"){oCfg.setProperty("iframe",false);Dom.setStyle(this.element,"display","block");oCfg.setProperty("visible",true);} -else{Dom.setStyle(this.element,"visibility","hidden");} -if(sCSSPosition=="absolute"){var nZIndex=oCfg.getProperty("zindex");if(!nZIndex||nZIndex===0){nZIndex=this.parent?(this.parent.parent.cfg.getProperty("zindex")+1):1;oCfg.setProperty("zindex",nZIndex);}}},configIframe:function(p_sType,p_aArgs,p_oMenu){if(this.cfg.getProperty("position")=="dynamic"){YAHOO.widget.Menu.superclass.configIframe.call(this,p_sType,p_aArgs,p_oMenu);}},configHideDelay:function(p_sType,p_aArgs,p_oMenu){var nHideDelay=p_aArgs[0],oMouseOutEvent=this.mouseOutEvent,oMouseOverEvent=this.mouseOverEvent,oKeyDownEvent=this.keyDownEvent;if(nHideDelay>0){if(!this._bHideDelayEventHandlersAssigned){oMouseOutEvent.subscribe(this._execHideDelay,true);oMouseOverEvent.subscribe(this._cancelHideDelay,this,true);oKeyDownEvent.subscribe(this._cancelHideDelay,this,true);this._bHideDelayEventHandlersAssigned=true;}} -else{oMouseOutEvent.unsubscribe(this._execHideDelay,this);oMouseOverEvent.unsubscribe(this._cancelHideDelay,this);oKeyDownEvent.unsubscribe(this._cancelHideDelay,this);this._bHideDelayEventHandlersAssigned=false;}},configContainer:function(p_sType,p_aArgs,p_oMenu){var oElement=p_aArgs[0];if(typeof oElement=='string'){this.cfg.setProperty("container",document.getElementById(oElement),true);}},configMaxHeight:function(p_sType,p_aArgs,p_oMenu){var nMaxHeight=p_aArgs[0],oBody=this.body,oHeader=this.header,oFooter=this.footer,fnMouseOver=this._onScrollTargetMouseOver,fnMouseOut=this._onScrollTargetMouseOut;if((nMaxHeight>0)&&(oBody.offsetHeight>nMaxHeight)){if(!this.cfg.getProperty("width")){this._setWidth();} -if(!oHeader&&!oFooter){this.setHeader(" ");this.setFooter(" ");oHeader=this.header;oFooter=this.footer;Dom.addClass(oHeader,"topscrollbar");Dom.addClass(oFooter,"bottomscrollbar");this.element.insertBefore(oHeader,oBody);this.element.appendChild(oFooter);Event.addListener(oHeader,"mouseover",fnMouseOver,this,true);Event.addListener(oHeader,"mouseout",fnMouseOut,this,true);Event.addListener(oFooter,"mouseover",fnMouseOver,this,true);Event.addListener(oFooter,"mouseout",fnMouseOut,this,true);} -var nHeight=(nMaxHeight- -(this.footer.offsetHeight+this.header.offsetHeight));Dom.setStyle(oBody,"height",(nHeight+"px"));Dom.setStyle(oBody,"overflow","hidden");} -else if(oHeader&&oFooter){Dom.setStyle(oBody,"height","auto");Dom.setStyle(oBody,"overflow","visible");Event.removeListener(oHeader,"mouseover",fnMouseOver);Event.removeListener(oHeader,"mouseout",fnMouseOut);Event.removeListener(oFooter,"mouseover",fnMouseOver);Event.removeListener(oFooter,"mouseout",fnMouseOut);this.element.removeChild(oHeader);this.element.removeChild(oFooter);this.header=null;this.footer=null;}},configClassName:function(p_sType,p_aArgs,p_oMenu){var sClassName=p_aArgs[0];if(this._sClassName){Dom.removeClass(this.element,this._sClassName);} -Dom.addClass(this.element,sClassName);this._sClassName=sClassName;},initEvents:function(){YAHOO.widget.Menu.superclass.initEvents.call(this);var CustomEvent=YAHOO.util.CustomEvent;this.mouseOverEvent=new CustomEvent("mouseOverEvent",this);this.mouseOutEvent=new CustomEvent("mouseOutEvent",this);this.mouseDownEvent=new CustomEvent("mouseDownEvent",this);this.mouseUpEvent=new CustomEvent("mouseUpEvent",this);this.clickEvent=new CustomEvent("clickEvent",this);this.keyPressEvent=new CustomEvent("keyPressEvent",this);this.keyDownEvent=new CustomEvent("keyDownEvent",this);this.keyUpEvent=new CustomEvent("keyUpEvent",this);this.itemAddedEvent=new CustomEvent("itemAddedEvent",this);this.itemRemovedEvent=new CustomEvent("itemRemovedEvent",this);},getRoot:function(){var oItem=this.parent;if(oItem){var oParentMenu=oItem.parent;return oParentMenu?oParentMenu.getRoot():this;} -else{return this;}},toString:function(){return("Menu "+this.id);},setItemGroupTitle:function(p_sGroupTitle,p_nGroupIndex){if(typeof p_sGroupTitle=="string"&&p_sGroupTitle.length>0){var nGroupIndex=typeof p_nGroupIndex=="number"?p_nGroupIndex:0,oTitle=this._aGroupTitleElements[nGroupIndex];if(oTitle){oTitle.innerHTML=p_sGroupTitle;} -else{oTitle=document.createElement(this.GROUP_TITLE_TAG_NAME);oTitle.innerHTML=p_sGroupTitle;this._aGroupTitleElements[nGroupIndex]=oTitle;} -var i=this._aGroupTitleElements.length-1,nFirstIndex;do{if(this._aGroupTitleElements[i]){Dom.removeClass(this._aGroupTitleElements[i],"first-of-type");nFirstIndex=i;}} -while(i--);if(nFirstIndex!==null){Dom.addClass(this._aGroupTitleElements[nFirstIndex],"first-of-type");}}},addItem:function(p_oItem,p_nGroupIndex){if(p_oItem){return this._addItemToGroup(p_nGroupIndex,p_oItem);}},addItems:function(p_aItems,p_nGroupIndex){if(Lang.isArray(p_aItems)){var nItems=p_aItems.length,aItems=[],oItem;for(var i=0;i<nItems;i++){oItem=p_aItems[i];if(oItem){if(Lang.isArray(oItem)){aItems[aItems.length]=this.addItems(oItem,i);} -else{aItems[aItems.length]=this._addItemToGroup(p_nGroupIndex,oItem);}}} -if(aItems.length){return aItems;}}},insertItem:function(p_oItem,p_nItemIndex,p_nGroupIndex){if(p_oItem){return this._addItemToGroup(p_nGroupIndex,p_oItem,p_nItemIndex);}},removeItem:function(p_oObject,p_nGroupIndex){if(typeof p_oObject!="undefined"){var oItem;if(p_oObject instanceof YAHOO.widget.MenuItem){oItem=this._removeItemFromGroupByValue(p_nGroupIndex,p_oObject);} -else if(typeof p_oObject=="number"){oItem=this._removeItemFromGroupByIndex(p_nGroupIndex,p_oObject);} -if(oItem){oItem.destroy();return oItem;}}},getItems:function(){var aGroups=this._aItemGroups,nGroups=aGroups.length;return((nGroups==1)?aGroups[0]:(Array.prototype.concat.apply([],aGroups)));},getItemGroups:function(){return this._aItemGroups;},getItem:function(p_nItemIndex,p_nGroupIndex){if(typeof p_nItemIndex=="number"){var aGroup=this._getItemGroup(p_nGroupIndex);if(aGroup){return aGroup[p_nItemIndex];}}},clearContent:function(){var aItems=this.getItems(),nItems=aItems.length,oElement=this.element,oBody=this.body,oHeader=this.header,oFooter=this.footer;if(nItems>0){var i=nItems-1,oItem,oSubmenu;do{oItem=aItems[i];if(oItem){oSubmenu=oItem.cfg.getProperty("submenu");if(oSubmenu){this.cfg.configChangedEvent.unsubscribe(this._onParentMenuConfigChange,oSubmenu);this.renderEvent.unsubscribe(this._onParentMenuRender,oSubmenu);} -oItem.destroy();}} -while(i--);} -if(oHeader){Event.purgeElement(oHeader);oElement.removeChild(oHeader);} -if(oFooter){Event.purgeElement(oFooter);oElement.removeChild(oFooter);} -if(oBody){Event.purgeElement(oBody);oBody.innerHTML="";} -this._aItemGroups=[];this._aListElements=[];this._aGroupTitleElements=[];},destroy:function(){Event.purgeElement(this.element);this.mouseOverEvent.unsubscribeAll();this.mouseOutEvent.unsubscribeAll();this.mouseDownEvent.unsubscribeAll();this.mouseUpEvent.unsubscribeAll();this.clickEvent.unsubscribeAll();this.keyPressEvent.unsubscribeAll();this.keyDownEvent.unsubscribeAll();this.keyUpEvent.unsubscribeAll();this.itemAddedEvent.unsubscribeAll();this.itemRemovedEvent.unsubscribeAll();YAHOO.widget.Module.textResizeEvent.unsubscribe(this._onTextResize,this);this.clearContent();this._aItemGroups=null;this._aListElements=null;this._aGroupTitleElements=null;YAHOO.widget.Menu.superclass.destroy.call(this);},setInitialFocus:function(){var oItem=this._getFirstEnabledItem();if(oItem){oItem.focus();}},setInitialSelection:function(){var oItem=this._getFirstEnabledItem();if(oItem){oItem.cfg.setProperty("selected",true);}},clearActiveItem:function(p_bBlur){if(this.cfg.getProperty("showdelay")>0){this._cancelShowDelay();} -var oActiveItem=this.activeItem;if(oActiveItem){var oConfig=oActiveItem.cfg;oConfig.setProperty("selected",false);var oSubmenu=oConfig.getProperty("submenu");if(oSubmenu){oSubmenu.hide();} -if(p_bBlur){oActiveItem.blur();}}},initDefaultConfig:function(){YAHOO.widget.Menu.superclass.initDefaultConfig.call(this);var oConfig=this.cfg;oConfig.addProperty("visible",{value:false,handler:this.configVisible,validator:this.cfg.checkBoolean});oConfig.addProperty("constraintoviewport",{value:true,handler:this.configConstrainToViewport,validator:this.cfg.checkBoolean,supercedes:["iframe","x","y","xy"]});oConfig.addProperty("position",{value:"dynamic",handler:this.configPosition,validator:this._checkPosition,supercedes:["visible"]});oConfig.addProperty("submenualignment",{value:["tl","tr"]});oConfig.addProperty("autosubmenudisplay",{value:true,validator:oConfig.checkBoolean});oConfig.addProperty("showdelay",{value:250,validator:oConfig.checkNumber});oConfig.addProperty("hidedelay",{value:0,validator:oConfig.checkNumber,handler:this.configHideDelay,suppressEvent:true});oConfig.addProperty("submenuhidedelay",{value:250,validator:oConfig.checkNumber});oConfig.addProperty("clicktohide",{value:true,validator:oConfig.checkBoolean});oConfig.addProperty("container",{value:document.body,handler:this.configContainer});oConfig.addProperty("maxheight",{value:0,validator:oConfig.checkNumber,handler:this.configMaxHeight});oConfig.addProperty("classname",{value:null,handler:this.configClassName,validator:this._checkString});}});})();(function(){var Dom=YAHOO.util.Dom,Module=YAHOO.widget.Module,Menu=YAHOO.widget.Menu,m_oMenuItemElement=null,m_oSubmenuIndicator=null,m_oCheckedIndicator=null;YAHOO.widget.MenuItem=function(p_oObject,p_oConfig){if(p_oObject){if(p_oConfig){this.parent=p_oConfig.parent;this.value=p_oConfig.value;this.id=p_oConfig.id;} -this.init(p_oObject,p_oConfig);}};YAHOO.widget.MenuItem.prototype={SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_nrm_1.gif",SELECTED_SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_hov_1.gif",DISABLED_SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_dim_1.gif",COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT:"Collapsed. Click to expand.",EXPANDED_SUBMENU_INDICATOR_ALT_TEXT:"Expanded. Click to collapse.",DISABLED_SUBMENU_INDICATOR_ALT_TEXT:"Disabled.",COLLAPSED_SUBMENU_INDICATOR_TEXT:"Submenu collapsed. Click to expand submenu.",EXPANDED_SUBMENU_INDICATOR_TEXT:"Submenu expanded. Click to collapse submenu.",DISABLED_SUBMENU_INDICATOR_TEXT:"Submenu collapsed. (Item disabled.)",CHECKED_IMAGE_PATH:"nt/ic/ut/bsc/menuchk8_nrm_1.gif",SELECTED_CHECKED_IMAGE_PATH:"nt/ic/ut/bsc/menuchk8_hov_1.gif",DISABLED_CHECKED_IMAGE_PATH:"nt/ic/ut/bsc/menuchk8_dim_1.gif",CHECKED_IMAGE_ALT_TEXT:"Checked.",DISABLED_CHECKED_IMAGE_ALT_TEXT:"Checked. (Item disabled.)",CHECKED_TEXT:"Menu item checked.",DISABLED_CHECKED_TEXT:"Checked. (Item disabled.)",CSS_CLASS_NAME:"yuimenuitem",SUBMENU_TYPE:null,IMG_ROOT:"http://us.i1.yimg.com/us.yimg.com/i/",IMG_ROOT_SSL:"https://a248.e.akamai.net/sec.yimg.com/i/",_oAnchor:null,_oText:null,_oHelpTextEM:null,_oSubmenu:null,_checkImage:null,_oCheckedIndicator:null,_oOnclickAttributeValue:null,_sClassName:null,constructor:YAHOO.widget.MenuItem,imageRoot:null,isSecure:Module.prototype.isSecure,index:null,groupIndex:null,parent:null,element:null,srcElement:null,value:null,submenuIndicator:null,browser:Module.prototype.browser,id:null,destroyEvent:null,mouseOverEvent:null,mouseOutEvent:null,mouseDownEvent:null,mouseUpEvent:null,clickEvent:null,keyPressEvent:null,keyDownEvent:null,keyUpEvent:null,focusEvent:null,blurEvent:null,init:function(p_oObject,p_oConfig){if(!this.SUBMENU_TYPE){this.SUBMENU_TYPE=Menu;} -this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();var oConfig=this.cfg;if(this._checkString(p_oObject)){this._createRootNodeStructure();oConfig.setProperty("text",p_oObject);} -else if(this._checkDOMNode(p_oObject)){switch(p_oObject.tagName.toUpperCase()){case"OPTION":this._createRootNodeStructure();oConfig.setProperty("text",p_oObject.text);this.srcElement=p_oObject;break;case"OPTGROUP":this._createRootNodeStructure();oConfig.setProperty("text",p_oObject.label);this.srcElement=p_oObject;this._initSubTree();break;case"LI":var oAnchor=this._getFirstElement(p_oObject,"A"),sURL="#",sTarget,sText;if(oAnchor){sURL=oAnchor.getAttribute("href");sTarget=oAnchor.getAttribute("target");if(oAnchor.innerText){sText=oAnchor.innerText;} -else{var oRange=oAnchor.ownerDocument.createRange();oRange.selectNodeContents(oAnchor);sText=oRange.toString();}} -else{var oText=p_oObject.firstChild;sText=oText.nodeValue;oAnchor=document.createElement("a");oAnchor.setAttribute("href",sURL);p_oObject.replaceChild(oAnchor,oText);oAnchor.appendChild(oText);} -this.srcElement=p_oObject;this.element=p_oObject;this._oAnchor=oAnchor;var oEmphasisNode=this._getFirstElement(oAnchor),bEmphasis=false,bStrongEmphasis=false;if(oEmphasisNode){this._oText=oEmphasisNode.firstChild;switch(oEmphasisNode.tagName.toUpperCase()){case"EM":bEmphasis=true;break;case"STRONG":bStrongEmphasis=true;break;}} -else{this._oText=oAnchor.firstChild;} -oConfig.setProperty("text",sText,true);oConfig.setProperty("url",sURL,true);oConfig.setProperty("target",sTarget,true);oConfig.setProperty("emphasis",bEmphasis,true);oConfig.setProperty("strongemphasis",bStrongEmphasis,true);this._initSubTree();break;}} -if(this.element){var sId=this.element.id;if(!sId){sId=this.id||Dom.generateId();this.element.id=sId;} -this.id=sId;Dom.addClass(this.element,this.CSS_CLASS_NAME);var CustomEvent=YAHOO.util.CustomEvent;this.destroyEvent=new CustomEvent("destroyEvent",this);this.mouseOverEvent=new CustomEvent("mouseOverEvent",this);this.mouseOutEvent=new CustomEvent("mouseOutEvent",this);this.mouseDownEvent=new CustomEvent("mouseDownEvent",this);this.mouseUpEvent=new CustomEvent("mouseUpEvent",this);this.clickEvent=new CustomEvent("clickEvent",this);this.keyPressEvent=new CustomEvent("keyPressEvent",this);this.keyDownEvent=new CustomEvent("keyDownEvent",this);this.keyUpEvent=new CustomEvent("keyUpEvent",this);this.focusEvent=new CustomEvent("focusEvent",this);this.blurEvent=new CustomEvent("blurEvent",this);if(p_oConfig){oConfig.applyConfig(p_oConfig);} -oConfig.fireQueue();}},_getFirstElement:function(p_oElement,p_sTagName){var oFirstChild=p_oElement.firstChild,oElement;if(oFirstChild){if(oFirstChild.nodeType==1){oElement=oFirstChild;} -else{var oNextSibling=oFirstChild.nextSibling;if(oNextSibling&&oNextSibling.nodeType==1){oElement=oNextSibling;}}} -if(p_sTagName){return(oElement&&oElement.tagName.toUpperCase()==p_sTagName)?oElement:false;} -return oElement;},_checkString:function(p_oObject){return(typeof p_oObject=="string");},_checkDOMNode:function(p_oObject){return(p_oObject&&p_oObject.tagName);},_createRootNodeStructure:function(){if(!m_oMenuItemElement){m_oMenuItemElement=document.createElement("li");m_oMenuItemElement.innerHTML="<a href=\"#\">s</a>";} -this.element=m_oMenuItemElement.cloneNode(true);this._oAnchor=this.element.firstChild;this._oText=this._oAnchor.firstChild;this.element.appendChild(this._oAnchor);},_initSubTree:function(){var oSrcEl=this.srcElement,oConfig=this.cfg;if(oSrcEl.childNodes.length>0){if(this.parent.lazyLoad&&this.parent.srcElement&&this.parent.srcElement.tagName.toUpperCase()=="SELECT"){oConfig.setProperty("submenu",{id:Dom.generateId(),itemdata:oSrcEl.childNodes});} -else{var oNode=oSrcEl.firstChild,aOptions=[];do{if(oNode&&oNode.tagName){switch(oNode.tagName.toUpperCase()){case"DIV":oConfig.setProperty("submenu",oNode);break;case"OPTION":aOptions[aOptions.length]=oNode;break;}}} -while((oNode=oNode.nextSibling));var nOptions=aOptions.length;if(nOptions>0){var oMenu=new this.SUBMENU_TYPE(Dom.generateId());oConfig.setProperty("submenu",oMenu);for(var n=0;n<nOptions;n++){oMenu.addItem((new oMenu.ITEM_TYPE(aOptions[n])));}}}}},_preloadImage:function(p_sPath){var sPath=this.imageRoot+p_sPath;if(!document.images[sPath]){var oImage=document.createElement("img");oImage.src=sPath;oImage.name=sPath;oImage.id=sPath;oImage.style.display="none";document.body.appendChild(oImage);}},configText:function(p_sType,p_aArgs,p_oItem){var sText=p_aArgs[0];if(this._oText){this._oText.nodeValue=sText;}},configHelpText:function(p_sType,p_aArgs,p_oItem){var me=this,oHelpText=p_aArgs[0],oEl=this.element,oConfig=this.cfg,aNodes=[oEl,this._oAnchor],oSubmenuIndicator=this.submenuIndicator;function initHelpText(){Dom.addClass(aNodes,"hashelptext");if(oConfig.getProperty("disabled")){oConfig.refireEvent("disabled");} -if(oConfig.getProperty("selected")){oConfig.refireEvent("selected");}} -function removeHelpText(){Dom.removeClass(aNodes,"hashelptext");oEl.removeChild(me._oHelpTextEM);me._oHelpTextEM=null;} -if(this._checkDOMNode(oHelpText)){oHelpText.className="helptext";if(this._oHelpTextEM){this._oHelpTextEM.parentNode.replaceChild(oHelpText,this._oHelpTextEM);} -else{this._oHelpTextEM=oHelpText;oEl.insertBefore(this._oHelpTextEM,oSubmenuIndicator);} -initHelpText();} -else if(this._checkString(oHelpText)){if(oHelpText.length===0){removeHelpText();} -else{if(!this._oHelpTextEM){this._oHelpTextEM=document.createElement("em");this._oHelpTextEM.className="helptext";oEl.insertBefore(this._oHelpTextEM,oSubmenuIndicator);} -this._oHelpTextEM.innerHTML=oHelpText;initHelpText();}} -else if(!oHelpText&&this._oHelpTextEM){removeHelpText();}},configURL:function(p_sType,p_aArgs,p_oItem){var sURL=p_aArgs[0];if(!sURL){sURL="#";} -this._oAnchor.setAttribute("href",sURL);},configTarget:function(p_sType,p_aArgs,p_oItem){var sTarget=p_aArgs[0],oAnchor=this._oAnchor;if(sTarget&&sTarget.length>0){oAnchor.setAttribute("target",sTarget);} -else{oAnchor.removeAttribute("target");}},configEmphasis:function(p_sType,p_aArgs,p_oItem){var bEmphasis=p_aArgs[0],oAnchor=this._oAnchor,oText=this._oText,oConfig=this.cfg,oEM;if(bEmphasis&&oConfig.getProperty("strongemphasis")){oConfig.setProperty("strongemphasis",false);} -if(oAnchor){if(bEmphasis){oEM=document.createElement("em");oEM.appendChild(oText);oAnchor.appendChild(oEM);} -else{oEM=this._getFirstElement(oAnchor,"EM");if(oEM){oAnchor.removeChild(oEM);oAnchor.appendChild(oText);}}}},configStrongEmphasis:function(p_sType,p_aArgs,p_oItem){var bStrongEmphasis=p_aArgs[0],oAnchor=this._oAnchor,oText=this._oText,oConfig=this.cfg,oStrong;if(bStrongEmphasis&&oConfig.getProperty("emphasis")){oConfig.setProperty("emphasis",false);} -if(oAnchor){if(bStrongEmphasis){oStrong=document.createElement("strong");oStrong.appendChild(oText);oAnchor.appendChild(oStrong);} -else{oStrong=this._getFirstElement(oAnchor,"STRONG");if(oStrong){oAnchor.removeChild(oStrong);oAnchor.appendChild(oText);}}}},configChecked:function(p_sType,p_aArgs,p_oItem){var bChecked=p_aArgs[0],oEl=this.element,oConfig=this.cfg,oEM;if(bChecked){if(!m_oCheckedIndicator){m_oCheckedIndicator=document.createElement("em");m_oCheckedIndicator.innerHTML=this.CHECKED_TEXT;m_oCheckedIndicator.className="checkedindicator";} -oEM=m_oCheckedIndicator.cloneNode(true);var oSubmenu=this.cfg.getProperty("submenu");if(oSubmenu&&oSubmenu.element){oEl.insertBefore(oEM,oSubmenu.element);} -else{oEl.appendChild(oEM);} -Dom.addClass(oEl,"checked");this._oCheckedIndicator=oEM;if(oConfig.getProperty("disabled")){oConfig.refireEvent("disabled");} -if(oConfig.getProperty("selected")){oConfig.refireEvent("selected");}} -else{oEM=this._oCheckedIndicator;Dom.removeClass(oEl,"checked");if(oEM){oEl.removeChild(oEM);} -this._oCheckedIndicator=null;}},configDisabled:function(p_sType,p_aArgs,p_oItem){var bDisabled=p_aArgs[0],oConfig=this.cfg,oAnchor=this._oAnchor,aNodes=[this.element,oAnchor],oHelpText=this._oHelpTextEM,oCheckedIndicator=this._oCheckedIndicator,oSubmenuIndicator=this.submenuIndicator,i=1;if(oHelpText){i++;aNodes[i]=oHelpText;} -if(oCheckedIndicator){oCheckedIndicator.firstChild.nodeValue=bDisabled?this.DISABLED_CHECKED_TEXT:this.CHECKED_TEXT;i++;aNodes[i]=oCheckedIndicator;} -if(oSubmenuIndicator){oSubmenuIndicator.firstChild.nodeValue=bDisabled?this.DISABLED_SUBMENU_INDICATOR_TEXT:this.COLLAPSED_SUBMENU_INDICATOR_TEXT;i++;aNodes[i]=oSubmenuIndicator;} -if(bDisabled){if(oConfig.getProperty("selected")){oConfig.setProperty("selected",false);} -oAnchor.removeAttribute("href");Dom.addClass(aNodes,"disabled");} -else{oAnchor.setAttribute("href",oConfig.getProperty("url"));Dom.removeClass(aNodes,"disabled");}},configSelected:function(p_sType,p_aArgs,p_oItem){if(!this.cfg.getProperty("disabled")){var bSelected=p_aArgs[0],oHelpText=this._oHelpTextEM,oSubmenuIndicator=this.submenuIndicator,oCheckedIndicator=this._oCheckedIndicator,aNodes=[this.element,this._oAnchor],i=1;if(oHelpText){i++;aNodes[i]=oHelpText;} -if(oSubmenuIndicator){i++;aNodes[i]=oSubmenuIndicator;} -if(oCheckedIndicator){i++;aNodes[i]=oCheckedIndicator;} -if(bSelected){Dom.addClass(aNodes,"selected");} -else{Dom.removeClass(aNodes,"selected");}}},configSubmenu:function(p_sType,p_aArgs,p_oItem){var oEl=this.element,oSubmenu=p_aArgs[0],oSubmenuIndicator=this.submenuIndicator,oConfig=this.cfg,aNodes=[this.element,this._oAnchor],bLazyLoad=this.parent&&this.parent.lazyLoad,oMenu;if(oSubmenu){if(oSubmenu instanceof Menu){oMenu=oSubmenu;oMenu.parent=this;oMenu.lazyLoad=bLazyLoad;} -else if(typeof oSubmenu=="object"&&oSubmenu.id&&!oSubmenu.nodeType){var sSubmenuId=oSubmenu.id,oSubmenuConfig=oSubmenu;oSubmenuConfig.lazyload=bLazyLoad;oSubmenuConfig.parent=this;oMenu=new this.SUBMENU_TYPE(sSubmenuId,oSubmenuConfig);this.cfg.setProperty("submenu",oMenu,true);} -else{oMenu=new this.SUBMENU_TYPE(oSubmenu,{lazyload:bLazyLoad,parent:this});this.cfg.setProperty("submenu",oMenu,true);} -if(oMenu){this._oSubmenu=oMenu;if(!oSubmenuIndicator){if(!m_oSubmenuIndicator){m_oSubmenuIndicator=document.createElement("em");m_oSubmenuIndicator.innerHTML=this.COLLAPSED_SUBMENU_INDICATOR_TEXT;m_oSubmenuIndicator.className="submenuindicator";} -oSubmenuIndicator=m_oSubmenuIndicator.cloneNode(true);if(oMenu.element.parentNode==oEl){if(this.browser=="opera"){oEl.appendChild(oSubmenuIndicator);oMenu.renderEvent.subscribe(function(){oSubmenuIndicator.parentNode.insertBefore(oSubmenuIndicator,oMenu.element);});} -else{oEl.insertBefore(oSubmenuIndicator,oMenu.element);}} -else{oEl.appendChild(oSubmenuIndicator);} -this.submenuIndicator=oSubmenuIndicator;} -Dom.addClass(aNodes,"hassubmenu");if(oConfig.getProperty("disabled")){oConfig.refireEvent("disabled");} -if(oConfig.getProperty("selected")){oConfig.refireEvent("selected");}}} -else{Dom.removeClass(aNodes,"hassubmenu");if(oSubmenuIndicator){oEl.removeChild(oSubmenuIndicator);} -if(this._oSubmenu){this._oSubmenu.destroy();}}},configOnClick:function(p_sType,p_aArgs,p_oItem){var oObject=p_aArgs[0];if(this._oOnclickAttributeValue&&(this._oOnclickAttributeValue!=oObject)){this.clickEvent.unsubscribe(this._oOnclickAttributeValue.fn,this._oOnclickAttributeValue.obj);this._oOnclickAttributeValue=null;} -if(!this._oOnclickAttributeValue&&typeof oObject=="object"&&typeof oObject.fn=="function"){this.clickEvent.subscribe(oObject.fn,(oObject.obj||this),oObject.scope);this._oOnclickAttributeValue=oObject;}},configClassName:function(p_sType,p_aArgs,p_oItem){var sClassName=p_aArgs[0];if(this._sClassName){Dom.removeClass(this.element,this._sClassName);} -Dom.addClass(this.element,sClassName);this._sClassName=sClassName;},initDefaultConfig:function(){var oConfig=this.cfg,CheckBoolean=oConfig.checkBoolean;oConfig.addProperty("text",{value:"",handler:this.configText,validator:this._checkString,suppressEvent:true});oConfig.addProperty("helptext",{handler:this.configHelpText});oConfig.addProperty("url",{value:"#",handler:this.configURL,suppressEvent:true});oConfig.addProperty("target",{handler:this.configTarget,suppressEvent:true});oConfig.addProperty("emphasis",{value:false,handler:this.configEmphasis,validator:CheckBoolean,suppressEvent:true});oConfig.addProperty("strongemphasis",{value:false,handler:this.configStrongEmphasis,validator:CheckBoolean,suppressEvent:true});oConfig.addProperty("checked",{value:false,handler:this.configChecked,validator:this.cfg.checkBoolean,suppressEvent:true,supercedes:["disabled"]});oConfig.addProperty("disabled",{value:false,handler:this.configDisabled,validator:CheckBoolean,suppressEvent:true});oConfig.addProperty("selected",{value:false,handler:this.configSelected,validator:CheckBoolean,suppressEvent:true});oConfig.addProperty("submenu",{handler:this.configSubmenu});oConfig.addProperty("onclick",{handler:this.configOnClick});oConfig.addProperty("classname",{value:null,handler:this.configClassName,validator:this._checkString});},getNextEnabledSibling:function(){if(this.parent instanceof Menu){var nGroupIndex=this.groupIndex;function getNextArrayItem(p_aArray,p_nStartIndex){return p_aArray[p_nStartIndex]||getNextArrayItem(p_aArray,(p_nStartIndex+1));} -var aItemGroups=this.parent.getItemGroups(),oNextItem;if(this.index<(aItemGroups[nGroupIndex].length-1)){oNextItem=getNextArrayItem(aItemGroups[nGroupIndex],(this.index+1));} -else{var nNextGroupIndex;if(nGroupIndex<(aItemGroups.length-1)){nNextGroupIndex=nGroupIndex+1;} -else{nNextGroupIndex=0;} -var aNextGroup=getNextArrayItem(aItemGroups,nNextGroupIndex);oNextItem=getNextArrayItem(aNextGroup,0);} -return(oNextItem.cfg.getProperty("disabled")||oNextItem.element.style.display=="none")?oNextItem.getNextEnabledSibling():oNextItem;}},getPreviousEnabledSibling:function(){if(this.parent instanceof Menu){var nGroupIndex=this.groupIndex;function getPreviousArrayItem(p_aArray,p_nStartIndex){return p_aArray[p_nStartIndex]||getPreviousArrayItem(p_aArray,(p_nStartIndex-1));} -function getFirstItemIndex(p_aArray,p_nStartIndex){return p_aArray[p_nStartIndex]?p_nStartIndex:getFirstItemIndex(p_aArray,(p_nStartIndex+1));} -var aItemGroups=this.parent.getItemGroups(),oPreviousItem;if(this.index>getFirstItemIndex(aItemGroups[nGroupIndex],0)){oPreviousItem=getPreviousArrayItem(aItemGroups[nGroupIndex],(this.index-1));} -else{var nPreviousGroupIndex;if(nGroupIndex>getFirstItemIndex(aItemGroups,0)){nPreviousGroupIndex=nGroupIndex-1;} -else{nPreviousGroupIndex=aItemGroups.length-1;} -var aPreviousGroup=getPreviousArrayItem(aItemGroups,nPreviousGroupIndex);oPreviousItem=getPreviousArrayItem(aPreviousGroup,(aPreviousGroup.length-1));} -return(oPreviousItem.cfg.getProperty("disabled")||oPreviousItem.element.style.display=="none")?oPreviousItem.getPreviousEnabledSibling():oPreviousItem;}},focus:function(){var oParent=this.parent,oAnchor=this._oAnchor,oActiveItem=oParent.activeItem;function setFocus(){try{oAnchor.focus();} -catch(e){}} -if(!this.cfg.getProperty("disabled")&&oParent&&oParent.cfg.getProperty("visible")&&this.element.style.display!="none"){if(oActiveItem){oActiveItem.blur();} -window.setTimeout(setFocus,0);this.focusEvent.fire();}},blur:function(){var oParent=this.parent;if(!this.cfg.getProperty("disabled")&&oParent&&Dom.getStyle(oParent.element,"visibility")=="visible"){this._oAnchor.blur();this.blurEvent.fire();}},destroy:function(){var oEl=this.element;if(oEl){var oSubmenu=this.cfg.getProperty("submenu");if(oSubmenu){oSubmenu.destroy();} -this.mouseOverEvent.unsubscribeAll();this.mouseOutEvent.unsubscribeAll();this.mouseDownEvent.unsubscribeAll();this.mouseUpEvent.unsubscribeAll();this.clickEvent.unsubscribeAll();this.keyPressEvent.unsubscribeAll();this.keyDownEvent.unsubscribeAll();this.keyUpEvent.unsubscribeAll();this.focusEvent.unsubscribeAll();this.blurEvent.unsubscribeAll();this.cfg.configChangedEvent.unsubscribeAll();var oParentNode=oEl.parentNode;if(oParentNode){oParentNode.removeChild(oEl);this.destroyEvent.fire();} -this.destroyEvent.unsubscribeAll();}},toString:function(){return("MenuItem: "+this.cfg.getProperty("text"));}};})();YAHOO.widget.ContextMenu=function(p_oElement,p_oConfig){YAHOO.widget.ContextMenu.superclass.constructor.call(this,p_oElement,p_oConfig);};YAHOO.lang.extend(YAHOO.widget.ContextMenu,YAHOO.widget.Menu,{_oTrigger:null,_bCancelled:false,contextEventTarget:null,triggerContextMenuEvent:null,init:function(p_oElement,p_oConfig){if(!this.ITEM_TYPE){this.ITEM_TYPE=YAHOO.widget.ContextMenuItem;} -YAHOO.widget.ContextMenu.superclass.init.call(this,p_oElement);this.beforeInitEvent.fire(YAHOO.widget.ContextMenu);if(p_oConfig){this.cfg.applyConfig(p_oConfig,true);} -this.initEvent.fire(YAHOO.widget.ContextMenu);},initEvents:function(){YAHOO.widget.ContextMenu.superclass.initEvents.call(this);this.triggerContextMenuEvent=new YAHOO.util.CustomEvent("triggerContextMenuEvent",this);},cancel:function(){this._bCancelled=true;},_removeEventHandlers:function(){var Event=YAHOO.util.Event,oTrigger=this._oTrigger,bOpera=(this.browser=="opera");Event.removeListener(oTrigger,(bOpera?"mousedown":"contextmenu"),this._onTriggerContextMenu);if(bOpera){Event.removeListener(oTrigger,"click",this._onTriggerClick);}},_onTriggerClick:function(p_oEvent,p_oMenu){if(p_oEvent.ctrlKey){YAHOO.util.Event.stopEvent(p_oEvent);}},_onTriggerContextMenu:function(p_oEvent,p_oMenu){var Event=YAHOO.util.Event;if(p_oEvent.type=="mousedown"&&!p_oEvent.ctrlKey){return;} -Event.stopEvent(p_oEvent);YAHOO.widget.MenuManager.hideVisible();this.contextEventTarget=Event.getTarget(p_oEvent);this.triggerContextMenuEvent.fire(p_oEvent);if(!this._bCancelled){this.cfg.setProperty("xy",Event.getXY(p_oEvent));this.show();} -this._bCancelled=false;},toString:function(){return("ContextMenu "+this.id);},initDefaultConfig:function(){YAHOO.widget.ContextMenu.superclass.initDefaultConfig.call(this);this.cfg.addProperty("trigger",{handler:this.configTrigger});},destroy:function(){this._removeEventHandlers();YAHOO.widget.ContextMenu.superclass.destroy.call(this);},configTrigger:function(p_sType,p_aArgs,p_oMenu){var Event=YAHOO.util.Event,oTrigger=p_aArgs[0];if(oTrigger){if(this._oTrigger){this._removeEventHandlers();} -this._oTrigger=oTrigger;var bOpera=(this.browser=="opera");Event.addListener(oTrigger,(bOpera?"mousedown":"contextmenu"),this._onTriggerContextMenu,this,true);if(bOpera){Event.addListener(oTrigger,"click",this._onTriggerClick,this,true);}} -else{this._removeEventHandlers();}}});YAHOO.widget.ContextMenuItem=function(p_oObject,p_oConfig){YAHOO.widget.ContextMenuItem.superclass.constructor.call(this,p_oObject,p_oConfig);};YAHOO.lang.extend(YAHOO.widget.ContextMenuItem,YAHOO.widget.MenuItem,{init:function(p_oObject,p_oConfig){if(!this.SUBMENU_TYPE){this.SUBMENU_TYPE=YAHOO.widget.ContextMenu;} -YAHOO.widget.ContextMenuItem.superclass.init.call(this,p_oObject);var oConfig=this.cfg;if(p_oConfig){oConfig.applyConfig(p_oConfig,true);} -oConfig.fireQueue();},toString:function(){return("ContextMenuItem: "+this.cfg.getProperty("text"));}});YAHOO.widget.MenuBar=function(p_oElement,p_oConfig){YAHOO.widget.MenuBar.superclass.constructor.call(this,p_oElement,p_oConfig);};YAHOO.lang.extend(YAHOO.widget.MenuBar,YAHOO.widget.Menu,{init:function(p_oElement,p_oConfig){if(!this.ITEM_TYPE){this.ITEM_TYPE=YAHOO.widget.MenuBarItem;} -YAHOO.widget.MenuBar.superclass.init.call(this,p_oElement);this.beforeInitEvent.fire(YAHOO.widget.MenuBar);if(p_oConfig){this.cfg.applyConfig(p_oConfig,true);} -this.initEvent.fire(YAHOO.widget.MenuBar);},CSS_CLASS_NAME:"yuimenubar",_onKeyDown:function(p_sType,p_aArgs,p_oMenuBar){var Event=YAHOO.util.Event,oEvent=p_aArgs[0],oItem=p_aArgs[1],oSubmenu;if(oItem&&!oItem.cfg.getProperty("disabled")){var oItemCfg=oItem.cfg;switch(oEvent.keyCode){case 37:case 39:if(oItem==this.activeItem&&!oItemCfg.getProperty("selected")){oItemCfg.setProperty("selected",true);} -else{var oNextItem=(oEvent.keyCode==37)?oItem.getPreviousEnabledSibling():oItem.getNextEnabledSibling();if(oNextItem){this.clearActiveItem();oNextItem.cfg.setProperty("selected",true);if(this.cfg.getProperty("autosubmenudisplay")){oSubmenu=oNextItem.cfg.getProperty("submenu");if(oSubmenu){oSubmenu.show();oSubmenu.activeItem.blur();oSubmenu.activeItem=null;}} -oNextItem.focus();}} -Event.preventDefault(oEvent);break;case 40:if(this.activeItem!=oItem){this.clearActiveItem();oItemCfg.setProperty("selected",true);oItem.focus();} -oSubmenu=oItemCfg.getProperty("submenu");if(oSubmenu){if(oSubmenu.cfg.getProperty("visible")){oSubmenu.setInitialSelection();oSubmenu.setInitialFocus();} -else{oSubmenu.show();}} -Event.preventDefault(oEvent);break;}} -if(oEvent.keyCode==27&&this.activeItem){oSubmenu=this.activeItem.cfg.getProperty("submenu");if(oSubmenu&&oSubmenu.cfg.getProperty("visible")){oSubmenu.hide();this.activeItem.focus();} -else{this.activeItem.cfg.setProperty("selected",false);this.activeItem.blur();} -Event.preventDefault(oEvent);}},_onClick:function(p_sType,p_aArgs,p_oMenuBar){YAHOO.widget.MenuBar.superclass._onClick.call(this,p_sType,p_aArgs,p_oMenuBar);var oItem=p_aArgs[1];if(oItem&&!oItem.cfg.getProperty("disabled")){var Event=YAHOO.util.Event,Dom=YAHOO.util.Dom,oEvent=p_aArgs[0],oTarget=Event.getTarget(oEvent),oActiveItem=this.activeItem,oConfig=this.cfg;if(oActiveItem&&oActiveItem!=oItem){this.clearActiveItem();} -oItem.cfg.setProperty("selected",true);oItem.focus();var oSubmenu=oItem.cfg.getProperty("submenu");if(oSubmenu&&oTarget!=oItem.submenuIndicator){if(oSubmenu.cfg.getProperty("visible")){oSubmenu.hide();} -else{oSubmenu.show();}}}},toString:function(){return("MenuBar "+this.id);},initDefaultConfig:function(){YAHOO.widget.MenuBar.superclass.initDefaultConfig.call(this);var oConfig=this.cfg;oConfig.addProperty("position",{value:"static",handler:this.configPosition,validator:this._checkPosition,supercedes:["visible"]});oConfig.addProperty("submenualignment",{value:["tl","bl"]});oConfig.addProperty("autosubmenudisplay",{value:false,validator:oConfig.checkBoolean});}});YAHOO.widget.MenuBarItem=function(p_oObject,p_oConfig){YAHOO.widget.MenuBarItem.superclass.constructor.call(this,p_oObject,p_oConfig);};YAHOO.lang.extend(YAHOO.widget.MenuBarItem,YAHOO.widget.MenuItem,{init:function(p_oObject,p_oConfig){if(!this.SUBMENU_TYPE){this.SUBMENU_TYPE=YAHOO.widget.Menu;} -YAHOO.widget.MenuBarItem.superclass.init.call(this,p_oObject);var oConfig=this.cfg;if(p_oConfig){oConfig.applyConfig(p_oConfig,true);} -oConfig.fireQueue();},CSS_CLASS_NAME:"yuimenubaritem",toString:function(){return("MenuBarItem: "+this.cfg.getProperty("text"));}});YAHOO.register("menu",YAHOO.widget.Menu,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/menu/menu.js b/interface/web/js/yui/menu/menu.js deleted file mode 100644 index 4cbecba881..0000000000 --- a/interface/web/js/yui/menu/menu.js +++ /dev/null @@ -1,8265 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - - -/** -* @module menu -* @description <p>The Menu family of components features a collection of -* controls that make it easy to add menus to your website or web application. -* With the Menu Controls you can create website fly-out menus, customized -* context menus, or application-style menu bars with just a small amount of -* scripting.</p><p>The Menu family of controls features:</p> -* <ul> -* <li>Screen-reader accessibility.</li> -* <li>Keyboard and mouse navigation.</li> -* <li>A rich event model that provides access to all of a menu's -* interesting moments.</li> -* <li>Support for -* <a href="http://en.wikipedia.org/wiki/Progressive_Enhancement">Progressive -* Enhancement</a>; Menus can be created from simple, -* semantic markup on the page or purely through JavaScript.</li> -* </ul> -* @title Menu -* @namespace YAHOO.widget -* @requires Event, Dom, Container -*/ -(function() { - -var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event; - -/** -* Singleton that manages a collection of all menus and menu items. Listens for -* DOM events at the document level and dispatches the events to the -* corresponding menu or menu item. -* -* @namespace YAHOO.widget -* @class MenuManager -* @static -*/ -YAHOO.widget.MenuManager = function() { - - // Private member variables - - - // Flag indicating if the DOM event handlers have been attached - - var m_bInitializedEventHandlers = false, - - - // Collection of menus - - m_oMenus = {}, - - - // Collection of menu items - - m_oItems = {}, - - - // Collection of visible menus - - m_oVisibleMenus = {}, - - me = this; - - - - - // Private methods - - - /** - * @method addItem - * @description Adds an item to the collection of known menu items. - * @private - * @param {YAHOO.widget.MenuItem} p_oItem Object specifying the MenuItem - * instance to be added. - */ - function addItem(p_oItem) { - - var sId = p_oItem.id; - - if(p_oItem && m_oItems[sId] != p_oItem) { - - m_oItems[sId] = p_oItem; - - p_oItem.destroyEvent.subscribe(onItemDestroy, p_oItem); - - - } - - } - - - /** - * @method removeItem - * @description Removes an item from the collection of known menu items. - * @private - * @param {YAHOO.widget.MenuItem} p_oItem Object specifying the MenuItem - * instance to be removed. - */ - function removeItem(p_oItem) { - - var sId = p_oItem.id; - - if(sId && m_oItems[sId]) { - - delete m_oItems[sId]; - - - } - - } - - - /** - * @method getMenuRootElement - * @description Finds the root DIV node of a menu or the root LI node of a - * menu item. - * @private - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-58190037">HTMLElement</a>} p_oElement Object specifying - * an HTML element. - */ - function getMenuRootElement(p_oElement) { - - var oParentNode; - - if(p_oElement && p_oElement.tagName) { - - switch(p_oElement.tagName.toUpperCase()) { - - case "DIV": - - oParentNode = p_oElement.parentNode; - - // Check if the DIV is the inner "body" node of a menu - - if( - ( - Dom.hasClass(p_oElement, "hd") || - Dom.hasClass(p_oElement, "bd") || - Dom.hasClass(p_oElement, "ft") - ) - && - oParentNode && - oParentNode.tagName && - oParentNode.tagName.toUpperCase() == "DIV" - ) { - - return oParentNode; - - } - else { - - return p_oElement; - - } - - break; - - case "LI": - - return p_oElement; - - default: - - oParentNode = p_oElement.parentNode; - - if(oParentNode) { - - return getMenuRootElement(oParentNode); - - } - - break; - - } - - } - - } - - - - // Private event handlers - - - /** - * @method onDOMEvent - * @description Generic, global event handler for all of a menu's DOM-based - * events. This listens for events against the document object. If the - * target of a given event is a member of a menu or menu item's DOM, the - * instance's corresponding Custom Event is fired. - * @private - * @param {Event} p_oEvent Object representing the DOM event object passed - * back by the event utility (YAHOO.util.Event). - */ - function onDOMEvent(p_oEvent) { - - // Get the target node of the DOM event - - var oTarget = Event.getTarget(p_oEvent), - - - // See if the target of the event was a menu, or a menu item - - oElement = getMenuRootElement(oTarget), - oMenuItem, - oMenu; - - - if(oElement) { - - var sTagName = oElement.tagName.toUpperCase(); - - if(sTagName == "LI") { - - var sId = oElement.id; - - if(sId && m_oItems[sId]) { - - oMenuItem = m_oItems[sId]; - oMenu = oMenuItem.parent; - - } - - } - else if(sTagName == "DIV") { - - if(oElement.id) { - - oMenu = m_oMenus[oElement.id]; - - } - - } - - } - - if(oMenu) { - - // Map of DOM event names to CustomEvent names - - var oEventTypes = { - "click": "clickEvent", - "mousedown": "mouseDownEvent", - "mouseup": "mouseUpEvent", - "mouseover": "mouseOverEvent", - "mouseout": "mouseOutEvent", - "keydown": "keyDownEvent", - "keyup": "keyUpEvent", - "keypress": "keyPressEvent" - }, - - sCustomEventType = oEventTypes[p_oEvent.type]; - - - // Fire the Custom Even that corresponds the current DOM event - - if(oMenuItem && !oMenuItem.cfg.getProperty("disabled")) { - - oMenuItem[sCustomEventType].fire(p_oEvent); - - } - - oMenu[sCustomEventType].fire(p_oEvent, oMenuItem); - - } - else if(p_oEvent.type == "mousedown") { - - - /* - If the target of the event wasn't a menu, hide all - dynamically positioned menus - */ - - var oActiveItem; - - for(var i in m_oMenus) { - - if(m_oMenus.hasOwnProperty(i)) { - - oMenu = m_oMenus[i]; - - if( - oMenu.cfg.getProperty("clicktohide") && - oMenu.cfg.getProperty("position") == "dynamic" - ) { - - oMenu.hide(); - - } - else { - - oMenu.clearActiveItem(true); - - } - - } - - } - - } - - } - - - /** - * @method onMenuDestroy - * @description "destroy" event handler for a 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.Menu} p_oMenu Object representing the menu that - * fired the event. - */ - function onMenuDestroy(p_sType, p_aArgs, p_oMenu) { - - if(p_oMenu && m_oMenus[p_oMenu.id]) { - - delete m_oMenus[p_oMenu.id]; - - - } - - } - - - /** - * @method onItemDestroy - * @description "destroy" event handler for a MenuItem instance. - * @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 fired the event. - */ - function onItemDestroy(p_sType, p_aArgs, p_oItem) { - - var sId = p_oItem.id; - - if(sId && m_oItems[sId]) { - - delete m_oItems[sId]; - - } - - } - - - /** - * @method onMenuVisibleConfigChange - * @description Event handler for when the "visible" configuration property - * of a Menu instance changes. - * @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.Menu} p_oMenu Object representing the menu that - * fired the event. - */ - function onMenuVisibleConfigChange(p_sType, p_aArgs, p_oMenu) { - - var bVisible = p_aArgs[0]; - - if(bVisible) { - - m_oVisibleMenus[p_oMenu.id] = p_oMenu; - - - } - else if(m_oVisibleMenus[p_oMenu.id]) { - - delete m_oVisibleMenus[p_oMenu.id]; - - - } - - } - - - /** - * @method onItemAdded - * @description "itemadded" event handler for a Menu instance. - * @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. - */ - function onItemAdded(p_sType, p_aArgs) { - - addItem(p_aArgs[0]); - - } - - - /** - * @method onItemRemoved - * @description "itemremoved" event handler for a Menu instance. - * @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. - */ - function onItemRemoved(p_sType, p_aArgs) { - - removeItem(p_aArgs[0]); - - } - - - - return { - - // Privileged methods - - - /** - * @method addMenu - * @description Adds a menu to the collection of known menus. - * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu - * instance to be added. - */ - addMenu: function(p_oMenu) { - - if(p_oMenu && p_oMenu.id && !m_oMenus[p_oMenu.id]) { - - m_oMenus[p_oMenu.id] = p_oMenu; - - - if(!m_bInitializedEventHandlers) { - - var oDoc = document; - - Event.addListener(oDoc, "mouseover", onDOMEvent, me, true); - Event.addListener(oDoc, "mouseout", onDOMEvent, me, true); - Event.addListener(oDoc, "mousedown", onDOMEvent, me, true); - Event.addListener(oDoc, "mouseup", onDOMEvent, me, true); - Event.addListener(oDoc, "click", onDOMEvent, me, true); - Event.addListener(oDoc, "keydown", onDOMEvent, me, true); - Event.addListener(oDoc, "keyup", onDOMEvent, me, true); - Event.addListener(oDoc, "keypress", onDOMEvent, me, true); - - m_bInitializedEventHandlers = true; - - - } - - p_oMenu.destroyEvent.subscribe(onMenuDestroy, p_oMenu, me); - - p_oMenu.cfg.subscribeToConfigEvent( - "visible", - onMenuVisibleConfigChange, - p_oMenu - ); - - p_oMenu.itemAddedEvent.subscribe(onItemAdded); - p_oMenu.itemRemovedEvent.subscribe(onItemRemoved); - - - } - - }, - - - /** - * @method removeMenu - * @description Removes a menu from the collection of known menus. - * @param {YAHOO.widget.Menu} p_oMenu Object specifying the Menu - * instance to be removed. - */ - removeMenu: function(p_oMenu) { - - if(p_oMenu && m_oMenus[p_oMenu.id]) { - - delete m_oMenus[p_oMenu.id]; - - - } - - }, - - - /** - * @method hideVisible - * @description Hides all visible, dynamically positioned menus. - */ - hideVisible: function() { - - var oMenu; - - for(var i in m_oVisibleMenus) { - - if(m_oVisibleMenus.hasOwnProperty(i)) { - - oMenu = m_oVisibleMenus[i]; - - if(oMenu.cfg.getProperty("position") == "dynamic") { - - oMenu.hide(); - - } - - } - - } - - }, - - - /** - * @method getMenus - * @description Returns an array of all menus registered with the - * menu manger. - * @return {Array} - */ - getMenus: function() { - - return m_oMenus; - - }, - - - /** - * @method getMenu - * @description Returns a menu with the specified id. - * @param {String} p_sId String specifying the id of the menu to - * be retrieved. - * @return {YAHOO.widget.Menu} - */ - getMenu: function(p_sId) { - - if(m_oMenus[p_sId]) { - - return m_oMenus[p_sId]; - - } - - }, - - - /** - * @method toString - * @description Returns a string representing the menu manager. - * @return {String} - */ - toString: function() { - - return ("MenuManager"); - - } - - }; - -}(); - -})(); - - - -/** -* The Menu class creates a container that holds a vertical list representing -* a set of options or commands. Menu is the base class for all -* menu containers. -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the menu. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source -* for the menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object -* specifying the <code><div></code> element of the menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement -* Object specifying the <code><select></code> element to be used as -* the data source for the menu. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu. See configuration class documentation for -* more details. -* @namespace YAHOO.widget -* @class Menu -* @constructor -* @extends YAHOO.widget.Overlay -*/ -(function() { - -var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event, - Lang = YAHOO.lang; - - -YAHOO.widget.Menu = function(p_oElement, p_oConfig) { - - if(p_oConfig) { - - this.parent = p_oConfig.parent; - this.lazyLoad = p_oConfig.lazyLoad || p_oConfig.lazyload; - this.itemData = p_oConfig.itemData || p_oConfig.itemdata; - - } - - - YAHOO.widget.Menu.superclass.constructor.call( - this, - p_oElement, - p_oConfig - ); - -}; - - -YAHOO.lang.extend(YAHOO.widget.Menu, YAHOO.widget.Overlay, { - - -// Constants - - -/** -* @property CSS_CLASS_NAME -* @description String representing the CSS class(es) to be applied to the -* menu's <code><div></code> element. -* @default "yuimenu" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuimenu", - - -/** -* @property ITEM_TYPE -* @description Object representing the type of menu item to instantiate and -* add when parsing the child nodes (either <code><li></code> element, -* <code><optgroup></code> element or <code><option></code>) -* of the menu's source HTML element. -* @default YAHOO.widget.MenuItem -* @final -* @type YAHOO.widget.MenuItem -*/ -ITEM_TYPE: null, - - -/** -* @property GROUP_TITLE_TAG_NAME -* @description String representing the tagname of the HTML element used to -* title the menu's item groups. -* @default H6 -* @final -* @type String -*/ -GROUP_TITLE_TAG_NAME: "h6", - - - -// Private properties - - -/** -* @property _nHideDelayId -* @description Number representing the time-out setting used to cancel the -* hiding of a menu. -* @default null -* @private -* @type Number -*/ -_nHideDelayId: null, - - -/** -* @property _nShowDelayId -* @description Number representing the time-out setting used to cancel the -* showing of a menu. -* @default null -* @private -* @type Number -*/ -_nShowDelayId: null, - - -/** -* @property _nSubmenuHideDelayId -* @description Number representing the time-out setting used to cancel the -* hiding of a submenu. -* @default null -* @private -* @type Number -*/ -_nSubmenuHideDelayId: null, - - -/** -* @property _nBodyScrollId -* @description Number representing the time-out setting used to cancel the -* scrolling of the menu's body element. -* @default null -* @private -* @type Number -*/ -_nBodyScrollId: null, - - -/** -* @property _bHideDelayEventHandlersAssigned -* @description Boolean indicating if the "mouseover" and "mouseout" event -* handlers used for hiding the menu via a call to "window.setTimeout" have -* already been assigned. -* @default false -* @private -* @type Boolean -*/ -_bHideDelayEventHandlersAssigned: false, - - -/** -* @property _bHandledMouseOverEvent -* @description Boolean indicating the current state of the menu's -* "mouseover" event. -* @default false -* @private -* @type Boolean -*/ -_bHandledMouseOverEvent: false, - - -/** -* @property _bHandledMouseOutEvent -* @description Boolean indicating the current state of the menu's -* "mouseout" event. -* @default false -* @private -* @type Boolean -*/ -_bHandledMouseOutEvent: false, - - -/** -* @property _aGroupTitleElements -* @description Array of HTML element used to title groups of menu items. -* @default [] -* @private -* @type Array -*/ -_aGroupTitleElements: null, - - -/** -* @property _aItemGroups -* @description Multi-dimensional Array representing the menu items as they -* are grouped in the menu. -* @default [] -* @private -* @type Array -*/ -_aItemGroups: null, - - -/** -* @property _aListElements -* @description Array of <code><ul></code> elements, each of which is -* the parent node for each item's <code><li></code> element. -* @default [] -* @private -* @type Array -*/ -_aListElements: null, - - -/** -* @property _nCurrentMouseX -* @description The current x coordinate of the mouse inside the area of -* the menu. -* @default 0 -* @private -* @type Number -*/ -_nCurrentMouseX: 0, - - -/** -* @property _nMaxHeight -* @description The original value of the "maxheight" configuration property -* as set by the user. -* @default -1 -* @private -* @type Number -*/ -_nMaxHeight: -1, - - -/** -* @property _bStopMouseEventHandlers -* @description Stops "mouseover," "mouseout," and "mousemove" event handlers -* from executing. -* @default false -* @private -* @type Boolean -*/ -_bStopMouseEventHandlers: false, - - -/** -* @property _sClassName -* @description The current value of the "classname" configuration attribute. -* @default null -* @private -* @type String -*/ -_sClassName: null, - - - -// Public properties - - -/** -* @property lazyLoad -* @description Boolean indicating if the menu's "lazy load" feature is -* enabled. If set to "true," initialization and rendering of the menu's -* items will be deferred until the first time it is made visible. This -* property should be set via the constructor using the configuration -* object literal. -* @default false -* @type Boolean -*/ -lazyLoad: false, - - -/** -* @property itemData -* @description Array of items to be added to the menu. The array can contain -* strings representing the text for each item to be created, object literals -* representing the menu item configuration properties, or MenuItem instances. -* This property should be set via the constructor using the configuration -* object literal. -* @default null -* @type Array -*/ -itemData: null, - - -/** -* @property activeItem -* @description Object reference to the item in the menu that has focus. -* @default null -* @type YAHOO.widget.MenuItem -*/ -activeItem: null, - - -/** -* @property parent -* @description Object reference to the menu's parent menu or menu item. -* This property can be set via the constructor using the configuration -* object literal. -* @default null -* @type YAHOO.widget.MenuItem -*/ -parent: null, - - -/** -* @property srcElement -* @description Object reference to the HTML element (either -* <code><select></code> or <code><div></code>) used to -* create the menu. -* @default null -* @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-94282980">HTMLSelectElement</a>|<a -* href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html. -* html#ID-22445964">HTMLDivElement</a> -*/ -srcElement: null, - - - -// Events - - -/** -* @event mouseOverEvent -* @description Fires when the mouse has entered the menu. Passes back -* the DOM Event object as an argument. -*/ -mouseOverEvent: null, - - -/** -* @event mouseOutEvent -* @description Fires when the mouse has left the menu. Passes back the DOM -* Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -mouseOutEvent: null, - - -/** -* @event mouseDownEvent -* @description Fires when the user mouses down on the menu. Passes back the -* DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -mouseDownEvent: null, - - -/** -* @event mouseUpEvent -* @description Fires when the user releases a mouse button while the mouse is -* over the menu. Passes back the DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -mouseUpEvent: null, - - -/** -* @event clickEvent -* @description Fires when the user clicks the on the menu. Passes back the -* DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -clickEvent: null, - - -/** -* @event keyPressEvent -* @description Fires when the user presses an alphanumeric key when one of the -* menu's items has focus. Passes back the DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -keyPressEvent: null, - - -/** -* @event keyDownEvent -* @description Fires when the user presses a key when one of the menu's items -* has focus. Passes back the DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -keyDownEvent: null, - - -/** -* @event keyUpEvent -* @description Fires when the user releases a key when one of the menu's items -* has focus. Passes back the DOM Event object as an argument. -* @type YAHOO.util.CustomEvent -*/ -keyUpEvent: null, - - -/** -* @event itemAddedEvent -* @description Fires when an item is added to the menu. -* @type YAHOO.util.CustomEvent -*/ -itemAddedEvent: null, - - -/** -* @event itemRemovedEvent -* @description Fires when an item is removed to the menu. -* @type YAHOO.util.CustomEvent -*/ -itemRemovedEvent: null, - - -/** -* @method init -* @description The Menu class's initialization method. This method is -* automatically called by the constructor, and sets up all DOM references -* for pre-existing markup, and creates required markup if it is not -* already present. -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the menu. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source -* for the menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object -* specifying the <code><div></code> element of the menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ -* level-one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement -* Object specifying the <code><select></code> element to be used as -* the data source for the menu. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu. See configuration class documentation for -* more details. -*/ -init: function(p_oElement, p_oConfig) { - - this._aItemGroups = []; - this._aListElements = []; - this._aGroupTitleElements = []; - - - if(!this.ITEM_TYPE) { - - this.ITEM_TYPE = YAHOO.widget.MenuItem; - - } - - - var oElement; - - if(typeof p_oElement == "string") { - - oElement = document.getElementById(p_oElement); - - } - else if(p_oElement.tagName) { - - oElement = p_oElement; - - } - - - if(oElement && oElement.tagName) { - - switch(oElement.tagName.toUpperCase()) { - - case "DIV": - - this.srcElement = oElement; - - if(!oElement.id) { - - oElement.setAttribute("id", Dom.generateId()); - - } - - - /* - Note: we don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.Menu.superclass.init.call(this, oElement); - - this.beforeInitEvent.fire(YAHOO.widget.Menu); - - - - break; - - case "SELECT": - - this.srcElement = oElement; - - - /* - The source element is not something that we can use - outright, so we need to create a new Overlay - - Note: we don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.Menu.superclass.init.call(this, Dom.generateId()); - - this.beforeInitEvent.fire(YAHOO.widget.Menu); - - - - break; - - } - - } - else { - - /* - Note: we don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.Menu.superclass.init.call(this, p_oElement); - - this.beforeInitEvent.fire(YAHOO.widget.Menu); - - - - } - - - if(this.element) { - - var oEl = this.element; - - Dom.addClass(oEl, this.CSS_CLASS_NAME); - - - // Subscribe to Custom Events - - this.initEvent.subscribe(this._onInit, this, true); - this.beforeRenderEvent.subscribe(this._onBeforeRender, this, true); - this.renderEvent.subscribe(this._setWidth, this, true); - this.beforeShowEvent.subscribe(this._onBeforeShow, this, true); - this.showEvent.subscribe(this._onShow, this, true); - this.beforeHideEvent.subscribe(this._onBeforeHide, this, true); - this.hideEvent.subscribe(this._onHide, this, true); - this.mouseOverEvent.subscribe(this._onMouseOver, this, true); - this.mouseOutEvent.subscribe(this._onMouseOut, this, true); - this.clickEvent.subscribe(this._onClick, this, true); - this.keyDownEvent.subscribe(this._onKeyDown, this, true); - this.keyPressEvent.subscribe(this._onKeyPress, this, true); - - YAHOO.widget.Module.textResizeEvent.subscribe( - this._onTextResize, - this, - true - ); - - - if(p_oConfig) { - - this.cfg.applyConfig(p_oConfig, true); - - } - - - // Register the Menu instance with the MenuManager - - YAHOO.widget.MenuManager.addMenu(this); - - - this.initEvent.fire(YAHOO.widget.Menu); - - } - -}, - - - -// Private methods - - -/** -* @method _initSubTree -* @description Iterates the childNodes of the source element to find nodes -* used to instantiate menu and menu items. -* @private -*/ -_initSubTree: function() { - - var oNode; - - if(this.srcElement.tagName.toUpperCase() == "DIV") { - - /* - Populate the collection of item groups and item - group titles - */ - - oNode = this.body.firstChild; - - var nGroup = 0, - sGroupTitleTagName = this.GROUP_TITLE_TAG_NAME.toUpperCase(); - - do { - - if(oNode && oNode.tagName) { - - switch(oNode.tagName.toUpperCase()) { - - case sGroupTitleTagName: - - this._aGroupTitleElements[nGroup] = oNode; - - break; - - case "UL": - - this._aListElements[nGroup] = oNode; - this._aItemGroups[nGroup] = []; - nGroup++; - - break; - - } - - } - - } - while((oNode = oNode.nextSibling)); - - - /* - Apply the "first-of-type" class to the first UL to mimic - the "first-of-type" CSS3 psuedo class. - */ - - if(this._aListElements[0]) { - - Dom.addClass(this._aListElements[0], "first-of-type"); - - } - - } - - - oNode = null; - - - if(this.srcElement.tagName) { - - var sSrcElementTagName = this.srcElement.tagName.toUpperCase(); - - - switch(sSrcElementTagName) { - - case "DIV": - - if(this._aListElements.length > 0) { - - - var i = this._aListElements.length - 1; - - do { - - oNode = this._aListElements[i].firstChild; - - - do { - - if( - oNode && - oNode.tagName && - oNode.tagName.toUpperCase() == "LI" - ) { - - - this.addItem( - new this.ITEM_TYPE( - oNode, - { parent: this } - ), - i - ); - - } - - } - while((oNode = oNode.nextSibling)); - - } - while(i--); - - } - - break; - - case "SELECT": - - - oNode = this.srcElement.firstChild; - - do { - - if(oNode && oNode.tagName) { - - switch(oNode.tagName.toUpperCase()) { - - case "OPTGROUP": - case "OPTION": - - - this.addItem( - new this.ITEM_TYPE( - oNode, - { parent: this } - ) - ); - - break; - - } - - } - - } - while((oNode = oNode.nextSibling)); - - break; - - } - - } - -}, - - -/** -* @method _getFirstEnabledItem -* @description Returns the first enabled item in the menu. -* @return {YAHOO.widget.MenuItem} -* @private -*/ -_getFirstEnabledItem: function() { - - var aItems = this.getItems(), - nItems = aItems.length, - oItem; - - for(var i=0; i<nItems; i++) { - - oItem = aItems[i]; - - if( - oItem && - !oItem.cfg.getProperty("disabled") && - oItem.element.style.display != "none" - ) { - - return oItem; - - } - - } - -}, - - -/** -* @method _checkPosition -* @description Checks to make sure that the value of the "position" property -* is one of the supported strings. Returns true if the position is supported. -* @private -* @param {Object} p_sPosition String specifying the position of the menu. -* @return {Boolean} -*/ -_checkPosition: function(p_sPosition) { - - if(typeof p_sPosition == "string") { - - var sPosition = p_sPosition.toLowerCase(); - - return ("dynamic,static".indexOf(sPosition) != -1); - - } - -}, - - -/** -* @method _addItemToGroup -* @description Adds a menu item to a group. -* @private -* @param {Number} p_nGroupIndex Number indicating the group to which the -* item belongs. -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance to be added to the menu. -* @param {String} p_oItem String specifying the text of the item to be added -* to the menu. -* @param {Object} p_oItem Object literal containing a set of menu item -* configuration properties. -* @param {Number} p_nItemIndex Optional. Number indicating the index at -* which the menu item should be added. -* @return {YAHOO.widget.MenuItem} -*/ -_addItemToGroup: function(p_nGroupIndex, p_oItem, p_nItemIndex) { - - var oItem; - - if(p_oItem instanceof this.ITEM_TYPE) { - - oItem = p_oItem; - oItem.parent = this; - - } - else if(typeof p_oItem == "string") { - - oItem = new this.ITEM_TYPE(p_oItem, { parent: this }); - - } - else if(typeof p_oItem == "object") { - - p_oItem.parent = this; - - oItem = new this.ITEM_TYPE(p_oItem.text, p_oItem); - - } - - - if(oItem) { - - var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0, - aGroup = this._getItemGroup(nGroupIndex), - oGroupItem; - - - if(!aGroup) { - - aGroup = this._createItemGroup(nGroupIndex); - - } - - - if(typeof p_nItemIndex == "number") { - - var bAppend = (p_nItemIndex >= aGroup.length); - - - if(aGroup[p_nItemIndex]) { - - aGroup.splice(p_nItemIndex, 0, oItem); - - } - else { - - aGroup[p_nItemIndex] = oItem; - - } - - - oGroupItem = aGroup[p_nItemIndex]; - - if(oGroupItem) { - - if( - bAppend && - ( - !oGroupItem.element.parentNode || - oGroupItem.element.parentNode.nodeType == 11 - ) - ) { - - this._aListElements[nGroupIndex].appendChild( - oGroupItem.element - ); - - } - else { - - function getNextItemSibling(p_aArray, p_nStartIndex) { - - return ( - p_aArray[p_nStartIndex] || - getNextItemSibling( - p_aArray, - (p_nStartIndex+1) - ) - ); - - } - - - var oNextItemSibling = - getNextItemSibling(aGroup, (p_nItemIndex+1)); - - if( - oNextItemSibling && - ( - !oGroupItem.element.parentNode || - oGroupItem.element.parentNode.nodeType == 11 - ) - ) { - - this._aListElements[nGroupIndex].insertBefore( - oGroupItem.element, - oNextItemSibling.element - ); - - } - - } - - - oGroupItem.parent = this; - - this._subscribeToItemEvents(oGroupItem); - - this._configureSubmenu(oGroupItem); - - this._updateItemProperties(nGroupIndex); - - - this.itemAddedEvent.fire(oGroupItem); - - return oGroupItem; - - } - - } - else { - - var nItemIndex = aGroup.length; - - aGroup[nItemIndex] = oItem; - - oGroupItem = aGroup[nItemIndex]; - - - if(oGroupItem) { - - if( - !Dom.isAncestor( - this._aListElements[nGroupIndex], - oGroupItem.element - ) - ) { - - this._aListElements[nGroupIndex].appendChild( - oGroupItem.element - ); - - } - - oGroupItem.element.setAttribute("groupindex", nGroupIndex); - oGroupItem.element.setAttribute("index", nItemIndex); - - oGroupItem.parent = this; - - oGroupItem.index = nItemIndex; - oGroupItem.groupIndex = nGroupIndex; - - this._subscribeToItemEvents(oGroupItem); - - this._configureSubmenu(oGroupItem); - - if(nItemIndex === 0) { - - Dom.addClass(oGroupItem.element, "first-of-type"); - - } - - - - this.itemAddedEvent.fire(oGroupItem); - - return oGroupItem; - - } - - } - - } - -}, - - -/** -* @method _removeItemFromGroupByIndex -* @description Removes a menu item from a group by index. Returns the menu -* item that was removed. -* @private -* @param {Number} p_nGroupIndex Number indicating the group to which the menu -* item belongs. -* @param {Number} p_nItemIndex Number indicating the index of the menu item -* to be removed. -* @return {YAHOO.widget.MenuItem} -*/ -_removeItemFromGroupByIndex: function(p_nGroupIndex, p_nItemIndex) { - - var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0, - aGroup = this._getItemGroup(nGroupIndex); - - if(aGroup) { - - var aArray = aGroup.splice(p_nItemIndex, 1), - oItem = aArray[0]; - - if(oItem) { - - // Update the index and className properties of each member - - this._updateItemProperties(nGroupIndex); - - if(aGroup.length === 0) { - - // Remove the UL - - var oUL = this._aListElements[nGroupIndex]; - - if(this.body && oUL) { - - this.body.removeChild(oUL); - - } - - // Remove the group from the array of items - - this._aItemGroups.splice(nGroupIndex, 1); - - - // Remove the UL from the array of ULs - - this._aListElements.splice(nGroupIndex, 1); - - - /* - Assign the "first-of-type" class to the new first UL - in the collection - */ - - oUL = this._aListElements[0]; - - if(oUL) { - - Dom.addClass(oUL, "first-of-type"); - - } - - } - - - this.itemRemovedEvent.fire(oItem); - - - // Return a reference to the item that was removed - - return oItem; - - } - - } - -}, - - -/** -* @method _removeItemFromGroupByValue -* @description Removes a menu item from a group by reference. Returns the -* menu item that was removed. -* @private -* @param {Number} p_nGroupIndex Number indicating the group to which the -* menu item belongs. -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance to be removed. -* @return {YAHOO.widget.MenuItem} -*/ -_removeItemFromGroupByValue: function(p_nGroupIndex, p_oItem) { - - var aGroup = this._getItemGroup(p_nGroupIndex); - - if(aGroup) { - - var nItems = aGroup.length, - nItemIndex = -1; - - if(nItems > 0) { - - var i = nItems-1; - - do { - - if(aGroup[i] == p_oItem) { - - nItemIndex = i; - break; - - } - - } - while(i--); - - if(nItemIndex > -1) { - - return this._removeItemFromGroupByIndex( - p_nGroupIndex, - nItemIndex - ); - - } - - } - - } - -}, - - -/** -* @method _updateItemProperties -* @description Updates the "index," "groupindex," and "className" properties -* of the menu items in the specified group. -* @private -* @param {Number} p_nGroupIndex Number indicating the group of items to update. -*/ -_updateItemProperties: function(p_nGroupIndex) { - - var aGroup = this._getItemGroup(p_nGroupIndex), - nItems = aGroup.length; - - if(nItems > 0) { - - var i = nItems - 1, - oItem, - oLI; - - // Update the index and className properties of each member - - do { - - oItem = aGroup[i]; - - if(oItem) { - - oLI = oItem.element; - - oItem.index = i; - oItem.groupIndex = p_nGroupIndex; - - oLI.setAttribute("groupindex", p_nGroupIndex); - oLI.setAttribute("index", i); - - Dom.removeClass(oLI, "first-of-type"); - - } - - } - while(i--); - - - if(oLI) { - - Dom.addClass(oLI, "first-of-type"); - - } - - } - -}, - - -/** -* @method _createItemGroup -* @description Creates a new menu item group (array) and its associated -* <code><ul></code> element. Returns an aray of menu item groups. -* @private -* @param {Number} p_nIndex Number indicating the group to create. -* @return {Array} -*/ -_createItemGroup: function(p_nIndex) { - - if(!this._aItemGroups[p_nIndex]) { - - this._aItemGroups[p_nIndex] = []; - - var oUL = document.createElement("ul"); - - this._aListElements[p_nIndex] = oUL; - - return this._aItemGroups[p_nIndex]; - - } - -}, - - -/** -* @method _getItemGroup -* @description Returns the menu item group at the specified index. -* @private -* @param {Number} p_nIndex Number indicating the index of the menu item group -* to be retrieved. -* @return {Array} -*/ -_getItemGroup: function(p_nIndex) { - - var nIndex = ((typeof p_nIndex == "number") ? p_nIndex : 0); - - return this._aItemGroups[nIndex]; - -}, - - -/** -* @method _configureSubmenu -* @description Subscribes the menu item's submenu to its parent menu's events. -* @private -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance with the submenu to be configured. -*/ -_configureSubmenu: function(p_oItem) { - - var oSubmenu = p_oItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - /* - Listen for configuration changes to the parent menu - so they they can be applied to the submenu. - */ - - this.cfg.configChangedEvent.subscribe( - this._onParentMenuConfigChange, - oSubmenu, - true - ); - - this.renderEvent.subscribe( - this._onParentMenuRender, - oSubmenu, - true - ); - - oSubmenu.beforeShowEvent.subscribe( - this._onSubmenuBeforeShow, - oSubmenu, - true - ); - - oSubmenu.showEvent.subscribe( - this._onSubmenuShow, - oSubmenu, - true - ); - - oSubmenu.hideEvent.subscribe( - this._onSubmenuHide, - oSubmenu, - true - ); - - } - -}, - - -/** -* @method _subscribeToItemEvents -* @description Subscribes a menu to a menu item's event. -* @private -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance whose events should be subscribed to. -*/ -_subscribeToItemEvents: function(p_oItem) { - - p_oItem.focusEvent.subscribe(this._onMenuItemFocus, p_oItem, this); - - p_oItem.blurEvent.subscribe(this._onMenuItemBlur, this, true); - - p_oItem.cfg.configChangedEvent.subscribe( - this._onMenuItemConfigChange, - p_oItem, - this - ); - -}, - - -/** -* @method _getOffsetWidth -* @description Returns the offset width of the menu's -* <code><div></code> element. -* @private -*/ -_getOffsetWidth: function() { - - var oClone = this.element.cloneNode(true); - - Dom.setStyle(oClone, "width", ""); - - document.body.appendChild(oClone); - - var sWidth = oClone.offsetWidth; - - document.body.removeChild(oClone); - - return sWidth; - -}, - - -/** -* @method _setWidth -* @description Sets the width of the menu's root <code><div></code> -* element to its offsetWidth. -* @private -*/ -_setWidth: function() { - - if(this.cfg.getProperty("position") == "dynamic") { - - var sWidth; - - if(this.element.parentNode.tagName.toUpperCase() == "BODY") { - - if(this.browser == "opera") { - - sWidth = this._getOffsetWidth(); - - } - else { - - Dom.setStyle(this.element, "width", "auto"); - - sWidth = this.element.offsetWidth; - - } - - } - else { - - sWidth = this._getOffsetWidth(); - - } - - this.cfg.setProperty("width", (sWidth + "px")); - - } - -}, - - -/** -* @method _cancelHideDelay -* @description Cancels the call to "hideMenu." -* @private -*/ -_cancelHideDelay: function() { - - var oRoot = this.getRoot(); - - if(oRoot._nHideDelayId) { - - window.clearTimeout(oRoot._nHideDelayId); - - } - -}, - - -/** -* @method _execHideDelay -* @description Hides the menu after the number of milliseconds specified by -* the "hidedelay" configuration property. -* @private -*/ -_execHideDelay: function() { - - this._cancelHideDelay(); - - var oRoot = this.getRoot(), - me = this; - - function hideMenu() { - - if(oRoot.activeItem) { - - oRoot.clearActiveItem(); - - } - - if(oRoot == me && me.cfg.getProperty("position") == "dynamic") { - - me.hide(); - - } - - } - - - oRoot._nHideDelayId = - window.setTimeout(hideMenu, oRoot.cfg.getProperty("hidedelay")); - -}, - - -/** -* @method _cancelShowDelay -* @description Cancels the call to the "showMenu." -* @private -*/ -_cancelShowDelay: function() { - - var oRoot = this.getRoot(); - - if(oRoot._nShowDelayId) { - - window.clearTimeout(oRoot._nShowDelayId); - - } - -}, - - -/** -* @method _execShowDelay -* @description Shows the menu after the number of milliseconds specified by -* the "showdelay" configuration property have ellapsed. -* @private -* @param {YAHOO.widget.Menu} p_oMenu Object specifying the menu that should -* be made visible. -*/ -_execShowDelay: function(p_oMenu) { - - var oRoot = this.getRoot(); - - function showMenu() { - - if(p_oMenu.parent.cfg.getProperty("selected")) { - - p_oMenu.show(); - - } - - } - - - oRoot._nShowDelayId = - window.setTimeout(showMenu, oRoot.cfg.getProperty("showdelay")); - -}, - - -/** -* @method _execSubmenuHideDelay -* @description Hides a submenu after the number of milliseconds specified by -* the "submenuhidedelay" configuration property have ellapsed. -* @private -* @param {YAHOO.widget.Menu} p_oSubmenu Object specifying the submenu that -* should be hidden. -* @param {Number} p_nMouseX The x coordinate of the mouse when it left -* the specified submenu's parent menu item. -* @param {Number} p_nHideDelay The number of milliseconds that should ellapse -* before the submenu is hidden. -*/ -_execSubmenuHideDelay: function(p_oSubmenu, p_nMouseX, p_nHideDelay) { - - var me = this; - - p_oSubmenu._nSubmenuHideDelayId = window.setTimeout(function () { - - if(me._nCurrentMouseX > (p_nMouseX + 10)) { - - p_oSubmenu._nSubmenuHideDelayId = window.setTimeout(function () { - - p_oSubmenu.hide(); - - }, p_nHideDelay); - - } - else { - - p_oSubmenu.hide(); - - } - - }, 50); - -}, - - - -// Protected methods - - -/** -* @method _disableScrollHeader -* @description Disables the header used for scrolling the body of the menu. -* @protected -*/ -_disableScrollHeader: function() { - - if(!this._bHeaderDisabled) { - - Dom.addClass(this.header, "topscrollbar_disabled"); - this._bHeaderDisabled = true; - - } - -}, - - -/** -* @method _disableScrollFooter -* @description Disables the footer used for scrolling the body of the menu. -* @protected -*/ -_disableScrollFooter: function() { - - if(!this._bFooterDisabled) { - - Dom.addClass(this.footer, "bottomscrollbar_disabled"); - this._bFooterDisabled = true; - - } - -}, - - -/** -* @method _enableScrollHeader -* @description Enables the header used for scrolling the body of the menu. -* @protected -*/ -_enableScrollHeader: function() { - - if(this._bHeaderDisabled) { - - Dom.removeClass(this.header, "topscrollbar_disabled"); - this._bHeaderDisabled = false; - - } - -}, - - -/** -* @method _enableScrollFooter -* @description Enables the footer used for scrolling the body of the menu. -* @protected -*/ -_enableScrollFooter: function() { - - if(this._bFooterDisabled) { - - Dom.removeClass(this.footer, "bottomscrollbar_disabled"); - this._bFooterDisabled = false; - - } - -}, - - - -/** -* @method _onMouseOver -* @description "mouseover" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onMouseOver: function(p_sType, p_aArgs, p_oMenu) { - - if(this._bStopMouseEventHandlers) { - - return false; - - } - - - var oEvent = p_aArgs[0], - oItem = p_aArgs[1], - oTarget = Event.getTarget(oEvent); - - - if( - !this._bHandledMouseOverEvent && - (oTarget == this.element || Dom.isAncestor(this.element, oTarget)) - ) { - - // Menu mouseover logic - - this._nCurrentMouseX = 0; - - Event.addListener( - this.element, - "mousemove", - this._onMouseMove, - this, - true - ); - - - this.clearActiveItem(); - - - if(this.parent && this._nSubmenuHideDelayId) { - - window.clearTimeout(this._nSubmenuHideDelayId); - - this.parent.cfg.setProperty("selected", true); - - var oParentMenu = this.parent.parent; - - oParentMenu.activeItem = this.parent; - - oParentMenu._bHandledMouseOutEvent = true; - oParentMenu._bHandledMouseOverEvent = false; - - } - - - this._bHandledMouseOverEvent = true; - this._bHandledMouseOutEvent = false; - - } - - - if( - oItem && !oItem.handledMouseOverEvent && - !oItem.cfg.getProperty("disabled") && - (oTarget == oItem.element || Dom.isAncestor(oItem.element, oTarget)) - ) { - - // Menu Item mouseover logic - - var nShowDelay = this.cfg.getProperty("showdelay"), - bShowDelay = (nShowDelay > 0); - - - if(bShowDelay) { - - this._cancelShowDelay(); - - } - - - var oActiveItem = this.activeItem; - - if(oActiveItem) { - - oActiveItem.cfg.setProperty("selected", false); - - } - - - var oItemCfg = oItem.cfg; - - // Select and focus the current menu item - - oItemCfg.setProperty("selected", true); - oItem.focus(); - - - if(this.cfg.getProperty("autosubmenudisplay")) { - - // Show the submenu this menu item - - var oSubmenu = oItemCfg.getProperty("submenu"); - - if(oSubmenu) { - - if(bShowDelay) { - - this._execShowDelay(oSubmenu); - - } - else { - - oSubmenu.show(); - - } - - } - - } - - oItem.handledMouseOverEvent = true; - oItem.handledMouseOutEvent = false; - - } - -}, - - -/** -* @method _onMouseOut -* @description "mouseout" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onMouseOut: function(p_sType, p_aArgs, p_oMenu) { - - if(this._bStopMouseEventHandlers) { - - return false; - - } - - - var oEvent = p_aArgs[0], - oItem = p_aArgs[1], - oRelatedTarget = Event.getRelatedTarget(oEvent), - bMovingToSubmenu = false; - - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var oItemCfg = oItem.cfg, - oSubmenu = oItemCfg.getProperty("submenu"); - - - if( - oSubmenu && - ( - oRelatedTarget == oSubmenu.element || - Dom.isAncestor(oSubmenu.element, oRelatedTarget) - ) - ) { - - bMovingToSubmenu = true; - - } - - - if( - !oItem.handledMouseOutEvent && - ( - ( - oRelatedTarget != oItem.element && - !Dom.isAncestor(oItem.element, oRelatedTarget) - ) || bMovingToSubmenu - ) - ) { - - // Menu Item mouseout logic - - if(!bMovingToSubmenu) { - - oItem.cfg.setProperty("selected", false); - - - if(oSubmenu) { - - var nSubmenuHideDelay = - this.cfg.getProperty("submenuhidedelay"), - - nShowDelay = this.cfg.getProperty("showdelay"); - - if( - !(this instanceof YAHOO.widget.MenuBar) && - nSubmenuHideDelay > 0 && - nShowDelay >= nSubmenuHideDelay - ) { - - this._execSubmenuHideDelay( - oSubmenu, - Event.getPageX(oEvent), - nSubmenuHideDelay - ); - - } - else { - - oSubmenu.hide(); - - } - - } - - } - - - oItem.handledMouseOutEvent = true; - oItem.handledMouseOverEvent = false; - - } - - } - - - if( - !this._bHandledMouseOutEvent && - ( - ( - oRelatedTarget != this.element && - !Dom.isAncestor(this.element, oRelatedTarget) - ) - || bMovingToSubmenu - ) - ) { - - // Menu mouseout logic - - Event.removeListener(this.element, "mousemove", this._onMouseMove); - - this._nCurrentMouseX = Event.getPageX(oEvent); - - this._bHandledMouseOutEvent = true; - this._bHandledMouseOverEvent = false; - - } - -}, - - -/** -* @method _onMouseMove -* @description "click" event handler for the menu. -* @protected -* @param {Event} p_oEvent Object representing the DOM event object passed -* back by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onMouseMove: function(p_oEvent, p_oMenu) { - - if(this._bStopMouseEventHandlers) { - - return false; - - } - - this._nCurrentMouseX = Event.getPageX(p_oEvent); - -}, - - -/** -* @method _onClick -* @description "click" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onClick: function(p_sType, p_aArgs, p_oMenu) { - - var oEvent = p_aArgs[0], - oItem = p_aArgs[1], - oTarget = Event.getTarget(oEvent); - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var oItemCfg = oItem.cfg, - oSubmenu = oItemCfg.getProperty("submenu"); - - - /* - ACCESSIBILITY FEATURE FOR SCREEN READERS: - Expand/collapse the submenu when the user clicks - on the submenu indicator image. - */ - - if(oTarget == oItem.submenuIndicator && oSubmenu) { - - if(oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.hide(); - - oSubmenu.parent.focus(); - - } - else { - - this.clearActiveItem(); - - this.activeItem = oItem; - - oItem.cfg.setProperty("selected", true); - - oSubmenu.show(); - - } - - } - else { - - var sURL = oItemCfg.getProperty("url"), - bCurrentPageURL = (sURL.substr((sURL.length-1),1) == "#"), - sTarget = oItemCfg.getProperty("target"), - bHasTarget = (sTarget && sTarget.length > 0); - - /* - Prevent the browser from following links - equal to "#" - */ - - if( - oTarget.tagName.toUpperCase() == "A" && - bCurrentPageURL && !bHasTarget - ) { - - Event.preventDefault(oEvent); - - } - - if( - oTarget.tagName.toUpperCase() != "A" && - !bCurrentPageURL && !bHasTarget - ) { - - /* - Follow the URL of the item regardless of - whether or not the user clicked specifically - on the anchor element. - */ - - document.location = sURL; - - } - - - /* - If the item doesn't navigate to a URL and it doesn't have - a submenu, then collapse the menu tree. - */ - - if(bCurrentPageURL && !oSubmenu) { - - var oRoot = this.getRoot(); - - if(oRoot.cfg.getProperty("position") == "static") { - - oRoot.clearActiveItem(); - - } - else if(oRoot.cfg.getProperty("clicktohide")) { - - oRoot.hide(); - - } - - } - - } - - } - -}, - - -/** -* @method _onKeyDown -* @description "keydown" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onKeyDown: function(p_sType, p_aArgs, p_oMenu) { - - var oEvent = p_aArgs[0], - oItem = p_aArgs[1], - me = this, - oSubmenu; - - - /* - This function is called to prevent a bug in Firefox. In Firefox, - moving a DOM element into a stationary mouse pointer will cause the - browser to fire mouse events. This can result in the menu mouse - event handlers being called uncessarily, especially when menus are - moved into a stationary mouse pointer as a result of a - key event handler. - */ - function stopMouseEventHandlers() { - - me._bStopMouseEventHandlers = true; - - window.setTimeout(function() { - - me._bStopMouseEventHandlers = false; - - }, 10); - - } - - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var oItemCfg = oItem.cfg, - oParentItem = this.parent, - oRoot, - oNextItem; - - - switch(oEvent.keyCode) { - - case 38: // Up arrow - case 40: // Down arrow - - if( - oItem == this.activeItem && - !oItemCfg.getProperty("selected") - ) { - - oItemCfg.setProperty("selected", true); - - } - else { - - oNextItem = (oEvent.keyCode == 38) ? - oItem.getPreviousEnabledSibling() : - oItem.getNextEnabledSibling(); - - if(oNextItem) { - - this.clearActiveItem(); - - oNextItem.cfg.setProperty("selected", true); - oNextItem.focus(); - - - if(this.cfg.getProperty("maxheight") > 0) { - - var oBody = this.body; - - oBody.scrollTop = - - ( - oNextItem.element.offsetTop + - oNextItem.element.offsetHeight - ) - oBody.offsetHeight; - - - var nScrollTop = oBody.scrollTop, - nScrollTarget = - oBody.scrollHeight - oBody.offsetHeight; - - if(nScrollTop === 0) { - - this._disableScrollHeader(); - this._enableScrollFooter(); - - } - else if(nScrollTop == nScrollTarget) { - - this._enableScrollHeader(); - this._disableScrollFooter(); - - } - else { - - this._enableScrollHeader(); - this._enableScrollFooter(); - - } - - } - - } - - } - - Event.preventDefault(oEvent); - - stopMouseEventHandlers(); - - break; - - - case 39: // Right arrow - - oSubmenu = oItemCfg.getProperty("submenu"); - - if(oSubmenu) { - - if(!oItemCfg.getProperty("selected")) { - - oItemCfg.setProperty("selected", true); - - } - - oSubmenu.show(); - - oSubmenu.setInitialSelection(); - - } - else { - - oRoot = this.getRoot(); - - if(oRoot instanceof YAHOO.widget.MenuBar) { - - oNextItem = oRoot.activeItem.getNextEnabledSibling(); - - if(oNextItem) { - - oRoot.clearActiveItem(); - - oNextItem.cfg.setProperty("selected", true); - - oSubmenu = oNextItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.show(); - - } - - oNextItem.focus(); - - } - - } - - } - - - Event.preventDefault(oEvent); - - stopMouseEventHandlers(); - - break; - - - case 37: // Left arrow - - if(oParentItem) { - - var oParentMenu = oParentItem.parent; - - if(oParentMenu instanceof YAHOO.widget.MenuBar) { - - oNextItem = - oParentMenu.activeItem.getPreviousEnabledSibling(); - - if(oNextItem) { - - oParentMenu.clearActiveItem(); - - oNextItem.cfg.setProperty("selected", true); - - oSubmenu = oNextItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.show(); - - } - - oNextItem.focus(); - - } - - } - else { - - this.hide(); - - oParentItem.focus(); - - } - - } - - Event.preventDefault(oEvent); - - stopMouseEventHandlers(); - - break; - - } - - - } - - - if(oEvent.keyCode == 27) { // Esc key - - if(this.cfg.getProperty("position") == "dynamic") { - - this.hide(); - - if(this.parent) { - - this.parent.focus(); - - } - - } - else if(this.activeItem) { - - oSubmenu = this.activeItem.cfg.getProperty("submenu"); - - if(oSubmenu && oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.hide(); - this.activeItem.focus(); - - } - else { - - this.activeItem.cfg.setProperty("selected", false); - this.activeItem.blur(); - - } - - } - - - Event.preventDefault(oEvent); - - } - -}, - - -/** -* @method _onKeyPress -* @description "keypress" event handler for a Menu instance. -* @protected -* @param {String} p_sType The name of the event that was fired. -* @param {Array} p_aArgs Collection of arguments sent when the event -* was fired. -* @param {YAHOO.widget.Menu} p_oMenu The Menu instance that fired the event. -*/ -_onKeyPress: function(p_sType, p_aArgs, p_oMenu) { - - var oEvent = p_aArgs[0]; - - - if(oEvent.keyCode == 40 || oEvent.keyCode == 38) { - - YAHOO.util.Event.preventDefault(oEvent); - - } - -}, - - -/** -* @method _onTextResize -* @description "textresize" event handler for the menu. -* @protected -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onTextResize: function(p_sType, p_aArgs, p_oMenu) { - - if(this.browser == "gecko" && !this._handleResize) { - - this._handleResize = true; - return; - - } - - - var oConfig = this.cfg; - - if(oConfig.getProperty("position") == "dynamic") { - - oConfig.setProperty("width", (this._getOffsetWidth() + "px")); - - } - -}, - - -/** -* @method _onScrollTargetMouseOver -* @description "mouseover" event handler for the menu's "header" and "footer" -* elements. Used to scroll the body of the menu up and down when the -* menu's "maxheight" configuration property is set to a value greater than 0. -* @protected -* @param {Event} p_oEvent Object representing the DOM event object passed -* back by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onScrollTargetMouseOver: function(p_oEvent, p_oMenu) { - - this._cancelHideDelay(); - - var oTarget = Event.getTarget(p_oEvent), - oBody = this.body, - me = this, - nScrollTarget, - fnScrollFunction; - - - function scrollBodyDown() { - - var nScrollTop = oBody.scrollTop; - - - if(nScrollTop < nScrollTarget) { - - oBody.scrollTop = (nScrollTop + 1); - - me._enableScrollHeader(); - - } - else { - - oBody.scrollTop = nScrollTarget; - - window.clearInterval(me._nBodyScrollId); - - me._disableScrollFooter(); - - } - - } - - - function scrollBodyUp() { - - var nScrollTop = oBody.scrollTop; - - - if(nScrollTop > 0) { - - oBody.scrollTop = (nScrollTop - 1); - - me._enableScrollFooter(); - - } - else { - - oBody.scrollTop = 0; - - window.clearInterval(me._nBodyScrollId); - - me._disableScrollHeader(); - - } - - } - - - if(Dom.hasClass(oTarget, "hd")) { - - fnScrollFunction = scrollBodyUp; - - } - else { - - nScrollTarget = oBody.scrollHeight - oBody.offsetHeight; - - fnScrollFunction = scrollBodyDown; - - } - - - this._nBodyScrollId = window.setInterval(fnScrollFunction, 10); - -}, - - -/** -* @method _onScrollTargetMouseOut -* @description "mouseout" event handler for the menu's "header" and "footer" -* elements. Used to stop scrolling the body of the menu up and down when the -* menu's "maxheight" configuration property is set to a value greater than 0. -* @protected -* @param {Event} p_oEvent Object representing the DOM event object passed -* back by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onScrollTargetMouseOut: function(p_oEvent, p_oMenu) { - - window.clearInterval(this._nBodyScrollId); - - this._cancelHideDelay(); - -}, - - - -// Private methods - - -/** -* @method _onInit -* @description "init" event handler for the 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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onInit: function(p_sType, p_aArgs, p_oMenu) { - - if( - ( - (this.parent && !this.lazyLoad) || - (!this.parent && this.cfg.getProperty("position") == "static") || - ( - !this.parent && - !this.lazyLoad && - this.cfg.getProperty("position") == "dynamic" - ) - ) && - this.getItemGroups().length === 0 - ) { - - if(this.srcElement) { - - this._initSubTree(); - - } - - - if(this.itemData) { - - this.addItems(this.itemData); - - } - - } - else if(this.lazyLoad) { - - this.cfg.fireQueue(); - - } - -}, - - -/** -* @method _onBeforeRender -* @description "beforerender" event handler for the menu. Appends all of the -* <code><ul></code>, <code><li></code> and their accompanying -* title elements to the body element of the 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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onBeforeRender: function(p_sType, p_aArgs, p_oMenu) { - - var oConfig = this.cfg, - oEl = this.element, - nListElements = this._aListElements.length; - - - if(nListElements > 0) { - - var i = 0, - bFirstList = true, - oUL, - oGroupTitle; - - - do { - - oUL = this._aListElements[i]; - - if(oUL) { - - if(bFirstList) { - - Dom.addClass(oUL, "first-of-type"); - bFirstList = false; - - } - - - if(!Dom.isAncestor(oEl, oUL)) { - - this.appendToBody(oUL); - - } - - - oGroupTitle = this._aGroupTitleElements[i]; - - if(oGroupTitle) { - - if(!Dom.isAncestor(oEl, oGroupTitle)) { - - oUL.parentNode.insertBefore(oGroupTitle, oUL); - - } - - - Dom.addClass(oUL, "hastitle"); - - } - - } - - i++; - - } - while(i < nListElements); - - } - -}, - - -/** -* @method _onBeforeShow -* @description "beforeshow" event handler for the 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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -_onBeforeShow: function(p_sType, p_aArgs, p_oMenu) { - - if(this.lazyLoad && this.getItemGroups().length === 0) { - - if(this.srcElement) { - - this._initSubTree(); - - } - - - if(this.itemData) { - - if( - this.parent && this.parent.parent && - this.parent.parent.srcElement && - this.parent.parent.srcElement.tagName.toUpperCase() == "SELECT" - ) { - - var nOptions = this.itemData.length; - - for(var n=0; n<nOptions; n++) { - - if(this.itemData[n].tagName) { - - this.addItem((new this.ITEM_TYPE(this.itemData[n]))); - - } - - } - - } - else { - - this.addItems(this.itemData); - - } - - } - - - var oSrcElement = this.srcElement; - - if(oSrcElement) { - - if(oSrcElement.tagName.toUpperCase() == "SELECT") { - - if(Dom.inDocument(oSrcElement)) { - - this.render(oSrcElement.parentNode); - - } - else { - - this.render(this.cfg.getProperty("container")); - - } - - } - else { - - this.render(); - - } - - } - else { - - if(this.parent) { - - this.render(this.parent.element); - - } - else { - - this.render(this.cfg.getProperty("container")); - - } - - } - - } - - - - if(this.cfg.getProperty("position") == "dynamic") { - - var nViewportHeight = Dom.getViewportHeight(); - - if(this.element.offsetHeight >= nViewportHeight) { - - var nMaxHeight = this.cfg.getProperty("maxheight"); - - /* - Cache the original value for the "maxheight" configuration - property so that we can set it back when the menu is hidden. - */ - - this._nMaxHeight = nMaxHeight; - - this.cfg.setProperty("maxheight", (nViewportHeight - 20)); - - } - - - if(this.cfg.getProperty("maxheight") > 0) { - - var oBody = this.body; - - if(oBody.scrollTop > 0) { - - oBody.scrollTop = 0; - - } - - this._disableScrollHeader(); - this._enableScrollFooter(); - - } - - } - - -}, - - -/** -* @method _onShow -* @description "show" event handler for the 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.Menu} p_oMenu Object representing the menu that fired -* the event. -*/ -_onShow: function(p_sType, p_aArgs, p_oMenu) { - - this.setInitialFocus(); - - var oParent = this.parent; - - if(oParent) { - - var oParentMenu = oParent.parent, - aParentAlignment = oParentMenu.cfg.getProperty("submenualignment"), - aAlignment = this.cfg.getProperty("submenualignment"); - - - if( - (aParentAlignment[0] != aAlignment[0]) && - (aParentAlignment[1] != aAlignment[1]) - ) { - - this.cfg.setProperty( - "submenualignment", - [ aParentAlignment[0], aParentAlignment[1] ] - ); - - } - - - if( - !oParentMenu.cfg.getProperty("autosubmenudisplay") && - oParentMenu.cfg.getProperty("position") == "static" - ) { - - oParentMenu.cfg.setProperty("autosubmenudisplay", true); - - - function disableAutoSubmenuDisplay(p_oEvent) { - - if( - p_oEvent.type == "mousedown" || - (p_oEvent.type == "keydown" && p_oEvent.keyCode == 27) - ) { - - /* - Set the "autosubmenudisplay" to "false" if the user - clicks outside the menu bar. - */ - - var oTarget = Event.getTarget(p_oEvent); - - if( - oTarget != oParentMenu.element || - !YAHOO.util.Dom.isAncestor(oParentMenu.element, oTarget) - ) { - - oParentMenu.cfg.setProperty( - "autosubmenudisplay", - false - ); - - Event.removeListener( - document, - "mousedown", - disableAutoSubmenuDisplay - ); - - Event.removeListener( - document, - "keydown", - disableAutoSubmenuDisplay - ); - - } - - } - - } - - Event.addListener(document, "mousedown", disableAutoSubmenuDisplay); - Event.addListener(document, "keydown", disableAutoSubmenuDisplay); - - } - - } - else if(!oParent && this.lazyLoad) { - - this.cfg.refireEvent("xy"); - - } - -}, - - -/** -* @method _onBeforeHide -* @description "beforehide" event handler for the 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.Menu} p_oMenu Object representing the menu that fired -* the event. -*/ -_onBeforeHide: function(p_sType, p_aArgs, p_oMenu) { - - var oActiveItem = this.activeItem; - - if(oActiveItem) { - - var oConfig = oActiveItem.cfg; - - oConfig.setProperty("selected", false); - - var oSubmenu = oConfig.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.hide(); - - } - - oActiveItem.blur(); - - } - -}, - - -/** -* @method _onHide -* @description "hide" event handler for the 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.Menu} p_oMenu Object representing the menu that fired -* the event. -*/ -_onHide: function(p_sType, p_aArgs, p_oMenu) { - - if(this._nMaxHeight != -1) { - - this.cfg.setProperty("maxheight", this._nMaxHeight); - - this._nMaxHeight = -1; - - } - -}, - - -/** -* @method _onParentMenuConfigChange -* @description "configchange" event handler for a submenu. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onParentMenuConfigChange: function(p_sType, p_aArgs, p_oSubmenu) { - - var sPropertyName = p_aArgs[0][0], - oPropertyValue = p_aArgs[0][1]; - - switch(sPropertyName) { - - case "iframe": - case "constraintoviewport": - case "hidedelay": - case "showdelay": - case "submenuhidedelay": - case "clicktohide": - case "effect": - case "classname": - - p_oSubmenu.cfg.setProperty(sPropertyName, oPropertyValue); - - break; - - } - -}, - - -/** -* @method _onParentMenuRender -* @description "render" event handler for a submenu. Renders a -* submenu in response to the firing of its parent's "render" event. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onParentMenuRender: function(p_sType, p_aArgs, p_oSubmenu) { - - var oParentMenu = p_oSubmenu.parent.parent, - - oConfig = { - - constraintoviewport: - oParentMenu.cfg.getProperty("constraintoviewport"), - - xy: [0,0], - - clicktohide: oParentMenu.cfg.getProperty("clicktohide"), - - effect: oParentMenu.cfg.getProperty("effect"), - - showdelay: oParentMenu.cfg.getProperty("showdelay"), - - hidedelay: oParentMenu.cfg.getProperty("hidedelay"), - - submenuhidedelay: oParentMenu.cfg.getProperty("submenuhidedelay"), - - classname: oParentMenu.cfg.getProperty("classname") - - }; - - - /* - Only sync the "iframe" configuration property if the parent - menu's "position" configuration is the same. - */ - - if( - this.cfg.getProperty("position") == - oParentMenu.cfg.getProperty("position") - ) { - - oConfig.iframe = oParentMenu.cfg.getProperty("iframe"); - - } - - - p_oSubmenu.cfg.applyConfig(oConfig); - - - if(!this.lazyLoad) { - - var oLI = this.parent.element; - - if(this.element.parentNode == oLI) { - - this.render(); - - } - else { - - this.render(oLI); - - } - - } - -}, - - -/** -* @method _onSubmenuBeforeShow -* @description "beforeshow" event handler for a submenu. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onSubmenuBeforeShow: function(p_sType, p_aArgs, p_oSubmenu) { - - var oParent = this.parent, - aAlignment = oParent.parent.cfg.getProperty("submenualignment"); - - this.cfg.setProperty( - "context", - [oParent.element, aAlignment[0], aAlignment[1]] - ); - - - var nScrollTop = oParent.parent.body.scrollTop; - - if( - (this.browser == "gecko" || this.browser == "safari") - && nScrollTop > 0 - ) { - - this.cfg.setProperty("y", (this.cfg.getProperty("y") - nScrollTop)); - - } - -}, - - -/** -* @method _onSubmenuShow -* @description "show" event handler for a submenu. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onSubmenuShow: function(p_sType, p_aArgs, p_oSubmenu) { - - var oParent = this.parent; - - oParent.submenuIndicator.firstChild.nodeValue = - oParent.EXPANDED_SUBMENU_INDICATOR_TEXT; - -}, - - -/** -* @method _onSubmenuHide -* @description "hide" Custom Event handler for a submenu. -* @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.Menu} p_oSubmenu Object representing the submenu that -* subscribed to the event. -*/ -_onSubmenuHide: function(p_sType, p_aArgs, p_oSubmenu) { - - var oParent = this.parent; - - oParent.submenuIndicator.firstChild.nodeValue = - oParent.COLLAPSED_SUBMENU_INDICATOR_TEXT; - -}, - - -/** -* @method _onMenuItemFocus -* @description "focus" event handler for the menu's items. -* @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 fired the event. -*/ -_onMenuItemFocus: function(p_sType, p_aArgs, p_oItem) { - - this.activeItem = p_oItem; - -}, - - -/** -* @method _onMenuItemBlur -* @description "blur" event handler for the menu's items. -* @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. -*/ -_onMenuItemBlur: function(p_sType, p_aArgs) { - - this.activeItem = null; - -}, - - -/** -* @method _onMenuItemConfigChange -* @description "configchange" event handler for the menu's items. -* @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 fired the event. -*/ -_onMenuItemConfigChange: function(p_sType, p_aArgs, p_oItem) { - - var sProperty = p_aArgs[0][0]; - - switch(sProperty) { - - case "submenu": - - var oSubmenu = p_aArgs[0][1]; - - if(oSubmenu) { - - this._configureSubmenu(p_oItem); - - } - - break; - - case "text": - case "helptext": - - /* - A change to an item's "text" or "helptext" - configuration properties requires the width of the parent - menu to be recalculated. - */ - - if(this.element.style.width) { - - var sWidth = this._getOffsetWidth() + "px"; - - Dom.setStyle(this.element, "width", sWidth); - - } - - break; - - } - -}, - - - -// Public event handlers for configuration properties - - -/** -* @method enforceConstraints -* @description The default event handler executed when the moveEvent is fired, -* if the "constraintoviewport" configuration property is set to true. -* @param {String} type The name of the event that was fired. -* @param {Array} args Collection of arguments sent when the -* event was fired. -* @param {Array} obj Array containing the current Menu instance -* and the item that fired the event. -*/ -enforceConstraints: function(type, args, obj) { - - var oConfig = this.cfg, - pos = args[0], - - x = pos[0], - y = pos[1], - - offsetHeight = this.element.offsetHeight, - offsetWidth = this.element.offsetWidth, - - viewPortWidth = YAHOO.util.Dom.getViewportWidth(), - viewPortHeight = YAHOO.util.Dom.getViewportHeight(), - - scrollX = Math.max( - document.documentElement.scrollLeft, - document.body.scrollLeft - ), - - scrollY = Math.max( - document.documentElement.scrollTop, - document.body.scrollTop - ), - - nPadding = ( - this.parent && - this.parent.parent instanceof YAHOO.widget.MenuBar - ) ? 0 : 10, - - topConstraint = scrollY + nPadding, - leftConstraint = scrollX + nPadding, - bottomConstraint = scrollY + viewPortHeight - offsetHeight - nPadding, - rightConstraint = scrollX + viewPortWidth - offsetWidth - nPadding, - - aContext = oConfig.getProperty("context"), - oContextElement = aContext ? aContext[0] : null; - - - if (x < 10) { - - x = leftConstraint; - - } else if ((x + offsetWidth) > viewPortWidth) { - - if( - oContextElement && - ((x - oContextElement.offsetWidth) > offsetWidth) - ) { - - x = (x - (oContextElement.offsetWidth + offsetWidth)); - - } - else { - - x = rightConstraint; - - } - - } - - if (y < 10) { - - y = topConstraint; - - } else if (y > bottomConstraint) { - - if(oContextElement && (y > offsetHeight)) { - - y = ((y + oContextElement.offsetHeight) - offsetHeight); - - } - else { - - y = bottomConstraint; - - } - - } - - oConfig.setProperty("x", x, true); - oConfig.setProperty("y", y, true); - oConfig.setProperty("xy", [x,y], true); - -}, - - -/** -* @method configVisible -* @description Event handler for when the "visible" configuration property -* the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configVisible: function(p_sType, p_aArgs, p_oMenu) { - - if(this.cfg.getProperty("position") == "dynamic") { - - YAHOO.widget.Menu.superclass.configVisible.call( - this, - p_sType, - p_aArgs, - p_oMenu - ); - - } - else { - - var bVisible = p_aArgs[0], - sDisplay = Dom.getStyle(this.element, "display"); - - if(bVisible) { - - if(sDisplay != "block") { - this.beforeShowEvent.fire(); - Dom.setStyle(this.element, "display", "block"); - this.showEvent.fire(); - } - - } - else { - - if(sDisplay == "block") { - this.beforeHideEvent.fire(); - Dom.setStyle(this.element, "display", "none"); - this.hideEvent.fire(); - } - - } - - } - -}, - - -/** -* @method configPosition -* @description Event handler for when the "position" configuration property -* of the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configPosition: function(p_sType, p_aArgs, p_oMenu) { - - var sCSSPosition = p_aArgs[0] == "static" ? "static" : "absolute", - oCfg = this.cfg; - - Dom.setStyle(this.element, "position", sCSSPosition); - - - if(sCSSPosition == "static") { - - /* - Remove the iframe for statically positioned menus since it will - intercept mouse events. - */ - - oCfg.setProperty("iframe", false); - - - // Statically positioned menus are visible by default - - Dom.setStyle(this.element, "display", "block"); - - oCfg.setProperty("visible", true); - - } - else { - - /* - Even though the "visible" property is queued to - "false" by default, we need to set the "visibility" property to - "hidden" since Overlay's "configVisible" implementation checks the - element's "visibility" style property before deciding whether - or not to show an Overlay instance. - */ - - Dom.setStyle(this.element, "visibility", "hidden"); - - } - - - if(sCSSPosition == "absolute") { - - var nZIndex = oCfg.getProperty("zindex"); - - if(!nZIndex || nZIndex === 0) { - - nZIndex = this.parent ? - (this.parent.parent.cfg.getProperty("zindex") + 1) : 1; - - oCfg.setProperty("zindex", nZIndex); - - } - - } - -}, - - -/** -* @method configIframe -* @description Event handler for when the "iframe" configuration property of -* the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configIframe: function(p_sType, p_aArgs, p_oMenu) { - - if(this.cfg.getProperty("position") == "dynamic") { - - YAHOO.widget.Menu.superclass.configIframe.call( - this, - p_sType, - p_aArgs, - p_oMenu - ); - - } - -}, - - -/** -* @method configHideDelay -* @description Event handler for when the "hidedelay" configuration property -* of the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configHideDelay: function(p_sType, p_aArgs, p_oMenu) { - - var nHideDelay = p_aArgs[0], - oMouseOutEvent = this.mouseOutEvent, - oMouseOverEvent = this.mouseOverEvent, - oKeyDownEvent = this.keyDownEvent; - - if(nHideDelay > 0) { - - /* - Only assign event handlers once. This way the user change - the value for the hidedelay as many times as they want. - */ - - if(!this._bHideDelayEventHandlersAssigned) { - - oMouseOutEvent.subscribe(this._execHideDelay, true); - oMouseOverEvent.subscribe(this._cancelHideDelay, this, true); - oKeyDownEvent.subscribe(this._cancelHideDelay, this, true); - - this._bHideDelayEventHandlersAssigned = true; - - } - - } - else { - - oMouseOutEvent.unsubscribe(this._execHideDelay, this); - oMouseOverEvent.unsubscribe(this._cancelHideDelay, this); - oKeyDownEvent.unsubscribe(this._cancelHideDelay, this); - - this._bHideDelayEventHandlersAssigned = false; - - } - -}, - - -/** -* @method configContainer -* @description Event handler for when the "container" configuration property -of the menu changes. -* @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.Menu} p_oMenu Object representing the menu that -* fired the event. -*/ -configContainer: function(p_sType, p_aArgs, p_oMenu) { - - var oElement = p_aArgs[0]; - - if(typeof oElement == 'string') { - - this.cfg.setProperty( - "container", - document.getElementById(oElement), - true - ); - - } - -}, - - -/** -* @method configMaxHeight -* @description Event handler for when the "maxheight" configuration property of -* a Menu changes. -* @param {String} p_sType The name of the event that was fired. -* @param {Array} p_aArgs Collection of arguments sent when the event -* was fired. -* @param {YAHOO.widget.Menu} p_oMenu The Menu instance fired -* the event. -*/ -configMaxHeight: function(p_sType, p_aArgs, p_oMenu) { - - var nMaxHeight = p_aArgs[0], - oBody = this.body, - oHeader = this.header, - oFooter = this.footer, - fnMouseOver = this._onScrollTargetMouseOver, - fnMouseOut = this._onScrollTargetMouseOut; - - - if((nMaxHeight > 0) && (oBody.offsetHeight > nMaxHeight)) { - - if(!this.cfg.getProperty("width")) { - - this._setWidth(); - - } - - if(!oHeader && !oFooter) { - - this.setHeader(" "); - this.setFooter(" "); - - oHeader = this.header; - oFooter = this.footer; - - Dom.addClass(oHeader, "topscrollbar"); - Dom.addClass(oFooter, "bottomscrollbar"); - - this.element.insertBefore(oHeader, oBody); - this.element.appendChild(oFooter); - - Event.addListener(oHeader, "mouseover", fnMouseOver, this, true); - Event.addListener(oHeader, "mouseout", fnMouseOut, this, true); - Event.addListener(oFooter, "mouseover", fnMouseOver, this, true); - Event.addListener(oFooter, "mouseout", fnMouseOut, this, true); - - } - - var nHeight = - - ( - nMaxHeight - - (this.footer.offsetHeight + this.header.offsetHeight) - ); - - Dom.setStyle(oBody, "height", (nHeight + "px")); - Dom.setStyle(oBody, "overflow", "hidden"); - - } - else if(oHeader && oFooter) { - - Dom.setStyle(oBody, "height", "auto"); - Dom.setStyle(oBody, "overflow", "visible"); - - Event.removeListener(oHeader, "mouseover", fnMouseOver); - Event.removeListener(oHeader, "mouseout", fnMouseOut); - Event.removeListener(oFooter, "mouseover", fnMouseOver); - Event.removeListener(oFooter, "mouseout", fnMouseOut); - - this.element.removeChild(oHeader); - this.element.removeChild(oFooter); - - this.header = null; - this.footer = null; - - } - -}, - - -/** -* @method configClassName -* @description Event handler for when the "classname" configuration property of -* a menu changes. -* @param {String} p_sType The name of the event that was fired. -* @param {Array} p_aArgs Collection of arguments sent when the event was fired. -* @param {YAHOO.widget.Menu} p_oMenu The Menu instance fired the event. -*/ -configClassName: function(p_sType, p_aArgs, p_oMenu) { - - var sClassName = p_aArgs[0]; - - if(this._sClassName) { - - Dom.removeClass(this.element, this._sClassName); - - } - - Dom.addClass(this.element, sClassName); - this._sClassName = sClassName; - -}, - - -// Public methods - - -/** -* @method initEvents -* @description Initializes the custom events for the menu. -*/ -initEvents: function() { - - YAHOO.widget.Menu.superclass.initEvents.call(this); - - // Create custom events - - var CustomEvent = YAHOO.util.CustomEvent; - - this.mouseOverEvent = new CustomEvent("mouseOverEvent", this); - this.mouseOutEvent = new CustomEvent("mouseOutEvent", this); - this.mouseDownEvent = new CustomEvent("mouseDownEvent", this); - this.mouseUpEvent = new CustomEvent("mouseUpEvent", this); - this.clickEvent = new CustomEvent("clickEvent", this); - this.keyPressEvent = new CustomEvent("keyPressEvent", this); - this.keyDownEvent = new CustomEvent("keyDownEvent", this); - this.keyUpEvent = new CustomEvent("keyUpEvent", this); - this.itemAddedEvent = new CustomEvent("itemAddedEvent", this); - this.itemRemovedEvent = new CustomEvent("itemRemovedEvent", this); - -}, - - -/** -* @method getRoot -* @description Finds the menu's root menu. -*/ -getRoot: function() { - - var oItem = this.parent; - - if(oItem) { - - var oParentMenu = oItem.parent; - - return oParentMenu ? oParentMenu.getRoot() : this; - - } - else { - - return this; - - } - -}, - - -/** -* @method toString -* @description Returns a string representing the menu. -* @return {String} -*/ -toString: function() { - - return ("Menu " + this.id); - -}, - - -/** -* @method setItemGroupTitle -* @description Sets the title of a group of menu items. -* @param {String} p_sGroupTitle String specifying the title of the group. -* @param {Number} p_nGroupIndex Optional. Number specifying the group to which -* the title belongs. -*/ -setItemGroupTitle: function(p_sGroupTitle, p_nGroupIndex) { - - if(typeof p_sGroupTitle == "string" && p_sGroupTitle.length > 0) { - - var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0, - oTitle = this._aGroupTitleElements[nGroupIndex]; - - - if(oTitle) { - - oTitle.innerHTML = p_sGroupTitle; - - } - else { - - oTitle = document.createElement(this.GROUP_TITLE_TAG_NAME); - - oTitle.innerHTML = p_sGroupTitle; - - this._aGroupTitleElements[nGroupIndex] = oTitle; - - } - - - var i = this._aGroupTitleElements.length - 1, - nFirstIndex; - - do { - - if(this._aGroupTitleElements[i]) { - - Dom.removeClass(this._aGroupTitleElements[i], "first-of-type"); - - nFirstIndex = i; - - } - - } - while(i--); - - - if(nFirstIndex !== null) { - - Dom.addClass( - this._aGroupTitleElements[nFirstIndex], - "first-of-type" - ); - - } - - } - -}, - - - -/** -* @method addItem -* @description Appends an item to the menu. -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance to be added to the menu. -* @param {String} p_oItem String specifying the text of the item to be added -* to the menu. -* @param {Object} p_oItem Object literal containing a set of menu item -* configuration properties. -* @param {Number} p_nGroupIndex Optional. Number indicating the group to -* which the item belongs. -* @return {YAHOO.widget.MenuItem} -*/ -addItem: function(p_oItem, p_nGroupIndex) { - - if(p_oItem) { - - return this._addItemToGroup(p_nGroupIndex, p_oItem); - - } - -}, - - -/** -* @method addItems -* @description Adds an array of items to the menu. -* @param {Array} p_aItems Array of items to be added to the menu. The array -* can contain strings specifying the text for each item to be created, object -* literals specifying each of the menu item configuration properties, -* or MenuItem instances. -* @param {Number} p_nGroupIndex Optional. Number specifying the group to -* which the items belongs. -* @return {Array} -*/ -addItems: function(p_aItems, p_nGroupIndex) { - - if(Lang.isArray(p_aItems)) { - - var nItems = p_aItems.length, - aItems = [], - oItem; - - - for(var i=0; i<nItems; i++) { - - oItem = p_aItems[i]; - - if(oItem) { - - if(Lang.isArray(oItem)) { - - aItems[aItems.length] = this.addItems(oItem, i); - - } - else { - - aItems[aItems.length] = - this._addItemToGroup(p_nGroupIndex, oItem); - - } - - } - - } - - - if(aItems.length) { - - return aItems; - - } - - } - -}, - - -/** -* @method insertItem -* @description Inserts an item into the menu at the specified index. -* @param {YAHOO.widget.MenuItem} p_oItem Object reference for the MenuItem -* instance to be added to the menu. -* @param {String} p_oItem String specifying the text of the item to be added -* to the menu. -* @param {Object} p_oItem Object literal containing a set of menu item -* configuration properties. -* @param {Number} p_nItemIndex Number indicating the ordinal position at which -* the item should be added. -* @param {Number} p_nGroupIndex Optional. Number indicating the group to which -* the item belongs. -* @return {YAHOO.widget.MenuItem} -*/ -insertItem: function(p_oItem, p_nItemIndex, p_nGroupIndex) { - - if(p_oItem) { - - return this._addItemToGroup(p_nGroupIndex, p_oItem, p_nItemIndex); - - } - -}, - - -/** -* @method removeItem -* @description Removes the specified item from the menu. -* @param {YAHOO.widget.MenuItem} p_oObject Object reference for the MenuItem -* instance to be removed from the menu. -* @param {Number} p_oObject Number specifying the index of the item -* to be removed. -* @param {Number} p_nGroupIndex Optional. Number specifying the group to -* which the item belongs. -* @return {YAHOO.widget.MenuItem} -*/ -removeItem: function(p_oObject, p_nGroupIndex) { - - if(typeof p_oObject != "undefined") { - - var oItem; - - if(p_oObject instanceof YAHOO.widget.MenuItem) { - - oItem = this._removeItemFromGroupByValue(p_nGroupIndex, p_oObject); - - } - else if(typeof p_oObject == "number") { - - oItem = this._removeItemFromGroupByIndex(p_nGroupIndex, p_oObject); - - } - - if(oItem) { - - oItem.destroy(); - - - return oItem; - - } - - } - -}, - - -/** -* @method getItems -* @description Returns an array of all of the items in the menu. -* @return {Array} -*/ -getItems: function() { - - var aGroups = this._aItemGroups, - nGroups = aGroups.length; - - return ( - (nGroups == 1) ? aGroups[0] : - (Array.prototype.concat.apply([], aGroups)) - ); - -}, - - -/** -* @method getItemGroups -* @description Multi-dimensional Array representing the menu items as they -* are grouped in the menu. -* @return {Array} -*/ -getItemGroups: function() { - - return this._aItemGroups; - -}, - - -/** -* @method getItem -* @description Returns the item at the specified index. -* @param {Number} p_nItemIndex Number indicating the ordinal position of the -* item to be retrieved. -* @param {Number} p_nGroupIndex Optional. Number indicating the group to which -* the item belongs. -* @return {YAHOO.widget.MenuItem} -*/ -getItem: function(p_nItemIndex, p_nGroupIndex) { - - if(typeof p_nItemIndex == "number") { - - var aGroup = this._getItemGroup(p_nGroupIndex); - - if(aGroup) { - - return aGroup[p_nItemIndex]; - - } - - } - -}, - - -/** -* @method clearContent -* @description Removes all of the content from the menu, including the menu -* items, group titles, header and footer. -*/ -clearContent: function() { - - var aItems = this.getItems(), - nItems = aItems.length, - oElement = this.element, - oBody = this.body, - oHeader = this.header, - oFooter = this.footer; - - - if(nItems > 0) { - - var i = nItems - 1, - oItem, - oSubmenu; - - do { - - oItem = aItems[i]; - - if(oItem) { - - oSubmenu = oItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - this.cfg.configChangedEvent.unsubscribe( - this._onParentMenuConfigChange, - oSubmenu - ); - - this.renderEvent.unsubscribe( - this._onParentMenuRender, - oSubmenu - ); - - } - - oItem.destroy(); - - } - - } - while(i--); - - } - - - if(oHeader) { - - Event.purgeElement(oHeader); - oElement.removeChild(oHeader); - - } - - - if(oFooter) { - - Event.purgeElement(oFooter); - oElement.removeChild(oFooter); - } - - - if(oBody) { - - Event.purgeElement(oBody); - - oBody.innerHTML = ""; - - } - - - this._aItemGroups = []; - this._aListElements = []; - this._aGroupTitleElements = []; - -}, - - -/** -* @method destroy -* @description Removes the menu's <code><div></code> element -* (and accompanying child nodes) from the document. -*/ -destroy: function() { - - // Remove all DOM event listeners - - Event.purgeElement(this.element); - - - // Remove Custom Event listeners - - this.mouseOverEvent.unsubscribeAll(); - this.mouseOutEvent.unsubscribeAll(); - this.mouseDownEvent.unsubscribeAll(); - this.mouseUpEvent.unsubscribeAll(); - this.clickEvent.unsubscribeAll(); - this.keyPressEvent.unsubscribeAll(); - this.keyDownEvent.unsubscribeAll(); - this.keyUpEvent.unsubscribeAll(); - this.itemAddedEvent.unsubscribeAll(); - this.itemRemovedEvent.unsubscribeAll(); - - YAHOO.widget.Module.textResizeEvent.unsubscribe(this._onTextResize, this); - - - // Remove all items - - this.clearContent(); - - - this._aItemGroups = null; - this._aListElements = null; - this._aGroupTitleElements = null; - - - // Continue with the superclass implementation of this method - - YAHOO.widget.Menu.superclass.destroy.call(this); - - -}, - - -/** -* @method setInitialFocus -* @description Sets focus to the menu's first enabled item. -*/ -setInitialFocus: function() { - - var oItem = this._getFirstEnabledItem(); - - if(oItem) { - - oItem.focus(); - } - -}, - - -/** -* @method setInitialSelection -* @description Sets the "selected" configuration property of the menu's first -* enabled item to "true." -*/ -setInitialSelection: function() { - - var oItem = this._getFirstEnabledItem(); - - if(oItem) { - - oItem.cfg.setProperty("selected", true); - } - -}, - - -/** -* @method clearActiveItem -* @description Sets the "selected" configuration property of the menu's active -* item to "false" and hides the item's submenu. -* @param {Boolean} p_bBlur Boolean indicating if the menu's active item -* should be blurred. -*/ -clearActiveItem: function(p_bBlur) { - - if(this.cfg.getProperty("showdelay") > 0) { - - this._cancelShowDelay(); - - } - - - var oActiveItem = this.activeItem; - - if(oActiveItem) { - - var oConfig = oActiveItem.cfg; - - oConfig.setProperty("selected", false); - - var oSubmenu = oConfig.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.hide(); - - } - - if(p_bBlur) { - - oActiveItem.blur(); - - } - - } - -}, - - -/** -* @description Initializes the class's configurable properties which can be -* changed using the menu's Config object ("cfg"). -* @method initDefaultConfig -*/ -initDefaultConfig: function() { - - YAHOO.widget.Menu.superclass.initDefaultConfig.call(this); - - var oConfig = this.cfg; - - // Add configuration attributes - - /* - Change the default value for the "visible" configuration - property to "false" by re-adding the property. - */ - - /** - * @config visible - * @description Boolean indicating whether or not the menu is visible. If - * the menu's "position" configuration property is set to "dynamic" (the - * default), this property toggles the menu's <code><div></code> - * element's "visibility" style property between "visible" (true) or - * "hidden" (false). If the menu's "position" configuration property is - * set to "static" this property toggles the menu's - * <code><div></code> element's "display" style property - * between "block" (true) or "none" (false). - * @default false - * @type Boolean - */ - oConfig.addProperty( - "visible", - { - value:false, - handler:this.configVisible, - validator:this.cfg.checkBoolean - } - ); - - - /* - Change the default value for the "constraintoviewport" configuration - property to "true" by re-adding the property. - */ - - /** - * @config constraintoviewport - * @description Boolean indicating if the menu will try to remain inside - * the boundaries of the size of viewport. - * @default true - * @type Boolean - */ - oConfig.addProperty( - "constraintoviewport", - { - value:true, - handler:this.configConstrainToViewport, - validator:this.cfg.checkBoolean, - supercedes:["iframe","x","y","xy"] - } - ); - - - /** - * @config position - * @description String indicating how a menu should be positioned on the - * screen. Possible values are "static" and "dynamic." Static menus are - * visible by default and reside in the normal flow of the document - * (CSS position: static). Dynamic menus are hidden by default, reside - * out of the normal flow of the document (CSS position: absolute), and - * can overlay other elements on the screen. - * @default dynamic - * @type String - */ - oConfig.addProperty( - "position", - { - value: "dynamic", - handler: this.configPosition, - validator: this._checkPosition, - supercedes: ["visible"] - } - ); - - - /** - * @config submenualignment - * @description Array defining how submenus should be aligned to their - * parent menu item. The format is: [itemCorner, submenuCorner]. By default - * a submenu's top left corner is aligned to its parent menu item's top - * right corner. - * @default ["tl","tr"] - * @type Array - */ - oConfig.addProperty("submenualignment", { value: ["tl","tr"] } ); - - - /** - * @config autosubmenudisplay - * @description Boolean indicating if submenus are automatically made - * visible when the user mouses over the menu's items. - * @default true - * @type Boolean - */ - oConfig.addProperty( - "autosubmenudisplay", - { - value: true, - validator: oConfig.checkBoolean - } - ); - - - /** - * @config showdelay - * @description Number indicating the time (in milliseconds) that should - * expire before a submenu is made visible when the user mouses over - * the menu's items. - * @default 250 - * @type Number - */ - oConfig.addProperty( - "showdelay", - { - value: 250, - validator: oConfig.checkNumber - } - ); - - - /** - * @config hidedelay - * @description Number indicating the time (in milliseconds) that should - * expire before the menu is hidden. - * @default 0 - * @type Number - */ - oConfig.addProperty( - "hidedelay", - { - value: 0, - validator: oConfig.checkNumber, - handler: this.configHideDelay, - suppressEvent: true - } - ); - - - /** - * @config submenuhidedelay - * @description 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. - * @default 250 - * @type Number - */ - oConfig.addProperty( - "submenuhidedelay", - { - value: 250, - validator: oConfig.checkNumber - } - ); - - - /** - * @config clicktohide - * @description Boolean indicating if the menu will automatically be - * hidden if the user clicks outside of it. - * @default true - * @type Boolean - */ - oConfig.addProperty( - "clicktohide", - { - value: true, - validator: oConfig.checkBoolean - } - ); - - - /** - * @config container - * @description HTML element reference or string specifying the id - * attribute of the HTML element that the menu's markup should be - * rendered into. - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|String - * @default document.body - */ - oConfig.addProperty( - "container", - { - value:document.body, - handler:this.configContainer - } - ); - - - /** - * @config maxheight - * @description Defines the maximum height (in pixels) for a menu before the - * contents of the body are scrolled. - * @default 0 - * @type Number - */ - oConfig.addProperty( - "maxheight", - { - value: 0, - validator: oConfig.checkNumber, - handler: this.configMaxHeight - } - ); - - - /** - * @config classname - * @description CSS class to be applied to the menu's root - * <code><div></code> element. The specified class(es) are - * appended in addition to the default class as specified by the menu's - * CSS_CLASS_NAME constant. - * @default null - * @type String - */ - oConfig.addProperty( - "classname", - { - value: null, - handler: this.configClassName, - validator: this._checkString - } - ); - -} - -}); // END YAHOO.lang.extend - -})(); - - - -(function() { - -var Dom = YAHOO.util.Dom, - Module = YAHOO.widget.Module, - Menu = YAHOO.widget.Menu, - - m_oMenuItemElement = null, - m_oSubmenuIndicator = null, - m_oCheckedIndicator = null; - - -/** -* Creates an item for a menu. -* -* @param {String} p_oObject String specifying the text of the menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying -* the <code><li></code> element of the menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object -* specifying the <code><option></code> element of the menu item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu item. See configuration class documentation -* for more details. -* @class MenuItem -* @constructor -*/ -YAHOO.widget.MenuItem = function(p_oObject, p_oConfig) { - - if(p_oObject) { - - if(p_oConfig) { - - this.parent = p_oConfig.parent; - this.value = p_oConfig.value; - this.id = p_oConfig.id; - - } - - this.init(p_oObject, p_oConfig); - - } - -}; - - -YAHOO.widget.MenuItem.prototype = { - - // Constants - - - /** - * @property SUBMENU_INDICATOR_IMAGE_PATH - * @description String representing the path to the image to be used for the - * menu item's submenu arrow indicator. - * @default "nt/ic/ut/alt1/menuarorght8_nrm_1.gif" - * @final - * @type String - * @deprecated All submenu indicator images are applied via a CSS - * background image. See "submenuindicator" class name in menu.css. - */ - SUBMENU_INDICATOR_IMAGE_PATH: "nt/ic/ut/alt1/menuarorght8_nrm_1.gif", - - - /** - * @property SELECTED_SUBMENU_INDICATOR_IMAGE_PATH - * @description String representing the path to the image to be used for the - * submenu arrow indicator when the menu item is selected. - * @default "nt/ic/ut/alt1/menuarorght8_hov_1.gif" - * @final - * @type String - * @deprecated All submenu indicator images are applied via a CSS - * background image. See "submenuindicator" class name in menu.css. - */ - SELECTED_SUBMENU_INDICATOR_IMAGE_PATH: - "nt/ic/ut/alt1/menuarorght8_hov_1.gif", - - - /** - * @property DISABLED_SUBMENU_INDICATOR_IMAGE_PATH - * @description String representing the path to the image to be used for the - * submenu arrow indicator when the menu item is disabled. - * @default "nt/ic/ut/alt1/menuarorght8_dim_1.gif" - * @final - * @type String - * @deprecated All submenu indicator images are applied via a CSS - * background image. See "submenuindicator" class name in menu.css. - */ - DISABLED_SUBMENU_INDICATOR_IMAGE_PATH: - "nt/ic/ut/alt1/menuarorght8_dim_1.gif", - - - /** - * @property COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the submenu arrow indicator. - * @default "Collapsed. Click to expand." - * @final - * @type String - * @deprecated Use COLLAPSED_SUBMENU_INDICATOR_TEXT. - */ - COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT: "Collapsed. Click to expand.", - - - /** - * @property EXPANDED_SUBMENU_INDICATOR_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the submenu arrow indicator when the submenu is visible. - * @default "Expanded. Click to collapse." - * @final - * @type String - * @deprecated Use EXPANDED_SUBMENU_INDICATOR_TEXT. - */ - EXPANDED_SUBMENU_INDICATOR_ALT_TEXT: "Expanded. Click to collapse.", - - - /** - * @property DISABLED_SUBMENU_INDICATOR_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the submenu arrow indicator when the menu item is disabled. - * @default "Disabled." - * @final - * @type String - * @deprecated Use DISABLED_SUBMENU_INDICATOR_TEXT. - */ - DISABLED_SUBMENU_INDICATOR_ALT_TEXT: "Disabled.", - - - /** - * @property COLLAPSED_SUBMENU_INDICATOR_TEXT - * @description String representing the text for the <code><em><code> - * element used for the submenu arrow indicator. - * @default "Submenu collapsed. Click to expand submenu." - * @final - * @type String - */ - COLLAPSED_SUBMENU_INDICATOR_TEXT: - "Submenu collapsed. Click to expand submenu.", - - - /** - * @property EXPANDED_SUBMENU_INDICATOR_TEXT - * @description String representing the text for the submenu arrow indicator - * element (<code><em><code>) when the submenu is visible. - * @default "Submenu expanded. Click to collapse submenu." - * @final - * @type String - */ - EXPANDED_SUBMENU_INDICATOR_TEXT: - "Submenu expanded. Click to collapse submenu.", - - - /** - * @property DISABLED_SUBMENU_INDICATOR_TEXT - * @description String representing the text for the submenu arrow indicator - * element (<code><em><code>) when the menu item is disabled. - * @default "Submenu collapsed. (Item disabled.)." - * @final - * @type String - */ - DISABLED_SUBMENU_INDICATOR_TEXT: "Submenu collapsed. (Item disabled.)", - - - /** - * @property CHECKED_IMAGE_PATH - * @description String representing the path to the image to be used for - * the checked state. - * @default "nt/ic/ut/bsc/menuchk8_nrm_1.gif" - * @final - * @type String - * @deprecated All checked indicator images are applied via a CSS - * background image. See "checkedindicator" class name in menu.css. - */ - CHECKED_IMAGE_PATH: "nt/ic/ut/bsc/menuchk8_nrm_1.gif", - - - /** - * @property SELECTED_CHECKED_IMAGE_PATH - * @description String representing the path to the image to be used for - * the selected checked state. - * @default "nt/ic/ut/bsc/menuchk8_hov_1.gif" - * @final - * @type String - * @deprecated All checked indicator images are applied via a CSS - * background image. See "checkedindicator" class name in menu.css. - */ - SELECTED_CHECKED_IMAGE_PATH: "nt/ic/ut/bsc/menuchk8_hov_1.gif", - - - /** - * @property DISABLED_CHECKED_IMAGE_PATH - * @description String representing the path to the image to be used for - * the disabled checked state. - * @default "nt/ic/ut/bsc/menuchk8_dim_1.gif" - * @final - * @type String - * @deprecated All checked indicator images are applied via a CSS - * background image. - */ - DISABLED_CHECKED_IMAGE_PATH: "nt/ic/ut/bsc/menuchk8_dim_1.gif", - - - /** - * @property CHECKED_IMAGE_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the checked image. - * @default "Checked." - * @final - * @type String - * @deprecated Use CHECKED_TEXT. - */ - CHECKED_IMAGE_ALT_TEXT: "Checked.", - - - /** - * @property DISABLED_CHECKED_IMAGE_ALT_TEXT - * @description String representing the alt text for the image to be used - * for the checked image when the item is disabled. - * @default "Checked. (Item disabled.)" - * @final - * @type String - * @deprecated Use DISABLED_CHECKED_TEXT. - */ - DISABLED_CHECKED_IMAGE_ALT_TEXT: "Checked. (Item disabled.)", - - - /** - * @property CHECKED_TEXT - * @description String representing the text to be used for the checked - * indicator element (<code><em><code>). - * @default "Checked." - * @final - * @type String - */ - CHECKED_TEXT: "Menu item checked.", - - - /** - * @property DISABLED_CHECKED_TEXT - * @description String representing the text to be used for the checked - * indicator element (<code><em><code>) when the menu item - * is disabled. - * @default "Checked. (Item disabled.)" - * @final - * @type String - */ - DISABLED_CHECKED_TEXT: "Checked. (Item disabled.)", - - - /** - * @property CSS_CLASS_NAME - * @description String representing the CSS class(es) to be applied to the - * <code><li></code> element of the menu item. - * @default "yuimenuitem" - * @final - * @type String - */ - CSS_CLASS_NAME: "yuimenuitem", - - - /** - * @property SUBMENU_TYPE - * @description Object representing the type of menu to instantiate and - * add when parsing the child nodes of the menu item's source HTML element. - * @final - * @type YAHOO.widget.Menu - */ - SUBMENU_TYPE: null, - - - /** - * @property IMG_ROOT - * @description String representing the prefix path to use for - * non-secure images. - * @default "http://us.i1.yimg.com/us.yimg.com/i/" - * @type String - * @deprecated All menu item images are now applied via CSS - * background images. - */ - IMG_ROOT: "http://us.i1.yimg.com/us.yimg.com/i/", - - - /** - * @property IMG_ROOT_SSL - * @description String representing the prefix path to use for securely - * served images. - * @default "https://a248.e.akamai.net/sec.yimg.com/i/" - * @type String - * @deprecated All menu item images are now applied via CSS - * background images. - */ - IMG_ROOT_SSL: "https://a248.e.akamai.net/sec.yimg.com/i/", - - - - // Private member variables - - - /** - * @property _oAnchor - * @description Object reference to the menu item's - * <code><a></code> element. - * @default null - * @private - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-48250443">HTMLAnchorElement</a> - */ - _oAnchor: null, - - - /** - * @property _oText - * @description Object reference to the menu item's text node. - * @default null - * @private - * @type TextNode - */ - _oText: null, - - - /** - * @property _oHelpTextEM - * @description Object reference to the menu item's help text - * <code><em></code> element. - * @default null - * @private - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-58190037">HTMLElement</a> - */ - _oHelpTextEM: null, - - - /** - * @property _oSubmenu - * @description Object reference to the menu item's submenu. - * @default null - * @private - * @type YAHOO.widget.Menu - */ - _oSubmenu: null, - - - /** - * @property _checkImage - * @description Object reference to the menu item's checkmark image. - * @default null - * @private - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-17701901">HTMLImageElement</a> - * @deprecated Use _oCheckedIndicator. - */ - _checkImage: null, - - - /** - * @property _oCheckedIndicator - * @description Object reference to the menu item's checkmark image. - * @default <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a> - * @private - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a> - */ - _oCheckedIndicator: null, - - - /** - * @property _oOnclickAttributeValue - * @description Object reference to the menu item's current value for the - * "onclick" configuration attribute. - * @default null - * @private - * @type Object - */ - _oOnclickAttributeValue: null, - - - /** - * @property _sClassName - * @description The current value of the "classname" configuration attribute. - * @default null - * @private - * @type String - */ - _sClassName: null, - - - - // Public properties - - - /** - * @property constructor - * @description Object reference to the menu item's constructor function. - * @default YAHOO.widget.MenuItem - * @type YAHOO.widget.MenuItem - */ - constructor: YAHOO.widget.MenuItem, - - - /** - * @property imageRoot - * @description String representing the root path for all of the menu - * item's images. - * @type String - * @deprecated All menu item images are now applied via CSS - * background images. - */ - imageRoot: null, - - - /** - * @property isSecure - * @description Boolean representing whether or not the current browsing - * context is secure (HTTPS). - * @type Boolean - * @deprecated All menu item images are now applied via CSS - * background images. - */ - isSecure: Module.prototype.isSecure, - - - /** - * @property index - * @description Number indicating the ordinal position of the menu item in - * its group. - * @default null - * @type Number - */ - index: null, - - - /** - * @property groupIndex - * @description Number indicating the index of the group to which the menu - * item belongs. - * @default null - * @type Number - */ - groupIndex: null, - - - /** - * @property parent - * @description Object reference to the menu item's parent menu. - * @default null - * @type YAHOO.widget.Menu - */ - parent: null, - - - /** - * @property element - * @description Object reference to the menu item's - * <code><li></code> element. - * @default <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level - * -one-html.html#ID-74680021">HTMLLIElement</a> - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-74680021">HTMLLIElement</a> - */ - element: null, - - - /** - * @property srcElement - * @description Object reference to the HTML element (either - * <code><li></code>, <code><optgroup></code> or - * <code><option></code>) used create the menu item. - * @default <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-74680021">HTMLLIElement</a>|<a href="http://www. - * w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-38450247" - * >HTMLOptGroupElement</a>|<a href="http://www.w3.org/TR/2000/WD-DOM- - * Level-1-20000929/level-one-html.html#ID-70901257">HTMLOptionElement</a> - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-74680021">HTMLLIElement</a>|<a href="http://www.w3. - * org/TR/2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-38450247"> - * HTMLOptGroupElement</a>|<a href="http://www.w3.org/TR/2000/WD-DOM- - * Level-1-20000929/level-one-html.html#ID-70901257">HTMLOptionElement</a> - */ - srcElement: null, - - - /** - * @property value - * @description Object reference to the menu item's value. - * @default null - * @type Object - */ - value: null, - - - /** - * @property submenuIndicator - * @description Object reference to the <code><em></code> element - * used to create the submenu indicator for the menu item. - * @default <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a> - * @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a> - */ - submenuIndicator: null, - - - /** - * @property browser - * @description String representing the browser. - * @type String - */ - browser: Module.prototype.browser, - - - /** - * @property id - * @description Id of the menu item's root <code><li></code> - * element. This property should be set via the constructor using the - * configuration object literal. If an id is not specified, then one will - * be created using the "generateId" method of the Dom utility. - * @default null - * @type String - */ - id: null, - - - - // Events - - - /** - * @event destroyEvent - * @description Fires when the menu item's <code><li></code> - * element is removed from its parent <code><ul></code> element. - * @type YAHOO.util.CustomEvent - */ - destroyEvent: null, - - - /** - * @event mouseOverEvent - * @description Fires when the mouse has entered the menu item. Passes - * back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - mouseOverEvent: null, - - - /** - * @event mouseOutEvent - * @description Fires when the mouse has left the menu item. Passes back - * the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - mouseOutEvent: null, - - - /** - * @event mouseDownEvent - * @description Fires when the user mouses down on the menu item. Passes - * back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - mouseDownEvent: null, - - - /** - * @event mouseUpEvent - * @description Fires when the user releases a mouse button while the mouse - * is over the menu item. Passes back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - mouseUpEvent: null, - - - /** - * @event clickEvent - * @description Fires when the user clicks the on the menu item. Passes - * back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - clickEvent: null, - - - /** - * @event keyPressEvent - * @description Fires when the user presses an alphanumeric key when the - * menu item has focus. Passes back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - keyPressEvent: null, - - - /** - * @event keyDownEvent - * @description Fires when the user presses a key when the menu item has - * focus. Passes back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - keyDownEvent: null, - - - /** - * @event keyUpEvent - * @description Fires when the user releases a key when the menu item has - * focus. Passes back the DOM Event object as an argument. - * @type YAHOO.util.CustomEvent - */ - keyUpEvent: null, - - - /** - * @event focusEvent - * @description Fires when the menu item receives focus. - * @type YAHOO.util.CustomEvent - */ - focusEvent: null, - - - /** - * @event blurEvent - * @description Fires when the menu item loses the input focus. - * @type YAHOO.util.CustomEvent - */ - blurEvent: null, - - - /** - * @method init - * @description The MenuItem class's initialization method. This method is - * automatically called by the constructor, and sets up all DOM references - * for pre-existing markup, and creates required markup if it is not - * already present. - * @param {String} p_oObject String specifying the text of the menu item. - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying - * the <code><li></code> element of the menu item. - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object - * specifying the <code><optgroup></code> element of the menu item. - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- - * one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object - * specifying the <code><option></code> element of the menu item. - * @param {Object} p_oConfig Optional. Object literal specifying the - * configuration for the menu item. See configuration class documentation - * for more details. - */ - init: function(p_oObject, p_oConfig) { - - - if(!this.SUBMENU_TYPE) { - - this.SUBMENU_TYPE = Menu; - - } - - - // Create the config object - - this.cfg = new YAHOO.util.Config(this); - - this.initDefaultConfig(); - - var oConfig = this.cfg; - - - if(this._checkString(p_oObject)) { - - this._createRootNodeStructure(); - - oConfig.setProperty("text", p_oObject); - - } - else if(this._checkDOMNode(p_oObject)) { - - switch(p_oObject.tagName.toUpperCase()) { - - case "OPTION": - - this._createRootNodeStructure(); - - oConfig.setProperty("text", p_oObject.text); - - this.srcElement = p_oObject; - - break; - - case "OPTGROUP": - - this._createRootNodeStructure(); - - oConfig.setProperty("text", p_oObject.label); - - this.srcElement = p_oObject; - - this._initSubTree(); - - break; - - case "LI": - - // Get the anchor node (if it exists) - - var oAnchor = this._getFirstElement(p_oObject, "A"), - sURL = "#", - sTarget, - sText; - - - // Capture the "text" and/or the "URL" - - if(oAnchor) { - - sURL = oAnchor.getAttribute("href"); - sTarget = oAnchor.getAttribute("target"); - - if(oAnchor.innerText) { - - sText = oAnchor.innerText; - - } - else { - - var oRange = oAnchor.ownerDocument.createRange(); - - oRange.selectNodeContents(oAnchor); - - sText = oRange.toString(); - - } - - } - else { - - var oText = p_oObject.firstChild; - - sText = oText.nodeValue; - - oAnchor = document.createElement("a"); - - oAnchor.setAttribute("href", sURL); - - p_oObject.replaceChild(oAnchor, oText); - - oAnchor.appendChild(oText); - - } - - - this.srcElement = p_oObject; - this.element = p_oObject; - this._oAnchor = oAnchor; - - - // Check if emphasis has been applied to the MenuItem - - var oEmphasisNode = this._getFirstElement(oAnchor), - bEmphasis = false, - bStrongEmphasis = false; - - if(oEmphasisNode) { - - // Set a reference to the text node - - this._oText = oEmphasisNode.firstChild; - - switch(oEmphasisNode.tagName.toUpperCase()) { - - case "EM": - - bEmphasis = true; - - break; - - case "STRONG": - - bStrongEmphasis = true; - - break; - - } - - } - else { - - // Set a reference to the text node - - this._oText = oAnchor.firstChild; - - } - - - /* - Set these properties silently to sync up the - configuration object without making changes to the - element's DOM - */ - - oConfig.setProperty("text", sText, true); - oConfig.setProperty("url", sURL, true); - oConfig.setProperty("target", sTarget, true); - oConfig.setProperty("emphasis", bEmphasis, true); - oConfig.setProperty( - "strongemphasis", - bStrongEmphasis, - true - ); - - this._initSubTree(); - - break; - - } - - } - - - if(this.element) { - - var sId = this.element.id; - - if(!sId) { - - sId = this.id || Dom.generateId(); - - this.element.id = sId; - - } - - this.id = sId; - - - Dom.addClass(this.element, this.CSS_CLASS_NAME); - - - // Create custom events - - var CustomEvent = YAHOO.util.CustomEvent; - - this.destroyEvent = new CustomEvent("destroyEvent", this); - this.mouseOverEvent = new CustomEvent("mouseOverEvent", this); - this.mouseOutEvent = new CustomEvent("mouseOutEvent", this); - this.mouseDownEvent = new CustomEvent("mouseDownEvent", this); - this.mouseUpEvent = new CustomEvent("mouseUpEvent", this); - this.clickEvent = new CustomEvent("clickEvent", this); - this.keyPressEvent = new CustomEvent("keyPressEvent", this); - this.keyDownEvent = new CustomEvent("keyDownEvent", this); - this.keyUpEvent = new CustomEvent("keyUpEvent", this); - this.focusEvent = new CustomEvent("focusEvent", this); - this.blurEvent = new CustomEvent("blurEvent", this); - - - if(p_oConfig) { - - oConfig.applyConfig(p_oConfig); - - } - - oConfig.fireQueue(); - - - - - } - - }, - - - - // Private methods - - - /** - * @method _getFirstElement - * @description Returns an HTML element's first HTML element node. - * @private - * @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>} p_oElement Object - * reference specifying the element to be evaluated. - * @param {String} p_sTagName Optional. String specifying the tagname of - * the element to be retrieved. - * @return {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>} - */ - _getFirstElement: function(p_oElement, p_sTagName) { - - var oFirstChild = p_oElement.firstChild, - oElement; - - if(oFirstChild) { - - if(oFirstChild.nodeType == 1) { - - oElement = oFirstChild; - - } - else { - - var oNextSibling = oFirstChild.nextSibling; - - if(oNextSibling && oNextSibling.nodeType == 1) { - - oElement = oNextSibling; - - } - - } - - } - - - if(p_sTagName) { - - return (oElement && oElement.tagName.toUpperCase() == p_sTagName) ? - oElement : false; - - } - - return oElement; - - }, - - - /** - * @method _checkString - * @description Determines if an object is a string. - * @private - * @param {Object} p_oObject Object to be evaluated. - * @return {Boolean} - */ - _checkString: function(p_oObject) { - - return (typeof p_oObject == "string"); - - }, - - - /** - * @method _checkDOMNode - * @description Determines if an object is an HTML element. - * @private - * @param {Object} p_oObject Object to be evaluated. - * @return {Boolean} - */ - _checkDOMNode: function(p_oObject) { - - return (p_oObject && p_oObject.tagName); - - }, - - - /** - * @method _createRootNodeStructure - * @description Creates the core DOM structure for the menu item. - * @private - */ - _createRootNodeStructure: function () { - - if(!m_oMenuItemElement) { - - m_oMenuItemElement = document.createElement("li"); - m_oMenuItemElement.innerHTML = "<a href=\"#\">s</a>"; - - } - - this.element = m_oMenuItemElement.cloneNode(true); - this._oAnchor = this.element.firstChild; - this._oText = this._oAnchor.firstChild; - - this.element.appendChild(this._oAnchor); - - }, - - - /** - * @method _initSubTree - * @description Iterates the source element's childNodes collection and uses - * the child nodes to instantiate other menus. - * @private - */ - _initSubTree: function() { - - var oSrcEl = this.srcElement, - oConfig = this.cfg; - - - if(oSrcEl.childNodes.length > 0) { - - if( - this.parent.lazyLoad && - this.parent.srcElement && - this.parent.srcElement.tagName.toUpperCase() == "SELECT" - ) { - - oConfig.setProperty( - "submenu", - { id: Dom.generateId(), itemdata: oSrcEl.childNodes } - ); - - } - else { - - var oNode = oSrcEl.firstChild, - aOptions = []; - - do { - - if(oNode && oNode.tagName) { - - switch(oNode.tagName.toUpperCase()) { - - case "DIV": - - oConfig.setProperty("submenu", oNode); - - break; - - case "OPTION": - - aOptions[aOptions.length] = oNode; - - break; - - } - - } - - } - while((oNode = oNode.nextSibling)); - - - var nOptions = aOptions.length; - - if(nOptions > 0) { - - var oMenu = new this.SUBMENU_TYPE(Dom.generateId()); - - oConfig.setProperty("submenu", oMenu); - - for(var n=0; n<nOptions; n++) { - - oMenu.addItem((new oMenu.ITEM_TYPE(aOptions[n]))); - - } - - } - - } - - } - - }, - - - /** - * @method _preloadImage - * @description Preloads an image by creating an image element from the - * specified path and appending the image to the body of the document. - * @private - * @param {String} p_sPath String specifying the path to the image. - * @deprecated All menu item images are now applied via CSS - * background images. - */ - _preloadImage: function(p_sPath) { - - var sPath = this.imageRoot + p_sPath; - - if(!document.images[sPath]) { - - var oImage = document.createElement("img"); - oImage.src = sPath; - oImage.name = sPath; - oImage.id = sPath; - oImage.style.display = "none"; - - document.body.appendChild(oImage); - - } - - }, - - - - // Event handlers for configuration properties - - - /** - * @method configText - * @description Event handler for when the "text" configuration property of - * the menu item changes. - * @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 fired the event. - */ - configText: function(p_sType, p_aArgs, p_oItem) { - - var sText = p_aArgs[0]; - - - if(this._oText) { - - this._oText.nodeValue = sText; - - } - - }, - - - /** - * @method configHelpText - * @description Event handler for when the "helptext" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configHelpText: function(p_sType, p_aArgs, p_oItem) { - - var me = this, - oHelpText = p_aArgs[0], - oEl = this.element, - oConfig = this.cfg, - aNodes = [oEl, this._oAnchor], - oSubmenuIndicator = this.submenuIndicator; - - - function initHelpText() { - - Dom.addClass(aNodes, "hashelptext"); - - if(oConfig.getProperty("disabled")) { - - oConfig.refireEvent("disabled"); - - } - - if(oConfig.getProperty("selected")) { - - oConfig.refireEvent("selected"); - - } - - } - - - function removeHelpText() { - - Dom.removeClass(aNodes, "hashelptext"); - - oEl.removeChild(me._oHelpTextEM); - me._oHelpTextEM = null; - - } - - - if(this._checkDOMNode(oHelpText)) { - - oHelpText.className = "helptext"; - - if(this._oHelpTextEM) { - - this._oHelpTextEM.parentNode.replaceChild( - oHelpText, - this._oHelpTextEM - ); - - } - else { - - this._oHelpTextEM = oHelpText; - - oEl.insertBefore(this._oHelpTextEM, oSubmenuIndicator); - - } - - initHelpText(); - - } - else if(this._checkString(oHelpText)) { - - if(oHelpText.length === 0) { - - removeHelpText(); - - } - else { - - if(!this._oHelpTextEM) { - - this._oHelpTextEM = document.createElement("em"); - this._oHelpTextEM.className = "helptext"; - - oEl.insertBefore(this._oHelpTextEM, oSubmenuIndicator); - - } - - this._oHelpTextEM.innerHTML = oHelpText; - - initHelpText(); - - } - - } - else if(!oHelpText && this._oHelpTextEM) { - - removeHelpText(); - - } - - }, - - - /** - * @method configURL - * @description Event handler for when the "url" configuration property of - * the menu item changes. - * @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 fired the event. - */ - configURL: function(p_sType, p_aArgs, p_oItem) { - - var sURL = p_aArgs[0]; - - if(!sURL) { - - sURL = "#"; - - } - - this._oAnchor.setAttribute("href", sURL); - - }, - - - /** - * @method configTarget - * @description Event handler for when the "target" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configTarget: function(p_sType, p_aArgs, p_oItem) { - - var sTarget = p_aArgs[0], - oAnchor = this._oAnchor; - - if(sTarget && sTarget.length > 0) { - - oAnchor.setAttribute("target", sTarget); - - } - else { - - oAnchor.removeAttribute("target"); - - } - - }, - - - /** - * @method configEmphasis - * @description Event handler for when the "emphasis" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configEmphasis: function(p_sType, p_aArgs, p_oItem) { - - var bEmphasis = p_aArgs[0], - oAnchor = this._oAnchor, - oText = this._oText, - oConfig = this.cfg, - oEM; - - - if(bEmphasis && oConfig.getProperty("strongemphasis")) { - - oConfig.setProperty("strongemphasis", false); - - } - - - if(oAnchor) { - - if(bEmphasis) { - - oEM = document.createElement("em"); - oEM.appendChild(oText); - - oAnchor.appendChild(oEM); - - } - else { - - oEM = this._getFirstElement(oAnchor, "EM"); - - if(oEM) { - - oAnchor.removeChild(oEM); - oAnchor.appendChild(oText); - - } - - } - - } - - }, - - - /** - * @method configStrongEmphasis - * @description Event handler for when the "strongemphasis" configuration - * property of the menu item changes. - * @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 fired the event. - */ - configStrongEmphasis: function(p_sType, p_aArgs, p_oItem) { - - var bStrongEmphasis = p_aArgs[0], - oAnchor = this._oAnchor, - oText = this._oText, - oConfig = this.cfg, - oStrong; - - if(bStrongEmphasis && oConfig.getProperty("emphasis")) { - - oConfig.setProperty("emphasis", false); - - } - - if(oAnchor) { - - if(bStrongEmphasis) { - - oStrong = document.createElement("strong"); - oStrong.appendChild(oText); - - oAnchor.appendChild(oStrong); - - } - else { - - oStrong = this._getFirstElement(oAnchor, "STRONG"); - - if(oStrong) { - - oAnchor.removeChild(oStrong); - oAnchor.appendChild(oText); - - } - - } - - } - - }, - - - /** - * @method configChecked - * @description Event handler for when the "checked" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configChecked: function(p_sType, p_aArgs, p_oItem) { - - var bChecked = p_aArgs[0], - oEl = this.element, - oConfig = this.cfg, - oEM; - - - if(bChecked) { - - if(!m_oCheckedIndicator) { - - m_oCheckedIndicator = document.createElement("em"); - m_oCheckedIndicator.innerHTML = this.CHECKED_TEXT; - m_oCheckedIndicator.className = "checkedindicator"; - - } - - oEM = m_oCheckedIndicator.cloneNode(true); - - var oSubmenu = this.cfg.getProperty("submenu"); - - if(oSubmenu && oSubmenu.element) { - - oEl.insertBefore(oEM, oSubmenu.element); - - } - else { - - oEl.appendChild(oEM); - - } - - - Dom.addClass(oEl, "checked"); - - this._oCheckedIndicator = oEM; - - if(oConfig.getProperty("disabled")) { - - oConfig.refireEvent("disabled"); - - } - - if(oConfig.getProperty("selected")) { - - oConfig.refireEvent("selected"); - - } - - } - else { - - oEM = this._oCheckedIndicator; - - Dom.removeClass(oEl, "checked"); - - if(oEM) { - - oEl.removeChild(oEM); - - } - - this._oCheckedIndicator = null; - - } - - }, - - - - /** - * @method configDisabled - * @description Event handler for when the "disabled" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configDisabled: function(p_sType, p_aArgs, p_oItem) { - - var bDisabled = p_aArgs[0], - oConfig = this.cfg, - oAnchor = this._oAnchor, - aNodes = [this.element, oAnchor], - oHelpText = this._oHelpTextEM, - oCheckedIndicator = this._oCheckedIndicator, - oSubmenuIndicator = this.submenuIndicator, - i = 1; - - - if(oHelpText) { - - i++; - aNodes[i] = oHelpText; - - } - - - if(oCheckedIndicator) { - - oCheckedIndicator.firstChild.nodeValue = bDisabled ? - this.DISABLED_CHECKED_TEXT : - this.CHECKED_TEXT; - - i++; - aNodes[i] = oCheckedIndicator; - - } - - - if(oSubmenuIndicator) { - - oSubmenuIndicator.firstChild.nodeValue = bDisabled ? - this.DISABLED_SUBMENU_INDICATOR_TEXT : - this.COLLAPSED_SUBMENU_INDICATOR_TEXT; - - i++; - aNodes[i] = oSubmenuIndicator; - - } - - - if(bDisabled) { - - if(oConfig.getProperty("selected")) { - - oConfig.setProperty("selected", false); - - } - - oAnchor.removeAttribute("href"); - - Dom.addClass(aNodes, "disabled"); - - } - else { - - oAnchor.setAttribute("href", oConfig.getProperty("url")); - - Dom.removeClass(aNodes, "disabled"); - - } - - }, - - - /** - * @method configSelected - * @description Event handler for when the "selected" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configSelected: function(p_sType, p_aArgs, p_oItem) { - - if(!this.cfg.getProperty("disabled")) { - - var bSelected = p_aArgs[0], - oHelpText = this._oHelpTextEM, - oSubmenuIndicator = this.submenuIndicator, - oCheckedIndicator = this._oCheckedIndicator, - aNodes = [this.element, this._oAnchor], - i = 1; - - - if(oHelpText) { - - i++; - aNodes[i] = oHelpText; - - } - - - if(oSubmenuIndicator) { - - i++; - aNodes[i] = oSubmenuIndicator; - - } - - - if(oCheckedIndicator) { - - i++; - aNodes[i] = oCheckedIndicator; - - } - - - if(bSelected) { - - Dom.addClass(aNodes, "selected"); - - } - else { - - Dom.removeClass(aNodes, "selected"); - - } - - } - - }, - - - /** - * @method configSubmenu - * @description Event handler for when the "submenu" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configSubmenu: function(p_sType, p_aArgs, p_oItem) { - - var oEl = this.element, - oSubmenu = p_aArgs[0], - oSubmenuIndicator = this.submenuIndicator, - oConfig = this.cfg, - aNodes = [this.element, this._oAnchor], - bLazyLoad = this.parent && this.parent.lazyLoad, - oMenu; - - - if(oSubmenu) { - - if(oSubmenu instanceof Menu) { - - oMenu = oSubmenu; - oMenu.parent = this; - oMenu.lazyLoad = bLazyLoad; - - } - else if( - typeof oSubmenu == "object" && - oSubmenu.id && - !oSubmenu.nodeType - ) { - - var sSubmenuId = oSubmenu.id, - oSubmenuConfig = oSubmenu; - - oSubmenuConfig.lazyload = bLazyLoad; - oSubmenuConfig.parent = this; - - oMenu = new this.SUBMENU_TYPE(sSubmenuId, oSubmenuConfig); - - - // Set the value of the property to the Menu instance - - this.cfg.setProperty("submenu", oMenu, true); - - } - else { - - oMenu = new this.SUBMENU_TYPE( - oSubmenu, - { lazyload: bLazyLoad, parent: this } - ); - - - // Set the value of the property to the Menu instance - - this.cfg.setProperty("submenu", oMenu, true); - - } - - - if(oMenu) { - - this._oSubmenu = oMenu; - - - if(!oSubmenuIndicator) { - - - if(!m_oSubmenuIndicator) { - - m_oSubmenuIndicator = document.createElement("em"); - m_oSubmenuIndicator.innerHTML = - this.COLLAPSED_SUBMENU_INDICATOR_TEXT; - m_oSubmenuIndicator.className = "submenuindicator"; - - } - - - oSubmenuIndicator = m_oSubmenuIndicator.cloneNode(true); - - - if(oMenu.element.parentNode == oEl) { - - if(this.browser == "opera") { - - oEl.appendChild(oSubmenuIndicator); - - oMenu.renderEvent.subscribe(function() { - - oSubmenuIndicator.parentNode.insertBefore( - oSubmenuIndicator, - oMenu.element - ); - - }); - - } - else { - - oEl.insertBefore(oSubmenuIndicator, oMenu.element); - - } - - } - else { - - oEl.appendChild(oSubmenuIndicator); - - } - - this.submenuIndicator = oSubmenuIndicator; - - } - - - Dom.addClass(aNodes, "hassubmenu"); - - - if(oConfig.getProperty("disabled")) { - - oConfig.refireEvent("disabled"); - - } - - if(oConfig.getProperty("selected")) { - - oConfig.refireEvent("selected"); - - } - - } - - } - else { - - Dom.removeClass(aNodes, "hassubmenu"); - - if(oSubmenuIndicator) { - - oEl.removeChild(oSubmenuIndicator); - - } - - if(this._oSubmenu) { - - this._oSubmenu.destroy(); - - } - - } - - }, - - - /** - * @method configOnClick - * @description Event handler for when the "onclick" configuration property - * of the menu item changes. - * @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 fired the event. - */ - configOnClick: function(p_sType, p_aArgs, p_oItem) { - - var oObject = p_aArgs[0]; - - /* - Remove any existing listeners if a "click" event handler has - already been specified. - */ - - if( - this._oOnclickAttributeValue && - (this._oOnclickAttributeValue != oObject) - ) { - - this.clickEvent.unsubscribe( - this._oOnclickAttributeValue.fn, - this._oOnclickAttributeValue.obj - ); - - this._oOnclickAttributeValue = null; - - } - - - if( - !this._oOnclickAttributeValue && - typeof oObject == "object" && - typeof oObject.fn == "function" - ) { - - this.clickEvent.subscribe( - oObject.fn, - (oObject.obj || this), - oObject.scope - ); - - this._oOnclickAttributeValue = oObject; - - } - - }, - - - /** - * @method configClassName - * @description Event handler for when the "classname" configuration - * property of a menu item changes. - * @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 fired the event. - */ - configClassName: function(p_sType, p_aArgs, p_oItem) { - - var sClassName = p_aArgs[0]; - - if(this._sClassName) { - - Dom.removeClass(this.element, this._sClassName); - - } - - Dom.addClass(this.element, sClassName); - this._sClassName = sClassName; - - }, - - - - // Public methods - - - /** - * @method initDefaultConfig - * @description Initializes an item's configurable properties. - */ - initDefaultConfig : function() { - - var oConfig = this.cfg, - CheckBoolean = oConfig.checkBoolean; - - - // Define the configuration attributes - - /** - * @config text - * @description String specifying the text label for the menu item. - * When building a menu from existing HTML the value of this property - * will be interpreted from the menu's markup. - * @default "" - * @type String - */ - oConfig.addProperty( - "text", - { - value: "", - handler: this.configText, - validator: this._checkString, - suppressEvent: true - } - ); - - - /** - * @config helptext - * @description String specifying additional instructional text to - * accompany the text for the nenu item. - * @default null - * @type String|<a href="http://www.w3.org/TR/ - * 2000/WD-DOM-Level-1-20000929/level-one-html.html#ID-58190037"> - * HTMLElement</a> - */ - oConfig.addProperty("helptext", { handler: this.configHelpText }); - - - /** - * @config url - * @description String specifying the URL for the menu item's anchor's - * "href" attribute. When building a menu from existing HTML the value - * of this property will be interpreted from the menu's markup. - * @default "#" - * @type String - */ - oConfig.addProperty( - "url", - { value: "#", handler: this.configURL, suppressEvent: true } - ); - - - /** - * @config target - * @description String specifying the value for the "target" attribute - * of the menu item's anchor element. <strong>Specifying a target will - * require the user to click directly on the menu item's anchor node in - * order to cause the browser to navigate to the specified URL.</strong> - * When building a menu from existing HTML the value of this property - * will be interpreted from the menu's markup. - * @default null - * @type String - */ - oConfig.addProperty( - "target", - { handler: this.configTarget, suppressEvent: true } - ); - - - /** - * @config emphasis - * @description Boolean indicating if the text of the menu item will be - * rendered with emphasis. When building a menu from existing HTML the - * value of this property will be interpreted from the menu's markup. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "emphasis", - { - value: false, - handler: this.configEmphasis, - validator: CheckBoolean, - suppressEvent: true - } - ); - - - /** - * @config strongemphasis - * @description Boolean indicating if the text of the menu item will be - * rendered with strong emphasis. When building a menu from existing - * HTML the value of this property will be interpreted from the - * menu's markup. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "strongemphasis", - { - value: false, - handler: this.configStrongEmphasis, - validator: CheckBoolean, - suppressEvent: true - } - ); - - - /** - * @config checked - * @description Boolean indicating if the menu item should be rendered - * with a checkmark. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "checked", - { - value: false, - handler: this.configChecked, - validator: this.cfg.checkBoolean, - suppressEvent: true, - supercedes:["disabled"] - } - ); - - - /** - * @config disabled - * @description Boolean indicating if the menu item should be disabled. - * (Disabled menu items are dimmed and will not respond to user input - * or fire events.) - * @default false - * @type Boolean - */ - oConfig.addProperty( - "disabled", - { - value: false, - handler: this.configDisabled, - validator: CheckBoolean, - suppressEvent: true - } - ); - - - /** - * @config selected - * @description Boolean indicating if the menu item should - * be highlighted. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "selected", - { - value: false, - handler: this.configSelected, - validator: CheckBoolean, - suppressEvent: true - } - ); - - - /** - * @config submenu - * @description Object specifying the submenu to be appended to the - * menu item. The value can be one of the following: <ul><li>Object - * specifying a Menu instance.</li><li>Object literal specifying the - * menu to be created. Format: <code>{ id: [menu id], itemdata: - * [<a href="YAHOO.widget.Menu.html#itemData">array of values for - * items</a>] }</code>.</li><li>String specifying the id attribute - * of the <code><div></code> element of the menu.</li><li> - * Object specifying the <code><div></code> element of the - * menu.</li></ul> - * @default null - * @type Menu|String|Object|<a href="http://www.w3.org/TR/2000/ - * WD-DOM-Level-1-20000929/level-one-html.html#ID-58190037"> - * HTMLElement</a> - */ - oConfig.addProperty("submenu", { handler: this.configSubmenu }); - - - /** - * @config onclick - * @description Object literal representing the code to be executed when - * the button is clicked. Format:<br> <code> {<br> - * <strong>fn:</strong> Function, // The handler to call when - * the event fires.<br> <strong>obj:</strong> Object, // An - * object to pass back to the handler.<br> <strong>scope:</strong> - * Object // The object to use for the scope of the handler. - * <br> } </code> - * @type Object - * @default null - */ - oConfig.addProperty("onclick", { handler: this.configOnClick }); - - - /** - * @config classname - * @description CSS class to be applied to the menu item's root - * <code><li></code> element. The specified class(es) are - * appended in addition to the default class as specified by the menu - * item's CSS_CLASS_NAME constant. - * @default null - * @type String - */ - oConfig.addProperty( - "classname", - { - value: null, - handler: this.configClassName, - validator: this._checkString - } - ); - - }, - - - /** - * @method getNextEnabledSibling - * @description Finds the menu item's next enabled sibling. - * @return YAHOO.widget.MenuItem - */ - getNextEnabledSibling: function() { - - if(this.parent instanceof Menu) { - - var nGroupIndex = this.groupIndex; - - function getNextArrayItem(p_aArray, p_nStartIndex) { - - return p_aArray[p_nStartIndex] || - getNextArrayItem(p_aArray, (p_nStartIndex+1)); - - } - - - var aItemGroups = this.parent.getItemGroups(), - oNextItem; - - - if(this.index < (aItemGroups[nGroupIndex].length - 1)) { - - oNextItem = getNextArrayItem( - aItemGroups[nGroupIndex], - (this.index+1) - ); - - } - else { - - var nNextGroupIndex; - - if(nGroupIndex < (aItemGroups.length - 1)) { - - nNextGroupIndex = nGroupIndex + 1; - - } - else { - - nNextGroupIndex = 0; - - } - - var aNextGroup = getNextArrayItem(aItemGroups, nNextGroupIndex); - - // Retrieve the first menu item in the next group - - oNextItem = getNextArrayItem(aNextGroup, 0); - - } - - return ( - oNextItem.cfg.getProperty("disabled") || - oNextItem.element.style.display == "none" - ) ? - oNextItem.getNextEnabledSibling() : oNextItem; - - } - - }, - - - /** - * @method getPreviousEnabledSibling - * @description Finds the menu item's previous enabled sibling. - * @return {YAHOO.widget.MenuItem} - */ - getPreviousEnabledSibling: function() { - - if(this.parent instanceof Menu) { - - var nGroupIndex = this.groupIndex; - - function getPreviousArrayItem(p_aArray, p_nStartIndex) { - - return p_aArray[p_nStartIndex] || - getPreviousArrayItem(p_aArray, (p_nStartIndex-1)); - - } - - function getFirstItemIndex(p_aArray, p_nStartIndex) { - - return p_aArray[p_nStartIndex] ? - p_nStartIndex : - getFirstItemIndex(p_aArray, (p_nStartIndex+1)); - - } - - var aItemGroups = this.parent.getItemGroups(), - oPreviousItem; - - if( - this.index > getFirstItemIndex(aItemGroups[nGroupIndex], 0) - ) { - - oPreviousItem = - getPreviousArrayItem( - aItemGroups[nGroupIndex], - (this.index-1) - ); - - } - else { - - var nPreviousGroupIndex; - - if(nGroupIndex > getFirstItemIndex(aItemGroups, 0)) { - - nPreviousGroupIndex = nGroupIndex - 1; - - } - else { - - nPreviousGroupIndex = aItemGroups.length - 1; - - } - - var aPreviousGroup = - getPreviousArrayItem(aItemGroups, nPreviousGroupIndex); - - oPreviousItem = - getPreviousArrayItem( - aPreviousGroup, - (aPreviousGroup.length - 1) - ); - - } - - return ( - oPreviousItem.cfg.getProperty("disabled") || - oPreviousItem.element.style.display == "none" - ) ? - oPreviousItem.getPreviousEnabledSibling() : oPreviousItem; - - } - - }, - - - /** - * @method focus - * @description Causes the menu item to receive the focus and fires the - * focus event. - */ - focus: function() { - - var oParent = this.parent, - oAnchor = this._oAnchor, - oActiveItem = oParent.activeItem; - - - function setFocus() { - - try { - - oAnchor.focus(); - - } - catch(e) { - - } - - } - - - if( - !this.cfg.getProperty("disabled") && - oParent && - oParent.cfg.getProperty("visible") && - this.element.style.display != "none" - ) { - - if(oActiveItem) { - - oActiveItem.blur(); - - } - - - /* - Setting focus via a timer fixes a race condition in Firefox, IE - and Opera where the browser viewport jumps as it trys to - position and focus the menu. - */ - - window.setTimeout(setFocus, 0); - - this.focusEvent.fire(); - - } - - }, - - - /** - * @method blur - * @description Causes the menu item to lose focus and fires the - * onblur event. - */ - blur: function() { - - var oParent = this.parent; - - if( - !this.cfg.getProperty("disabled") && - oParent && - Dom.getStyle(oParent.element, "visibility") == "visible" - ) { - - this._oAnchor.blur(); - - this.blurEvent.fire(); - - } - - }, - - - /** - * @method destroy - * @description Removes the menu item's <code><li></code> element - * from its parent <code><ul></code> element. - */ - destroy: function() { - - var oEl = this.element; - - if(oEl) { - - - // If the item has a submenu, destroy it first - - var oSubmenu = this.cfg.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.destroy(); - - } - - - // Remove CustomEvent listeners - - this.mouseOverEvent.unsubscribeAll(); - this.mouseOutEvent.unsubscribeAll(); - this.mouseDownEvent.unsubscribeAll(); - this.mouseUpEvent.unsubscribeAll(); - this.clickEvent.unsubscribeAll(); - this.keyPressEvent.unsubscribeAll(); - this.keyDownEvent.unsubscribeAll(); - this.keyUpEvent.unsubscribeAll(); - this.focusEvent.unsubscribeAll(); - this.blurEvent.unsubscribeAll(); - this.cfg.configChangedEvent.unsubscribeAll(); - - - // Remove the element from the parent node - - var oParentNode = oEl.parentNode; - - if(oParentNode) { - - oParentNode.removeChild(oEl); - - this.destroyEvent.fire(); - - } - - this.destroyEvent.unsubscribeAll(); - - } - - }, - - - /** - * @method toString - * @description Returns a string representing the menu item. - * @return {String} - */ - toString: function() { - - return ("MenuItem: " + this.cfg.getProperty("text")); - - } - -}; - -})(); - - - -/** -* Creates a list of options or commands which are made visible in response to -* an HTML element's "contextmenu" event ("mousedown" for Opera). -* -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the context menu. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source for the -* context menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object specifying the -* <code><div></code> element of the context menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-94282980">HTMLSelectElement</a>} p_oElement Object specifying -* the <code><select></code> element to be used as the data source for -* the context menu. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the context menu. See configuration class documentation -* for more details. -* @class ContextMenu -* @constructor -* @extends YAHOO.widget.Menu -* @namespace YAHOO.widget -*/ -YAHOO.widget.ContextMenu = function(p_oElement, p_oConfig) { - - YAHOO.widget.ContextMenu.superclass.constructor.call( - this, - p_oElement, - p_oConfig - ); - -}; - - -YAHOO.lang.extend(YAHOO.widget.ContextMenu, YAHOO.widget.Menu, { - - - -// Private properties - - -/** -* @property _oTrigger -* @description Object reference to the current value of the "trigger" -* configuration property. -* @default null -* @private -* @type String|<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/leve -* l-one-html.html#ID-58190037">HTMLElement</a>|Array -*/ -_oTrigger: null, - - -/** -* @property _bCancelled -* @description Boolean indicating if the display of the context menu should -* be cancelled. -* @default false -* @private -* @type Boolean -*/ -_bCancelled: false, - - -// Public properties - - -/** -* @property contextEventTarget -* @description Object reference for the HTML element that was the target of the -* "contextmenu" DOM event ("mousedown" for Opera) that triggered the display of -* the context menu. -* @default null -* @type <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-58190037">HTMLElement</a> -*/ -contextEventTarget: null, - - - -// Events - - -/** -* @event triggerContextMenuEvent -* @description Custom Event wrapper for the "contextmenu" DOM event -* ("mousedown" for Opera) fired by the element(s) that trigger the display of -* the context menu. -*/ -triggerContextMenuEvent: null, - - - - - -/** -* @method init -* @description The ContextMenu class's initialization method. This method is -* automatically called by the constructor, and sets up all DOM references for -* pre-existing markup, and creates required markup if it is not already present. -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the context menu. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source for -* the context menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object specifying the -* <code><div></code> element of the context menu. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one- -* html.html#ID-94282980">HTMLSelectElement</a>} p_oElement Object specifying -* the <code><select></code> element to be used as the data source for -* the context menu. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the context menu. See configuration class documentation -* for more details. -*/ -init: function(p_oElement, p_oConfig) { - - if(!this.ITEM_TYPE) { - - this.ITEM_TYPE = YAHOO.widget.ContextMenuItem; - - } - - - // Call the init of the superclass (YAHOO.widget.Menu) - - YAHOO.widget.ContextMenu.superclass.init.call(this, p_oElement); - - - this.beforeInitEvent.fire(YAHOO.widget.ContextMenu); - - - if(p_oConfig) { - - this.cfg.applyConfig(p_oConfig, true); - - } - - - this.initEvent.fire(YAHOO.widget.ContextMenu); - -}, - - -/** -* @method initEvents -* @description Initializes the custom events for the context menu. -*/ -initEvents: function() { - - YAHOO.widget.ContextMenu.superclass.initEvents.call(this); - - // Create custom events - - this.triggerContextMenuEvent = - new YAHOO.util.CustomEvent("triggerContextMenuEvent", this); - -}, - - -/** -* @method cancel -* @description Cancels the display of the context menu. -*/ -cancel: function() { - - this._bCancelled = true; - -}, - - - -// Private methods - - -/** -* @method _removeEventHandlers -* @description Removes all of the DOM event handlers from the HTML element(s) -* whose "context menu" event ("click" for Opera) trigger the display of -* the context menu. -* @private -*/ -_removeEventHandlers: function() { - - var Event = YAHOO.util.Event, - oTrigger = this._oTrigger, - bOpera = (this.browser == "opera"); - - - // Remove the event handlers from the trigger(s) - - Event.removeListener( - oTrigger, - (bOpera ? "mousedown" : "contextmenu"), - this._onTriggerContextMenu - ); - - if(bOpera) { - - Event.removeListener(oTrigger, "click", this._onTriggerClick); - - } - -}, - - - -// Private event handlers - - -/** -* @method _onTriggerClick -* @description "click" event handler for the HTML element(s) identified as the -* "trigger" for the context menu. Used to cancel default behaviors in Opera. -* @private -* @param {Event} p_oEvent Object representing the DOM event object passed back -* by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.ContextMenu} p_oMenu Object representing the context -* menu that is handling the event. -*/ -_onTriggerClick: function(p_oEvent, p_oMenu) { - - if(p_oEvent.ctrlKey) { - - YAHOO.util.Event.stopEvent(p_oEvent); - - } - -}, - - -/** -* @method _onTriggerContextMenu -* @description "contextmenu" event handler ("mousedown" for Opera) for the HTML -* element(s) that trigger the display of the context menu. -* @private -* @param {Event} p_oEvent Object representing the DOM event object passed back -* by the event utility (YAHOO.util.Event). -* @param {YAHOO.widget.ContextMenu} p_oMenu Object representing the context -* menu that is handling the event. -*/ -_onTriggerContextMenu: function(p_oEvent, p_oMenu) { - - var Event = YAHOO.util.Event; - - if(p_oEvent.type == "mousedown" && !p_oEvent.ctrlKey) { - - return; - - } - - - /* - Prevent the browser's default context menu from appearing and - stop the propagation of the "contextmenu" event so that - other ContextMenu instances are not displayed. - */ - - Event.stopEvent(p_oEvent); - - - // Hide any other ContextMenu instances that might be visible - - YAHOO.widget.MenuManager.hideVisible(); - - - this.contextEventTarget = Event.getTarget(p_oEvent); - - this.triggerContextMenuEvent.fire(p_oEvent); - - - if(!this._bCancelled) { - - // Position and display the context menu - - this.cfg.setProperty("xy", Event.getXY(p_oEvent)); - - this.show(); - - } - - this._bCancelled = false; - -}, - - - -// Public methods - - -/** -* @method toString -* @description Returns a string representing the context menu. -* @return {String} -*/ -toString: function() { - - return ("ContextMenu " + this.id); - -}, - - -/** -* @method initDefaultConfig -* @description Initializes the class's configurable properties which can be -* changed using the context menu's Config object ("cfg"). -*/ -initDefaultConfig: function() { - - YAHOO.widget.ContextMenu.superclass.initDefaultConfig.call(this); - - /** - * @config trigger - * @description The HTML element(s) whose "contextmenu" event ("mousedown" - * for Opera) trigger the display of the context menu. Can be a string - * representing the id attribute of the HTML element, an object reference - * for the HTML element, or an array of strings or HTML element references. - * @default null - * @type String|<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ - * level-one-html.html#ID-58190037">HTMLElement</a>|Array - */ - this.cfg.addProperty("trigger", { handler: this.configTrigger }); - -}, - - -/** -* @method destroy -* @description Removes the context menu's <code><div></code> element -* (and accompanying child nodes) from the document. -*/ -destroy: function() { - - // Remove the DOM event handlers from the current trigger(s) - - this._removeEventHandlers(); - - - // Continue with the superclass implementation of this method - - YAHOO.widget.ContextMenu.superclass.destroy.call(this); - -}, - - - -// Public event handlers for configuration properties - - -/** -* @method configTrigger -* @description Event handler for when the value of the "trigger" configuration -* property changes. -* @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.ContextMenu} p_oMenu Object representing the context -* menu that fired the event. -*/ -configTrigger: function(p_sType, p_aArgs, p_oMenu) { - - var Event = YAHOO.util.Event, - oTrigger = p_aArgs[0]; - - if(oTrigger) { - - /* - If there is a current "trigger" - remove the event handlers - from that element(s) before assigning new ones - */ - - if(this._oTrigger) { - - this._removeEventHandlers(); - - } - - this._oTrigger = oTrigger; - - - /* - Listen for the "mousedown" event in Opera b/c it does not - support the "contextmenu" event - */ - - var bOpera = (this.browser == "opera"); - - Event.addListener( - oTrigger, - (bOpera ? "mousedown" : "contextmenu"), - this._onTriggerContextMenu, - this, - true - ); - - - /* - Assign a "click" event handler to the trigger element(s) for - Opera to prevent default browser behaviors. - */ - - if(bOpera) { - - Event.addListener( - oTrigger, - "click", - this._onTriggerClick, - this, - true - ); - - } - - } - else { - - this._removeEventHandlers(); - - } - -} - -}); // END YAHOO.lang.extend - - - -/** -* Creates an item for a context menu. -* -* @param {String} p_oObject String specifying the text of the context menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying the -* <code><li></code> element of the context menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the context -* menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object specifying -* the <code><option></code> element of the context menu item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the context menu item. See configuration class -* documentation for more details. -* @class ContextMenuItem -* @constructor -* @extends YAHOO.widget.MenuItem -*/ -YAHOO.widget.ContextMenuItem = function(p_oObject, p_oConfig) { - - YAHOO.widget.ContextMenuItem.superclass.constructor.call( - this, - p_oObject, - p_oConfig - ); - -}; - -YAHOO.lang.extend(YAHOO.widget.ContextMenuItem, YAHOO.widget.MenuItem, { - - -/** -* @method init -* @description The ContextMenuItem class's initialization method. This method -* is automatically called by the constructor, and sets up all DOM references -* for pre-existing markup, and creates required markup if it is not -* already present. -* @param {String} p_oObject String specifying the text of the context menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying the -* <code><li></code> element of the context menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the context -* menu item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object specifying -* the <code><option></code> element of the context menu item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the context menu item. See configuration class -* documentation for more details. -*/ -init: function(p_oObject, p_oConfig) { - - if(!this.SUBMENU_TYPE) { - - this.SUBMENU_TYPE = YAHOO.widget.ContextMenu; - - } - - - /* - Call the init of the superclass (YAHOO.widget.MenuItem) - Note: We don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.ContextMenuItem.superclass.init.call(this, p_oObject); - - var oConfig = this.cfg; - - if(p_oConfig) { - - oConfig.applyConfig(p_oConfig, true); - - } - - oConfig.fireQueue(); - -}, - - - -// Public methods - - -/** -* @method toString -* @description Returns a string representing the context menu item. -* @return {String} -*/ -toString: function() { - - return ("ContextMenuItem: " + this.cfg.getProperty("text")); - -} - -}); // END YAHOO.lang.extend - - - -/** -* Horizontal collection of items, each of which can contain a submenu. -* -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the menu bar. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source for the -* menu bar. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object specifying -* the <code><div></code> element of the menu bar. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement Object -* specifying the <code><select></code> element to be used as the data -* source for the menu bar. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu bar. See configuration class documentation for -* more details. -* @class Menubar -* @constructor -* @extends YAHOO.widget.Menu -* @namespace YAHOO.widget -*/ -YAHOO.widget.MenuBar = function(p_oElement, p_oConfig) { - - YAHOO.widget.MenuBar.superclass.constructor.call( - this, - p_oElement, - p_oConfig - ); - -}; - -YAHOO.lang.extend(YAHOO.widget.MenuBar, YAHOO.widget.Menu, { - -/** -* @method init -* @description The MenuBar class's initialization method. This method is -* automatically called by the constructor, and sets up all DOM references for -* pre-existing markup, and creates required markup if it is not already present. -* @param {String} p_oElement String specifying the id attribute of the -* <code><div></code> element of the menu bar. -* @param {String} p_oElement String specifying the id attribute of the -* <code><select></code> element to be used as the data source for the -* menu bar. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-22445964">HTMLDivElement</a>} p_oElement Object specifying -* the <code><div></code> element of the menu bar. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-94282980">HTMLSelectElement</a>} p_oElement Object -* specifying the <code><select></code> element to be used as the data -* source for the menu bar. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu bar. See configuration class documentation for -* more details. -*/ -init: function(p_oElement, p_oConfig) { - - if(!this.ITEM_TYPE) { - - this.ITEM_TYPE = YAHOO.widget.MenuBarItem; - - } - - - // Call the init of the superclass (YAHOO.widget.Menu) - - YAHOO.widget.MenuBar.superclass.init.call(this, p_oElement); - - - this.beforeInitEvent.fire(YAHOO.widget.MenuBar); - - - if(p_oConfig) { - - this.cfg.applyConfig(p_oConfig, true); - - } - - this.initEvent.fire(YAHOO.widget.MenuBar); - -}, - - - -// Constants - - -/** -* @property CSS_CLASS_NAME -* @description String representing the CSS class(es) to be applied to the menu -* bar's <code><div></code> element. -* @default "yuimenubar" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuimenubar", - - - -// Protected event handlers - - -/** -* @method _onKeyDown -* @description "keydown" Custom Event handler for the menu bar. -* @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.MenuBar} p_oMenuBar Object representing the menu bar -* that fired the event. -*/ -_onKeyDown: function(p_sType, p_aArgs, p_oMenuBar) { - - var Event = YAHOO.util.Event, - oEvent = p_aArgs[0], - oItem = p_aArgs[1], - oSubmenu; - - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var oItemCfg = oItem.cfg; - - switch(oEvent.keyCode) { - - case 37: // Left arrow - case 39: // Right arrow - - if( - oItem == this.activeItem && - !oItemCfg.getProperty("selected") - ) { - - oItemCfg.setProperty("selected", true); - - } - else { - - var oNextItem = (oEvent.keyCode == 37) ? - oItem.getPreviousEnabledSibling() : - oItem.getNextEnabledSibling(); - - if(oNextItem) { - - this.clearActiveItem(); - - oNextItem.cfg.setProperty("selected", true); - - - if(this.cfg.getProperty("autosubmenudisplay")) { - - oSubmenu = oNextItem.cfg.getProperty("submenu"); - - if(oSubmenu) { - - oSubmenu.show(); - oSubmenu.activeItem.blur(); - oSubmenu.activeItem = null; - - } - - } - - oNextItem.focus(); - - } - - } - - Event.preventDefault(oEvent); - - break; - - case 40: // Down arrow - - if(this.activeItem != oItem) { - - this.clearActiveItem(); - - oItemCfg.setProperty("selected", true); - oItem.focus(); - - } - - oSubmenu = oItemCfg.getProperty("submenu"); - - if(oSubmenu) { - - if(oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.setInitialSelection(); - oSubmenu.setInitialFocus(); - - } - else { - - oSubmenu.show(); - - } - - } - - Event.preventDefault(oEvent); - - break; - - } - - } - - - if(oEvent.keyCode == 27 && this.activeItem) { // Esc key - - oSubmenu = this.activeItem.cfg.getProperty("submenu"); - - if(oSubmenu && oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.hide(); - this.activeItem.focus(); - - } - else { - - this.activeItem.cfg.setProperty("selected", false); - this.activeItem.blur(); - - } - - Event.preventDefault(oEvent); - - } - -}, - - -/** -* @method _onClick -* @description "click" event handler for the menu bar. -* @protected -* @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.MenuBar} p_oMenuBar Object representing the menu bar -* that fired the event. -*/ -_onClick: function(p_sType, p_aArgs, p_oMenuBar) { - - YAHOO.widget.MenuBar.superclass._onClick.call( - this, - p_sType, - p_aArgs, - p_oMenuBar - ); - - - var oItem = p_aArgs[1]; - - if(oItem && !oItem.cfg.getProperty("disabled")) { - - var Event = YAHOO.util.Event, - Dom = YAHOO.util.Dom, - - oEvent = p_aArgs[0], - oTarget = Event.getTarget(oEvent), - - oActiveItem = this.activeItem, - oConfig = this.cfg; - - - // Hide any other submenus that might be visible - - if(oActiveItem && oActiveItem != oItem) { - - this.clearActiveItem(); - - } - - - // Select and focus the current item - - oItem.cfg.setProperty("selected", true); - oItem.focus(); - - - // Show the submenu for the item - - var oSubmenu = oItem.cfg.getProperty("submenu"); - - - if(oSubmenu && oTarget != oItem.submenuIndicator) { - - if(oSubmenu.cfg.getProperty("visible")) { - - oSubmenu.hide(); - - } - else { - - oSubmenu.show(); - - } - - } - - } - -}, - - - -// Public methods - - -/** -* @method toString -* @description Returns a string representing the menu bar. -* @return {String} -*/ -toString: function() { - - return ("MenuBar " + this.id); - -}, - - -/** -* @description Initializes the class's configurable properties which can be -* changed using the menu bar's Config object ("cfg"). -* @method initDefaultConfig -*/ -initDefaultConfig: function() { - - YAHOO.widget.MenuBar.superclass.initDefaultConfig.call(this); - - var oConfig = this.cfg; - - // Add configuration properties - - - /* - Set the default value for the "position" configuration property - to "static" by re-adding the property. - */ - - /** - * @config position - * @description String indicating how a menu bar should be positioned on the - * screen. Possible values are "static" and "dynamic." Static menu bars - * are visible by default and reside in the normal flow of the document - * (CSS position: static). Dynamic menu bars are hidden by default, reside - * out of the normal flow of the document (CSS position: absolute), and can - * overlay other elements on the screen. - * @default static - * @type String - */ - oConfig.addProperty( - "position", - { - value: "static", - handler: this.configPosition, - validator: this._checkPosition, - supercedes: ["visible"] - } - ); - - - /* - Set the default value for the "submenualignment" configuration property - to ["tl","bl"] by re-adding the property. - */ - - /** - * @config submenualignment - * @description Array defining how submenus should be aligned to their - * parent menu bar item. The format is: [itemCorner, submenuCorner]. - * @default ["tl","bl"] - * @type Array - */ - oConfig.addProperty("submenualignment", { value: ["tl","bl"] } ); - - - /* - Change the default value for the "autosubmenudisplay" configuration - property to "false" by re-adding the property. - */ - - /** - * @config autosubmenudisplay - * @description Boolean indicating if submenus are automatically made - * visible when the user mouses over the menu bar's items. - * @default false - * @type Boolean - */ - oConfig.addProperty( - "autosubmenudisplay", - { value: false, validator: oConfig.checkBoolean } - ); - -} - -}); // END YAHOO.lang.extend - - - -/** -* Creates an item for a menu bar. -* -* @param {String} p_oObject String specifying the text of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying the -* <code><li></code> element of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object specifying -* the <code><option></code> element of the menu bar item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu bar item. See configuration class documentation -* for more details. -* @class MenuBarItem -* @constructor -* @extends YAHOO.widget.MenuItem -*/ -YAHOO.widget.MenuBarItem = function(p_oObject, p_oConfig) { - - YAHOO.widget.MenuBarItem.superclass.constructor.call( - this, - p_oObject, - p_oConfig - ); - -}; - -YAHOO.lang.extend(YAHOO.widget.MenuBarItem, YAHOO.widget.MenuItem, { - - -/** -* @method init -* @description The MenuBarItem class's initialization method. This method is -* automatically called by the constructor, and sets up all DOM references for -* pre-existing markup, and creates required markup if it is not already present. -* @param {String} p_oObject String specifying the text of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-74680021">HTMLLIElement</a>} p_oObject Object specifying the -* <code><li></code> element of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-38450247">HTMLOptGroupElement</a>} p_oObject Object -* specifying the <code><optgroup></code> element of the menu bar item. -* @param {<a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level- -* one-html.html#ID-70901257">HTMLOptionElement</a>} p_oObject Object specifying -* the <code><option></code> element of the menu bar item. -* @param {Object} p_oConfig Optional. Object literal specifying the -* configuration for the menu bar item. See configuration class documentation -* for more details. -*/ -init: function(p_oObject, p_oConfig) { - - if(!this.SUBMENU_TYPE) { - - this.SUBMENU_TYPE = YAHOO.widget.Menu; - - } - - - /* - Call the init of the superclass (YAHOO.widget.MenuItem) - Note: We don't pass the user config in here yet - because we only want it executed once, at the lowest - subclass level. - */ - - YAHOO.widget.MenuBarItem.superclass.init.call(this, p_oObject); - - - var oConfig = this.cfg; - - if(p_oConfig) { - - oConfig.applyConfig(p_oConfig, true); - - } - - oConfig.fireQueue(); - -}, - - - -// Constants - -/** -* @property CSS_CLASS_NAME -* @description String representing the CSS class(es) to be applied to the -* <code><li></code> element of the menu bar item. -* @default "yuimenubaritem" -* @final -* @type String -*/ -CSS_CLASS_NAME: "yuimenubaritem", - - - -// Public methods - - -/** -* @method toString -* @description Returns a string representing the menu bar item. -* @return {String} -*/ -toString: function() { - - return ("MenuBarItem: " + this.cfg.getProperty("text")); - -} - -}); // END YAHOO.lang.extend -YAHOO.register("menu", YAHOO.widget.Menu, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/reset-fonts-grids/README b/interface/web/js/yui/reset-fonts-grids/README deleted file mode 100644 index d0b211725a..0000000000 --- a/interface/web/js/yui/reset-fonts-grids/README +++ /dev/null @@ -1,24 +0,0 @@ -YUI Library - Reset+Fonts+Grids (RFG) - Release Notes - -*** NOTE *** - -This document is not updated with each release. Changes to -the reset-fonts-grids.css source are noted in the README -file for each component that comprises this aggregate: - -reset/README -fonts/README -grids/README - -************ - -Version 2.2.0 - - * No changes. - -Version 0.12.0 - - * Initial release. - - * This file is a convenience file containing an in-order - concatonation of Reset, Fonts, and Grids. \ No newline at end of file diff --git a/interface/web/js/yui/reset-fonts-grids/reset-fonts-grids.css b/interface/web/js/yui/reset-fonts-grids/reset-fonts-grids.css deleted file mode 100644 index d511cec353..0000000000 --- a/interface/web/js/yui/reset-fonts-grids/reset-fonts-grids.css +++ /dev/null @@ -1,9 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/*reset.css*/body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}ol,ul {list-style:none;}caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;} -/*fonts.css*/body{font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;} -/*grids.css*/body{text-align:center;}#ft{clear:both;}#doc,#doc2,#doc3,.yui-t1,.yui-t2,.yui-t3,.yui-t4,.yui-t5,.yui-t6,.yui-t7{margin:auto;text-align:left;width:57.69em;*width:56.3em;min-width:750px;}#doc2{width:73.074em;*width:71.313em;min-width:950px;}#doc3{margin:auto 10px;width:auto;}.yui-b{position:relative;}.yui-b{_position:static;}#yui-main .yui-b{position:static;}#yui-main{width:100%;}.yui-t1 #yui-main,.yui-t2 #yui-main,.yui-t3 #yui-main{float:right;margin-left:-25em;}.yui-t4 #yui-main,.yui-t5 #yui-main,.yui-t6 #yui-main{float:left;margin-right:-25em;}.yui-t1 .yui-b{float:left;width:12.3207em;*width:12.0106em;}.yui-t1 #yui-main .yui-b{margin-left:13.3207em;*margin-left:13.0106em;}.yui-t2 .yui-b{float:left;width:13.8456em;*width:13.512em;}.yui-t2 #yui-main .yui-b{margin-left:14.8456em;*margin-left:14.512em;}.yui-t3 .yui-b{float:left;width:23.0759em;*width:22.52em;}.yui-t3 #yui-main .yui-b{margin-left:24.0759em;*margin-left:23.52em;}.yui-t4 .yui-b{float:right;width:13.8456em;*width:13.512em;}.yui-t4 #yui-main .yui-b{margin-right:14.8456em;*margin-right:14.512em;}.yui-t5 .yui-b{float:right;width:18.4608em;*width:18.016em;}.yui-t5 #yui-main .yui-b{margin-right:19.4608em;*margin-right:19.016em;}.yui-t6 .yui-b{float:right;width:23.0759em;*width:22.52em;}.yui-t6 #yui-main .yui-b{margin-right:24.0759em;*margin-right:23.52em;}.yui-t7 #yui-main .yui-b{display:block;margin:0 0 1em 0;}#yui-main .yui-b{float:none;width:auto;}.yui-g .yui-u,.yui-g .yui-g,.yui-gc .yui-u,.yui-gc .yui-g .yui-u,.yui-ge .yui-u,.yui-gf .yui-u{float:right;display:inline;}.yui-g div.first,.yui-gc div.first,.yui-gc div.first div.first,.yui-gd div.first,.yui-ge div.first,.yui-gf div.first{float:left;}.yui-g .yui-u,.yui-g .yui-g{width:49.1%;}.yui-g .yui-g .yui-u,.yui-gc .yui-g .yui-u{width:48.1%;}.yui-gb .yui-u,.yui-gc .yui-u,.yui-gd .yui-u{float:left;margin-left:2%;*margin-left:1.895%;width:32%;}.yui-gb div.first,.yui-gc div.first,.yui-gd div.first{margin-left:0;}.yui-gc div.first,.yui-gd .yui-u{width:66%;}.yui-gd div.first{width:32%;}.yui-ge .yui-u{width:24%;}.yui-ge div.first,.yui-gf .yui-u{width:74.2%;}.yui-gf div.first{width:24%;}.yui-ge div.first{width:74.2%;}#bd:after,.yui-g:after,.yui-gb:after,.yui-gc:after,.yui-gd:after,.yui-ge:after,.yui-gf:after{content:".";display:block;height:0;clear:both;visibility:hidden;}#bd,.yui-g,.yui-gb,.yui-gc,.yui-gd,.yui-ge,.yui-gf{zoom:1;} \ No newline at end of file diff --git a/interface/web/js/yui/reset/README b/interface/web/js/yui/reset/README deleted file mode 100644 index e25df68269..0000000000 --- a/interface/web/js/yui/reset/README +++ /dev/null @@ -1,25 +0,0 @@ -YUI Library - Reset - Release Notes - -Version 2.2.0 - - * No changes. - -Version 0.12.1 - 0.12.2 - - * No changes. - -Version 0.12.0 - - * Added: h1,h2,h3,h4,h5,h6{font-weight:normal;} - - * Added: abbr,acronym {border:0;} - - * Added: textarea {padding:0;margin:0;} - -Version 0.11.0 - - * No changes. - -Version 0.10.0 - - * Initial release. \ No newline at end of file diff --git a/interface/web/js/yui/reset/reset-min.css b/interface/web/js/yui/reset/reset-min.css deleted file mode 100644 index daa85b7bb0..0000000000 --- a/interface/web/js/yui/reset/reset-min.css +++ /dev/null @@ -1,7 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}ol,ul {list-style:none;}caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;} \ No newline at end of file diff --git a/interface/web/js/yui/reset/reset.css b/interface/web/js/yui/reset/reset.css deleted file mode 100644 index e8ea97eb39..0000000000 --- a/interface/web/js/yui/reset/reset.css +++ /dev/null @@ -1,15 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;} -table{border-collapse:collapse;border-spacing:0;} -fieldset,img{border:0;} -address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;} -ol,ul {list-style:none;} -caption,th {text-align:left;} -h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;} -q:before,q:after{content:'';} -abbr,acronym {border:0;} \ No newline at end of file diff --git a/interface/web/js/yui/slider/README b/interface/web/js/yui/slider/README deleted file mode 100644 index e435635fa4..0000000000 --- a/interface/web/js/yui/slider/README +++ /dev/null @@ -1,69 +0,0 @@ -Slider - Release Notes - -2.2.0 - - * Added the missing "force" parameter to the signature for setRegionValue - - * deprecated the moveComplete flag - -0.12.2 - - * No change - -0.12.1 - - * Removed unneccessary getXY calls that were contribuing to slower performance - in FireFox when the slider was deeply nested in the DOM. - -0.12.0 - - * Added "slideStart", "slideEnd", and "change" custom events. The abstract - methods these will eventually replace still work. - - * The default animation duration is 0.2 seconds (reduced from 0.4 seconds), - and is configurable via the animationDuration property. - - * Keyboard navigation is now built in. The background needs a tabindex for - keyboard nav to work. Keyboard nav can be disabled by setting enableKeys - to false. The number of pixels the slider moves when the arrow keys - are pressed is controlled by keyIncrement, and defaults to 20. Note, - Safari support limited to background element types that support focus - in that browser. http://bugs.webkit.org/show_bug.cgi?id=7138 - - * Fixed broken doctype in examples/index.html - - * Catching an unhandled script exception in FF that could occur when - attempting to focus the slider background while a text field without - autocomplete="false" has focus - -0.11.3 - - * No change - -0.11.0 - - * When the thumb is clicked and dragged, the click position delta is properly - applied. - - * The slider background can be disabled by setting backgroundEnabled to false. - - * Added SliderThumb->clearTicks - - * Incorporated updated drag and drop performance improvements - -0.10.0 - - * Drag and drop's autoscroll feature is now turned off by default - in the slider. - - * The slider no longer sets its initial value upon initialization - - * RGB slider example fixed for IE7. - - * Updated to work with the onAvailable feature in Drag and Drop. - - * Updated the basic slider example page to make the control more - accessible to non-FF1.5 browsers. - - * Split the examples into separate pages - diff --git a/interface/web/js/yui/slider/slider-debug.js b/interface/web/js/yui/slider/slider-debug.js deleted file mode 100644 index d65dcae936..0000000000 --- a/interface/web/js/yui/slider/slider-debug.js +++ /dev/null @@ -1,1259 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The Slider component is a UI control that enables the user to adjust - * values in a finite range along one or two axes. Typically, the Slider - * control is used in a web application as a rich, visual replacement - * for an input box that takes a number as input. The Slider control can - * also easily accommodate a second dimension, providing x,y output for - * a selection point chosen from a rectangular region. - * - * @module slider - * @title Slider Widget - * @namespace YAHOO.widget - * @requires yahoo,dom,dragdrop,event - * @optional animation - */ - -/** - * A DragDrop implementation that can be used as a background for a - * slider. It takes a reference to the thumb instance - * so it can delegate some of the events to it. The goal is to make the - * thumb jump to the location on the background when the background is - * clicked. - * - * @class Slider - * @extends YAHOO.util.DragDrop - * @uses YAHOO.util.EventProvider - * @constructor - * @param {String} id The id of the element linked to this instance - * @param {String} sGroup The group of related DragDrop items - * @param {SliderThumb} oThumb The thumb for this slider - * @param {String} sType The type of slider (horiz, vert, region) - */ -YAHOO.widget.Slider = function(sElementId, sGroup, oThumb, sType) { - if (sElementId) { - this.init(sElementId, sGroup, true); - this.initSlider(sType); - this.initThumb(oThumb); - } -}; - -/** - * Factory method for creating a horizontal slider - * @method YAHOO.widget.Slider.getHorizSlider - * @static - * @param {String} sBGElId the id of the slider's background element - * @param {String} sHandleElId the id of the thumb element - * @param {int} iLeft the number of pixels the element can move left - * @param {int} iRight the number of pixels the element can move right - * @param {int} iTickSize optional parameter for specifying that the element - * should move a certain number pixels at a time. - * @return {Slider} a horizontal slider control - */ -YAHOO.widget.Slider.getHorizSlider = - function (sBGElId, sHandleElId, iLeft, iRight, iTickSize) { - return new YAHOO.widget.Slider(sBGElId, sBGElId, - new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, - iLeft, iRight, 0, 0, iTickSize), "horiz"); -}; - -/** - * Factory method for creating a vertical slider - * @method YAHOO.widget.Slider.getVertSlider - * @static - * @param {String} sBGElId the id of the slider's background element - * @param {String} sHandleElId the id of the thumb element - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize optional parameter for specifying that the element - * should move a certain number pixels at a time. - * @return {Slider} a vertical slider control - */ -YAHOO.widget.Slider.getVertSlider = - function (sBGElId, sHandleElId, iUp, iDown, iTickSize) { - return new YAHOO.widget.Slider(sBGElId, sBGElId, - new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, 0, 0, - iUp, iDown, iTickSize), "vert"); -}; - -/** - * Factory method for creating a slider region like the one in the color - * picker example - * @method YAHOO.widget.Slider.getSliderRegion - * @static - * @param {String} sBGElId the id of the slider's background element - * @param {String} sHandleElId the id of the thumb element - * @param {int} iLeft the number of pixels the element can move left - * @param {int} iRight the number of pixels the element can move right - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize optional parameter for specifying that the element - * should move a certain number pixels at a time. - * @return {Slider} a slider region control - */ -YAHOO.widget.Slider.getSliderRegion = - function (sBGElId, sHandleElId, iLeft, iRight, iUp, iDown, iTickSize) { - return new YAHOO.widget.Slider(sBGElId, sBGElId, - new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, iLeft, iRight, - iUp, iDown, iTickSize), "region"); -}; - -/** - * By default, animation is available if the animation library is detected. - * @property YAHOO.widget.Slider.ANIM_AVAIL - * @static - * @type boolean - */ -YAHOO.widget.Slider.ANIM_AVAIL = true; - -YAHOO.extend(YAHOO.widget.Slider, YAHOO.util.DragDrop, { - - /** - * Initializes the slider. Executed in the constructor - * @method initSlider - * @param {string} sType the type of slider (horiz, vert, region) - */ - initSlider: function(sType) { - - /** - * The type of the slider (horiz, vert, region) - * @property type - * @type string - */ - this.type = sType; - - //this.removeInvalidHandleType("A"); - - this.logger = new YAHOO.widget.LogWriter(this.toString()); - - /** - * Event the fires when the value of the control changes. If - * the control is animated the event will fire every point - * along the way. - * @event change - * @param {int} newOffset|x the new offset for normal sliders, or the new - * x offset for region sliders - * @param {int} y the number of pixels the thumb has moved on the y axis - * (region sliders only) - */ - this.createEvent("change", this); - - /** - * Event that fires at the beginning of a slider thumb move. - * @event slideStart - */ - this.createEvent("slideStart", this); - - /** - * Event that fires at the end of a slider thumb move - * @event slideEnd - */ - this.createEvent("slideEnd", this); - - /** - * Overrides the isTarget property in YAHOO.util.DragDrop - * @property isTarget - * @private - */ - this.isTarget = false; - - /** - * Flag that determines if the thumb will animate when moved - * @property animate - * @type boolean - */ - this.animate = YAHOO.widget.Slider.ANIM_AVAIL; - - /** - * Set to false to disable a background click thumb move - * @property backgroundEnabled - * @type boolean - */ - this.backgroundEnabled = true; - - /** - * Adjustment factor for tick animation, the more ticks, the - * faster the animation (by default) - * @property tickPause - * @type int - */ - this.tickPause = 40; - - /** - * Enables the arrow, home and end keys, defaults to true. - * @property enableKeys - * @type boolean - */ - this.enableKeys = true; - - /** - * Specifies the number of pixels the arrow keys will move the slider. - * Default is 25. - * @property keyIncrement - * @type int - */ - this.keyIncrement = 20; - - /** - * moveComplete is set to true when the slider has moved to its final - * destination. For animated slider, this value can be checked in - * the onChange handler to make it possible to execute logic only - * when the move is complete rather than at all points along the way. - * Deprecated because this flag is only useful when the background is - * clicked and the slider is animated. If the user drags the thumb, - * the flag is updated when the drag is over ... the final onDrag event - * fires before the mouseup the ends the drag, so the implementer will - * never see it. - * - * @property moveComplete - * @type Boolean - * @deprecated use the slideEnd event instead - */ - this.moveComplete = true; - - /** - * If animation is configured, specifies the length of the animation - * in seconds. - * @property animationDuration - * @type int - * @default 0.2 - */ - this.animationDuration = 0.2; - }, - - /** - * Initializes the slider's thumb. Executed in the constructor. - * @method initThumb - * @param {YAHOO.widget.SliderThumb} t the slider thumb - */ - initThumb: function(t) { - - var self = this; - - /** - * A YAHOO.widget.SliderThumb instance that we will use to - * reposition the thumb when the background is clicked - * @property thumb - * @type YAHOO.widget.SliderThumb - */ - this.thumb = t; - t.cacheBetweenDrags = true; - - // add handler for the handle onchange event - t.onChange = function() { - self.handleThumbChange(); - }; - - if (t._isHoriz && t.xTicks && t.xTicks.length) { - this.tickPause = Math.round(360 / t.xTicks.length); - } else if (t.yTicks && t.yTicks.length) { - this.tickPause = Math.round(360 / t.yTicks.length); - } - - this.logger.log("tickPause: " + this.tickPause); - - // delegate thumb methods - t.onMouseDown = function () { return self.focus(); }; - t.onMouseUp = function() { self.thumbMouseUp(); }; - t.onDrag = function() { self.fireEvents(true); }; - t.onAvailable = function() { return self.setStartSliderState(); }; - - }, - - /** - * Executed when the slider element is available - * @method onAvailable - */ - onAvailable: function() { - var Event = YAHOO.util.Event; - Event.on(this.id, "keydown", this.handleKeyDown, this, true); - Event.on(this.id, "keypress", this.handleKeyPress, this, true); - }, - - /** - * Executed when a keypress event happens with the control focused. - * Prevents the default behavior for navigation keys. The actual - * logic for moving the slider thumb in response to a key event - * happens in handleKeyDown. - * @param {Event} e the keypress event - */ - handleKeyPress: function(e) { - if (this.enableKeys) { - var Event = YAHOO.util.Event; - var kc = Event.getCharCode(e); - switch (kc) { - case 0x25: // left - case 0x26: // up - case 0x27: // right - case 0x28: // down - case 0x24: // home - case 0x23: // end - Event.preventDefault(e); - break; - default: - } - } - }, - - /** - * Executed when a keydown event happens with the control focused. - * Updates the slider value and display when the keypress is an - * arrow key, home, or end as long as enableKeys is set to true. - * @param {Event} e the keydown event - */ - handleKeyDown: function(e) { - if (this.enableKeys) { - var Event = YAHOO.util.Event; - - var kc = Event.getCharCode(e), t=this.thumb; - var h=this.getXValue(),v=this.getYValue(); - - var horiz = false; - var changeValue = true; - switch (kc) { - - // left - case 0x25: h -= this.keyIncrement; break; - - // up - case 0x26: v -= this.keyIncrement; break; - - // right - case 0x27: h += this.keyIncrement; break; - - // down - case 0x28: v += this.keyIncrement; break; - - // home - case 0x24: h = t.leftConstraint; - v = t.topConstraint; - break; - - // end - case 0x23: h = t.rightConstraint; - v = t.bottomConstraint; - break; - - default: changeValue = false; - } - - if (changeValue) { - if (t._isRegion) { - this.setRegionValue(h, v, true); - } else { - var newVal = (t._isHoriz) ? h : v; - this.setValue(newVal, true); - } - Event.stopEvent(e); - } - - } - }, - - /** - * Initialization that sets up the value offsets once the elements are ready - * @method setStartSliderState - */ - setStartSliderState: function() { - - this.logger.log("Fixing state"); - - this.setThumbCenterPoint(); - - /** - * The basline position of the background element, used - * to determine if the background has moved since the last - * operation. - * @property baselinePos - * @type [int, int] - */ - this.baselinePos = YAHOO.util.Dom.getXY(this.getEl()); - - this.thumb.startOffset = this.thumb.getOffsetFromParent(this.baselinePos); - - if (this.thumb._isRegion) { - if (this.deferredSetRegionValue) { - this.setRegionValue.apply(this, this.deferredSetRegionValue, true); - this.deferredSetRegionValue = null; - } else { - this.setRegionValue(0, 0, true, true); - } - } else { - if (this.deferredSetValue) { - this.setValue.apply(this, this.deferredSetValue, true); - this.deferredSetValue = null; - } else { - this.setValue(0, true, true); - } - } - }, - - /** - * When the thumb is available, we cache the centerpoint of the element so - * we can position the element correctly when the background is clicked - * @method setThumbCenterPoint - */ - setThumbCenterPoint: function() { - - var el = this.thumb.getEl(); - - if (el) { - /** - * The center of the slider element is stored so we can - * place it in the correct position when the background is clicked. - * @property thumbCenterPoint - * @type {"x": int, "y": int} - */ - this.thumbCenterPoint = { - x: parseInt(el.offsetWidth/2, 10), - y: parseInt(el.offsetHeight/2, 10) - }; - } - - }, - - /** - * Locks the slider, overrides YAHOO.util.DragDrop - * @method lock - */ - lock: function() { - this.logger.log("locking"); - this.thumb.lock(); - this.locked = true; - }, - - /** - * Unlocks the slider, overrides YAHOO.util.DragDrop - * @method unlock - */ - unlock: function() { - this.logger.log("unlocking"); - this.thumb.unlock(); - this.locked = false; - }, - - /** - * Handles mouseup event on the slider background - * @method thumbMouseUp - * @private - */ - thumbMouseUp: function() { - this.logger.log("bg mouseup"); - if (!this.isLocked() && !this.moveComplete) { - this.endMove(); - } - - }, - - /** - * Returns a reference to this slider's thumb - * @method getThumb - * @return {SliderThumb} this slider's thumb - */ - getThumb: function() { - return this.thumb; - }, - - /** - * Try to focus the element when clicked so we can add - * accessibility features - * @method focus - * @private - */ - focus: function() { - this.logger.log("focus"); - - // Focus the background element if possible - var el = this.getEl(); - - if (el.focus) { - try { - el.focus(); - } catch(e) { - // Prevent permission denied unhandled exception in FF that can - // happen when setting focus while another element is handling - // the blur. @TODO this is still writing to the error log - // (unhandled error) in FF1.5 with strict error checking on. - } - } - - this.verifyOffset(); - - if (this.isLocked()) { - return false; - } else { - this.onSlideStart(); - return true; - } - }, - - /** - * Event that fires when the value of the slider has changed - * @method onChange - * @param {int} firstOffset the number of pixels the thumb has moved - * from its start position. Normal horizontal and vertical sliders will only - * have the firstOffset. Regions will have both, the first is the horizontal - * offset, the second the vertical. - * @param {int} secondOffset the y offset for region sliders - * @deprecated use instance.subscribe("change") instead - */ - onChange: function (firstOffset, secondOffset) { - /* override me */ - this.logger.log("onChange: " + firstOffset + ", " + secondOffset); - }, - - /** - * Event that fires when the at the beginning of the slider thumb move - * @method onSlideStart - * @deprecated use instance.subscribe("slideStart") instead - */ - onSlideStart: function () { - /* override me */ - this.logger.log("onSlideStart"); - }, - - /** - * Event that fires at the end of a slider thumb move - * @method onSliderEnd - * @deprecated use instance.subscribe("slideEnd") instead - */ - onSlideEnd: function () { - /* override me */ - this.logger.log("onSlideEnd"); - }, - - /** - * Returns the slider's thumb offset from the start position - * @method getValue - * @return {int} the current value - */ - getValue: function () { - return this.thumb.getValue(); - }, - - /** - * Returns the slider's thumb X offset from the start position - * @method getXValue - * @return {int} the current horizontal offset - */ - getXValue: function () { - return this.thumb.getXValue(); - }, - - /** - * Returns the slider's thumb Y offset from the start position - * @method getYValue - * @return {int} the current vertical offset - */ - getYValue: function () { - return this.thumb.getYValue(); - }, - - /** - * Internal handler for the slider thumb's onChange event - * @method handleThumbChange - * @private - */ - handleThumbChange: function () { - var t = this.thumb; - if (t._isRegion) { - t.onChange(t.getXValue(), t.getYValue()); - this.fireEvent("change", { x: t.getXValue(), y: t.getYValue() } ); - } else { - t.onChange(t.getValue()); - this.fireEvent("change", t.getValue()); - } - - }, - - /** - * Provides a way to set the value of the slider in code. - * @method setValue - * @param {int} newOffset the number of pixels the thumb should be - * positioned away from the initial start point - * @param {boolean} skipAnim set to true to disable the animation - * for this move action (but not others). - * @param {boolean} force ignore the locked setting and set value anyway - * @return {boolean} true if the move was performed, false if it failed - */ - setValue: function(newOffset, skipAnim, force) { - this.logger.log("setValue " + newOffset); - - if (!this.thumb.available) { - this.logger.log("defer setValue until after onAvailble"); - this.deferredSetValue = arguments; - return false; - } - - if (this.isLocked() && !force) { - this.logger.log("Can't set the value, the control is locked"); - return false; - } - - if ( isNaN(newOffset) ) { - this.logger.log("setValue, Illegal argument: " + newOffset); - return false; - } - - var t = this.thumb; - var newX, newY; - this.verifyOffset(true); - if (t._isRegion) { - return false; - } else if (t._isHoriz) { - this.onSlideStart(); - // this.fireEvent("slideStart"); - newX = t.initPageX + newOffset + this.thumbCenterPoint.x; - this.moveThumb(newX, t.initPageY, skipAnim); - } else { - this.onSlideStart(); - // this.fireEvent("slideStart"); - newY = t.initPageY + newOffset + this.thumbCenterPoint.y; - this.moveThumb(t.initPageX, newY, skipAnim); - } - - return true; - }, - - /** - * Provides a way to set the value of the region slider in code. - * @method setRegionValue - * @param {int} newOffset the number of pixels the thumb should be - * positioned away from the initial start point (x axis for region) - * @param {int} newOffset2 the number of pixels the thumb should be - * positioned away from the initial start point (y axis for region) - * @param {boolean} skipAnim set to true to disable the animation - * for this move action (but not others). - * @param {boolean} force ignore the locked setting and set value anyway - * @return {boolean} true if the move was performed, false if it failed - */ - setRegionValue: function(newOffset, newOffset2, skipAnim, force) { - - if (!this.thumb.available) { - this.logger.log("defer setRegionValue until after onAvailble"); - this.deferredSetRegionValue = arguments; - return false; - } - - if (this.isLocked() && !force) { - this.logger.log("Can't set the value, the control is locked"); - return false; - } - - if ( isNaN(newOffset) ) { - this.logger.log("setRegionValue, Illegal argument: " + newOffset); - return false; - } - - var t = this.thumb; - if (t._isRegion) { - this.onSlideStart(); - var newX = t.initPageX + newOffset + this.thumbCenterPoint.x; - var newY = t.initPageY + newOffset2 + this.thumbCenterPoint.y; - this.moveThumb(newX, newY, skipAnim); - return true; - } - - return false; - - }, - - /** - * Checks the background position element position. If it has moved from the - * baseline position, the constraints for the thumb are reset - * @param checkPos {boolean} check the position instead of using cached value - * @method verifyOffset - * @return {boolean} True if the offset is the same as the baseline. - */ - verifyOffset: function(checkPos) { - - var newPos = YAHOO.util.Dom.getXY(this.getEl()); - //var newPos = [this.initPageX, this.initPageY]; - - this.logger.log("newPos: " + newPos, "warn"); - - if (newPos[0] != this.baselinePos[0] || newPos[1] != this.baselinePos[1]) { - this.logger.log("background moved, resetting constraints"); - this.thumb.resetConstraints(); - this.baselinePos = newPos; - return false; - } - - return true; - }, - - /** - * Move the associated slider moved to a timeout to try to get around the - * mousedown stealing moz does when I move the slider element between the - * cursor and the background during the mouseup event - * @method moveThumb - * @param {int} x the X coordinate of the click - * @param {int} y the Y coordinate of the click - * @param {boolean} skipAnim don't animate if the move happend onDrag - * @private - */ - moveThumb: function(x, y, skipAnim) { - - // this.logger.log("move thumb", "warn"); - - var t = this.thumb; - var self = this; - - if (!t.available) { - this.logger.log("thumb is not available yet, aborting move"); - return; - } - - this.logger.log("move thumb, x: " + x + ", y: " + y); - - // this.verifyOffset(); - - t.setDelta(this.thumbCenterPoint.x, this.thumbCenterPoint.y); - - var _p = t.getTargetCoord(x, y); - var p = [_p.x, _p.y]; - - - this.fireEvent("slideStart"); - - if (this.animate && YAHOO.widget.Slider.ANIM_AVAIL && t._graduated && !skipAnim) { - this.logger.log("graduated"); - // this.thumb._animating = true; - this.lock(); - - // cache the current thumb pos - this.curCoord = YAHOO.util.Dom.getXY(this.thumb.getEl()); - - setTimeout( function() { self.moveOneTick(p); }, this.tickPause ); - - } else if (this.animate && YAHOO.widget.Slider.ANIM_AVAIL && !skipAnim) { - this.logger.log("animating to " + p); - - // this.thumb._animating = true; - this.lock(); - - var oAnim = new YAHOO.util.Motion( - t.id, { points: { to: p } }, - this.animationDuration, - YAHOO.util.Easing.easeOut ); - - oAnim.onComplete.subscribe( function() { self.endMove(); } ); - oAnim.animate(); - } else { - t.setDragElPos(x, y); - // this.fireEvents(); - this.endMove(); - } - }, - - /** - * Move the slider one tick mark towards its final coordinate. Used - * for the animation when tick marks are defined - * @method moveOneTick - * @param {int[]} the destination coordinate - * @private - */ - moveOneTick: function(finalCoord) { - - var t = this.thumb, tmp; - - - // redundant call to getXY since we set the position most of time prior - // to getting here. Moved to this.curCoord - //var curCoord = YAHOO.util.Dom.getXY(t.getEl()); - - // alignElWithMouse caches position in lastPageX, lastPageY .. doesn't work - //var curCoord = [this.lastPageX, this.lastPageY]; - - // var thresh = Math.min(t.tickSize + (Math.floor(t.tickSize/2)), 10); - // var thresh = 10; - // var thresh = t.tickSize + (Math.floor(t.tickSize/2)); - - var nextCoord = null; - - if (t._isRegion) { - nextCoord = this._getNextX(this.curCoord, finalCoord); - var tmpX = (nextCoord) ? nextCoord[0] : this.curCoord[0]; - nextCoord = this._getNextY([tmpX, this.curCoord[1]], finalCoord); - - } else if (t._isHoriz) { - nextCoord = this._getNextX(this.curCoord, finalCoord); - } else { - nextCoord = this._getNextY(this.curCoord, finalCoord); - } - - this.logger.log("moveOneTick: " + - " finalCoord: " + finalCoord + - " this.curCoord: " + this.curCoord + - " nextCoord: " + nextCoord); - - if (nextCoord) { - - // cache the position - this.curCoord = nextCoord; - - // move to the next coord - // YAHOO.util.Dom.setXY(t.getEl(), nextCoord); - - // var el = t.getEl(); - // YAHOO.util.Dom.setStyle(el, "left", (nextCoord[0] + this.thumb.deltaSetXY[0]) + "px"); - // YAHOO.util.Dom.setStyle(el, "top", (nextCoord[1] + this.thumb.deltaSetXY[1]) + "px"); - - this.thumb.alignElWithMouse(t.getEl(), nextCoord[0], nextCoord[1]); - - // check if we are in the final position, if not make a recursive call - if (!(nextCoord[0] == finalCoord[0] && nextCoord[1] == finalCoord[1])) { - var self = this; - setTimeout(function() { self.moveOneTick(finalCoord); }, - this.tickPause); - } else { - this.endMove(); - } - } else { - this.endMove(); - } - - //this.tickPause = Math.round(this.tickPause/2); - }, - - /** - * Returns the next X tick value based on the current coord and the target coord. - * @method _getNextX - * @private - */ - _getNextX: function(curCoord, finalCoord) { - this.logger.log("getNextX: " + curCoord + ", " + finalCoord); - var t = this.thumb; - var thresh; - var tmp = []; - var nextCoord = null; - if (curCoord[0] > finalCoord[0]) { - thresh = t.tickSize - this.thumbCenterPoint.x; - tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] ); - nextCoord = [tmp.x, tmp.y]; - } else if (curCoord[0] < finalCoord[0]) { - thresh = t.tickSize + this.thumbCenterPoint.x; - tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] ); - nextCoord = [tmp.x, tmp.y]; - } else { - // equal, do nothing - } - - return nextCoord; - }, - - /** - * Returns the next Y tick value based on the current coord and the target coord. - * @method _getNextY - * @private - */ - _getNextY: function(curCoord, finalCoord) { - var t = this.thumb; - var thresh; - var tmp = []; - var nextCoord = null; - - if (curCoord[1] > finalCoord[1]) { - thresh = t.tickSize - this.thumbCenterPoint.y; - tmp = t.getTargetCoord( curCoord[0], curCoord[1] - thresh ); - nextCoord = [tmp.x, tmp.y]; - } else if (curCoord[1] < finalCoord[1]) { - thresh = t.tickSize + this.thumbCenterPoint.y; - tmp = t.getTargetCoord( curCoord[0], curCoord[1] + thresh ); - nextCoord = [tmp.x, tmp.y]; - } else { - // equal, do nothing - } - - return nextCoord; - }, - - /** - * Resets the constraints before moving the thumb. - * @method b4MouseDown - * @private - */ - b4MouseDown: function(e) { - this.thumb.autoOffset(); - this.thumb.resetConstraints(); - }, - - - /** - * Handles the mousedown event for the slider background - * @method onMouseDown - * @private - */ - onMouseDown: function(e) { - // this.resetConstraints(true); - // this.thumb.resetConstraints(true); - - if (! this.isLocked() && this.backgroundEnabled) { - var x = YAHOO.util.Event.getPageX(e); - var y = YAHOO.util.Event.getPageY(e); - this.logger.log("bg mousedown: " + x + "," + y); - - this.focus(); - this.moveThumb(x, y); - } - - }, - - /** - * Handles the onDrag event for the slider background - * @method onDrag - * @private - */ - onDrag: function(e) { - if (! this.isLocked()) { - var x = YAHOO.util.Event.getPageX(e); - var y = YAHOO.util.Event.getPageY(e); - this.moveThumb(x, y, true); - } - }, - - /** - * Fired when the slider movement ends - * @method endMove - * @private - */ - endMove: function () { - // this._animating = false; - this.unlock(); - this.moveComplete = true; - this.fireEvents(); - }, - - /** - * Fires the change event if the value has been changed. Ignored if we are in - * the middle of an animation as the event will fire when the animation is - * complete - * @method fireEvents - * @param {boolean} thumbEvent set to true if this event is fired from an event - * that occurred on the thumb. If it is, the state of the - * thumb dd object should be correct. Otherwise, the event - * originated on the background, so the thumb state needs to - * be refreshed before proceeding. - * @private - */ - fireEvents: function (thumbEvent) { - - var t = this.thumb; - // this.logger.log("FireEvents: " + t._isRegion); - - if (!thumbEvent) { - t.cachePosition(); - } - - if (! this.isLocked()) { - if (t._isRegion) { - this.logger.log("region"); - var newX = t.getXValue(); - var newY = t.getYValue(); - - if (newX != this.previousX || newY != this.previousY) { - // this.logger.log("Firing onchange"); - this.onChange(newX, newY); - this.fireEvent("change", { x: newX, y: newY }); - } - - this.previousX = newX; - this.previousY = newY; - - } else { - var newVal = t.getValue(); - if (newVal != this.previousVal) { - this.logger.log("Firing onchange: " + newVal); - this.onChange( newVal ); - this.fireEvent("change", newVal); - } - this.previousVal = newVal; - } - - if (this.moveComplete) { - this.onSlideEnd(); - this.fireEvent("slideEnd"); - this.moveComplete = false; - } - - } - }, - - /** - * Slider toString - * @method toString - * @return {string} string representation of the instance - */ - toString: function () { - return ("Slider (" + this.type +") " + this.id); - } - -}); - -YAHOO.augment(YAHOO.widget.Slider, YAHOO.util.EventProvider); - -/** - * A drag and drop implementation to be used as the thumb of a slider. - * @class SliderThumb - * @extends YAHOO.util.DD - * @constructor - * @param {String} id the id of the slider html element - * @param {String} sGroup the group of related DragDrop items - * @param {int} iLeft the number of pixels the element can move left - * @param {int} iRight the number of pixels the element can move right - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize optional parameter for specifying that the element - * should move a certain number pixels at a time. - */ -YAHOO.widget.SliderThumb = function(id, sGroup, iLeft, iRight, iUp, iDown, iTickSize) { - - if (id) { - //this.init(id, sGroup); - YAHOO.widget.SliderThumb.superclass.constructor.call(this, id, sGroup); - - /** - * The id of the thumbs parent HTML element (the slider background - * element). - * @property parentElId - * @type string - */ - this.parentElId = sGroup; - } - - - //this.removeInvalidHandleType("A"); - - this.logger = new YAHOO.widget.LogWriter(this.toString()); - - /** - * Overrides the isTarget property in YAHOO.util.DragDrop - * @property isTarget - * @private - */ - this.isTarget = false; - - /** - * The tick size for this slider - * @property tickSize - * @type int - * @private - */ - this.tickSize = iTickSize; - - /** - * Informs the drag and drop util that the offsets should remain when - * resetting the constraints. This preserves the slider value when - * the constraints are reset - * @property maintainOffset - * @type boolean - * @private - */ - this.maintainOffset = true; - - this.initSlider(iLeft, iRight, iUp, iDown, iTickSize); - - /** - * Turns off the autoscroll feature in drag and drop - * @property scroll - * @private - */ - this.scroll = false; - -}; - -YAHOO.extend(YAHOO.widget.SliderThumb, YAHOO.util.DD, { - - /** - * The (X and Y) difference between the thumb location and its parent - * (the slider background) when the control is instantiated. - * @property startOffset - * @type [int, int] - */ - startOffset: null, - - /** - * Flag used to figure out if this is a horizontal or vertical slider - * @property _isHoriz - * @type boolean - * @private - */ - _isHoriz: false, - - /** - * Cache the last value so we can check for change - * @property _prevVal - * @type int - * @private - */ - _prevVal: 0, - - /** - * The slider is _graduated if there is a tick interval defined - * @property _graduated - * @type boolean - * @private - */ - _graduated: false, - - - /** - * Returns the difference between the location of the thumb and its parent. - * @method getOffsetFromParent - * @param {[int, int]} parentPos Optionally accepts the position of the parent - * @type [int, int] - */ - getOffsetFromParent0: function(parentPos) { - var myPos = YAHOO.util.Dom.getXY(this.getEl()); - var ppos = parentPos || YAHOO.util.Dom.getXY(this.parentElId); - - return [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ]; - }, - - getOffsetFromParent: function(parentPos) { - - var el = this.getEl(); - - if (!this.deltaOffset) { - - var myPos = YAHOO.util.Dom.getXY(el); - var ppos = parentPos || YAHOO.util.Dom.getXY(this.parentElId); - - var newOffset = [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ]; - - var l = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 ); - var t = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 ); - - var deltaX = l - newOffset[0]; - var deltaY = t - newOffset[1]; - - if (isNaN(deltaX) || isNaN(deltaY)) { - this.logger.log("element does not have a position style def yet"); - } else { - this.deltaOffset = [deltaX, deltaY]; - } - - } else { - var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 ); - var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 ); - - newOffset = [newLeft + this.deltaOffset[0], newTop + this.deltaOffset[1]]; - } - - return newOffset; - - //return [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ]; - }, - - /** - * Set up the slider, must be called in the constructor of all subclasses - * @method initSlider - * @param {int} iLeft the number of pixels the element can move left - * @param {int} iRight the number of pixels the element can move right - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize the width of the tick interval. - */ - initSlider: function (iLeft, iRight, iUp, iDown, iTickSize) { - - - //document these. new for 0.12.1 - this.initLeft = iLeft; - this.initRight = iRight; - this.initUp = iUp; - this.initDown = iDown; - - this.setXConstraint(iLeft, iRight, iTickSize); - this.setYConstraint(iUp, iDown, iTickSize); - - if (iTickSize && iTickSize > 1) { - this._graduated = true; - } - - this._isHoriz = (iLeft || iRight); - this._isVert = (iUp || iDown); - this._isRegion = (this._isHoriz && this._isVert); - - }, - - /** - * Clear's the slider's ticks - * @method clearTicks - */ - clearTicks: function () { - YAHOO.widget.SliderThumb.superclass.clearTicks.call(this); - this.tickSize = 0; - this._graduated = false; - }, - - - /** - * Gets the current offset from the element's start position in - * pixels. - * @method getValue - * @return {int} the number of pixels (positive or negative) the - * slider has moved from the start position. - */ - getValue: function () { - if (!this.available) { return 0; } - var val = (this._isHoriz) ? this.getXValue() : this.getYValue(); - //this.logger.log("getVal: " + val); - return val; - }, - - /** - * Gets the current X offset from the element's start position in - * pixels. - * @method getXValue - * @return {int} the number of pixels (positive or negative) the - * slider has moved horizontally from the start position. - */ - getXValue: function () { - if (!this.available) { return 0; } - var newOffset = this.getOffsetFromParent(); - return (newOffset[0] - this.startOffset[0]); - }, - - /** - * Gets the current Y offset from the element's start position in - * pixels. - * @method getYValue - * @return {int} the number of pixels (positive or negative) the - * slider has moved vertically from the start position. - */ - getYValue: function () { - if (!this.available) { return 0; } - var newOffset = this.getOffsetFromParent(); - return (newOffset[1] - this.startOffset[1]); - }, - - /** - * Thumb toString - * @method toString - * @return {string} string representation of the instance - */ - toString: function () { - return "SliderThumb " + this.id; - }, - - /** - * The onchange event for the handle/thumb is delegated to the YAHOO.widget.Slider - * instance it belongs to. - * @method onChange - * @private - */ - onChange: function (x, y) { - } - -}); - -if ("undefined" == typeof YAHOO.util.Anim) { - YAHOO.widget.Slider.ANIM_AVAIL = false; -} - -YAHOO.register("slider", YAHOO.widget.Slider, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/slider/slider-min.js b/interface/web/js/yui/slider/slider-min.js deleted file mode 100644 index 322628dcfa..0000000000 --- a/interface/web/js/yui/slider/slider-min.js +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -YAHOO.widget.Slider=function(sElementId,sGroup,oThumb,sType){if(sElementId){this.init(sElementId,sGroup,true);this.initSlider(sType);this.initThumb(oThumb);}};YAHOO.widget.Slider.getHorizSlider=function(sBGElId,sHandleElId,iLeft,iRight,iTickSize){return new YAHOO.widget.Slider(sBGElId,sBGElId,new YAHOO.widget.SliderThumb(sHandleElId,sBGElId,iLeft,iRight,0,0,iTickSize),"horiz");};YAHOO.widget.Slider.getVertSlider=function(sBGElId,sHandleElId,iUp,iDown,iTickSize){return new YAHOO.widget.Slider(sBGElId,sBGElId,new YAHOO.widget.SliderThumb(sHandleElId,sBGElId,0,0,iUp,iDown,iTickSize),"vert");};YAHOO.widget.Slider.getSliderRegion=function(sBGElId,sHandleElId,iLeft,iRight,iUp,iDown,iTickSize){return new YAHOO.widget.Slider(sBGElId,sBGElId,new YAHOO.widget.SliderThumb(sHandleElId,sBGElId,iLeft,iRight,iUp,iDown,iTickSize),"region");};YAHOO.widget.Slider.ANIM_AVAIL=true;YAHOO.extend(YAHOO.widget.Slider,YAHOO.util.DragDrop,{initSlider:function(sType){this.type=sType;this.createEvent("change",this);this.createEvent("slideStart",this);this.createEvent("slideEnd",this);this.isTarget=false;this.animate=YAHOO.widget.Slider.ANIM_AVAIL;this.backgroundEnabled=true;this.tickPause=40;this.enableKeys=true;this.keyIncrement=20;this.moveComplete=true;this.animationDuration=0.2;},initThumb:function(t){var self=this;this.thumb=t;t.cacheBetweenDrags=true;t.onChange=function(){self.handleThumbChange();};if(t._isHoriz&&t.xTicks&&t.xTicks.length){this.tickPause=Math.round(360/t.xTicks.length);}else if(t.yTicks&&t.yTicks.length){this.tickPause=Math.round(360/t.yTicks.length);} -t.onMouseDown=function(){return self.focus();};t.onMouseUp=function(){self.thumbMouseUp();};t.onDrag=function(){self.fireEvents(true);};t.onAvailable=function(){return self.setStartSliderState();};},onAvailable:function(){var Event=YAHOO.util.Event;Event.on(this.id,"keydown",this.handleKeyDown,this,true);Event.on(this.id,"keypress",this.handleKeyPress,this,true);},handleKeyPress:function(e){if(this.enableKeys){var Event=YAHOO.util.Event;var kc=Event.getCharCode(e);switch(kc){case 0x25:case 0x26:case 0x27:case 0x28:case 0x24:case 0x23:Event.preventDefault(e);break;default:}}},handleKeyDown:function(e){if(this.enableKeys){var Event=YAHOO.util.Event;var kc=Event.getCharCode(e),t=this.thumb;var h=this.getXValue(),v=this.getYValue();var horiz=false;var changeValue=true;switch(kc){case 0x25:h-=this.keyIncrement;break;case 0x26:v-=this.keyIncrement;break;case 0x27:h+=this.keyIncrement;break;case 0x28:v+=this.keyIncrement;break;case 0x24:h=t.leftConstraint;v=t.topConstraint;break;case 0x23:h=t.rightConstraint;v=t.bottomConstraint;break;default:changeValue=false;} -if(changeValue){if(t._isRegion){this.setRegionValue(h,v,true);}else{var newVal=(t._isHoriz)?h:v;this.setValue(newVal,true);} -Event.stopEvent(e);}}},setStartSliderState:function(){this.setThumbCenterPoint();this.baselinePos=YAHOO.util.Dom.getXY(this.getEl());this.thumb.startOffset=this.thumb.getOffsetFromParent(this.baselinePos);if(this.thumb._isRegion){if(this.deferredSetRegionValue){this.setRegionValue.apply(this,this.deferredSetRegionValue,true);this.deferredSetRegionValue=null;}else{this.setRegionValue(0,0,true,true);}}else{if(this.deferredSetValue){this.setValue.apply(this,this.deferredSetValue,true);this.deferredSetValue=null;}else{this.setValue(0,true,true);}}},setThumbCenterPoint:function(){var el=this.thumb.getEl();if(el){this.thumbCenterPoint={x:parseInt(el.offsetWidth/2,10),y:parseInt(el.offsetHeight/2,10)};}},lock:function(){this.thumb.lock();this.locked=true;},unlock:function(){this.thumb.unlock();this.locked=false;},thumbMouseUp:function(){if(!this.isLocked()&&!this.moveComplete){this.endMove();}},getThumb:function(){return this.thumb;},focus:function(){var el=this.getEl();if(el.focus){try{el.focus();}catch(e){}} -this.verifyOffset();if(this.isLocked()){return false;}else{this.onSlideStart();return true;}},onChange:function(firstOffset,secondOffset){},onSlideStart:function(){},onSlideEnd:function(){},getValue:function(){return this.thumb.getValue();},getXValue:function(){return this.thumb.getXValue();},getYValue:function(){return this.thumb.getYValue();},handleThumbChange:function(){var t=this.thumb;if(t._isRegion){t.onChange(t.getXValue(),t.getYValue());this.fireEvent("change",{x:t.getXValue(),y:t.getYValue()});}else{t.onChange(t.getValue());this.fireEvent("change",t.getValue());}},setValue:function(newOffset,skipAnim,force){if(!this.thumb.available){this.deferredSetValue=arguments;return false;} -if(this.isLocked()&&!force){return false;} -if(isNaN(newOffset)){return false;} -var t=this.thumb;var newX,newY;this.verifyOffset(true);if(t._isRegion){return false;}else if(t._isHoriz){this.onSlideStart();newX=t.initPageX+newOffset+this.thumbCenterPoint.x;this.moveThumb(newX,t.initPageY,skipAnim);}else{this.onSlideStart();newY=t.initPageY+newOffset+this.thumbCenterPoint.y;this.moveThumb(t.initPageX,newY,skipAnim);} -return true;},setRegionValue:function(newOffset,newOffset2,skipAnim,force){if(!this.thumb.available){this.deferredSetRegionValue=arguments;return false;} -if(this.isLocked()&&!force){return false;} -if(isNaN(newOffset)){return false;} -var t=this.thumb;if(t._isRegion){this.onSlideStart();var newX=t.initPageX+newOffset+this.thumbCenterPoint.x;var newY=t.initPageY+newOffset2+this.thumbCenterPoint.y;this.moveThumb(newX,newY,skipAnim);return true;} -return false;},verifyOffset:function(checkPos){var newPos=YAHOO.util.Dom.getXY(this.getEl());if(newPos[0]!=this.baselinePos[0]||newPos[1]!=this.baselinePos[1]){this.thumb.resetConstraints();this.baselinePos=newPos;return false;} -return true;},moveThumb:function(x,y,skipAnim){var t=this.thumb;var self=this;if(!t.available){return;} -t.setDelta(this.thumbCenterPoint.x,this.thumbCenterPoint.y);var _p=t.getTargetCoord(x,y);var p=[_p.x,_p.y];this.fireEvent("slideStart");if(this.animate&&YAHOO.widget.Slider.ANIM_AVAIL&&t._graduated&&!skipAnim){this.lock();this.curCoord=YAHOO.util.Dom.getXY(this.thumb.getEl());setTimeout(function(){self.moveOneTick(p);},this.tickPause);}else if(this.animate&&YAHOO.widget.Slider.ANIM_AVAIL&&!skipAnim){this.lock();var oAnim=new YAHOO.util.Motion(t.id,{points:{to:p}},this.animationDuration,YAHOO.util.Easing.easeOut);oAnim.onComplete.subscribe(function(){self.endMove();});oAnim.animate();}else{t.setDragElPos(x,y);this.endMove();}},moveOneTick:function(finalCoord){var t=this.thumb,tmp;var nextCoord=null;if(t._isRegion){nextCoord=this._getNextX(this.curCoord,finalCoord);var tmpX=(nextCoord)?nextCoord[0]:this.curCoord[0];nextCoord=this._getNextY([tmpX,this.curCoord[1]],finalCoord);}else if(t._isHoriz){nextCoord=this._getNextX(this.curCoord,finalCoord);}else{nextCoord=this._getNextY(this.curCoord,finalCoord);} -if(nextCoord){this.curCoord=nextCoord;this.thumb.alignElWithMouse(t.getEl(),nextCoord[0],nextCoord[1]);if(!(nextCoord[0]==finalCoord[0]&&nextCoord[1]==finalCoord[1])){var self=this;setTimeout(function(){self.moveOneTick(finalCoord);},this.tickPause);}else{this.endMove();}}else{this.endMove();}},_getNextX:function(curCoord,finalCoord){var t=this.thumb;var thresh;var tmp=[];var nextCoord=null;if(curCoord[0]>finalCoord[0]){thresh=t.tickSize-this.thumbCenterPoint.x;tmp=t.getTargetCoord(curCoord[0]-thresh,curCoord[1]);nextCoord=[tmp.x,tmp.y];}else if(curCoord[0]<finalCoord[0]){thresh=t.tickSize+this.thumbCenterPoint.x;tmp=t.getTargetCoord(curCoord[0]+thresh,curCoord[1]);nextCoord=[tmp.x,tmp.y];}else{} -return nextCoord;},_getNextY:function(curCoord,finalCoord){var t=this.thumb;var thresh;var tmp=[];var nextCoord=null;if(curCoord[1]>finalCoord[1]){thresh=t.tickSize-this.thumbCenterPoint.y;tmp=t.getTargetCoord(curCoord[0],curCoord[1]-thresh);nextCoord=[tmp.x,tmp.y];}else if(curCoord[1]<finalCoord[1]){thresh=t.tickSize+this.thumbCenterPoint.y;tmp=t.getTargetCoord(curCoord[0],curCoord[1]+thresh);nextCoord=[tmp.x,tmp.y];}else{} -return nextCoord;},b4MouseDown:function(e){this.thumb.autoOffset();this.thumb.resetConstraints();},onMouseDown:function(e){if(!this.isLocked()&&this.backgroundEnabled){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.focus();this.moveThumb(x,y);}},onDrag:function(e){if(!this.isLocked()){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.moveThumb(x,y,true);}},endMove:function(){this.unlock();this.moveComplete=true;this.fireEvents();},fireEvents:function(thumbEvent){var t=this.thumb;if(!thumbEvent){t.cachePosition();} -if(!this.isLocked()){if(t._isRegion){var newX=t.getXValue();var newY=t.getYValue();if(newX!=this.previousX||newY!=this.previousY){this.onChange(newX,newY);this.fireEvent("change",{x:newX,y:newY});} -this.previousX=newX;this.previousY=newY;}else{var newVal=t.getValue();if(newVal!=this.previousVal){this.onChange(newVal);this.fireEvent("change",newVal);} -this.previousVal=newVal;} -if(this.moveComplete){this.onSlideEnd();this.fireEvent("slideEnd");this.moveComplete=false;}}},toString:function(){return("Slider ("+this.type+") "+this.id);}});YAHOO.augment(YAHOO.widget.Slider,YAHOO.util.EventProvider);YAHOO.widget.SliderThumb=function(id,sGroup,iLeft,iRight,iUp,iDown,iTickSize){if(id){YAHOO.widget.SliderThumb.superclass.constructor.call(this,id,sGroup);this.parentElId=sGroup;} -this.isTarget=false;this.tickSize=iTickSize;this.maintainOffset=true;this.initSlider(iLeft,iRight,iUp,iDown,iTickSize);this.scroll=false;};YAHOO.extend(YAHOO.widget.SliderThumb,YAHOO.util.DD,{startOffset:null,_isHoriz:false,_prevVal:0,_graduated:false,getOffsetFromParent0:function(parentPos){var myPos=YAHOO.util.Dom.getXY(this.getEl());var ppos=parentPos||YAHOO.util.Dom.getXY(this.parentElId);return[(myPos[0]-ppos[0]),(myPos[1]-ppos[1])];},getOffsetFromParent:function(parentPos){var el=this.getEl();if(!this.deltaOffset){var myPos=YAHOO.util.Dom.getXY(el);var ppos=parentPos||YAHOO.util.Dom.getXY(this.parentElId);var newOffset=[(myPos[0]-ppos[0]),(myPos[1]-ppos[1])];var l=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var t=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);var deltaX=l-newOffset[0];var deltaY=t-newOffset[1];if(isNaN(deltaX)||isNaN(deltaY)){}else{this.deltaOffset=[deltaX,deltaY];}}else{var newLeft=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var newTop=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);newOffset=[newLeft+this.deltaOffset[0],newTop+this.deltaOffset[1]];} -return newOffset;},initSlider:function(iLeft,iRight,iUp,iDown,iTickSize){this.initLeft=iLeft;this.initRight=iRight;this.initUp=iUp;this.initDown=iDown;this.setXConstraint(iLeft,iRight,iTickSize);this.setYConstraint(iUp,iDown,iTickSize);if(iTickSize&&iTickSize>1){this._graduated=true;} -this._isHoriz=(iLeft||iRight);this._isVert=(iUp||iDown);this._isRegion=(this._isHoriz&&this._isVert);},clearTicks:function(){YAHOO.widget.SliderThumb.superclass.clearTicks.call(this);this.tickSize=0;this._graduated=false;},getValue:function(){if(!this.available){return 0;} -var val=(this._isHoriz)?this.getXValue():this.getYValue();return val;},getXValue:function(){if(!this.available){return 0;} -var newOffset=this.getOffsetFromParent();return(newOffset[0]-this.startOffset[0]);},getYValue:function(){if(!this.available){return 0;} -var newOffset=this.getOffsetFromParent();return(newOffset[1]-this.startOffset[1]);},toString:function(){return"SliderThumb "+this.id;},onChange:function(x,y){}});if("undefined"==typeof YAHOO.util.Anim){YAHOO.widget.Slider.ANIM_AVAIL=false;} -YAHOO.register("slider",YAHOO.widget.Slider,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/slider/slider.js b/interface/web/js/yui/slider/slider.js deleted file mode 100644 index ddf23feb97..0000000000 --- a/interface/web/js/yui/slider/slider.js +++ /dev/null @@ -1,1222 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The Slider component is a UI control that enables the user to adjust - * values in a finite range along one or two axes. Typically, the Slider - * control is used in a web application as a rich, visual replacement - * for an input box that takes a number as input. The Slider control can - * also easily accommodate a second dimension, providing x,y output for - * a selection point chosen from a rectangular region. - * - * @module slider - * @title Slider Widget - * @namespace YAHOO.widget - * @requires yahoo,dom,dragdrop,event - * @optional animation - */ - -/** - * A DragDrop implementation that can be used as a background for a - * slider. It takes a reference to the thumb instance - * so it can delegate some of the events to it. The goal is to make the - * thumb jump to the location on the background when the background is - * clicked. - * - * @class Slider - * @extends YAHOO.util.DragDrop - * @uses YAHOO.util.EventProvider - * @constructor - * @param {String} id The id of the element linked to this instance - * @param {String} sGroup The group of related DragDrop items - * @param {SliderThumb} oThumb The thumb for this slider - * @param {String} sType The type of slider (horiz, vert, region) - */ -YAHOO.widget.Slider = function(sElementId, sGroup, oThumb, sType) { - if (sElementId) { - this.init(sElementId, sGroup, true); - this.initSlider(sType); - this.initThumb(oThumb); - } -}; - -/** - * Factory method for creating a horizontal slider - * @method YAHOO.widget.Slider.getHorizSlider - * @static - * @param {String} sBGElId the id of the slider's background element - * @param {String} sHandleElId the id of the thumb element - * @param {int} iLeft the number of pixels the element can move left - * @param {int} iRight the number of pixels the element can move right - * @param {int} iTickSize optional parameter for specifying that the element - * should move a certain number pixels at a time. - * @return {Slider} a horizontal slider control - */ -YAHOO.widget.Slider.getHorizSlider = - function (sBGElId, sHandleElId, iLeft, iRight, iTickSize) { - return new YAHOO.widget.Slider(sBGElId, sBGElId, - new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, - iLeft, iRight, 0, 0, iTickSize), "horiz"); -}; - -/** - * Factory method for creating a vertical slider - * @method YAHOO.widget.Slider.getVertSlider - * @static - * @param {String} sBGElId the id of the slider's background element - * @param {String} sHandleElId the id of the thumb element - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize optional parameter for specifying that the element - * should move a certain number pixels at a time. - * @return {Slider} a vertical slider control - */ -YAHOO.widget.Slider.getVertSlider = - function (sBGElId, sHandleElId, iUp, iDown, iTickSize) { - return new YAHOO.widget.Slider(sBGElId, sBGElId, - new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, 0, 0, - iUp, iDown, iTickSize), "vert"); -}; - -/** - * Factory method for creating a slider region like the one in the color - * picker example - * @method YAHOO.widget.Slider.getSliderRegion - * @static - * @param {String} sBGElId the id of the slider's background element - * @param {String} sHandleElId the id of the thumb element - * @param {int} iLeft the number of pixels the element can move left - * @param {int} iRight the number of pixels the element can move right - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize optional parameter for specifying that the element - * should move a certain number pixels at a time. - * @return {Slider} a slider region control - */ -YAHOO.widget.Slider.getSliderRegion = - function (sBGElId, sHandleElId, iLeft, iRight, iUp, iDown, iTickSize) { - return new YAHOO.widget.Slider(sBGElId, sBGElId, - new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, iLeft, iRight, - iUp, iDown, iTickSize), "region"); -}; - -/** - * By default, animation is available if the animation library is detected. - * @property YAHOO.widget.Slider.ANIM_AVAIL - * @static - * @type boolean - */ -YAHOO.widget.Slider.ANIM_AVAIL = true; - -YAHOO.extend(YAHOO.widget.Slider, YAHOO.util.DragDrop, { - - /** - * Initializes the slider. Executed in the constructor - * @method initSlider - * @param {string} sType the type of slider (horiz, vert, region) - */ - initSlider: function(sType) { - - /** - * The type of the slider (horiz, vert, region) - * @property type - * @type string - */ - this.type = sType; - - //this.removeInvalidHandleType("A"); - - - /** - * Event the fires when the value of the control changes. If - * the control is animated the event will fire every point - * along the way. - * @event change - * @param {int} newOffset|x the new offset for normal sliders, or the new - * x offset for region sliders - * @param {int} y the number of pixels the thumb has moved on the y axis - * (region sliders only) - */ - this.createEvent("change", this); - - /** - * Event that fires at the beginning of a slider thumb move. - * @event slideStart - */ - this.createEvent("slideStart", this); - - /** - * Event that fires at the end of a slider thumb move - * @event slideEnd - */ - this.createEvent("slideEnd", this); - - /** - * Overrides the isTarget property in YAHOO.util.DragDrop - * @property isTarget - * @private - */ - this.isTarget = false; - - /** - * Flag that determines if the thumb will animate when moved - * @property animate - * @type boolean - */ - this.animate = YAHOO.widget.Slider.ANIM_AVAIL; - - /** - * Set to false to disable a background click thumb move - * @property backgroundEnabled - * @type boolean - */ - this.backgroundEnabled = true; - - /** - * Adjustment factor for tick animation, the more ticks, the - * faster the animation (by default) - * @property tickPause - * @type int - */ - this.tickPause = 40; - - /** - * Enables the arrow, home and end keys, defaults to true. - * @property enableKeys - * @type boolean - */ - this.enableKeys = true; - - /** - * Specifies the number of pixels the arrow keys will move the slider. - * Default is 25. - * @property keyIncrement - * @type int - */ - this.keyIncrement = 20; - - /** - * moveComplete is set to true when the slider has moved to its final - * destination. For animated slider, this value can be checked in - * the onChange handler to make it possible to execute logic only - * when the move is complete rather than at all points along the way. - * Deprecated because this flag is only useful when the background is - * clicked and the slider is animated. If the user drags the thumb, - * the flag is updated when the drag is over ... the final onDrag event - * fires before the mouseup the ends the drag, so the implementer will - * never see it. - * - * @property moveComplete - * @type Boolean - * @deprecated use the slideEnd event instead - */ - this.moveComplete = true; - - /** - * If animation is configured, specifies the length of the animation - * in seconds. - * @property animationDuration - * @type int - * @default 0.2 - */ - this.animationDuration = 0.2; - }, - - /** - * Initializes the slider's thumb. Executed in the constructor. - * @method initThumb - * @param {YAHOO.widget.SliderThumb} t the slider thumb - */ - initThumb: function(t) { - - var self = this; - - /** - * A YAHOO.widget.SliderThumb instance that we will use to - * reposition the thumb when the background is clicked - * @property thumb - * @type YAHOO.widget.SliderThumb - */ - this.thumb = t; - t.cacheBetweenDrags = true; - - // add handler for the handle onchange event - t.onChange = function() { - self.handleThumbChange(); - }; - - if (t._isHoriz && t.xTicks && t.xTicks.length) { - this.tickPause = Math.round(360 / t.xTicks.length); - } else if (t.yTicks && t.yTicks.length) { - this.tickPause = Math.round(360 / t.yTicks.length); - } - - - // delegate thumb methods - t.onMouseDown = function () { return self.focus(); }; - t.onMouseUp = function() { self.thumbMouseUp(); }; - t.onDrag = function() { self.fireEvents(true); }; - t.onAvailable = function() { return self.setStartSliderState(); }; - - }, - - /** - * Executed when the slider element is available - * @method onAvailable - */ - onAvailable: function() { - var Event = YAHOO.util.Event; - Event.on(this.id, "keydown", this.handleKeyDown, this, true); - Event.on(this.id, "keypress", this.handleKeyPress, this, true); - }, - - /** - * Executed when a keypress event happens with the control focused. - * Prevents the default behavior for navigation keys. The actual - * logic for moving the slider thumb in response to a key event - * happens in handleKeyDown. - * @param {Event} e the keypress event - */ - handleKeyPress: function(e) { - if (this.enableKeys) { - var Event = YAHOO.util.Event; - var kc = Event.getCharCode(e); - switch (kc) { - case 0x25: // left - case 0x26: // up - case 0x27: // right - case 0x28: // down - case 0x24: // home - case 0x23: // end - Event.preventDefault(e); - break; - default: - } - } - }, - - /** - * Executed when a keydown event happens with the control focused. - * Updates the slider value and display when the keypress is an - * arrow key, home, or end as long as enableKeys is set to true. - * @param {Event} e the keydown event - */ - handleKeyDown: function(e) { - if (this.enableKeys) { - var Event = YAHOO.util.Event; - - var kc = Event.getCharCode(e), t=this.thumb; - var h=this.getXValue(),v=this.getYValue(); - - var horiz = false; - var changeValue = true; - switch (kc) { - - // left - case 0x25: h -= this.keyIncrement; break; - - // up - case 0x26: v -= this.keyIncrement; break; - - // right - case 0x27: h += this.keyIncrement; break; - - // down - case 0x28: v += this.keyIncrement; break; - - // home - case 0x24: h = t.leftConstraint; - v = t.topConstraint; - break; - - // end - case 0x23: h = t.rightConstraint; - v = t.bottomConstraint; - break; - - default: changeValue = false; - } - - if (changeValue) { - if (t._isRegion) { - this.setRegionValue(h, v, true); - } else { - var newVal = (t._isHoriz) ? h : v; - this.setValue(newVal, true); - } - Event.stopEvent(e); - } - - } - }, - - /** - * Initialization that sets up the value offsets once the elements are ready - * @method setStartSliderState - */ - setStartSliderState: function() { - - - this.setThumbCenterPoint(); - - /** - * The basline position of the background element, used - * to determine if the background has moved since the last - * operation. - * @property baselinePos - * @type [int, int] - */ - this.baselinePos = YAHOO.util.Dom.getXY(this.getEl()); - - this.thumb.startOffset = this.thumb.getOffsetFromParent(this.baselinePos); - - if (this.thumb._isRegion) { - if (this.deferredSetRegionValue) { - this.setRegionValue.apply(this, this.deferredSetRegionValue, true); - this.deferredSetRegionValue = null; - } else { - this.setRegionValue(0, 0, true, true); - } - } else { - if (this.deferredSetValue) { - this.setValue.apply(this, this.deferredSetValue, true); - this.deferredSetValue = null; - } else { - this.setValue(0, true, true); - } - } - }, - - /** - * When the thumb is available, we cache the centerpoint of the element so - * we can position the element correctly when the background is clicked - * @method setThumbCenterPoint - */ - setThumbCenterPoint: function() { - - var el = this.thumb.getEl(); - - if (el) { - /** - * The center of the slider element is stored so we can - * place it in the correct position when the background is clicked. - * @property thumbCenterPoint - * @type {"x": int, "y": int} - */ - this.thumbCenterPoint = { - x: parseInt(el.offsetWidth/2, 10), - y: parseInt(el.offsetHeight/2, 10) - }; - } - - }, - - /** - * Locks the slider, overrides YAHOO.util.DragDrop - * @method lock - */ - lock: function() { - this.thumb.lock(); - this.locked = true; - }, - - /** - * Unlocks the slider, overrides YAHOO.util.DragDrop - * @method unlock - */ - unlock: function() { - this.thumb.unlock(); - this.locked = false; - }, - - /** - * Handles mouseup event on the slider background - * @method thumbMouseUp - * @private - */ - thumbMouseUp: function() { - if (!this.isLocked() && !this.moveComplete) { - this.endMove(); - } - - }, - - /** - * Returns a reference to this slider's thumb - * @method getThumb - * @return {SliderThumb} this slider's thumb - */ - getThumb: function() { - return this.thumb; - }, - - /** - * Try to focus the element when clicked so we can add - * accessibility features - * @method focus - * @private - */ - focus: function() { - - // Focus the background element if possible - var el = this.getEl(); - - if (el.focus) { - try { - el.focus(); - } catch(e) { - // Prevent permission denied unhandled exception in FF that can - // happen when setting focus while another element is handling - // the blur. @TODO this is still writing to the error log - // (unhandled error) in FF1.5 with strict error checking on. - } - } - - this.verifyOffset(); - - if (this.isLocked()) { - return false; - } else { - this.onSlideStart(); - return true; - } - }, - - /** - * Event that fires when the value of the slider has changed - * @method onChange - * @param {int} firstOffset the number of pixels the thumb has moved - * from its start position. Normal horizontal and vertical sliders will only - * have the firstOffset. Regions will have both, the first is the horizontal - * offset, the second the vertical. - * @param {int} secondOffset the y offset for region sliders - * @deprecated use instance.subscribe("change") instead - */ - onChange: function (firstOffset, secondOffset) { - /* override me */ - }, - - /** - * Event that fires when the at the beginning of the slider thumb move - * @method onSlideStart - * @deprecated use instance.subscribe("slideStart") instead - */ - onSlideStart: function () { - /* override me */ - }, - - /** - * Event that fires at the end of a slider thumb move - * @method onSliderEnd - * @deprecated use instance.subscribe("slideEnd") instead - */ - onSlideEnd: function () { - /* override me */ - }, - - /** - * Returns the slider's thumb offset from the start position - * @method getValue - * @return {int} the current value - */ - getValue: function () { - return this.thumb.getValue(); - }, - - /** - * Returns the slider's thumb X offset from the start position - * @method getXValue - * @return {int} the current horizontal offset - */ - getXValue: function () { - return this.thumb.getXValue(); - }, - - /** - * Returns the slider's thumb Y offset from the start position - * @method getYValue - * @return {int} the current vertical offset - */ - getYValue: function () { - return this.thumb.getYValue(); - }, - - /** - * Internal handler for the slider thumb's onChange event - * @method handleThumbChange - * @private - */ - handleThumbChange: function () { - var t = this.thumb; - if (t._isRegion) { - t.onChange(t.getXValue(), t.getYValue()); - this.fireEvent("change", { x: t.getXValue(), y: t.getYValue() } ); - } else { - t.onChange(t.getValue()); - this.fireEvent("change", t.getValue()); - } - - }, - - /** - * Provides a way to set the value of the slider in code. - * @method setValue - * @param {int} newOffset the number of pixels the thumb should be - * positioned away from the initial start point - * @param {boolean} skipAnim set to true to disable the animation - * for this move action (but not others). - * @param {boolean} force ignore the locked setting and set value anyway - * @return {boolean} true if the move was performed, false if it failed - */ - setValue: function(newOffset, skipAnim, force) { - - if (!this.thumb.available) { - this.deferredSetValue = arguments; - return false; - } - - if (this.isLocked() && !force) { - return false; - } - - if ( isNaN(newOffset) ) { - return false; - } - - var t = this.thumb; - var newX, newY; - this.verifyOffset(true); - if (t._isRegion) { - return false; - } else if (t._isHoriz) { - this.onSlideStart(); - // this.fireEvent("slideStart"); - newX = t.initPageX + newOffset + this.thumbCenterPoint.x; - this.moveThumb(newX, t.initPageY, skipAnim); - } else { - this.onSlideStart(); - // this.fireEvent("slideStart"); - newY = t.initPageY + newOffset + this.thumbCenterPoint.y; - this.moveThumb(t.initPageX, newY, skipAnim); - } - - return true; - }, - - /** - * Provides a way to set the value of the region slider in code. - * @method setRegionValue - * @param {int} newOffset the number of pixels the thumb should be - * positioned away from the initial start point (x axis for region) - * @param {int} newOffset2 the number of pixels the thumb should be - * positioned away from the initial start point (y axis for region) - * @param {boolean} skipAnim set to true to disable the animation - * for this move action (but not others). - * @param {boolean} force ignore the locked setting and set value anyway - * @return {boolean} true if the move was performed, false if it failed - */ - setRegionValue: function(newOffset, newOffset2, skipAnim, force) { - - if (!this.thumb.available) { - this.deferredSetRegionValue = arguments; - return false; - } - - if (this.isLocked() && !force) { - return false; - } - - if ( isNaN(newOffset) ) { - return false; - } - - var t = this.thumb; - if (t._isRegion) { - this.onSlideStart(); - var newX = t.initPageX + newOffset + this.thumbCenterPoint.x; - var newY = t.initPageY + newOffset2 + this.thumbCenterPoint.y; - this.moveThumb(newX, newY, skipAnim); - return true; - } - - return false; - - }, - - /** - * Checks the background position element position. If it has moved from the - * baseline position, the constraints for the thumb are reset - * @param checkPos {boolean} check the position instead of using cached value - * @method verifyOffset - * @return {boolean} True if the offset is the same as the baseline. - */ - verifyOffset: function(checkPos) { - - var newPos = YAHOO.util.Dom.getXY(this.getEl()); - //var newPos = [this.initPageX, this.initPageY]; - - - if (newPos[0] != this.baselinePos[0] || newPos[1] != this.baselinePos[1]) { - this.thumb.resetConstraints(); - this.baselinePos = newPos; - return false; - } - - return true; - }, - - /** - * Move the associated slider moved to a timeout to try to get around the - * mousedown stealing moz does when I move the slider element between the - * cursor and the background during the mouseup event - * @method moveThumb - * @param {int} x the X coordinate of the click - * @param {int} y the Y coordinate of the click - * @param {boolean} skipAnim don't animate if the move happend onDrag - * @private - */ - moveThumb: function(x, y, skipAnim) { - - - var t = this.thumb; - var self = this; - - if (!t.available) { - return; - } - - - // this.verifyOffset(); - - t.setDelta(this.thumbCenterPoint.x, this.thumbCenterPoint.y); - - var _p = t.getTargetCoord(x, y); - var p = [_p.x, _p.y]; - - - this.fireEvent("slideStart"); - - if (this.animate && YAHOO.widget.Slider.ANIM_AVAIL && t._graduated && !skipAnim) { - // this.thumb._animating = true; - this.lock(); - - // cache the current thumb pos - this.curCoord = YAHOO.util.Dom.getXY(this.thumb.getEl()); - - setTimeout( function() { self.moveOneTick(p); }, this.tickPause ); - - } else if (this.animate && YAHOO.widget.Slider.ANIM_AVAIL && !skipAnim) { - - // this.thumb._animating = true; - this.lock(); - - var oAnim = new YAHOO.util.Motion( - t.id, { points: { to: p } }, - this.animationDuration, - YAHOO.util.Easing.easeOut ); - - oAnim.onComplete.subscribe( function() { self.endMove(); } ); - oAnim.animate(); - } else { - t.setDragElPos(x, y); - // this.fireEvents(); - this.endMove(); - } - }, - - /** - * Move the slider one tick mark towards its final coordinate. Used - * for the animation when tick marks are defined - * @method moveOneTick - * @param {int[]} the destination coordinate - * @private - */ - moveOneTick: function(finalCoord) { - - var t = this.thumb, tmp; - - - // redundant call to getXY since we set the position most of time prior - // to getting here. Moved to this.curCoord - //var curCoord = YAHOO.util.Dom.getXY(t.getEl()); - - // alignElWithMouse caches position in lastPageX, lastPageY .. doesn't work - //var curCoord = [this.lastPageX, this.lastPageY]; - - // var thresh = Math.min(t.tickSize + (Math.floor(t.tickSize/2)), 10); - // var thresh = 10; - // var thresh = t.tickSize + (Math.floor(t.tickSize/2)); - - var nextCoord = null; - - if (t._isRegion) { - nextCoord = this._getNextX(this.curCoord, finalCoord); - var tmpX = (nextCoord) ? nextCoord[0] : this.curCoord[0]; - nextCoord = this._getNextY([tmpX, this.curCoord[1]], finalCoord); - - } else if (t._isHoriz) { - nextCoord = this._getNextX(this.curCoord, finalCoord); - } else { - nextCoord = this._getNextY(this.curCoord, finalCoord); - } - - - if (nextCoord) { - - // cache the position - this.curCoord = nextCoord; - - // move to the next coord - // YAHOO.util.Dom.setXY(t.getEl(), nextCoord); - - // var el = t.getEl(); - // YAHOO.util.Dom.setStyle(el, "left", (nextCoord[0] + this.thumb.deltaSetXY[0]) + "px"); - // YAHOO.util.Dom.setStyle(el, "top", (nextCoord[1] + this.thumb.deltaSetXY[1]) + "px"); - - this.thumb.alignElWithMouse(t.getEl(), nextCoord[0], nextCoord[1]); - - // check if we are in the final position, if not make a recursive call - if (!(nextCoord[0] == finalCoord[0] && nextCoord[1] == finalCoord[1])) { - var self = this; - setTimeout(function() { self.moveOneTick(finalCoord); }, - this.tickPause); - } else { - this.endMove(); - } - } else { - this.endMove(); - } - - //this.tickPause = Math.round(this.tickPause/2); - }, - - /** - * Returns the next X tick value based on the current coord and the target coord. - * @method _getNextX - * @private - */ - _getNextX: function(curCoord, finalCoord) { - var t = this.thumb; - var thresh; - var tmp = []; - var nextCoord = null; - if (curCoord[0] > finalCoord[0]) { - thresh = t.tickSize - this.thumbCenterPoint.x; - tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] ); - nextCoord = [tmp.x, tmp.y]; - } else if (curCoord[0] < finalCoord[0]) { - thresh = t.tickSize + this.thumbCenterPoint.x; - tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] ); - nextCoord = [tmp.x, tmp.y]; - } else { - // equal, do nothing - } - - return nextCoord; - }, - - /** - * Returns the next Y tick value based on the current coord and the target coord. - * @method _getNextY - * @private - */ - _getNextY: function(curCoord, finalCoord) { - var t = this.thumb; - var thresh; - var tmp = []; - var nextCoord = null; - - if (curCoord[1] > finalCoord[1]) { - thresh = t.tickSize - this.thumbCenterPoint.y; - tmp = t.getTargetCoord( curCoord[0], curCoord[1] - thresh ); - nextCoord = [tmp.x, tmp.y]; - } else if (curCoord[1] < finalCoord[1]) { - thresh = t.tickSize + this.thumbCenterPoint.y; - tmp = t.getTargetCoord( curCoord[0], curCoord[1] + thresh ); - nextCoord = [tmp.x, tmp.y]; - } else { - // equal, do nothing - } - - return nextCoord; - }, - - /** - * Resets the constraints before moving the thumb. - * @method b4MouseDown - * @private - */ - b4MouseDown: function(e) { - this.thumb.autoOffset(); - this.thumb.resetConstraints(); - }, - - - /** - * Handles the mousedown event for the slider background - * @method onMouseDown - * @private - */ - onMouseDown: function(e) { - // this.resetConstraints(true); - // this.thumb.resetConstraints(true); - - if (! this.isLocked() && this.backgroundEnabled) { - var x = YAHOO.util.Event.getPageX(e); - var y = YAHOO.util.Event.getPageY(e); - - this.focus(); - this.moveThumb(x, y); - } - - }, - - /** - * Handles the onDrag event for the slider background - * @method onDrag - * @private - */ - onDrag: function(e) { - if (! this.isLocked()) { - var x = YAHOO.util.Event.getPageX(e); - var y = YAHOO.util.Event.getPageY(e); - this.moveThumb(x, y, true); - } - }, - - /** - * Fired when the slider movement ends - * @method endMove - * @private - */ - endMove: function () { - // this._animating = false; - this.unlock(); - this.moveComplete = true; - this.fireEvents(); - }, - - /** - * Fires the change event if the value has been changed. Ignored if we are in - * the middle of an animation as the event will fire when the animation is - * complete - * @method fireEvents - * @param {boolean} thumbEvent set to true if this event is fired from an event - * that occurred on the thumb. If it is, the state of the - * thumb dd object should be correct. Otherwise, the event - * originated on the background, so the thumb state needs to - * be refreshed before proceeding. - * @private - */ - fireEvents: function (thumbEvent) { - - var t = this.thumb; - - if (!thumbEvent) { - t.cachePosition(); - } - - if (! this.isLocked()) { - if (t._isRegion) { - var newX = t.getXValue(); - var newY = t.getYValue(); - - if (newX != this.previousX || newY != this.previousY) { - this.onChange(newX, newY); - this.fireEvent("change", { x: newX, y: newY }); - } - - this.previousX = newX; - this.previousY = newY; - - } else { - var newVal = t.getValue(); - if (newVal != this.previousVal) { - this.onChange( newVal ); - this.fireEvent("change", newVal); - } - this.previousVal = newVal; - } - - if (this.moveComplete) { - this.onSlideEnd(); - this.fireEvent("slideEnd"); - this.moveComplete = false; - } - - } - }, - - /** - * Slider toString - * @method toString - * @return {string} string representation of the instance - */ - toString: function () { - return ("Slider (" + this.type +") " + this.id); - } - -}); - -YAHOO.augment(YAHOO.widget.Slider, YAHOO.util.EventProvider); - -/** - * A drag and drop implementation to be used as the thumb of a slider. - * @class SliderThumb - * @extends YAHOO.util.DD - * @constructor - * @param {String} id the id of the slider html element - * @param {String} sGroup the group of related DragDrop items - * @param {int} iLeft the number of pixels the element can move left - * @param {int} iRight the number of pixels the element can move right - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize optional parameter for specifying that the element - * should move a certain number pixels at a time. - */ -YAHOO.widget.SliderThumb = function(id, sGroup, iLeft, iRight, iUp, iDown, iTickSize) { - - if (id) { - //this.init(id, sGroup); - YAHOO.widget.SliderThumb.superclass.constructor.call(this, id, sGroup); - - /** - * The id of the thumbs parent HTML element (the slider background - * element). - * @property parentElId - * @type string - */ - this.parentElId = sGroup; - } - - - //this.removeInvalidHandleType("A"); - - - /** - * Overrides the isTarget property in YAHOO.util.DragDrop - * @property isTarget - * @private - */ - this.isTarget = false; - - /** - * The tick size for this slider - * @property tickSize - * @type int - * @private - */ - this.tickSize = iTickSize; - - /** - * Informs the drag and drop util that the offsets should remain when - * resetting the constraints. This preserves the slider value when - * the constraints are reset - * @property maintainOffset - * @type boolean - * @private - */ - this.maintainOffset = true; - - this.initSlider(iLeft, iRight, iUp, iDown, iTickSize); - - /** - * Turns off the autoscroll feature in drag and drop - * @property scroll - * @private - */ - this.scroll = false; - -}; - -YAHOO.extend(YAHOO.widget.SliderThumb, YAHOO.util.DD, { - - /** - * The (X and Y) difference between the thumb location and its parent - * (the slider background) when the control is instantiated. - * @property startOffset - * @type [int, int] - */ - startOffset: null, - - /** - * Flag used to figure out if this is a horizontal or vertical slider - * @property _isHoriz - * @type boolean - * @private - */ - _isHoriz: false, - - /** - * Cache the last value so we can check for change - * @property _prevVal - * @type int - * @private - */ - _prevVal: 0, - - /** - * The slider is _graduated if there is a tick interval defined - * @property _graduated - * @type boolean - * @private - */ - _graduated: false, - - - /** - * Returns the difference between the location of the thumb and its parent. - * @method getOffsetFromParent - * @param {[int, int]} parentPos Optionally accepts the position of the parent - * @type [int, int] - */ - getOffsetFromParent0: function(parentPos) { - var myPos = YAHOO.util.Dom.getXY(this.getEl()); - var ppos = parentPos || YAHOO.util.Dom.getXY(this.parentElId); - - return [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ]; - }, - - getOffsetFromParent: function(parentPos) { - - var el = this.getEl(); - - if (!this.deltaOffset) { - - var myPos = YAHOO.util.Dom.getXY(el); - var ppos = parentPos || YAHOO.util.Dom.getXY(this.parentElId); - - var newOffset = [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ]; - - var l = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 ); - var t = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 ); - - var deltaX = l - newOffset[0]; - var deltaY = t - newOffset[1]; - - if (isNaN(deltaX) || isNaN(deltaY)) { - } else { - this.deltaOffset = [deltaX, deltaY]; - } - - } else { - var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 ); - var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 ); - - newOffset = [newLeft + this.deltaOffset[0], newTop + this.deltaOffset[1]]; - } - - return newOffset; - - //return [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ]; - }, - - /** - * Set up the slider, must be called in the constructor of all subclasses - * @method initSlider - * @param {int} iLeft the number of pixels the element can move left - * @param {int} iRight the number of pixels the element can move right - * @param {int} iUp the number of pixels the element can move up - * @param {int} iDown the number of pixels the element can move down - * @param {int} iTickSize the width of the tick interval. - */ - initSlider: function (iLeft, iRight, iUp, iDown, iTickSize) { - - - //document these. new for 0.12.1 - this.initLeft = iLeft; - this.initRight = iRight; - this.initUp = iUp; - this.initDown = iDown; - - this.setXConstraint(iLeft, iRight, iTickSize); - this.setYConstraint(iUp, iDown, iTickSize); - - if (iTickSize && iTickSize > 1) { - this._graduated = true; - } - - this._isHoriz = (iLeft || iRight); - this._isVert = (iUp || iDown); - this._isRegion = (this._isHoriz && this._isVert); - - }, - - /** - * Clear's the slider's ticks - * @method clearTicks - */ - clearTicks: function () { - YAHOO.widget.SliderThumb.superclass.clearTicks.call(this); - this.tickSize = 0; - this._graduated = false; - }, - - - /** - * Gets the current offset from the element's start position in - * pixels. - * @method getValue - * @return {int} the number of pixels (positive or negative) the - * slider has moved from the start position. - */ - getValue: function () { - if (!this.available) { return 0; } - var val = (this._isHoriz) ? this.getXValue() : this.getYValue(); - return val; - }, - - /** - * Gets the current X offset from the element's start position in - * pixels. - * @method getXValue - * @return {int} the number of pixels (positive or negative) the - * slider has moved horizontally from the start position. - */ - getXValue: function () { - if (!this.available) { return 0; } - var newOffset = this.getOffsetFromParent(); - return (newOffset[0] - this.startOffset[0]); - }, - - /** - * Gets the current Y offset from the element's start position in - * pixels. - * @method getYValue - * @return {int} the number of pixels (positive or negative) the - * slider has moved vertically from the start position. - */ - getYValue: function () { - if (!this.available) { return 0; } - var newOffset = this.getOffsetFromParent(); - return (newOffset[1] - this.startOffset[1]); - }, - - /** - * Thumb toString - * @method toString - * @return {string} string representation of the instance - */ - toString: function () { - return "SliderThumb " + this.id; - }, - - /** - * The onchange event for the handle/thumb is delegated to the YAHOO.widget.Slider - * instance it belongs to. - * @method onChange - * @private - */ - onChange: function (x, y) { - } - -}); - -if ("undefined" == typeof YAHOO.util.Anim) { - YAHOO.widget.Slider.ANIM_AVAIL = false; -} - -YAHOO.register("slider", YAHOO.widget.Slider, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/tabview/README b/interface/web/js/yui/tabview/README deleted file mode 100644 index 0c598a55d5..0000000000 --- a/interface/web/js/yui/tabview/README +++ /dev/null @@ -1,21 +0,0 @@ -*** version 2.2.0 ** - -* Element broken out into seperate pkg - NOTE: new dependency required - element-beta.js - -*** version 0.12.2 *** - -* var Tab is now private -* fixed Element.configureAttribute - -*** version 0.12.1 *** - -* tabs.css renamed to tabview.css -* calls to "set" now queued so they can be made before "contentReady" - - -*** version 0.12.0 *** - -* TabView widget introduced - -* Note: border_tabs.css included as basic skin to enable "tabs" look diff --git a/interface/web/js/yui/tabview/assets/border_tabs.css b/interface/web/js/yui/tabview/assets/border_tabs.css deleted file mode 100644 index 436c6b757a..0000000000 --- a/interface/web/js/yui/tabview/assets/border_tabs.css +++ /dev/null @@ -1,54 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -.yui-navset .yui-nav li a, .yui-navset .yui-content { - border:1px solid #000; /* label and content borders */ -} - -.yui-navset .yui-nav .selected a, .yui-navset .yui-nav a:hover, .yui-navset .yui-content { - background-color:#f6f7ee; /* active tab, tab hover, and content bgcolor */ -} - -.yui-navset .yui-nav li em { padding:.5em; } /* tab padding */ - -/* defaults to orientation "top" */ -.yui-navset .yui-nav .selected a { - border-bottom-width:0; /* no bottom border for active tab */ - padding-bottom:1px; /* to match height of other tabs */ -} - -.yui-navset .yui-content { - margin-top:-1px; /* for active tab overlap */ -} - -/* overrides for other orientations */ - -.yui-navset-bottom .yui-nav .selected a { - border-width:0 1px 1px; /* no top border for active tab */ - padding:1px 0 0; /* to match height of other tabs */ -} - -.yui-navset-bottom .yui-content { - margin:0 0 -1px; /* for active tab overlap */ -} - -.yui-navset-left .yui-nav li.selected a { - border-width:1px 0 1px 1px; /* no right border for active tab */ - padding:0 1px 0 0; /* to match width of other tabs */ -} - -.yui-navset-left .yui-content { - margin:0 0 0 -1px; /* for active tab overlap */ -} - -.yui-navset-right .yui-nav li.selected a { - border-width:1px 1px 1px 0; /* no left border for active tab */ - padding:0 0 0 1px; /* to match width of other tabs */ -} - -.yui-navset-right .yui-content { - margin:0 -1px 0 0; /* for active tab overlap */ -} \ No newline at end of file diff --git a/interface/web/js/yui/tabview/assets/tabview.css b/interface/web/js/yui/tabview/assets/tabview.css deleted file mode 100644 index d14ecd3dc7..0000000000 --- a/interface/web/js/yui/tabview/assets/tabview.css +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/* default space between tabs */ -.yui-navset .yui-nav li { - margin-right:0.5em; /* horizontal tabs */ -} -.yui-navset-left .yui-nav li, .yui-navset-right .yui-nav li { - margin:0 0 0.5em; /* vertical tabs */ -} - -/* default width for side tabs */ -.yui-navset-left .yui-nav, .yui-navset-right .yui-nav { width:6em; } -.yui-navset-left { padding-left:6em; } /* map to nav width */ -.yui-navset-right { padding-right:6em; } /* ditto */ - -/* core */ - -.yui-nav, .yui-nav li { - margin:0; - padding:0; - list-style:none; -} -.yui-navset li em { font-style:normal; } - -.yui-navset { - position:relative; /* contain absolute positioned tabs (left/right) */ - zoom:1; -} - -.yui-navset .yui-content { zoom:1; } - -.yui-navset .yui-nav li { - display:inline-block; - display:-moz-inline-stack; - *display:inline; /* IE */ - vertical-align:bottom; /* safari: for overlap */ - cursor:pointer; /* gecko: due to -moz-inline-stack on anchor */ - zoom:1; /* IE: kill space between horizontal tabs */ -} - -.yui-navset-left .yui-nav li, .yui-navset-right .yui-nav li { - display:block; -} - -.yui-navset .yui-nav a { - outline:0; /* gecko: keep from shifting */ -} - -.yui-navset .yui-nav a { position:relative; } /* IE: to allow overlap */ - -.yui-navset .yui-nav li a { - display:block; - display:inline-block; - vertical-align:bottom; /* safari: for overlap */ - 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; /* for inline overlap (reverse for Op border bug) */ -} - -.yui-navset .yui-nav li a em { display:block; } - -/* position left and right oriented tabs */ -.yui-navset-left .yui-nav, .yui-navset-right .yui-nav { position:absolute; z-index:1; } -.yui-navset-left .yui-nav { left:0; } -.yui-navset-right .yui-nav { right:0; } diff --git a/interface/web/js/yui/tabview/tabview-debug.js b/interface/web/js/yui/tabview/tabview-debug.js deleted file mode 100644 index 30e7cf4aa6..0000000000 --- a/interface/web/js/yui/tabview/tabview-debug.js +++ /dev/null @@ -1,1025 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -(function() { - - /** - * The tabview module provides a widget for managing content bound to tabs. - * @module tabview - * @requires yahoo, dom, event, element - * - */ - /** - * A widget to control tabbed views. - * @namespace YAHOO.widget - * @class TabView - * @extends YAHOO.util.Element - * @constructor - * @param {HTMLElement | String | Object} el(optional) The html - * element that represents the TabView, or the attribute object to use. - * An element will be created if none provided. - * @param {Object} attr (optional) A key map of the tabView's - * initial attributes. Ignored if first arg is attributes object. - */ - YAHOO.widget.TabView = function(el, attr) { - 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 = _createTabViewElement.call(this, attr); - } - YAHOO.widget.TabView.superclass.constructor.call(this, el, attr); - }; - - YAHOO.extend(YAHOO.widget.TabView, YAHOO.util.Element); - - var proto = YAHOO.widget.TabView.prototype; - var Dom = YAHOO.util.Dom; - var Event = YAHOO.util.Event; - var Tab = YAHOO.widget.Tab; - - - /** - * The className to add when building from scratch. - * @property CLASSNAME - * @default "navset" - */ - proto.CLASSNAME = 'yui-navset'; - - /** - * The className of the HTMLElement containing the TabView's tab elements - * to look for when building from existing markup, or to add when building - * from scratch. - * All childNodes of the tab container are treated as Tabs when building - * from existing markup. - * @property TAB_PARENT_CLASSNAME - * @default "nav" - */ - proto.TAB_PARENT_CLASSNAME = 'yui-nav'; - - /** - * The className of the HTMLElement containing the TabView's label elements - * to look for when building from existing markup, or to add when building - * from scratch. - * All childNodes of the content container are treated as content elements when - * building from existing markup. - * @property CONTENT_PARENT_CLASSNAME - * @default "nav-content" - */ - proto.CONTENT_PARENT_CLASSNAME = 'yui-content'; - - proto._tabParent = null; - proto._contentParent = null; - - /** - * Adds a Tab to the TabView instance. - * If no index is specified, the tab is added to the end of the tab list. - * @method addTab - * @param {YAHOO.widget.Tab} tab A Tab instance to add. - * @param {Integer} index The position to add the tab. - * @return void - */ - proto.addTab = function(tab, index) { - var tabs = this.get('tabs'); - if (!tabs) { // not ready yet - this._queue[this._queue.length] = ['addTab', arguments]; - return false; - } - - index = (index === undefined) ? tabs.length : index; - - var before = this.getTab(index); - - var self = this; - var el = this.get('element'); - var tabParent = this._tabParent; - var contentParent = this._contentParent; - - var tabElement = tab.get('element'); - var contentEl = tab.get('contentEl'); - - if ( before ) { - tabParent.insertBefore(tabElement, before.get('element')); - } else { - tabParent.appendChild(tabElement); - } - - if ( contentEl && !Dom.isAncestor(contentParent, contentEl) ) { - contentParent.appendChild(contentEl); - } - - if ( !tab.get('active') ) { - tab.set('contentVisible', false, true); /* hide if not active */ - } else { - this.set('activeTab', tab, true); - - } - - var activate = function(e) { - YAHOO.util.Event.preventDefault(e); - self.set('activeTab', this); - }; - - tab.addListener( tab.get('activationEvent'), activate); - - tab.addListener('activationEventChange', function(e) { - if (e.prevValue != e.newValue) { - tab.removeListener(e.prevValue, activate); - tab.addListener(e.newValue, activate); - } - }); - - tabs.splice(index, 0, tab); - }; - - /** - * Routes childNode events. - * @method DOMEventHandler - * @param {event} e The Dom event that is being handled. - * @return void - */ - proto.DOMEventHandler = function(e) { - var el = this.get('element'); - var target = YAHOO.util.Event.getTarget(e); - var tabParent = this._tabParent; - - if (Dom.isAncestor(tabParent, target) ) { - var tabEl; - var tab = null; - var contentEl; - var tabs = this.get('tabs'); - - for (var i = 0, len = tabs.length; i < len; i++) { - tabEl = tabs[i].get('element'); - contentEl = tabs[i].get('contentEl'); - - if ( target == tabEl || Dom.isAncestor(tabEl, target) ) { - tab = tabs[i]; - break; // note break - } - } - - if (tab) { - tab.fireEvent(e.type, e); - } - } - }; - - /** - * Returns the Tab instance at the specified index. - * @method getTab - * @param {Integer} index The position of the Tab. - * @return YAHOO.widget.Tab - */ - proto.getTab = function(index) { - return this.get('tabs')[index]; - }; - - /** - * Returns the index of given tab. - * @method getTabIndex - * @param {YAHOO.widget.Tab} tab The tab whose index will be returned. - * @return int - */ - proto.getTabIndex = function(tab) { - var index = null; - var tabs = this.get('tabs'); - for (var i = 0, len = tabs.length; i < len; ++i) { - if (tab == tabs[i]) { - index = i; - break; - } - } - - return index; - }; - - /** - * Removes the specified Tab from the TabView. - * @method removeTab - * @param {YAHOO.widget.Tab} item The Tab instance to be removed. - * @return void - */ - proto.removeTab = function(tab) { - var tabCount = this.get('tabs').length; - - var index = this.getTabIndex(tab); - var nextIndex = index + 1; - if ( tab == this.get('activeTab') ) { // select next tab - if (tabCount > 1) { - if (index + 1 == tabCount) { - this.set('activeIndex', index - 1); - } else { - this.set('activeIndex', index + 1); - } - } - } - - this._tabParent.removeChild( tab.get('element') ); - this._contentParent.removeChild( tab.get('contentEl') ); - this._configs.tabs.value.splice(index, 1); - - }; - - /** - * Provides a readable name for the TabView instance. - * @method toString - * @return String - */ - proto.toString = function() { - var name = this.get('id') || this.get('tagName'); - return "TabView " + name; - }; - - /** - * The transiton to use when switching between tabs. - * @method contentTransition - */ - proto.contentTransition = function(newTab, oldTab) { - newTab.set('contentVisible', true); - oldTab.set('contentVisible', false); - }; - - /** - * setAttributeConfigs TabView specific properties. - * @method initAttributes - * @param {Object} attr Hash of initial attributes - */ - proto.initAttributes = function(attr) { - YAHOO.widget.TabView.superclass.initAttributes.call(this, attr); - - if (!attr.orientation) { - attr.orientation = 'top'; - } - - var el = this.get('element'); - - /** - * The Tabs belonging to the TabView instance. - * @config tabs - * @type Array - */ - this.setAttributeConfig('tabs', { - value: [], - readOnly: true - }); - - /** - * The container of the tabView's label elements. - * @property _tabParent - * @private - * @type HTMLElement - */ - this._tabParent = - this.getElementsByClassName(this.TAB_PARENT_CLASSNAME, - 'ul' )[0] || _createTabParent.call(this); - - /** - * The container of the tabView's content elements. - * @property _contentParent - * @type HTMLElement - * @private - */ - this._contentParent = - this.getElementsByClassName(this.CONTENT_PARENT_CLASSNAME, - 'div')[0] || _createContentParent.call(this); - - /** - * How the Tabs should be oriented relative to the TabView. - * @config orientation - * @type String - * @default "top" - */ - this.setAttributeConfig('orientation', { - value: attr.orientation, - method: function(value) { - var current = this.get('orientation'); - this.addClass('yui-navset-' + value); - - if (current != value) { - this.removeClass('yui-navset-' + current); - } - - switch(value) { - case 'bottom': - this.appendChild(this._tabParent); - break; - } - } - }); - - /** - * The index of the tab currently active. - * @config activeIndex - * @type Int - */ - this.setAttributeConfig('activeIndex', { - value: attr.activeIndex, - method: function(value) { - this.set('activeTab', this.getTab(value)); - }, - validator: function(value) { - return !this.getTab(value).get('disabled'); // cannot activate if disabled - } - }); - - /** - * The tab currently active. - * @config activeTab - * @type YAHOO.widget.Tab - */ - this.setAttributeConfig('activeTab', { - value: attr.activeTab, - method: function(tab) { - var activeTab = this.get('activeTab'); - - if (tab) { - tab.set('active', true); - this._configs['activeIndex'].value = this.getTabIndex(tab); // keep in sync - } - - if (activeTab && activeTab != tab) { - activeTab.set('active', false); - } - - if (activeTab && tab != activeTab) { // no transition if only 1 - this.contentTransition(tab, activeTab); - } else if (tab) { - tab.set('contentVisible', true); - } - }, - validator: function(value) { - return !value.get('disabled'); // cannot activate if disabled - } - }); - - if ( this._tabParent ) { - _initTabs.call(this); - } - - for (var type in this.DOM_EVENTS) { - if ( YAHOO.lang.hasOwnProperty(this.DOM_EVENTS, type) ) { - this.addListener.call(this, type, this.DOMEventHandler); - } - } - }; - - /** - * Creates Tab instances from a collection of HTMLElements. - * @method createTabs - * @private - * @param {Array|HTMLCollection} elements The elements to use for Tabs. - * @return void - */ - var _initTabs = function() { - var tab, - attr, - contentEl; - - var el = this.get('element'); - var tabs = _getChildNodes(this._tabParent); - var contentElements = _getChildNodes(this._contentParent); - - for (var i = 0, len = tabs.length; i < len; ++i) { - attr = {}; - - if (contentElements[i]) { - attr.contentEl = contentElements[i]; - } - - tab = new YAHOO.widget.Tab(tabs[i], attr); - this.addTab(tab); - - if (tab.hasClass(tab.ACTIVE_CLASSNAME) ) { - this._configs.activeTab.value = tab; // dont invoke method - } - } - }; - - var _createTabViewElement = function(attr) { - var el = document.createElement('div'); - - if ( this.CLASSNAME ) { - el.className = this.CLASSNAME; - } - - return el; - }; - - var _createTabParent = function(attr) { - var el = document.createElement('ul'); - - if ( this.TAB_PARENT_CLASSNAME ) { - el.className = this.TAB_PARENT_CLASSNAME; - } - - this.get('element').appendChild(el); - - return el; - }; - - var _createContentParent = function(attr) { - var el = document.createElement('div'); - - if ( this.CONTENT_PARENT_CLASSNAME ) { - el.className = this.CONTENT_PARENT_CLASSNAME; - } - - this.get('element').appendChild(el); - - return el; - }; - - var _getChildNodes = function(el) { - var nodes = []; - var childNodes = el.childNodes; - - for (var i = 0, len = childNodes.length; i < len; ++i) { - if (childNodes[i].nodeType == 1) { - nodes[nodes.length] = childNodes[i]; - } - } - - return nodes; - }; - -/** - * Fires before the activeTab is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeActiveTabChange<br> - * <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>> - * prevValue</code> the currently active tab<br> - * <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>> - * newValue</code> the tab to be made active</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeActiveTabChange', handler);</code></p> - * @event beforeActiveTabChange - */ - -/** - * Fires after the activeTab is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> activeTabChange<br> - * <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>> - * prevValue</code> the formerly active tab<br> - * <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>> - * newValue</code> the new active tab</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('activeTabChange', handler);</code></p> - * @event activeTabChange - */ - -/** - * Fires before the orientation is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeOrientationChange<br> - * <code><String> - * prevValue</code> the current orientation<br> - * <code><String> - * newValue</code> the new orientation to be applied</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeOrientationChange', handler);</code></p> - * @event beforeOrientationChange - */ - -/** - * Fires after the orientation is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> orientationChange<br> - * <code><String> - * prevValue</code> the former orientation<br> - * <code><String> - * newValue</code> the new orientation</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('orientationChange', handler);</code></p> - * @event orientationChange - */ -})(); - -(function() { - var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event; - - /** - * A representation of a Tab's label and content. - * @namespace YAHOO.widget - * @class Tab - * @extends YAHOO.util.Element - * @constructor - * @param element {HTMLElement | String} (optional) The html element that - * represents the TabView. An element will be created if none provided. - * @param {Object} properties A key map of initial properties - */ - var Tab = function(el, attr) { - attr = attr || {}; - if (arguments.length == 1 && !YAHOO.lang.isString(el) && !el.nodeName) { - attr = el; - el = attr.element; - } - - if (!el && !attr.element) { - el = _createTabElement.call(this, attr); - } - - this.loadHandler = { - success: function(o) { - this.set('content', o.responseText); - }, - failure: function(o) { - YAHOO.log('loading failed: ' + o.statusText, - 'error', 'Tab'); - } - }; - - Tab.superclass.constructor.call(this, el, attr); - - this.DOM_EVENTS = {}; // delegating to tabView - }; - - YAHOO.extend(Tab, YAHOO.util.Element); - var proto = Tab.prototype; - - /** - * The default tag name for a Tab's inner element. - * @property LABEL_INNER_TAGNAME - * @type String - * @default "em" - */ - proto.LABEL_TAGNAME = 'em'; - - /** - * The class name applied to active tabs. - * @property ACTIVE_CLASSNAME - * @type String - * @default "on" - */ - proto.ACTIVE_CLASSNAME = 'selected'; - - /** - * The class name applied to disabled tabs. - * @property DISABLED_CLASSNAME - * @type String - * @default "disabled" - */ - proto.DISABLED_CLASSNAME = 'disabled'; - - /** - * The class name applied to dynamic tabs while loading. - * @property LOADING_CLASSNAME - * @type String - * @default "disabled" - */ - proto.LOADING_CLASSNAME = 'loading'; - - /** - * Provides a reference to the connection request object when data is - * loaded dynamically. - * @property dataConnection - * @type Object - */ - proto.dataConnection = null; - - /** - * Object containing success and failure callbacks for loading data. - * @property loadHandler - * @type object - */ - proto.loadHandler = null; - - /** - * Provides a readable name for the tab. - * @method toString - * @return String - */ - proto.toString = function() { - var el = this.get('element'); - var id = el.id || el.tagName; - return "Tab " + id; - }; - - /** - * setAttributeConfigs TabView specific properties. - * @method initAttributes - * @param {Object} attr Hash of initial attributes - */ - proto.initAttributes = function(attr) { - attr = attr || {}; - Tab.superclass.initAttributes.call(this, attr); - - var el = this.get('element'); - - /** - * The event that triggers the tab's activation. - * @config activationEvent - * @type String - */ - this.setAttributeConfig('activationEvent', { - value: attr.activationEvent || 'click' - }); - - /** - * The element that contains the tab's label. - * @config labelEl - * @type HTMLElement - */ - this.setAttributeConfig('labelEl', { - value: attr.labelEl || _getlabelEl.call(this), - method: function(value) { - var current = this.get('labelEl'); - - if (current) { - if (current == value) { - return false; // already set - } - - this.replaceChild(value, current); - } else if (el.firstChild) { // ensure label is firstChild by default - this.insertBefore(value, el.firstChild); - } else { - this.appendChild(value); - } - } - }); - - /** - * The tab's label text (or innerHTML). - * @config label - * @type String - */ - this.setAttributeConfig('label', { - value: attr.label || _getLabel.call(this), - method: function(value) { - var labelEl = this.get('labelEl'); - if (!labelEl) { // create if needed - this.set('labelEl', _createlabelEl.call(this)); - } - - _setLabel.call(this, value); - } - }); - - /** - * The HTMLElement that contains the tab's content. - * @config contentEl - * @type HTMLElement - */ - this.setAttributeConfig('contentEl', { - value: attr.contentEl || document.createElement('div'), - method: function(value) { - var current = this.get('contentEl'); - - if (current) { - if (current == value) { - return false; // already set - } - this.replaceChild(value, current); - } - } - }); - - /** - * The tab's content. - * @config content - * @type String - */ - this.setAttributeConfig('content', { - value: attr.content, - method: function(value) { - this.get('contentEl').innerHTML = value; - } - }); - - var _dataLoaded = false; - - /** - * The tab's data source, used for loading content dynamically. - * @config dataSrc - * @type String - */ - this.setAttributeConfig('dataSrc', { - value: attr.dataSrc - }); - - /** - * Whether or not content should be reloaded for every view. - * @config cacheData - * @type Boolean - * @default false - */ - this.setAttributeConfig('cacheData', { - value: attr.cacheData || false, - validator: YAHOO.lang.isBoolean - }); - - /** - * The method to use for the data request. - * @config loadMethod - * @type String - * @default "GET" - */ - this.setAttributeConfig('loadMethod', { - value: attr.loadMethod || 'GET', - validator: YAHOO.lang.isString - }); - - /** - * Whether or not any data has been loaded from the server. - * @config dataLoaded - * @type Boolean - */ - this.setAttributeConfig('dataLoaded', { - value: false, - validator: YAHOO.lang.isBoolean, - writeOnce: true - }); - - /** - * Number if milliseconds before aborting and calling failure handler. - * @config dataTimeout - * @type Number - * @default null - */ - this.setAttributeConfig('dataTimeout', { - value: attr.dataTimeout || null, - validator: YAHOO.lang.isNumber - }); - - /** - * Whether or not the tab is currently active. - * If a dataSrc is set for the tab, the content will be loaded from - * the given source. - * @config active - * @type Boolean - */ - this.setAttributeConfig('active', { - value: attr.active || this.hasClass(this.ACTIVE_CLASSNAME), - method: function(value) { - if (value === true) { - this.addClass(this.ACTIVE_CLASSNAME); - this.set('title', 'active'); - } else { - this.removeClass(this.ACTIVE_CLASSNAME); - this.set('title', ''); - } - }, - validator: function(value) { - return YAHOO.lang.isBoolean(value) && !this.get('disabled') ; - } - }); - - /** - * Whether or not the tab is disabled. - * @config disabled - * @type Boolean - */ - this.setAttributeConfig('disabled', { - value: attr.disabled || this.hasClass(this.DISABLED_CLASSNAME), - method: function(value) { - if (value === true) { - Dom.addClass(this.get('element'), this.DISABLED_CLASSNAME); - } else { - Dom.removeClass(this.get('element'), this.DISABLED_CLASSNAME); - } - }, - validator: YAHOO.lang.isBoolean - }); - - /** - * The href of the tab's anchor element. - * @config href - * @type String - * @default '#' - */ - this.setAttributeConfig('href', { - value: attr.href || '#', - method: function(value) { - this.getElementsByTagName('a')[0].href = value; - }, - validator: YAHOO.lang.isString - }); - - /** - * The Whether or not the tab's content is visible. - * @config contentVisible - * @type Boolean - * @default false - */ - this.setAttributeConfig('contentVisible', { - value: attr.contentVisible, - method: function(value) { - if (value) { - this.get('contentEl').style.display = 'block'; - - if ( this.get('dataSrc') ) { - // load dynamic content unless already loaded and caching - if ( !this.get('dataLoaded') || !this.get('cacheData') ) { - _dataConnect.call(this); - } - } - } else { - this.get('contentEl').style.display = 'none'; - } - }, - validator: YAHOO.lang.isBoolean - }); - }; - - var _createTabElement = function(attr) { - var el = document.createElement('li'); - var a = document.createElement('a'); - - a.href = attr.href || '#'; - - el.appendChild(a); - - var label = attr.label || null; - var labelEl = attr.labelEl || null; - - if (labelEl) { // user supplied labelEl - if (!label) { // user supplied label - label = _getLabel.call(this, labelEl); - } - } else { - labelEl = _createlabelEl.call(this); - } - - a.appendChild(labelEl); - - return el; - }; - - var _getlabelEl = function() { - return this.getElementsByTagName(this.LABEL_TAGNAME)[0]; - }; - - var _createlabelEl = function() { - var el = document.createElement(this.LABEL_TAGNAME); - return el; - }; - - var _setLabel = function(label) { - var el = this.get('labelEl'); - el.innerHTML = label; - }; - - var _getLabel = function() { - var label, - el = this.get('labelEl'); - - if (!el) { - return undefined; - } - - return el.innerHTML; - }; - - var _dataConnect = function() { - if (!YAHOO.util.Connect) { - YAHOO.log('YAHOO.util.Connect dependency not met', - 'error', 'Tab'); - return false; - } - - Dom.addClass(this.get('contentEl').parentNode, this.LOADING_CLASSNAME); - - this.dataConnection = YAHOO.util.Connect.asyncRequest( - this.get('loadMethod'), - this.get('dataSrc'), - { - success: function(o) { - this.loadHandler.success.call(this, o); - this.set('dataLoaded', true); - this.dataConnection = null; - Dom.removeClass(this.get('contentEl').parentNode, - this.LOADING_CLASSNAME); - }, - failure: function(o) { - this.loadHandler.failure.call(this, o); - this.dataConnection = null; - Dom.removeClass(this.get('contentEl').parentNode, - this.LOADING_CLASSNAME); - }, - scope: this, - timeout: this.get('dataTimeout') - } - ); - }; - - YAHOO.widget.Tab = Tab; - - /** - * Fires before the active state is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeActiveChange<br> - * <code><Boolean> - * prevValue</code> the current value<br> - * <code><Boolean> - * newValue</code> the new value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeActiveChange', handler);</code></p> - * @event beforeActiveChange - */ - - /** - * Fires after the active state is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> activeChange<br> - * <code><Boolean> - * prevValue</code> the previous value<br> - * <code><Boolean> - * newValue</code> the updated value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('activeChange', handler);</code></p> - * @event activeChange - */ - - /** - * Fires before the tab label is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeLabelChange<br> - * <code><String> - * prevValue</code> the current value<br> - * <code><String> - * newValue</code> the new value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeLabelChange', handler);</code></p> - * @event beforeLabelChange - */ - - /** - * Fires after the tab label is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> labelChange<br> - * <code><String> - * prevValue</code> the previous value<br> - * <code><String> - * newValue</code> the updated value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('labelChange', handler);</code></p> - * @event labelChange - */ - - /** - * Fires before the tab content is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeContentChange<br> - * <code><String> - * prevValue</code> the current value<br> - * <code><String> - * newValue</code> the new value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeContentChange', handler);</code></p> - * @event beforeContentChange - */ - - /** - * Fires after the tab content is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> contentChange<br> - * <code><String> - * prevValue</code> the previous value<br> - * <code><Boolean> - * newValue</code> the updated value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('contentChange', handler);</code></p> - * @event contentChange - */ -})(); - -YAHOO.register("tabview", YAHOO.widget.TabView, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/tabview/tabview-min.js b/interface/web/js/yui/tabview/tabview-min.js deleted file mode 100644 index 48bbd4cd4a..0000000000 --- a/interface/web/js/yui/tabview/tabview-min.js +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -(function(){YAHOO.widget.TabView=function(el,attr){attr=attr||{};if(arguments.length==1&&!YAHOO.lang.isString(el)&&!el.nodeName){attr=el;el=attr.element||null;} -if(!el&&!attr.element){el=_createTabViewElement.call(this,attr);} -YAHOO.widget.TabView.superclass.constructor.call(this,el,attr);};YAHOO.extend(YAHOO.widget.TabView,YAHOO.util.Element);var proto=YAHOO.widget.TabView.prototype;var Dom=YAHOO.util.Dom;var Event=YAHOO.util.Event;var Tab=YAHOO.widget.Tab;proto.CLASSNAME='yui-navset';proto.TAB_PARENT_CLASSNAME='yui-nav';proto.CONTENT_PARENT_CLASSNAME='yui-content';proto._tabParent=null;proto._contentParent=null;proto.addTab=function(tab,index){var tabs=this.get('tabs');if(!tabs){this._queue[this._queue.length]=['addTab',arguments];return false;} -index=(index===undefined)?tabs.length:index;var before=this.getTab(index);var self=this;var el=this.get('element');var tabParent=this._tabParent;var contentParent=this._contentParent;var tabElement=tab.get('element');var contentEl=tab.get('contentEl');if(before){tabParent.insertBefore(tabElement,before.get('element'));}else{tabParent.appendChild(tabElement);} -if(contentEl&&!Dom.isAncestor(contentParent,contentEl)){contentParent.appendChild(contentEl);} -if(!tab.get('active')){tab.set('contentVisible',false,true);}else{this.set('activeTab',tab,true);} -var activate=function(e){YAHOO.util.Event.preventDefault(e);self.set('activeTab',this);};tab.addListener(tab.get('activationEvent'),activate);tab.addListener('activationEventChange',function(e){if(e.prevValue!=e.newValue){tab.removeListener(e.prevValue,activate);tab.addListener(e.newValue,activate);}});tabs.splice(index,0,tab);};proto.DOMEventHandler=function(e){var el=this.get('element');var target=YAHOO.util.Event.getTarget(e);var tabParent=this._tabParent;if(Dom.isAncestor(tabParent,target)){var tabEl;var tab=null;var contentEl;var tabs=this.get('tabs');for(var i=0,len=tabs.length;i<len;i++){tabEl=tabs[i].get('element');contentEl=tabs[i].get('contentEl');if(target==tabEl||Dom.isAncestor(tabEl,target)){tab=tabs[i];break;}} -if(tab){tab.fireEvent(e.type,e);}}};proto.getTab=function(index){return this.get('tabs')[index];};proto.getTabIndex=function(tab){var index=null;var tabs=this.get('tabs');for(var i=0,len=tabs.length;i<len;++i){if(tab==tabs[i]){index=i;break;}} -return index;};proto.removeTab=function(tab){var tabCount=this.get('tabs').length;var index=this.getTabIndex(tab);var nextIndex=index+1;if(tab==this.get('activeTab')){if(tabCount>1){if(index+1==tabCount){this.set('activeIndex',index-1);}else{this.set('activeIndex',index+1);}}} -this._tabParent.removeChild(tab.get('element'));this._contentParent.removeChild(tab.get('contentEl'));this._configs.tabs.value.splice(index,1);};proto.toString=function(){var name=this.get('id')||this.get('tagName');return"TabView "+name;};proto.contentTransition=function(newTab,oldTab){newTab.set('contentVisible',true);oldTab.set('contentVisible',false);};proto.initAttributes=function(attr){YAHOO.widget.TabView.superclass.initAttributes.call(this,attr);if(!attr.orientation){attr.orientation='top';} -var el=this.get('element');this.setAttributeConfig('tabs',{value:[],readOnly:true});this._tabParent=this.getElementsByClassName(this.TAB_PARENT_CLASSNAME,'ul')[0]||_createTabParent.call(this);this._contentParent=this.getElementsByClassName(this.CONTENT_PARENT_CLASSNAME,'div')[0]||_createContentParent.call(this);this.setAttributeConfig('orientation',{value:attr.orientation,method:function(value){var current=this.get('orientation');this.addClass('yui-navset-'+value);if(current!=value){this.removeClass('yui-navset-'+current);} -switch(value){case'bottom':this.appendChild(this._tabParent);break;}}});this.setAttributeConfig('activeIndex',{value:attr.activeIndex,method:function(value){this.set('activeTab',this.getTab(value));},validator:function(value){return!this.getTab(value).get('disabled');}});this.setAttributeConfig('activeTab',{value:attr.activeTab,method:function(tab){var activeTab=this.get('activeTab');if(tab){tab.set('active',true);this._configs['activeIndex'].value=this.getTabIndex(tab);} -if(activeTab&&activeTab!=tab){activeTab.set('active',false);} -if(activeTab&&tab!=activeTab){this.contentTransition(tab,activeTab);}else if(tab){tab.set('contentVisible',true);}},validator:function(value){return!value.get('disabled');}});if(this._tabParent){_initTabs.call(this);} -for(var type in this.DOM_EVENTS){if(YAHOO.lang.hasOwnProperty(this.DOM_EVENTS,type)){this.addListener.call(this,type,this.DOMEventHandler);}}};var _initTabs=function(){var tab,attr,contentEl;var el=this.get('element');var tabs=_getChildNodes(this._tabParent);var contentElements=_getChildNodes(this._contentParent);for(var i=0,len=tabs.length;i<len;++i){attr={};if(contentElements[i]){attr.contentEl=contentElements[i];} -tab=new YAHOO.widget.Tab(tabs[i],attr);this.addTab(tab);if(tab.hasClass(tab.ACTIVE_CLASSNAME)){this._configs.activeTab.value=tab;}}};var _createTabViewElement=function(attr){var el=document.createElement('div');if(this.CLASSNAME){el.className=this.CLASSNAME;} -return el;};var _createTabParent=function(attr){var el=document.createElement('ul');if(this.TAB_PARENT_CLASSNAME){el.className=this.TAB_PARENT_CLASSNAME;} -this.get('element').appendChild(el);return el;};var _createContentParent=function(attr){var el=document.createElement('div');if(this.CONTENT_PARENT_CLASSNAME){el.className=this.CONTENT_PARENT_CLASSNAME;} -this.get('element').appendChild(el);return el;};var _getChildNodes=function(el){var nodes=[];var childNodes=el.childNodes;for(var i=0,len=childNodes.length;i<len;++i){if(childNodes[i].nodeType==1){nodes[nodes.length]=childNodes[i];}} -return nodes;};})();(function(){var Dom=YAHOO.util.Dom,Event=YAHOO.util.Event;var Tab=function(el,attr){attr=attr||{};if(arguments.length==1&&!YAHOO.lang.isString(el)&&!el.nodeName){attr=el;el=attr.element;} -if(!el&&!attr.element){el=_createTabElement.call(this,attr);} -this.loadHandler={success:function(o){this.set('content',o.responseText);},failure:function(o){}};Tab.superclass.constructor.call(this,el,attr);this.DOM_EVENTS={};};YAHOO.extend(Tab,YAHOO.util.Element);var proto=Tab.prototype;proto.LABEL_TAGNAME='em';proto.ACTIVE_CLASSNAME='selected';proto.DISABLED_CLASSNAME='disabled';proto.LOADING_CLASSNAME='loading';proto.dataConnection=null;proto.loadHandler=null;proto.toString=function(){var el=this.get('element');var id=el.id||el.tagName;return"Tab "+id;};proto.initAttributes=function(attr){attr=attr||{};Tab.superclass.initAttributes.call(this,attr);var el=this.get('element');this.setAttributeConfig('activationEvent',{value:attr.activationEvent||'click'});this.setAttributeConfig('labelEl',{value:attr.labelEl||_getlabelEl.call(this),method:function(value){var current=this.get('labelEl');if(current){if(current==value){return false;} -this.replaceChild(value,current);}else if(el.firstChild){this.insertBefore(value,el.firstChild);}else{this.appendChild(value);}}});this.setAttributeConfig('label',{value:attr.label||_getLabel.call(this),method:function(value){var labelEl=this.get('labelEl');if(!labelEl){this.set('labelEl',_createlabelEl.call(this));} -_setLabel.call(this,value);}});this.setAttributeConfig('contentEl',{value:attr.contentEl||document.createElement('div'),method:function(value){var current=this.get('contentEl');if(current){if(current==value){return false;} -this.replaceChild(value,current);}}});this.setAttributeConfig('content',{value:attr.content,method:function(value){this.get('contentEl').innerHTML=value;}});var _dataLoaded=false;this.setAttributeConfig('dataSrc',{value:attr.dataSrc});this.setAttributeConfig('cacheData',{value:attr.cacheData||false,validator:YAHOO.lang.isBoolean});this.setAttributeConfig('loadMethod',{value:attr.loadMethod||'GET',validator:YAHOO.lang.isString});this.setAttributeConfig('dataLoaded',{value:false,validator:YAHOO.lang.isBoolean,writeOnce:true});this.setAttributeConfig('dataTimeout',{value:attr.dataTimeout||null,validator:YAHOO.lang.isNumber});this.setAttributeConfig('active',{value:attr.active||this.hasClass(this.ACTIVE_CLASSNAME),method:function(value){if(value===true){this.addClass(this.ACTIVE_CLASSNAME);this.set('title','active');}else{this.removeClass(this.ACTIVE_CLASSNAME);this.set('title','');}},validator:function(value){return YAHOO.lang.isBoolean(value)&&!this.get('disabled');}});this.setAttributeConfig('disabled',{value:attr.disabled||this.hasClass(this.DISABLED_CLASSNAME),method:function(value){if(value===true){Dom.addClass(this.get('element'),this.DISABLED_CLASSNAME);}else{Dom.removeClass(this.get('element'),this.DISABLED_CLASSNAME);}},validator:YAHOO.lang.isBoolean});this.setAttributeConfig('href',{value:attr.href||'#',method:function(value){this.getElementsByTagName('a')[0].href=value;},validator:YAHOO.lang.isString});this.setAttributeConfig('contentVisible',{value:attr.contentVisible,method:function(value){if(value){this.get('contentEl').style.display='block';if(this.get('dataSrc')){if(!this.get('dataLoaded')||!this.get('cacheData')){_dataConnect.call(this);}}}else{this.get('contentEl').style.display='none';}},validator:YAHOO.lang.isBoolean});};var _createTabElement=function(attr){var el=document.createElement('li');var a=document.createElement('a');a.href=attr.href||'#';el.appendChild(a);var label=attr.label||null;var labelEl=attr.labelEl||null;if(labelEl){if(!label){label=_getLabel.call(this,labelEl);}}else{labelEl=_createlabelEl.call(this);} -a.appendChild(labelEl);return el;};var _getlabelEl=function(){return this.getElementsByTagName(this.LABEL_TAGNAME)[0];};var _createlabelEl=function(){var el=document.createElement(this.LABEL_TAGNAME);return el;};var _setLabel=function(label){var el=this.get('labelEl');el.innerHTML=label;};var _getLabel=function(){var label,el=this.get('labelEl');if(!el){return undefined;} -return el.innerHTML;};var _dataConnect=function(){if(!YAHOO.util.Connect){return false;} -Dom.addClass(this.get('contentEl').parentNode,this.LOADING_CLASSNAME);this.dataConnection=YAHOO.util.Connect.asyncRequest(this.get('loadMethod'),this.get('dataSrc'),{success:function(o){this.loadHandler.success.call(this,o);this.set('dataLoaded',true);this.dataConnection=null;Dom.removeClass(this.get('contentEl').parentNode,this.LOADING_CLASSNAME);},failure:function(o){this.loadHandler.failure.call(this,o);this.dataConnection=null;Dom.removeClass(this.get('contentEl').parentNode,this.LOADING_CLASSNAME);},scope:this,timeout:this.get('dataTimeout')});};YAHOO.widget.Tab=Tab;})();YAHOO.register("tabview",YAHOO.widget.TabView,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/tabview/tabview.js b/interface/web/js/yui/tabview/tabview.js deleted file mode 100644 index 01ce2bdf29..0000000000 --- a/interface/web/js/yui/tabview/tabview.js +++ /dev/null @@ -1,1021 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -(function() { - - /** - * The tabview module provides a widget for managing content bound to tabs. - * @module tabview - * @requires yahoo, dom, event, element - * - */ - /** - * A widget to control tabbed views. - * @namespace YAHOO.widget - * @class TabView - * @extends YAHOO.util.Element - * @constructor - * @param {HTMLElement | String | Object} el(optional) The html - * element that represents the TabView, or the attribute object to use. - * An element will be created if none provided. - * @param {Object} attr (optional) A key map of the tabView's - * initial attributes. Ignored if first arg is attributes object. - */ - YAHOO.widget.TabView = function(el, attr) { - 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 = _createTabViewElement.call(this, attr); - } - YAHOO.widget.TabView.superclass.constructor.call(this, el, attr); - }; - - YAHOO.extend(YAHOO.widget.TabView, YAHOO.util.Element); - - var proto = YAHOO.widget.TabView.prototype; - var Dom = YAHOO.util.Dom; - var Event = YAHOO.util.Event; - var Tab = YAHOO.widget.Tab; - - - /** - * The className to add when building from scratch. - * @property CLASSNAME - * @default "navset" - */ - proto.CLASSNAME = 'yui-navset'; - - /** - * The className of the HTMLElement containing the TabView's tab elements - * to look for when building from existing markup, or to add when building - * from scratch. - * All childNodes of the tab container are treated as Tabs when building - * from existing markup. - * @property TAB_PARENT_CLASSNAME - * @default "nav" - */ - proto.TAB_PARENT_CLASSNAME = 'yui-nav'; - - /** - * The className of the HTMLElement containing the TabView's label elements - * to look for when building from existing markup, or to add when building - * from scratch. - * All childNodes of the content container are treated as content elements when - * building from existing markup. - * @property CONTENT_PARENT_CLASSNAME - * @default "nav-content" - */ - proto.CONTENT_PARENT_CLASSNAME = 'yui-content'; - - proto._tabParent = null; - proto._contentParent = null; - - /** - * Adds a Tab to the TabView instance. - * If no index is specified, the tab is added to the end of the tab list. - * @method addTab - * @param {YAHOO.widget.Tab} tab A Tab instance to add. - * @param {Integer} index The position to add the tab. - * @return void - */ - proto.addTab = function(tab, index) { - var tabs = this.get('tabs'); - if (!tabs) { // not ready yet - this._queue[this._queue.length] = ['addTab', arguments]; - return false; - } - - index = (index === undefined) ? tabs.length : index; - - var before = this.getTab(index); - - var self = this; - var el = this.get('element'); - var tabParent = this._tabParent; - var contentParent = this._contentParent; - - var tabElement = tab.get('element'); - var contentEl = tab.get('contentEl'); - - if ( before ) { - tabParent.insertBefore(tabElement, before.get('element')); - } else { - tabParent.appendChild(tabElement); - } - - if ( contentEl && !Dom.isAncestor(contentParent, contentEl) ) { - contentParent.appendChild(contentEl); - } - - if ( !tab.get('active') ) { - tab.set('contentVisible', false, true); /* hide if not active */ - } else { - this.set('activeTab', tab, true); - - } - - var activate = function(e) { - YAHOO.util.Event.preventDefault(e); - self.set('activeTab', this); - }; - - tab.addListener( tab.get('activationEvent'), activate); - - tab.addListener('activationEventChange', function(e) { - if (e.prevValue != e.newValue) { - tab.removeListener(e.prevValue, activate); - tab.addListener(e.newValue, activate); - } - }); - - tabs.splice(index, 0, tab); - }; - - /** - * Routes childNode events. - * @method DOMEventHandler - * @param {event} e The Dom event that is being handled. - * @return void - */ - proto.DOMEventHandler = function(e) { - var el = this.get('element'); - var target = YAHOO.util.Event.getTarget(e); - var tabParent = this._tabParent; - - if (Dom.isAncestor(tabParent, target) ) { - var tabEl; - var tab = null; - var contentEl; - var tabs = this.get('tabs'); - - for (var i = 0, len = tabs.length; i < len; i++) { - tabEl = tabs[i].get('element'); - contentEl = tabs[i].get('contentEl'); - - if ( target == tabEl || Dom.isAncestor(tabEl, target) ) { - tab = tabs[i]; - break; // note break - } - } - - if (tab) { - tab.fireEvent(e.type, e); - } - } - }; - - /** - * Returns the Tab instance at the specified index. - * @method getTab - * @param {Integer} index The position of the Tab. - * @return YAHOO.widget.Tab - */ - proto.getTab = function(index) { - return this.get('tabs')[index]; - }; - - /** - * Returns the index of given tab. - * @method getTabIndex - * @param {YAHOO.widget.Tab} tab The tab whose index will be returned. - * @return int - */ - proto.getTabIndex = function(tab) { - var index = null; - var tabs = this.get('tabs'); - for (var i = 0, len = tabs.length; i < len; ++i) { - if (tab == tabs[i]) { - index = i; - break; - } - } - - return index; - }; - - /** - * Removes the specified Tab from the TabView. - * @method removeTab - * @param {YAHOO.widget.Tab} item The Tab instance to be removed. - * @return void - */ - proto.removeTab = function(tab) { - var tabCount = this.get('tabs').length; - - var index = this.getTabIndex(tab); - var nextIndex = index + 1; - if ( tab == this.get('activeTab') ) { // select next tab - if (tabCount > 1) { - if (index + 1 == tabCount) { - this.set('activeIndex', index - 1); - } else { - this.set('activeIndex', index + 1); - } - } - } - - this._tabParent.removeChild( tab.get('element') ); - this._contentParent.removeChild( tab.get('contentEl') ); - this._configs.tabs.value.splice(index, 1); - - }; - - /** - * Provides a readable name for the TabView instance. - * @method toString - * @return String - */ - proto.toString = function() { - var name = this.get('id') || this.get('tagName'); - return "TabView " + name; - }; - - /** - * The transiton to use when switching between tabs. - * @method contentTransition - */ - proto.contentTransition = function(newTab, oldTab) { - newTab.set('contentVisible', true); - oldTab.set('contentVisible', false); - }; - - /** - * setAttributeConfigs TabView specific properties. - * @method initAttributes - * @param {Object} attr Hash of initial attributes - */ - proto.initAttributes = function(attr) { - YAHOO.widget.TabView.superclass.initAttributes.call(this, attr); - - if (!attr.orientation) { - attr.orientation = 'top'; - } - - var el = this.get('element'); - - /** - * The Tabs belonging to the TabView instance. - * @config tabs - * @type Array - */ - this.setAttributeConfig('tabs', { - value: [], - readOnly: true - }); - - /** - * The container of the tabView's label elements. - * @property _tabParent - * @private - * @type HTMLElement - */ - this._tabParent = - this.getElementsByClassName(this.TAB_PARENT_CLASSNAME, - 'ul' )[0] || _createTabParent.call(this); - - /** - * The container of the tabView's content elements. - * @property _contentParent - * @type HTMLElement - * @private - */ - this._contentParent = - this.getElementsByClassName(this.CONTENT_PARENT_CLASSNAME, - 'div')[0] || _createContentParent.call(this); - - /** - * How the Tabs should be oriented relative to the TabView. - * @config orientation - * @type String - * @default "top" - */ - this.setAttributeConfig('orientation', { - value: attr.orientation, - method: function(value) { - var current = this.get('orientation'); - this.addClass('yui-navset-' + value); - - if (current != value) { - this.removeClass('yui-navset-' + current); - } - - switch(value) { - case 'bottom': - this.appendChild(this._tabParent); - break; - } - } - }); - - /** - * The index of the tab currently active. - * @config activeIndex - * @type Int - */ - this.setAttributeConfig('activeIndex', { - value: attr.activeIndex, - method: function(value) { - this.set('activeTab', this.getTab(value)); - }, - validator: function(value) { - return !this.getTab(value).get('disabled'); // cannot activate if disabled - } - }); - - /** - * The tab currently active. - * @config activeTab - * @type YAHOO.widget.Tab - */ - this.setAttributeConfig('activeTab', { - value: attr.activeTab, - method: function(tab) { - var activeTab = this.get('activeTab'); - - if (tab) { - tab.set('active', true); - this._configs['activeIndex'].value = this.getTabIndex(tab); // keep in sync - } - - if (activeTab && activeTab != tab) { - activeTab.set('active', false); - } - - if (activeTab && tab != activeTab) { // no transition if only 1 - this.contentTransition(tab, activeTab); - } else if (tab) { - tab.set('contentVisible', true); - } - }, - validator: function(value) { - return !value.get('disabled'); // cannot activate if disabled - } - }); - - if ( this._tabParent ) { - _initTabs.call(this); - } - - for (var type in this.DOM_EVENTS) { - if ( YAHOO.lang.hasOwnProperty(this.DOM_EVENTS, type) ) { - this.addListener.call(this, type, this.DOMEventHandler); - } - } - }; - - /** - * Creates Tab instances from a collection of HTMLElements. - * @method createTabs - * @private - * @param {Array|HTMLCollection} elements The elements to use for Tabs. - * @return void - */ - var _initTabs = function() { - var tab, - attr, - contentEl; - - var el = this.get('element'); - var tabs = _getChildNodes(this._tabParent); - var contentElements = _getChildNodes(this._contentParent); - - for (var i = 0, len = tabs.length; i < len; ++i) { - attr = {}; - - if (contentElements[i]) { - attr.contentEl = contentElements[i]; - } - - tab = new YAHOO.widget.Tab(tabs[i], attr); - this.addTab(tab); - - if (tab.hasClass(tab.ACTIVE_CLASSNAME) ) { - this._configs.activeTab.value = tab; // dont invoke method - } - } - }; - - var _createTabViewElement = function(attr) { - var el = document.createElement('div'); - - if ( this.CLASSNAME ) { - el.className = this.CLASSNAME; - } - - return el; - }; - - var _createTabParent = function(attr) { - var el = document.createElement('ul'); - - if ( this.TAB_PARENT_CLASSNAME ) { - el.className = this.TAB_PARENT_CLASSNAME; - } - - this.get('element').appendChild(el); - - return el; - }; - - var _createContentParent = function(attr) { - var el = document.createElement('div'); - - if ( this.CONTENT_PARENT_CLASSNAME ) { - el.className = this.CONTENT_PARENT_CLASSNAME; - } - - this.get('element').appendChild(el); - - return el; - }; - - var _getChildNodes = function(el) { - var nodes = []; - var childNodes = el.childNodes; - - for (var i = 0, len = childNodes.length; i < len; ++i) { - if (childNodes[i].nodeType == 1) { - nodes[nodes.length] = childNodes[i]; - } - } - - return nodes; - }; - -/** - * Fires before the activeTab is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeActiveTabChange<br> - * <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>> - * prevValue</code> the currently active tab<br> - * <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>> - * newValue</code> the tab to be made active</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeActiveTabChange', handler);</code></p> - * @event beforeActiveTabChange - */ - -/** - * Fires after the activeTab is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> activeTabChange<br> - * <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>> - * prevValue</code> the formerly active tab<br> - * <code><<a href="YAHOO.widget.Tab.html">YAHOO.widget.Tab</a>> - * newValue</code> the new active tab</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('activeTabChange', handler);</code></p> - * @event activeTabChange - */ - -/** - * Fires before the orientation is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeOrientationChange<br> - * <code><String> - * prevValue</code> the current orientation<br> - * <code><String> - * newValue</code> the new orientation to be applied</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeOrientationChange', handler);</code></p> - * @event beforeOrientationChange - */ - -/** - * Fires after the orientation is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> orientationChange<br> - * <code><String> - * prevValue</code> the former orientation<br> - * <code><String> - * newValue</code> the new orientation</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('orientationChange', handler);</code></p> - * @event orientationChange - */ -})(); - -(function() { - var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event; - - /** - * A representation of a Tab's label and content. - * @namespace YAHOO.widget - * @class Tab - * @extends YAHOO.util.Element - * @constructor - * @param element {HTMLElement | String} (optional) The html element that - * represents the TabView. An element will be created if none provided. - * @param {Object} properties A key map of initial properties - */ - var Tab = function(el, attr) { - attr = attr || {}; - if (arguments.length == 1 && !YAHOO.lang.isString(el) && !el.nodeName) { - attr = el; - el = attr.element; - } - - if (!el && !attr.element) { - el = _createTabElement.call(this, attr); - } - - this.loadHandler = { - success: function(o) { - this.set('content', o.responseText); - }, - failure: function(o) { - } - }; - - Tab.superclass.constructor.call(this, el, attr); - - this.DOM_EVENTS = {}; // delegating to tabView - }; - - YAHOO.extend(Tab, YAHOO.util.Element); - var proto = Tab.prototype; - - /** - * The default tag name for a Tab's inner element. - * @property LABEL_INNER_TAGNAME - * @type String - * @default "em" - */ - proto.LABEL_TAGNAME = 'em'; - - /** - * The class name applied to active tabs. - * @property ACTIVE_CLASSNAME - * @type String - * @default "on" - */ - proto.ACTIVE_CLASSNAME = 'selected'; - - /** - * The class name applied to disabled tabs. - * @property DISABLED_CLASSNAME - * @type String - * @default "disabled" - */ - proto.DISABLED_CLASSNAME = 'disabled'; - - /** - * The class name applied to dynamic tabs while loading. - * @property LOADING_CLASSNAME - * @type String - * @default "disabled" - */ - proto.LOADING_CLASSNAME = 'loading'; - - /** - * Provides a reference to the connection request object when data is - * loaded dynamically. - * @property dataConnection - * @type Object - */ - proto.dataConnection = null; - - /** - * Object containing success and failure callbacks for loading data. - * @property loadHandler - * @type object - */ - proto.loadHandler = null; - - /** - * Provides a readable name for the tab. - * @method toString - * @return String - */ - proto.toString = function() { - var el = this.get('element'); - var id = el.id || el.tagName; - return "Tab " + id; - }; - - /** - * setAttributeConfigs TabView specific properties. - * @method initAttributes - * @param {Object} attr Hash of initial attributes - */ - proto.initAttributes = function(attr) { - attr = attr || {}; - Tab.superclass.initAttributes.call(this, attr); - - var el = this.get('element'); - - /** - * The event that triggers the tab's activation. - * @config activationEvent - * @type String - */ - this.setAttributeConfig('activationEvent', { - value: attr.activationEvent || 'click' - }); - - /** - * The element that contains the tab's label. - * @config labelEl - * @type HTMLElement - */ - this.setAttributeConfig('labelEl', { - value: attr.labelEl || _getlabelEl.call(this), - method: function(value) { - var current = this.get('labelEl'); - - if (current) { - if (current == value) { - return false; // already set - } - - this.replaceChild(value, current); - } else if (el.firstChild) { // ensure label is firstChild by default - this.insertBefore(value, el.firstChild); - } else { - this.appendChild(value); - } - } - }); - - /** - * The tab's label text (or innerHTML). - * @config label - * @type String - */ - this.setAttributeConfig('label', { - value: attr.label || _getLabel.call(this), - method: function(value) { - var labelEl = this.get('labelEl'); - if (!labelEl) { // create if needed - this.set('labelEl', _createlabelEl.call(this)); - } - - _setLabel.call(this, value); - } - }); - - /** - * The HTMLElement that contains the tab's content. - * @config contentEl - * @type HTMLElement - */ - this.setAttributeConfig('contentEl', { - value: attr.contentEl || document.createElement('div'), - method: function(value) { - var current = this.get('contentEl'); - - if (current) { - if (current == value) { - return false; // already set - } - this.replaceChild(value, current); - } - } - }); - - /** - * The tab's content. - * @config content - * @type String - */ - this.setAttributeConfig('content', { - value: attr.content, - method: function(value) { - this.get('contentEl').innerHTML = value; - } - }); - - var _dataLoaded = false; - - /** - * The tab's data source, used for loading content dynamically. - * @config dataSrc - * @type String - */ - this.setAttributeConfig('dataSrc', { - value: attr.dataSrc - }); - - /** - * Whether or not content should be reloaded for every view. - * @config cacheData - * @type Boolean - * @default false - */ - this.setAttributeConfig('cacheData', { - value: attr.cacheData || false, - validator: YAHOO.lang.isBoolean - }); - - /** - * The method to use for the data request. - * @config loadMethod - * @type String - * @default "GET" - */ - this.setAttributeConfig('loadMethod', { - value: attr.loadMethod || 'GET', - validator: YAHOO.lang.isString - }); - - /** - * Whether or not any data has been loaded from the server. - * @config dataLoaded - * @type Boolean - */ - this.setAttributeConfig('dataLoaded', { - value: false, - validator: YAHOO.lang.isBoolean, - writeOnce: true - }); - - /** - * Number if milliseconds before aborting and calling failure handler. - * @config dataTimeout - * @type Number - * @default null - */ - this.setAttributeConfig('dataTimeout', { - value: attr.dataTimeout || null, - validator: YAHOO.lang.isNumber - }); - - /** - * Whether or not the tab is currently active. - * If a dataSrc is set for the tab, the content will be loaded from - * the given source. - * @config active - * @type Boolean - */ - this.setAttributeConfig('active', { - value: attr.active || this.hasClass(this.ACTIVE_CLASSNAME), - method: function(value) { - if (value === true) { - this.addClass(this.ACTIVE_CLASSNAME); - this.set('title', 'active'); - } else { - this.removeClass(this.ACTIVE_CLASSNAME); - this.set('title', ''); - } - }, - validator: function(value) { - return YAHOO.lang.isBoolean(value) && !this.get('disabled') ; - } - }); - - /** - * Whether or not the tab is disabled. - * @config disabled - * @type Boolean - */ - this.setAttributeConfig('disabled', { - value: attr.disabled || this.hasClass(this.DISABLED_CLASSNAME), - method: function(value) { - if (value === true) { - Dom.addClass(this.get('element'), this.DISABLED_CLASSNAME); - } else { - Dom.removeClass(this.get('element'), this.DISABLED_CLASSNAME); - } - }, - validator: YAHOO.lang.isBoolean - }); - - /** - * The href of the tab's anchor element. - * @config href - * @type String - * @default '#' - */ - this.setAttributeConfig('href', { - value: attr.href || '#', - method: function(value) { - this.getElementsByTagName('a')[0].href = value; - }, - validator: YAHOO.lang.isString - }); - - /** - * The Whether or not the tab's content is visible. - * @config contentVisible - * @type Boolean - * @default false - */ - this.setAttributeConfig('contentVisible', { - value: attr.contentVisible, - method: function(value) { - if (value) { - this.get('contentEl').style.display = 'block'; - - if ( this.get('dataSrc') ) { - // load dynamic content unless already loaded and caching - if ( !this.get('dataLoaded') || !this.get('cacheData') ) { - _dataConnect.call(this); - } - } - } else { - this.get('contentEl').style.display = 'none'; - } - }, - validator: YAHOO.lang.isBoolean - }); - }; - - var _createTabElement = function(attr) { - var el = document.createElement('li'); - var a = document.createElement('a'); - - a.href = attr.href || '#'; - - el.appendChild(a); - - var label = attr.label || null; - var labelEl = attr.labelEl || null; - - if (labelEl) { // user supplied labelEl - if (!label) { // user supplied label - label = _getLabel.call(this, labelEl); - } - } else { - labelEl = _createlabelEl.call(this); - } - - a.appendChild(labelEl); - - return el; - }; - - var _getlabelEl = function() { - return this.getElementsByTagName(this.LABEL_TAGNAME)[0]; - }; - - var _createlabelEl = function() { - var el = document.createElement(this.LABEL_TAGNAME); - return el; - }; - - var _setLabel = function(label) { - var el = this.get('labelEl'); - el.innerHTML = label; - }; - - var _getLabel = function() { - var label, - el = this.get('labelEl'); - - if (!el) { - return undefined; - } - - return el.innerHTML; - }; - - var _dataConnect = function() { - if (!YAHOO.util.Connect) { - return false; - } - - Dom.addClass(this.get('contentEl').parentNode, this.LOADING_CLASSNAME); - - this.dataConnection = YAHOO.util.Connect.asyncRequest( - this.get('loadMethod'), - this.get('dataSrc'), - { - success: function(o) { - this.loadHandler.success.call(this, o); - this.set('dataLoaded', true); - this.dataConnection = null; - Dom.removeClass(this.get('contentEl').parentNode, - this.LOADING_CLASSNAME); - }, - failure: function(o) { - this.loadHandler.failure.call(this, o); - this.dataConnection = null; - Dom.removeClass(this.get('contentEl').parentNode, - this.LOADING_CLASSNAME); - }, - scope: this, - timeout: this.get('dataTimeout') - } - ); - }; - - YAHOO.widget.Tab = Tab; - - /** - * Fires before the active state is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeActiveChange<br> - * <code><Boolean> - * prevValue</code> the current value<br> - * <code><Boolean> - * newValue</code> the new value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeActiveChange', handler);</code></p> - * @event beforeActiveChange - */ - - /** - * Fires after the active state is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> activeChange<br> - * <code><Boolean> - * prevValue</code> the previous value<br> - * <code><Boolean> - * newValue</code> the updated value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('activeChange', handler);</code></p> - * @event activeChange - */ - - /** - * Fires before the tab label is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeLabelChange<br> - * <code><String> - * prevValue</code> the current value<br> - * <code><String> - * newValue</code> the new value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeLabelChange', handler);</code></p> - * @event beforeLabelChange - */ - - /** - * Fires after the tab label is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> labelChange<br> - * <code><String> - * prevValue</code> the previous value<br> - * <code><String> - * newValue</code> the updated value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('labelChange', handler);</code></p> - * @event labelChange - */ - - /** - * Fires before the tab content is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p>If handler returns false, the change will be cancelled, and the value will not - * be set.</p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> beforeContentChange<br> - * <code><String> - * prevValue</code> the current value<br> - * <code><String> - * newValue</code> the new value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('beforeContentChange', handler);</code></p> - * @event beforeContentChange - */ - - /** - * Fires after the tab content is changed. - * <p>See: <a href="YAHOO.util.Element.html#addListener">Element.addListener</a></p> - * <p><strong>Event fields:</strong><br> - * <code><String> type</code> contentChange<br> - * <code><String> - * prevValue</code> the previous value<br> - * <code><Boolean> - * newValue</code> the updated value</p> - * <p><strong>Usage:</strong><br> - * <code>var handler = function(e) {var previous = e.prevValue};<br> - * myTabs.addListener('contentChange', handler);</code></p> - * @event contentChange - */ -})(); - -YAHOO.register("tabview", YAHOO.widget.TabView, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/treeview/README b/interface/web/js/yui/treeview/README deleted file mode 100644 index 6b24d39ee9..0000000000 --- a/interface/web/js/yui/treeview/README +++ /dev/null @@ -1,147 +0,0 @@ -TreeView - Release Notes - -2.2.0 - - * Node::insertAfter properly nulls the nextSibling attribute when the - inserted before the firstChild. - - * MenuNodes inserted at the root level will no longer lose the menu behavior. - - * TextNode::setUpLabel sets the data.label property as well as the label property. - - * TaskNode example: made the logger optional, and moved the creation of the logger - instance to the proper location. - - * TaskNodes added to a node that is in a fully selected state will update the - parent to a partially selected state. - - * TaskNode example fixed to propagate the labelClick event - - -0.12.2 - - * removeChildren will now work properly on the root node. - -0.12.1 - - * Added custom events for expandComplete and collapseComplete. These events are - needed in situations where the implementer needs to resize or reposition - something based on the new offset. - - * Added a "nowrap" property to Node, and set the default to false. Specifies - whether or not the content area of the node should be allowed to wrap - naturally. - - * Added additional HTML elements to preserve the tree presentation when constrained - by a parent element. - -0.12.0 - - * TreeView now augments EventProvider, and has custom events for expand, - collapse, animStart, animComplete, and labelClick. Existing implementations - using abstract methods for these events (if they exist) will still work. - New events can be plugged into the tree by the Node implementation. For - example, TaskNode adds a checkClick event. EventProvider makes it safe - to do this because implementing code can call subscribe() prior to the - event creation. - - * YAHOO.util.Event is now a requirement for the widget - - * TreeView::removeChildren no longer expands and collapses the node. - - * Documented the moveComplete property - - * createElement("DIV") changed to createElement("div") - -0.11.4 - - * Fixed a javascript error on the HTML node example page. - -0.11.3 - - * popNode now clears the tree, previousSibling, nextSibling, and parent - properties of the node that is being removed from the tree. - - * Fixed the paths to the images in the tree.css file that is included in - build/assets. - -0.11.0 - - * Added TreeView -> popNode, which differs from removeNode in that the - node's children are preserved so the entire branch can be re-inserted - into another part of the tree, or another tree. - - * Added TreeView -> getNodesByProperty, which differs from - getNodeByProperty by returning an array of all nodes that have the - specified property rather than just the first one. - - * Added Node -> insertBefore, insertAfter, and appendTo. These method - can be used to reorganize the tree. - - * removeChildren properly resets the node icon when executed against a - collpased node. - - * Moved depth assignment from the constructor to appendChild so that the - value is set properly if the node is moved within the tree. - - * Fixed broken loop in removeChildren. - - * RootNode -> loadComplete calls tree.draw for hot-wiring the dynamic load - feature for the top level nodes. - - * The treeview constructor will accept an element instead of an id. - -0.10.0 - - * If the child collection changes prior to a refresh(), the icon is now - changed appropriately. - - * Added TreeView removeChildren(node). This will recursively purge the node's - children, and reset its dynamic load state. - - * previousSibling and nextSibling are now adjusted correctly when a - node is deleted. - - * expand()/collapse() now will not expand/collapse the node if false is - returned from the onExpand/onCollapse event handlers. - - * The onExpand and onCollapse events now fire before the node is expanded - or collapsed so that the implementer can modify the node's child collection - prior to display. - - * The childrenRendered property previous was used to indicate both that - a dynamically loaded node has received its data, and also to indicate - that the children html has been created. This has been split into - two properties. dynamicLoadComplete and childrenRendered. - - * Implemented the renderHidden flag. If set to true, the html for the entire - tree will be created when tree.draw() is called, not just the html for the - visible nodes. - - * Added an onLabelClick listener to TextNode - - * TreeView.removeNode no longer automatically refreshes the tree. It has an - optional parameter to perform the refresh. - - * removeNode can now be executed on nodes that have not been rendered. - - * You can now delete top-level nodes. - - * Added onCheckClick listener to the TaskNode example - - * Added Node.iconMode, which is a property that configures the way - dynamically loaded nodes are displayed when they are expanded and contain - no children. - - * TreeView/Node.setDynamicLoad now accepts an optional second parameter to - set the iconMode property. - - * Fixed an issue in the TaskNode.js example that prevented setting the checked - state of a node through the constructor. - - * Fixed an issue in HTMLNode that caused rendering issues when hasIcon was - set to true. - - * Added TreeView.removeNode - - * Added Node.refresh diff --git a/interface/web/js/yui/treeview/assets/lm.gif b/interface/web/js/yui/treeview/assets/lm.gif deleted file mode 100644 index e7d0a3ce92eb825a95ca188133567cd4f8f31499..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 94 zcmZ?wbhEHb6krfzn8?8J|NsAnh6V;OL-8jIs|W)#gAS0(0Fq~5(x216Qtb79sX3ZA us+DiZoVZmeFVu3oV#=XiRnDKMs-2p#PO1G%cj6U(9<KHyixx95SOWm?1|w$x diff --git a/interface/web/js/yui/treeview/assets/lmh.gif b/interface/web/js/yui/treeview/assets/lmh.gif deleted file mode 100644 index 3ff6302723f154dfea4f21bfcd754097d491f51b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 106 zcmZ?wbhEHb6krfzSj586(9qzWyyp6yrwj}X|Ns97k`SQylZBCifrUW_#09BkVAl88 zb!Xj!lRuUA>b}?;FOZ<YGEZXCx%9rL4|e6G2(Ic()1Ljz{P5oy3kp1Rr1~eZFjxZs D!xki> diff --git a/interface/web/js/yui/treeview/assets/ln.gif b/interface/web/js/yui/treeview/assets/ln.gif deleted file mode 100644 index b7b3e55cd044af047e571b8e46d99dd4b801ee60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 142 zcmZ?wbhEHb6krfz*v!Dt(9rPz|9=MJ08pjkPZmZ727U&`e=?ytsfj5H?w)Q6!MTY= zCBcbhsYME5Ky0LEz@P&%5oCu0i}Z(+o~!p-ygs}8e}YEQf$*yI>683lZcElVAIHLA F4FFl;B{Tp4 diff --git a/interface/web/js/yui/treeview/assets/loading.gif b/interface/web/js/yui/treeview/assets/loading.gif deleted file mode 100644 index 0bbf3bc0c0e5e635553e8d1bf9ceddefbc402396..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2673 zcmchY_gj;P7RTSb83YJ1>=8y5ONL=ZcEgk+C?FydumNNz8c=c6`n&|fmMu_HHG%^w zNLVjHyfy)hAgHK_Kxkz+0Ktm5M|<t<efq<F{P~_g;GFY(p3nE3P2c)EyTlRz9pLRW z@ZrOU_wV1oef##!n>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=FOXxm6dsUd1Nv<IXO8j zEbQ^)$2~ngiHV6@w{DGzi4h8g9UUF}_wT=O;exZX^ZNDcEiEm5e0%}}1DBST?Ck7P zQc^Bnyy)cQ)ZN{^Wy_Yq!9f=nmn&DUL`O$QMMbTwtRy5PjE#*QJa{lYJ-wo$V$-Hg zPo6xve*OB16DLYaN|KV2N=r+-y1JN5roFv=R#sL~QBh-KV@^(vhlfXQZmyr79|S>Z zX=yul?BMZua=F~p)O7py?EwJ+w{PD*dGh2hzx?v((WCP6au$m<KR@5w+pDdued^Sy zUw{3zy}kYD(W4Cw4X&=Py1KeF8qLhiOe&S~`TWt*(IZEWT)uo+EEZQ+SC5R0q^71C z8XB6Ln;$=Z{D&WY@bvWLa5$~4t#x&E0|Ns=K|vys=<3z0-rnA2Wo1|_mPjNT85zaJ z#f653e*gXVNF-86M<+NqI3puNOG~T2zu(KtOD2<@J9n<Hua8crfBg9I)2C0LKY#w? zk3atWPkj;W|5M~YRk!$sZ}agA@w2z3BN1PwlHa400bm-i{%eE3Vgg{_13k)y0pb}c z7prMNYYb+23sgH|`g3iF-gyM{E-DjH^mFypGw%5_r7&pMzAWZ3Sun?T6MjOD2&C@N zpUP*qsj<Fv6(gJl=D5?2Ce|rSNX|M?Gzo?WX7mAl80YAb_ZlQAjKF#Z9T5jhoe<e2 zC#E`VAQ+7{OSFQRQj}UJ=43_wN*&Jc8&}Inwn)Y(cz{Xng;%yYMC8vgMls}y3rI85 zDS`$#g2=(_H(h+We>b!vmnqSpF6-9Ona(JQT#e>!KODwxYzG5#S|?M#v6eD#mg<?c zB1X+V&G*;ntaJTSB6fMbH0~GIYE1YVjgMbwXh~XTq}kZ+6f23^nSRcLOE!)RWkMK0 z0c_#K=&Tbs*%=$($es1#0-Zy#Ou_X^B-&hMAh)G5-!!(fnN&|s^x;fuyh=T{T-Idi z8OX~Y;zAIHk!m_oy&}!q7)UZCK`RC*eWVIV61VUR{nIiC5_qMg(9v3hq{oB`Xv#uL zPIFlRs1l&0qsJ7nl?q%fI{wAmkGdt`qE)PMz!Jiji_{q#6eN4YTvd*{z1Rlm=Q?Qg zsL$`-tR8H}Oz4-dII6BY64jZU-INCasI5pb?{OX)t=nPb9z(DQoWcKSH63Z^JhX)T zG5+?JbT;#AJl_0e#~@ee#m6e`89u+l?#r42P?B+;!e`IaB{aaa6Z-I{+!K2f#b^Bl z2CDiWvIJwuO0ZjbFhX{xT*o$~b`h~w2XVC*qQSLUOd$maI}O0}aiofhj_tb_{^P(o z^`vW|_OV0+sCq3Ro_Bl>O^`=~9EL;yL&>*dd5*+XG=_`^3=CG25PbLa+LJ%N(PW_s z=_-TaM{SB!w(n7k+dMDN2G6VPqUA$u7F4m@ABAZ1D`*UMfe}E6csJU}J1Tr<mt5uq zm<R6~o-Y~}<3TW)ntXT0iKCxKb!@Vsy)0@`W8@isroO6JhXlWd;`QG_5y`TrVKS}J zM#vCgyJLwYhzWBEN?$BqG4KZwfP0W6m<0h~;-j8=GIOYC+8}OO#P%s5S?)=m$XumX z+L~qp5^y+2$J@m{4kyNz<X94nGsSj!C1A1MMuN|(X&+D{2vc6nI-szonu|T?(sZJe ziCa~iRpl8uoTf<#l0<OOH5GdL0UExsEF?n9`;0T+mm*i%NS~SEy@iyNFD{X!x$3MO zyC`|Slmb;LuRDkbEQnr8hPWgO4QkT@zAc_~o-RNjp}m|bRNQ^}VIcq@+O-Xj9hY{^ zsJGb~)}~*6%|{@<M&kKDB(R$JX*o{_=S>mp#~7hZ5QSGpNvd1Uz$!Rf3q28pgSj9o zx?zwoWa8GYK@TOz^)mp#V2_VR5WfJ0W9BSS<B5!F(AS!r<&y=YUA?EJgLh>bn+cKb z7B9l9)K#s!?PSt;g%c8u;y7rd?hkP%>vq5BY=N>c=98V=+T&RSPgSu|<fv?2d8;cC zr4pKw#lV)<Tkq_5YCd7{?P#Pk-50!|%QFu<OTcce#55Jt8q}xAa3v5qf~C*%1!@zn z_9GYwfYQ(^sKN7U=6*SZt_14U;4^DaN6{G6*AV<S7YYU+t85Tm8#3#it%mkI$_`=m z2`1qoSw#vH;^4d0MA8OK0|gIY^&~v0vF4Rm%zd&%p$SJx*Hc#M9a>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<BcRf)zaWh%S-? zfB*ndqvvA>%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)<m9u(h2)uyC}r#wi2+rI%?d@LFO diff --git a/interface/web/js/yui/treeview/assets/lp.gif b/interface/web/js/yui/treeview/assets/lp.gif deleted file mode 100644 index b87f003154502f8e9f569fefb12d57a5a1ebb515..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 130 zcmZ?wbhEHb6krfz*v!Dt(9rPz|9=MJ08pjkPZmZ721W)QkPeU;3@rKvCp=eAeekN* v_`j$^Uvhd>oPv+$)O9m7&lFF%`-bKA@>z>*#XDKFr20=RDO%adz+epk!mc6H diff --git a/interface/web/js/yui/treeview/assets/lph.gif b/interface/web/js/yui/treeview/assets/lph.gif deleted file mode 100644 index e3478d8e37dadeba8c9d68c84ad29c3b2843a69b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 111 zcmZ?wbhEHb6krfzSj586(9qzWyyp6yrwj}X|Ns97k`SQylZBCifrUW_#09BkU^emC zb!Xj!lRuUA>b}?;FOZ<Y5@*q}<a49?jI=`vr<DaGk4P<6J-vESeB0rJ68$HZ6rG%+ I!oXk+0A+3_V*mgE diff --git a/interface/web/js/yui/treeview/assets/tm.gif b/interface/web/js/yui/treeview/assets/tm.gif deleted file mode 100644 index e30abad8900c51fd87ac22beaafb50abb77f884a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 545 zcmV++0^a>cNk%w1VGsZy1Cav&|Ns90004l1fdBvhA^8LW00093EC2ui01yBm0{{a5 zoR6s{>%SVDN!WWM*c`~(aUUXt+jx}0x_U$Nl_tuVt|Eu@i(%By01AUc;I0@!{*Fpg zbHaSSq>t#++QcfgNN&+P1PjGRs)M{VC)E{p+ns{P<x@JEa);9E@;t;}wFh`6SZHV1 zhX^;gmU#H+7`dqE#)w17X89&riK(XP1UV_%Nt)?t20F)iYWj&vrAoy5>Y55GCCfKT zdutnudlj5Dyj9$F{FNNGJl0(HoBNy=EnH1}ZJdp~t=!H0?Hmr>3p`F;E`5$S&AzVp z{?`tlZe5Rkubt1m@7)jnPh3E9yb6{Yh|XXugzgy9Q&`KPym)~q60+C`qA!W^6**q? znDL-Sb09BaG+A=fNOdVgwOqB*UQB#5_0{Be(_c=2I|cS6C^G26p9zIVB-#+^L!%p& zPJB7bX-BCasfHZNl%!RZTUBOd+0|uOm|ta<rFqt7TAXWjw&nTOXI!9I>mHq3)NWI} zN%=0-tJUw*u~7w2HCz?()w_VfD(3pwYh$yM(N<P_nQdmbo8fkr`<X7|(R)MZB^}sw zU)6t6J7zsNvRK(<VIQ`g8294Rt||An{2Oy{&BHkt_k0|5a?!k-r(S;A`D^H_skfHy j8#{3A!nqUoZX7&v@yf|Fe{McH`t{S(S9gCMeE|SFI+hRt diff --git a/interface/web/js/yui/treeview/assets/tmh.gif b/interface/web/js/yui/treeview/assets/tmh.gif deleted file mode 100644 index ad7e5579378d80b7e89b647d7955844984ae3390..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 563 zcmV-30?hqKNk%w1VGsZy1EK@~*WBexW2^uG0Dypi|Ns900000000000A^8LW000C4 zEC2ui01yBm0{{d6NV?pv<H`9Vy)EdyUjSeT1fCd@&S#FL;JR#N5vqx1E1Tvw!~K{b zL`WPKg|p)&shlvI73fk*c~TeFD<OO3QoT|zRNN#h%|~=mO=KgrQFy~0q+{$;IRjtS z@BLVSMu2=yf?J1$5{hwziI0Me4w7?_j**srlz*6=m!F!MdYgfsp{Apva-@T&psA>< zs&K4`v9z;VwY#}py<fj!!DGW^#b?K9$!p7P&2P85&vnyx)p@V7(Z1Wj-NN6*;l|_0 z<;v&G>CWrW*|_c0@z(R$uJ^F-()E4(hW?AL_0z|Vpf`iy5Q<Ysj-fe+=pd?-$c~~r zeA+C^(@2l_qrH3>;dvYwa^J{*Cj$a(RI*^pgD(@tTsX5~&4)K5=A5{*V$X{pgJ%4> zk!VMwABPGRiIn70lTA@ZRhg3IQ<qm^W|g^>W>=eEafa17mS<U?XMrkR%QS6Kw@2Y7 zZOay_T&H!h=GD5FYhSN_!3GvPm~3IQhtVchOSiGz#cv_Ul|1*cW4)L8X7;-oaA(1v z35Pa38gXgGrx{ybjhVG(*PLN{mJOP=XxpT5o7Rn*x9ZlwUk8spe0K5L$8RUky?l4` z-p_vvpH7^*aqGyjE7#7PyL0c*!Aq}B{(AZB=eMWtzW#gr@bAZ)pO2ot`q>Ep06Pc% BB!B<_ diff --git a/interface/web/js/yui/treeview/assets/tn.gif b/interface/web/js/yui/treeview/assets/tn.gif deleted file mode 100644 index 4a280397de0ae7564f625d9356204a1cb6a1f399..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 504 zcmV<U0SEp^Nk%w1VGsZy1AqYlfPjGi|NkNR1OWg50RSuj0000G03ZVZ0{@JUsRrx6 z8k|qki!8>i2fsz(rj1Z(I%uk_Z1$dUHLJCFC+@t*{rh7DQ$tg6bPOd)Ib9R>WJIOY zC1?7<S}$8lck-20wdAom8m66}Y1_Kl#-YpecP`$dv-NQP-G77UWETinBM4QexJP(s z$n)qE2{b8GNpxwHiL|NI$<zoLDmhA7YI%y8s=3P9>iG(~*cW?M%k^nH`*-V=i`xtK z>l-Y#TUe}i?3nDfEc#3uZ90uwt$NLx?Ya%yEz9_=8%|Cu4t!3WF5E0v&bw~>jvTK% z&s^_(54|tlPyNqYKx_lG736l%TS9Q=7LIEO5uQVI6V+8@m(N{9de0Z-ZN%5n-ba2T z{gniGQeaAgD-E_p_)=j^h7xB!tcjDOO^Q1$_QV)c-%pP@K@JsJlw?wqOHnpe`IKc; zms4R@m3ft>&a5}LdNs<GXIP(OfgTlFmgrZdYnirn`W9+jsdK5;wR#t8UaesFcI^w8 zZD6;9;TD#Am~LXbi}5zr`<Sob$%H8zwu~6FV$F;>JN672wB*X9FPF}IdUNW|t3S66 u{d%<N*{Er&w#^#1Yu&JU%dQRlcJSQ8cNgz{{I~Gs#F-m+jvPAQ0suSPkoRu@ diff --git a/interface/web/js/yui/treeview/assets/tp.gif b/interface/web/js/yui/treeview/assets/tp.gif deleted file mode 100644 index d6d0ed0aed40f3a5ab43dcea1ed5e0ad67e76304..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 539 zcmV+$0_6QiNk%w1VGsZy1Cas%0001hfPnx1{{R30A^8LW00062EC2ui01yBm0{{a5 zl#i(v>%SVDDcF0XR#Je|A>GGlz<CPI3Ld1oc`X-<7)Ir#&cnSP`ayz12eC*)4wXx$ z(fNcXr6Ov@TE*_PM`+jiWrmewWVv`2rhn^RoA(B4x7c{jPQg#~P43+1H^=ud7!`O} z_g7eBwK$b1s3;jpiP$)4N#%G|37ILinf2*~>1le|i8=~as(Px~3Y#jsDi#ZROFE0Y zt6NK!%i1gaYZh!fj9iR%44mw|tk!J&OdZWO&0MX0?UpUQ4c-m+jU8@2E_d#|PTsDb zepk*OpEvJbzjqJ+%A4QU&sRWV1C<qocF<ZvZVSaVME8(hM0^wZxw=TJqP%zP8~+j7 z*HNQAjw3x95~+`5N|TH-V)Ta+;7frs3Dz`t6Jbt;I~n$L_!DAKi9;zCwdgV_%%dTh zmW=sPrA(zXsoJ!P6RS?GJh}Sx3KXnRu|&xlHH&m9+NNutI$a6%<lCug>sGaU6>nC( zTlseN`xS6l!D9)RHGCFv+PjSNHs1TVZ{)v|16Lk=xp3ygn-h0l>^L-J(UM71Hf<R- zX4RTmb9U_+Ht5l`OV>VqJ9X~WyIc2u{X2H>*|v-0Hm(~vZ{@z319vVQI`QMwlUHAU dy?OTM+oN}%ZaqA9@!H9AH}4%ic+3R=06S)30ObGx diff --git a/interface/web/js/yui/treeview/assets/tph.gif b/interface/web/js/yui/treeview/assets/tph.gif deleted file mode 100644 index e4d7d991e44f0ebbe5f05ec261eb831d96332a4e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 568 zcmV-80>}MFNk%w1VGsZy1EK@~*WBexW2^uG0Dypi|Ns900000000000A^8LW000C4 zEC2ui01yBm0{{d6NV?pv<H`9Vy)EdyUjSeT1YRhFr1OC%m}Y<=%Oeq4#2TX|%d4Va zhQq-aA;%<AdBia<&gUd5tyG~`3N^dfa&2F0xZ&lNv*&BNx|X(|Z)RLMPu81ba-MNF z_A!50drO0XT7!gphEs@Oh>H@CVug*84wib4m7AKKl%9&5pQE9md6;~nrKG2-t)^qB zU9PdTVX}#@thKPWwqLl8yS}}^zh=j1$!g1N&2G<d(Q?yt)ppl-#mL*r-OS(4;n3sK z<<#fa>DcSq!^Z7?+4Av#^Y-<E@7(*|{owz^1td4nTtRdP)g@%N(A}zsx*+muNRJ{u zi~1xI!+0qDUq_CNJca}r>0ZW&C?{%!M{?3ielPvS1UOS*O@cQK=0vztVNZrX9j4qE zv|`bVM^CC8$};Ikrz4@36gjo!C6iB?!qh60D^0I9!QvFFlPpiOKG6bID|D$_qHK-E zMLJh0+_z2ZX2rXeZ&$xx0f!YlmT+0aXA!4Wyq0m>yO8rbmOGhlWxJ9i_tpHDb70Sd zK^GQ%m~>*(i%~aL{W!Dh&96Jh{yaN$?a{YO=RUnVb??=`Tf-hMn>cObwvppjuA4b; z=f0r>moB`x_2bu*XJ5X(dH3hvqlce9zB=~v+R<}Y@0~q(_u}D`mv273{q^_T=YMZI G0RTJi9wSr$ diff --git a/interface/web/js/yui/treeview/assets/tree.css b/interface/web/js/yui/treeview/assets/tree.css deleted file mode 100644 index 78222c9f47..0000000000 --- a/interface/web/js/yui/treeview/assets/tree.css +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/* first or middle sibling, no children */ -.ygtvtn { - width:16px; height:22px; - background: url(tn.gif) 0 0 no-repeat; -} - -/* first or middle sibling, collapsable */ -.ygtvtm { - width:16px; height:22px; - cursor:pointer ; - background: url(tm.gif) 0 0 no-repeat; -} - -/* first or middle sibling, collapsable, hover */ -.ygtvtmh { - width:16px; height:22px; - cursor:pointer ; - background: url(tmh.gif) 0 0 no-repeat; -} - -/* first or middle sibling, expandable */ -.ygtvtp { - width:16px; height:22px; - cursor:pointer ; - background: url(tp.gif) 0 0 no-repeat; -} - -/* first or middle sibling, expandable, hover */ -.ygtvtph { - width:16px; height:22px; - cursor:pointer ; - background: url(tph.gif) 0 0 no-repeat; -} - -/* last sibling, no children */ -.ygtvln { - width:16px; height:22px; - background: url(ln.gif) 0 0 no-repeat; -} - -/* Last sibling, collapsable */ -.ygtvlm { - width:16px; height:22px; - cursor:pointer ; - background: url(lm.gif) 0 0 no-repeat; -} - -/* Last sibling, collapsable, hover */ -.ygtvlmh { - width:16px; height:22px; - cursor:pointer ; - background: url(lmh.gif) 0 0 no-repeat; -} - -/* Last sibling, expandable */ -.ygtvlp { - width:16px; height:22px; - cursor:pointer ; - background: url(lp.gif) 0 0 no-repeat; -} - -/* Last sibling, expandable, hover */ -.ygtvlph { - width:16px; height:22px; cursor:pointer ; - background: url(lph.gif) 0 0 no-repeat; -} - -/* Loading icon */ -.ygtvloading { - width:16px; height:22px; - background: url(loading.gif) 0 0 no-repeat; -} - -/* the style for the empty cells that are used for rendering the depth - * of the node */ -.ygtvdepthcell { - width:16px; height:22px; - background: url(vline.gif) 0 0 no-repeat; -} - -.ygtvblankdepthcell { width:16px; height:22px; } - -/* the style of the div around each node */ -.ygtvitem { } - -/* the style of the div around each node's collection of children */ -.ygtvchildren { } -* html .ygtvchildren { height:2%; } - -/* the style of the text label in ygTextNode */ -.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover { - margin-left:2px; - text-decoration: none; -} - -.ygtvspacer { height: 10px; width: 10px; margin: 2px; } diff --git a/interface/web/js/yui/treeview/assets/vline.gif b/interface/web/js/yui/treeview/assets/vline.gif deleted file mode 100644 index 1fb0de8bb2911a51ff29f91fe7d231c0a5529091..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 503 zcmV<T0SNv_Nk%w1VGsZy1AqYlfPjGi|NkNR1OWg50RSuj0000G03ZVZ0{@JUsRrx6 z8k|qki!8=^)9yiF=!~Rdo|!tOY~Zr7I-fOphq<?JJ@={vOT$PJbxiy&%TIFkWJIOY zW@`$=T1DD!)f?RkzvM9ZDJGWD=VaQrcDIjjWSl-P)|L6;9%^={*BA76U`Q3H$R_AV z_=1?#SokPYNpoqFiL<HG$@A$G3N#5h%5>^fYPpKps`<(p>p2TrD|$=1D3^=ctGbK# zdo|2eJQh57td{J!4A)HgY!_`h&36sRSk21q>J1AnD^5#pYmSSqyUot4?)whhE*wu> zZ+wqDubj`k@7xdCKWPD}4YXDeTS9H_4t8_+4PrQn<0zK1cn)Jajn3;DdZfn@UPyT# z`Hi%95?@MvB>}GV*OK5%fiV%zG+6Ut&WJlF_N@5xV$h63Hx}&(@~B9qB$GNd$rNQ& zl~Y+hby*eWRhe07ZnfDJ=U1I$d6xBg7HC?bYl*fs`W7kFxJ&6aor@Q%U8#Gi_O+Uq z>tC&b!4CFXm~3LRi_tb#`<QKHx0B&kmaF%2UCnnhdlt-@Z)m@x0e?1Jn(%4Gs~NX; t{2Fp>$+IcfwtO2i=-iumcis&gwQteGNf$RAoON>7%V9T{{hW3I06UMq^ke`4 diff --git a/interface/web/js/yui/treeview/treeview-debug.js b/interface/web/js/yui/treeview/treeview-debug.js deleted file mode 100644 index 695d29f8f6..0000000000 --- a/interface/web/js/yui/treeview/treeview-debug.js +++ /dev/null @@ -1,2287 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The treeview widget is a generic tree building tool. - * @module treeview - * @title TreeView Widget - * @requires yahoo, event - * @optional animation - * @namespace YAHOO.widget - */ - -/** - * Contains the tree view state data and the root node. - * - * @class TreeView - * @uses YAHOO.util.EventProvider - * @constructor - * @param {string|HTMLElement} id The id of the element, or the element - * itself that the tree will be inserted into. - */ -YAHOO.widget.TreeView = function(id) { - if (id) { this.init(id); } -}; - -YAHOO.widget.TreeView.prototype = { - - /** - * The id of tree container element - * @property id - * @type String - */ - id: null, - - /** - * The host element for this tree - * @property _el - * @private - */ - _el: null, - - /** - * Flat collection of all nodes in this tree. This is a sparse - * array, so the length property can't be relied upon for a - * node count for the tree. - * @property _nodes - * @type Node[] - * @private - */ - _nodes: null, - - /** - * We lock the tree control while waiting for the dynamic loader to return - * @property locked - * @type boolean - */ - locked: false, - - /** - * The animation to use for expanding children, if any - * @property _expandAnim - * @type string - * @private - */ - _expandAnim: null, - - /** - * The animation to use for collapsing children, if any - * @property _collapseAnim - * @type string - * @private - */ - _collapseAnim: null, - - /** - * The current number of animations that are executing - * @property _animCount - * @type int - * @private - */ - _animCount: 0, - - /** - * The maximum number of animations to run at one time. - * @property maxAnim - * @type int - */ - maxAnim: 2, - - /** - * Sets up the animation for expanding children - * @method setExpandAnim - * @param {string} type the type of animation (acceptable values defined - * in YAHOO.widget.TVAnim) - */ - setExpandAnim: function(type) { - if (YAHOO.widget.TVAnim.isValid(type)) { - this._expandAnim = type; - } - }, - - /** - * Sets up the animation for collapsing children - * @method setCollapseAnim - * @param {string} the type of animation (acceptable values defined in - * YAHOO.widget.TVAnim) - */ - setCollapseAnim: function(type) { - if (YAHOO.widget.TVAnim.isValid(type)) { - this._collapseAnim = type; - } - }, - - /** - * Perform the expand animation if configured, or just show the - * element if not configured or too many animations are in progress - * @method animateExpand - * @param el {HTMLElement} the element to animate - * @param node {YAHOO.util.Node} the node that was expanded - * @return {boolean} true if animation could be invoked, false otherwise - */ - animateExpand: function(el, node) { - this.logger.log("animating expand"); - - if (this._expandAnim && this._animCount < this.maxAnim) { - // this.locked = true; - var tree = this; - var a = YAHOO.widget.TVAnim.getAnim(this._expandAnim, el, - function() { tree.expandComplete(node); }); - if (a) { - ++this._animCount; - this.fireEvent("animStart", { - "node": node, - "type": "expand" - }); - a.animate(); - } - - return true; - } - - return false; - }, - - /** - * Perform the collapse animation if configured, or just show the - * element if not configured or too many animations are in progress - * @method animateCollapse - * @param el {HTMLElement} the element to animate - * @param node {YAHOO.util.Node} the node that was expanded - * @return {boolean} true if animation could be invoked, false otherwise - */ - animateCollapse: function(el, node) { - this.logger.log("animating collapse"); - - if (this._collapseAnim && this._animCount < this.maxAnim) { - // this.locked = true; - var tree = this; - var a = YAHOO.widget.TVAnim.getAnim(this._collapseAnim, el, - function() { tree.collapseComplete(node); }); - if (a) { - ++this._animCount; - this.fireEvent("animStart", { - "node": node, - "type": "collapse" - }); - a.animate(); - } - - return true; - } - - return false; - }, - - /** - * Function executed when the expand animation completes - * @method expandComplete - */ - expandComplete: function(node) { - this.logger.log("expand complete: " + this.id); - --this._animCount; - this.fireEvent("animComplete", { - "node": node, - "type": "expand" - }); - // this.locked = false; - }, - - /** - * Function executed when the collapse animation completes - * @method collapseComplete - */ - collapseComplete: function(node) { - this.logger.log("collapse complete: " + this.id); - --this._animCount; - this.fireEvent("animComplete", { - "node": node, - "type": "collapse" - }); - // this.locked = false; - }, - - /** - * Initializes the tree - * @method init - * @parm {string|HTMLElement} id the id of the element that will hold the tree - * @private - */ - init: function(id) { - - this.id = id; - - if ("string" !== typeof id) { - this._el = id; - this.id = this.generateId(id); - } - - /** - * When animation is enabled, this event fires when the animation - * starts - * @event animStart - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that is expanding/collapsing - * @parm {String} type the type of animation ("expand" or "collapse") - */ - this.createEvent("animStart", this); - - /** - * When animation is enabled, this event fires when the animation - * completes - * @event animComplete - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that is expanding/collapsing - * @parm {String} type the type of animation ("expand" or "collapse") - */ - this.createEvent("animComplete", this); - - /** - * Fires when a node is going to be collapsed. Return false to stop - * the collapse. - * @event collapse - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that is collapsing - */ - this.createEvent("collapse", this); - - /** - * Fires after a node is successfully collapsed. This event will not fire - * if the "collapse" event was cancelled. - * @event collapseComplete - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that was collapsed - */ - this.createEvent("collapseComplete", this); - - /** - * Fires when a node is going to be expanded. Return false to stop - * the collapse. - * @event expand - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that is expanding - */ - this.createEvent("expand", this); - - /** - * Fires after a node is successfully expanded. This event will not fire - * if the "expand" event was cancelled. - * @event expandComplete - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that was expanded - */ - this.createEvent("expandComplete", this); - - this._nodes = []; - - // store a global reference - YAHOO.widget.TreeView.trees[this.id] = this; - - // Set up the root node - this.root = new YAHOO.widget.RootNode(this); - - this.logger = new YAHOO.widget.LogWriter(this.toString()); - - this.logger.log("tree init: " + this.id); - - //YAHOO.util.Event.onContentReady(this.id, this.handleAvailable, this, true); - YAHOO.util.Event.on(this.id, "click", this.handleClick, this, true); - }, - - - //handleAvailable: function() { - //var Event = YAHOO.util.Event; - //Event.on(this.id, - //}, - - /** - * Renders the tree boilerplate and visible nodes - * @method draw - */ - draw: function() { - var html = this.root.getHtml(); - this.getEl().innerHTML = html; - this.firstDraw = false; - }, - - /** - * Returns the tree's host element - * @method getEl - * @return {HTMLElement} the host element - */ - getEl: function() { - if (! this._el) { - this._el = document.getElementById(this.id); - } - return this._el; - }, - - /** - * Nodes register themselves with the tree instance when they are created. - * @method regNode - * @param node {Node} the node to register - * @private - */ - regNode: function(node) { - this._nodes[node.index] = node; - }, - - /** - * Returns the root node of this tree - * @method getRoot - * @return {Node} the root node - */ - getRoot: function() { - return this.root; - }, - - /** - * Configures this tree to dynamically load all child data - * @method setDynamicLoad - * @param {function} fnDataLoader the function that will be called to get the data - * @param iconMode {int} configures the icon that is displayed when a dynamic - * load node is expanded the first time without children. By default, the - * "collapse" icon will be used. If set to 1, the leaf node icon will be - * displayed. - */ - setDynamicLoad: function(fnDataLoader, iconMode) { - this.root.setDynamicLoad(fnDataLoader, iconMode); - }, - - /** - * Expands all child nodes. Note: this conflicts with the "multiExpand" - * node property. If expand all is called in a tree with nodes that - * do not allow multiple siblings to be displayed, only the last sibling - * will be expanded. - * @method expandAll - */ - expandAll: function() { - if (!this.locked) { - this.root.expandAll(); - } - }, - - /** - * Collapses all expanded child nodes in the entire tree. - * @method collapseAll - */ - collapseAll: function() { - if (!this.locked) { - this.root.collapseAll(); - } - }, - - /** - * Returns a node in the tree that has the specified index (this index - * is created internally, so this function probably will only be used - * in html generated for a given node.) - * @method getNodeByIndex - * @param {int} nodeIndex the index of the node wanted - * @return {Node} the node with index=nodeIndex, null if no match - */ - getNodeByIndex: function(nodeIndex) { - var n = this._nodes[nodeIndex]; - return (n) ? n : null; - }, - - /** - * Returns a node that has a matching property and value in the data - * object that was passed into its constructor. - * @method getNodeByProperty - * @param {object} property the property to search (usually a string) - * @param {object} value the value we want to find (usuall an int or string) - * @return {Node} the matching node, null if no match - */ - getNodeByProperty: function(property, value) { - for (var i in this._nodes) { - var n = this._nodes[i]; - if (n.data && value == n.data[property]) { - return n; - } - } - - return null; - }, - - /** - * Returns a collection of nodes that have a matching property - * and value in the data object that was passed into its constructor. - * @method getNodesByProperty - * @param {object} property the property to search (usually a string) - * @param {object} value the value we want to find (usuall an int or string) - * @return {Array} the matching collection of nodes, null if no match - */ - getNodesByProperty: function(property, value) { - var values = []; - for (var i in this._nodes) { - var n = this._nodes[i]; - if (n.data && value == n.data[property]) { - values.push(n); - } - } - - return (values.length) ? values : null; - }, - - /** - * Removes the node and its children, and optionally refreshes the - * branch of the tree that was affected. - * @method removeNode - * @param {Node} The node to remove - * @param {boolean} autoRefresh automatically refreshes branch if true - * @return {boolean} False is there was a problem, true otherwise. - */ - removeNode: function(node, autoRefresh) { - - // Don't delete the root node - if (node.isRoot()) { - return false; - } - - // Get the branch that we may need to refresh - var p = node.parent; - if (p.parent) { - p = p.parent; - } - - // Delete the node and its children - this._deleteNode(node); - - // Refresh the parent of the parent - if (autoRefresh && p && p.childrenRendered) { - p.refresh(); - } - - return true; - }, - - /** - * Deletes this nodes child collection, recursively. Also collapses - * the node, and resets the dynamic load flag. The primary use for - * this method is to purge a node and allow it to fetch its data - * dynamically again. - * @method removeChildren - * @param {Node} node the node to purge - */ - removeChildren: function(node) { - this.logger.log("Removing children for " + node); - while (node.children.length) { - this._deleteNode(node.children[0]); - } - - node.childrenRendered = false; - node.dynamicLoadComplete = false; - if (node.expanded) { - node.collapse(); - } else { - node.updateIcon(); - } - }, - - /** - * Deletes the node and recurses children - * @method _deleteNode - * @private - */ - _deleteNode: function(node) { - // Remove all the child nodes first - this.removeChildren(node); - - // Remove the node from the tree - this.popNode(node); - }, - - /** - * Removes the node from the tree, preserving the child collection - * to make it possible to insert the branch into another part of the - * tree, or another tree. - * @method popNode - * @param {Node} the node to remove - */ - popNode: function(node) { - var p = node.parent; - - // Update the parent's collection of children - var a = []; - - for (var i=0, len=p.children.length;i<len;++i) { - if (p.children[i] != node) { - a[a.length] = p.children[i]; - } - } - - p.children = a; - - // reset the childrenRendered flag for the parent - p.childrenRendered = false; - - // Update the sibling relationship - if (node.previousSibling) { - node.previousSibling.nextSibling = node.nextSibling; - } - - if (node.nextSibling) { - node.nextSibling.previousSibling = node.previousSibling; - } - - node.parent = null; - node.previousSibling = null; - node.nextSibling = null; - node.tree = null; - - // Update the tree's node collection - delete this._nodes[node.index]; - }, - - - /** - * TreeView instance toString - * @method toString - * @return {string} string representation of the tree - */ - toString: function() { - return "TreeView " + this.id; - }, - - /** - * Generates an unique id for an element if it doesn't yet have one - * @method generateId - * @private - */ - generateId: function(el) { - var id = el.id; - - if (!id) { - id = "yui-tv-auto-id-" + YAHOO.widget.TreeView.counter; - ++YAHOO.widget.TreeView.counter; - } - - return id; - }, - - /** - * Abstract method that is executed when a node is expanded - * @method onExpand - * @param node {Node} the node that was expanded - * @deprecated use treeobj.subscribe("expand") instead - */ - onExpand: function(node) { }, - - /** - * Abstract method that is executed when a node is collapsed. - * @method onCollapse - * @param node {Node} the node that was collapsed. - * @deprecated use treeobj.subscribe("collapse") instead - */ - onCollapse: function(node) { } - -}; - -YAHOO.augment(YAHOO.widget.TreeView, YAHOO.util.EventProvider); - -/** - * Running count of all nodes created in all trees. This is - * used to provide unique identifies for all nodes. Deleting - * nodes does not change the nodeCount. - * @property YAHOO.widget.TreeView.nodeCount - * @type int - * @static - */ -YAHOO.widget.TreeView.nodeCount = 0; - -/** - * Global cache of tree instances - * @property YAHOO.widget.TreeView.trees - * @type Array - * @static - * @private - */ -YAHOO.widget.TreeView.trees = []; - -/** - * Counter for generating a new unique element id - * @property YAHOO.widget.TreeView.counter - * @static - * @private - */ -YAHOO.widget.TreeView.counter = 0; - -/** - * Global method for getting a tree by its id. Used in the generated - * tree html. - * @method YAHOO.widget.TreeView.getTree - * @param treeId {String} the id of the tree instance - * @return {TreeView} the tree instance requested, null if not found. - * @static - */ -YAHOO.widget.TreeView.getTree = function(treeId) { - var t = YAHOO.widget.TreeView.trees[treeId]; - return (t) ? t : null; -}; - - -/** - * Global method for getting a node by its id. Used in the generated - * tree html. - * @method YAHOO.widget.TreeView.getNode - * @param treeId {String} the id of the tree instance - * @param nodeIndex {String} the index of the node to return - * @return {Node} the node instance requested, null if not found - * @static - */ -YAHOO.widget.TreeView.getNode = function(treeId, nodeIndex) { - var t = YAHOO.widget.TreeView.getTree(treeId); - return (t) ? t.getNodeByIndex(nodeIndex) : null; -}; - -/** - * Add a DOM event - * @method YAHOO.widget.TreeView.addHandler - * @param el the elment to bind the handler to - * @param {string} sType the type of event handler - * @param {function} fn the callback to invoke - * @static - */ -YAHOO.widget.TreeView.addHandler = function (el, sType, fn) { - if (el.addEventListener) { - el.addEventListener(sType, fn, false); - } else if (el.attachEvent) { - el.attachEvent("on" + sType, fn); - } -}; - -/** - * Remove a DOM event - * @method YAHOO.widget.TreeView.removeHandler - * @param el the elment to bind the handler to - * @param {string} sType the type of event handler - * @param {function} fn the callback to invoke - * @static - */ - -YAHOO.widget.TreeView.removeHandler = function (el, sType, fn) { - if (el.removeEventListener) { - el.removeEventListener(sType, fn, false); - } else if (el.detachEvent) { - el.detachEvent("on" + sType, fn); - } -}; - -/** - * Attempts to preload the images defined in the styles used to draw the tree by - * rendering off-screen elements that use the styles. - * @method YAHOO.widget.TreeView.preload - * @param {string} prefix the prefix to use to generate the names of the - * images to preload, default is ygtv - * @static - */ -YAHOO.widget.TreeView.preload = function(prefix) { - prefix = prefix || "ygtv"; - var styles = ["tn","tm","tmh","tp","tph","ln","lm","lmh","lp","lph","loading"]; - - var sb = []; - - for (var i = 0; i < styles.length; ++i) { - sb[sb.length] = '<span class="' + prefix + styles[i] + '"> </span>'; - } - - var f = document.createElement("div"); - var s = f.style; - s.position = "absolute"; - s.top = "-1000px"; - s.left = "-1000px"; - f.innerHTML = sb.join(""); - - document.body.appendChild(f); - - YAHOO.widget.TreeView.removeHandler(window, - "load", YAHOO.widget.TreeView.preload); - -}; - -YAHOO.widget.TreeView.addHandler(window, - "load", YAHOO.widget.TreeView.preload); - -/** - * The base class for all tree nodes. The node's presentation and behavior in - * response to mouse events is handled in Node subclasses. - * @namespace YAHOO.widget - * @class Node - * @uses YAHOO.util.EventProvider - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - * @constructor - */ -YAHOO.widget.Node = function(oData, oParent, expanded) { - if (oData) { this.init(oData, oParent, expanded); } -}; - -YAHOO.widget.Node.prototype = { - - /** - * The index for this instance obtained from global counter in YAHOO.widget.TreeView. - * @property index - * @type int - */ - index: 0, - - /** - * This node's child node collection. - * @property children - * @type Node[] - */ - children: null, - - /** - * Tree instance this node is part of - * @property tree - * @type TreeView - */ - tree: null, - - /** - * The data linked to this node. This can be any object or primitive - * value, and the data can be used in getNodeHtml(). - * @property data - * @type object - */ - data: null, - - /** - * Parent node - * @property parent - * @type Node - */ - parent: null, - - /** - * The depth of this node. We start at -1 for the root node. - * @property depth - * @type int - */ - depth: -1, - - /** - * The href for the node's label. If one is not specified, the href will - * be set so that it toggles the node. - * @property href - * @type string - */ - href: null, - - /** - * The label href target, defaults to current window - * @property target - * @type string - */ - target: "_self", - - /** - * The node's expanded/collapsed state - * @property expanded - * @type boolean - */ - expanded: false, - - /** - * Can multiple children be expanded at once? - * @property multiExpand - * @type boolean - */ - multiExpand: true, - - /** - * Should we render children for a collapsed node? It is possible that the - * implementer will want to render the hidden data... @todo verify that we - * need this, and implement it if we do. - * @property renderHidden - * @type boolean - */ - renderHidden: false, - - /** - * This flag is set to true when the html is generated for this node's - * children, and set to false when new children are added. - * @property childrenRendered - * @type boolean - */ - childrenRendered: false, - - /** - * Dynamically loaded nodes only fetch the data the first time they are - * expanded. This flag is set to true once the data has been fetched. - * @property dynamicLoadComplete - * @type boolean - */ - dynamicLoadComplete: false, - - /** - * This node's previous sibling - * @property previousSibling - * @type Node - */ - previousSibling: null, - - /** - * This node's next sibling - * @property nextSibling - * @type Node - */ - nextSibling: null, - - /** - * We can set the node up to call an external method to get the child - * data dynamically. - * @property _dynLoad - * @type boolean - * @private - */ - _dynLoad: false, - - /** - * Function to execute when we need to get this node's child data. - * @property dataLoader - * @type function - */ - dataLoader: null, - - /** - * This is true for dynamically loading nodes while waiting for the - * callback to return. - * @property isLoading - * @type boolean - */ - isLoading: false, - - /** - * The toggle/branch icon will not show if this is set to false. This - * could be useful if the implementer wants to have the child contain - * extra info about the parent, rather than an actual node. - * @property hasIcon - * @type boolean - */ - hasIcon: true, - - /** - * Used to configure what happens when a dynamic load node is expanded - * and we discover that it does not have children. By default, it is - * treated as if it still could have children (plus/minus icon). Set - * iconMode to have it display like a leaf node instead. - * @property iconMode - * @type int - */ - iconMode: 0, - - /** - * Specifies whether or not the content area of the node should be allowed - * to wrap. - * @property nowrap - * @type boolean - * @default true - */ - nowrap: false, - - /** - * The node type - * @property _type - * @private - */ - _type: "Node", - - /* - spacerPath: "http://us.i1.yimg.com/us.yimg.com/i/space.gif", - expandedText: "Expanded", - collapsedText: "Collapsed", - loadingText: "Loading", - */ - - /** - * Initializes this node, gets some of the properties from the parent - * @method init - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - */ - init: function(oData, oParent, expanded) { - - this.data = oData; - this.children = []; - this.index = YAHOO.widget.TreeView.nodeCount; - ++YAHOO.widget.TreeView.nodeCount; - this.expanded = expanded; - this.logger = new YAHOO.widget.LogWriter(this.toString()); - - /** - * The parentChange event is fired when a parent element is applied - * to the node. This is useful if you need to apply tree-level - * properties to a tree that need to happen if a node is moved from - * one tree to another. - * - * @event parentChange - * @type CustomEvent - */ - this.createEvent("parentChange", this); - - // oParent should never be null except when we create the root node. - if (oParent) { - oParent.appendChild(this); - } - }, - - /** - * Certain properties for the node cannot be set until the parent - * is known. This is called after the node is inserted into a tree. - * the parent is also applied to this node's children in order to - * make it possible to move a branch from one tree to another. - * @method applyParent - * @param {Node} parentNode this node's parent node - * @return {boolean} true if the application was successful - */ - applyParent: function(parentNode) { - if (!parentNode) { - return false; - } - - this.tree = parentNode.tree; - this.parent = parentNode; - this.depth = parentNode.depth + 1; - - if (!this.href) { - this.href = "javascript:" + this.getToggleLink(); - } - - // @todo why was this put here. This causes new nodes added at the - // root level to lose the menu behavior. - // if (! this.multiExpand) { - // this.multiExpand = parentNode.multiExpand; - // } - - this.tree.regNode(this); - parentNode.childrenRendered = false; - - // cascade update existing children - for (var i=0, len=this.children.length;i<len;++i) { - this.children[i].applyParent(this); - } - - this.fireEvent("parentChange"); - - return true; - }, - - /** - * Appends a node to the child collection. - * @method appendChild - * @param childNode {Node} the new node - * @return {Node} the child node - * @private - */ - appendChild: function(childNode) { - if (this.hasChildren()) { - var sib = this.children[this.children.length - 1]; - sib.nextSibling = childNode; - childNode.previousSibling = sib; - } - this.children[this.children.length] = childNode; - childNode.applyParent(this); - - return childNode; - }, - - /** - * Appends this node to the supplied node's child collection - * @method appendTo - * @param parentNode {Node} the node to append to. - * @return {Node} The appended node - */ - appendTo: function(parentNode) { - return parentNode.appendChild(this); - }, - - /** - * Inserts this node before this supplied node - * @method insertBefore - * @param node {Node} the node to insert this node before - * @return {Node} the inserted node - */ - insertBefore: function(node) { - this.logger.log("insertBefore: " + node); - var p = node.parent; - if (p) { - - if (this.tree) { - this.tree.popNode(this); - } - - var refIndex = node.isChildOf(p); - //this.logger.log(refIndex); - p.children.splice(refIndex, 0, this); - if (node.previousSibling) { - node.previousSibling.nextSibling = this; - } - this.previousSibling = node.previousSibling; - this.nextSibling = node; - node.previousSibling = this; - - this.applyParent(p); - } - - return this; - }, - - /** - * Inserts this node after the supplied node - * @method insertAfter - * @param node {Node} the node to insert after - * @return {Node} the inserted node - */ - insertAfter: function(node) { - this.logger.log("insertAfter: " + node); - var p = node.parent; - if (p) { - - if (this.tree) { - this.tree.popNode(this); - } - - var refIndex = node.isChildOf(p); - this.logger.log(refIndex); - - if (!node.nextSibling) { - this.nextSibling = null; - return this.appendTo(p); - } - - p.children.splice(refIndex + 1, 0, this); - - node.nextSibling.previousSibling = this; - this.previousSibling = node; - this.nextSibling = node.nextSibling; - node.nextSibling = this; - - this.applyParent(p); - } - - return this; - }, - - /** - * Returns true if the Node is a child of supplied Node - * @method isChildOf - * @param parentNode {Node} the Node to check - * @return {boolean} The node index if this Node is a child of - * supplied Node, else -1. - * @private - */ - isChildOf: function(parentNode) { - if (parentNode && parentNode.children) { - for (var i=0, len=parentNode.children.length; i<len ; ++i) { - if (parentNode.children[i] === this) { - return i; - } - } - } - - return -1; - }, - - /** - * Returns a node array of this node's siblings, null if none. - * @method getSiblings - * @return Node[] - */ - getSiblings: function() { - return this.parent.children; - }, - - /** - * Shows this node's children - * @method showChildren - */ - showChildren: function() { - if (!this.tree.animateExpand(this.getChildrenEl(), this)) { - if (this.hasChildren()) { - this.getChildrenEl().style.display = ""; - } - } - }, - - /** - * Hides this node's children - * @method hideChildren - */ - hideChildren: function() { - this.logger.log("hiding " + this.index); - - if (!this.tree.animateCollapse(this.getChildrenEl(), this)) { - this.getChildrenEl().style.display = "none"; - } - }, - - /** - * Returns the id for this node's container div - * @method getElId - * @return {string} the element id - */ - getElId: function() { - return "ygtv" + this.index; - }, - - /** - * Returns the id for this node's children div - * @method getChildrenElId - * @return {string} the element id for this node's children div - */ - getChildrenElId: function() { - return "ygtvc" + this.index; - }, - - /** - * Returns the id for this node's toggle element - * @method getToggleElId - * @return {string} the toggel element id - */ - getToggleElId: function() { - return "ygtvt" + this.index; - }, - - - /* - * Returns the id for this node's spacer image. The spacer is positioned - * over the toggle and provides feedback for screen readers. - * @method getSpacerId - * @return {string} the id for the spacer image - */ - /* - getSpacerId: function() { - return "ygtvspacer" + this.index; - }, - */ - - /** - * Returns this node's container html element - * @method getEl - * @return {HTMLElement} the container html element - */ - getEl: function() { - return document.getElementById(this.getElId()); - }, - - /** - * Returns the div that was generated for this node's children - * @method getChildrenEl - * @return {HTMLElement} this node's children div - */ - getChildrenEl: function() { - return document.getElementById(this.getChildrenElId()); - }, - - /** - * Returns the element that is being used for this node's toggle. - * @method getToggleEl - * @return {HTMLElement} this node's toggle html element - */ - getToggleEl: function() { - return document.getElementById(this.getToggleElId()); - }, - - /* - * Returns the element that is being used for this node's spacer. - * @method getSpacer - * @return {HTMLElement} this node's spacer html element - */ - /* - getSpacer: function() { - return document.getElementById( this.getSpacerId() ) || {}; - }, - */ - - /* - getStateText: function() { - if (this.isLoading) { - return this.loadingText; - } else if (this.hasChildren(true)) { - if (this.expanded) { - return this.expandedText; - } else { - return this.collapsedText; - } - } else { - return ""; - } - }, - */ - - /** - * Generates the link that will invoke this node's toggle method - * @method getToggleLink - * @return {string} the javascript url for toggling this node - */ - getToggleLink: function() { - return "YAHOO.widget.TreeView.getNode(\'" + this.tree.id + "\'," + - this.index + ").toggle()"; - }, - - /** - * Hides this nodes children (creating them if necessary), changes the - * @method collapse - * toggle style. - */ - collapse: function() { - // Only collapse if currently expanded - if (!this.expanded) { return; } - - // fire the collapse event handler - var ret = this.tree.onCollapse(this); - - if (false === ret) { - this.logger.log("Collapse was stopped by the abstract onCollapse"); - return; - } - - ret = this.tree.fireEvent("collapse", this); - - if (false === ret) { - this.logger.log("Collapse was stopped by a custom event handler"); - return; - } - - - if (!this.getEl()) { - this.expanded = false; - } else { - // hide the child div - this.hideChildren(); - this.expanded = false; - - this.updateIcon(); - } - - // this.getSpacer().title = this.getStateText(); - - ret = this.tree.fireEvent("collapseComplete", this); - - }, - - /** - * Shows this nodes children (creating them if necessary), changes the - * toggle style, and collapses its siblings if multiExpand is not set. - * @method expand - */ - expand: function() { - // Only expand if currently collapsed. - if (this.expanded) { return; } - - // fire the expand event handler - var ret = this.tree.onExpand(this); - - if (false === ret) { - this.logger.log("Expand was stopped by the abstract onExpand"); - return; - } - - ret = this.tree.fireEvent("expand", this); - - if (false === ret) { - this.logger.log("Expand was stopped by the custom event handler"); - return; - } - - if (!this.getEl()) { - this.expanded = true; - return; - } - - if (! this.childrenRendered) { - this.logger.log("children not rendered yet"); - this.getChildrenEl().innerHTML = this.renderChildren(); - } else { - this.logger.log("CHILDREN RENDERED"); - } - - this.expanded = true; - - this.updateIcon(); - - // this.getSpacer().title = this.getStateText(); - - // We do an extra check for children here because the lazy - // load feature can expose nodes that have no children. - - // if (!this.hasChildren()) { - if (this.isLoading) { - this.expanded = false; - return; - } - - if (! this.multiExpand) { - var sibs = this.getSiblings(); - for (var i=0; i<sibs.length; ++i) { - if (sibs[i] != this && sibs[i].expanded) { - sibs[i].collapse(); - } - } - } - - this.showChildren(); - - ret = this.tree.fireEvent("expandComplete", this); - }, - - updateIcon: function() { - if (this.hasIcon) { - var el = this.getToggleEl(); - if (el) { - el.className = this.getStyle(); - } - } - }, - - /** - * Returns the css style name for the toggle - * @method getStyle - * @return {string} the css class for this node's toggle - */ - getStyle: function() { - // this.logger.log("No children, " + " isDyanmic: " + this.isDynamic() + " expanded: " + this.expanded); - if (this.isLoading) { - this.logger.log("returning the loading icon"); - return "ygtvloading"; - } else { - // location top or bottom, middle nodes also get the top style - var loc = (this.nextSibling) ? "t" : "l"; - - // type p=plus(expand), m=minus(collapase), n=none(no children) - var type = "n"; - if (this.hasChildren(true) || (this.isDynamic() && !this.getIconMode())) { - // if (this.hasChildren(true)) { - type = (this.expanded) ? "m" : "p"; - } - - // this.logger.log("ygtv" + loc + type); - return "ygtv" + loc + type; - } - }, - - /** - * Returns the hover style for the icon - * @return {string} the css class hover state - * @method getHoverStyle - */ - getHoverStyle: function() { - var s = this.getStyle(); - if (this.hasChildren(true) && !this.isLoading) { - s += "h"; - } - return s; - }, - - /** - * Recursively expands all of this node's children. - * @method expandAll - */ - expandAll: function() { - for (var i=0;i<this.children.length;++i) { - var c = this.children[i]; - if (c.isDynamic()) { - alert("Not supported (lazy load + expand all)"); - break; - } else if (! c.multiExpand) { - alert("Not supported (no multi-expand + expand all)"); - break; - } else { - c.expand(); - c.expandAll(); - } - } - }, - - /** - * Recursively collapses all of this node's children. - * @method collapseAll - */ - collapseAll: function() { - for (var i=0;i<this.children.length;++i) { - this.children[i].collapse(); - this.children[i].collapseAll(); - } - }, - - /** - * Configures this node for dynamically obtaining the child data - * when the node is first expanded. Calling it without the callback - * will turn off dynamic load for the node. - * @method setDynamicLoad - * @param fmDataLoader {function} the function that will be used to get the data. - * @param iconMode {int} configures the icon that is displayed when a dynamic - * load node is expanded the first time without children. By default, the - * "collapse" icon will be used. If set to 1, the leaf node icon will be - * displayed. - */ - setDynamicLoad: function(fnDataLoader, iconMode) { - if (fnDataLoader) { - this.dataLoader = fnDataLoader; - this._dynLoad = true; - } else { - this.dataLoader = null; - this._dynLoad = false; - } - - if (iconMode) { - this.iconMode = iconMode; - } - }, - - /** - * Evaluates if this node is the root node of the tree - * @method isRoot - * @return {boolean} true if this is the root node - */ - isRoot: function() { - return (this == this.tree.root); - }, - - /** - * Evaluates if this node's children should be loaded dynamically. Looks for - * the property both in this instance and the root node. If the tree is - * defined to load all children dynamically, the data callback function is - * defined in the root node - * @method isDynamic - * @return {boolean} true if this node's children are to be loaded dynamically - */ - isDynamic: function() { - var lazy = (!this.isRoot() && (this._dynLoad || this.tree.root._dynLoad)); - // this.logger.log("isDynamic: " + lazy); - return lazy; - }, - - /** - * Returns the current icon mode. This refers to the way childless dynamic - * load nodes appear. - * @method getIconMode - * @return {int} 0 for collapse style, 1 for leaf node style - */ - getIconMode: function() { - return (this.iconMode || this.tree.root.iconMode); - }, - - /** - * Checks if this node has children. If this node is lazy-loading and the - * children have not been rendered, we do not know whether or not there - * are actual children. In most cases, we need to assume that there are - * children (for instance, the toggle needs to show the expandable - * presentation state). In other times we want to know if there are rendered - * children. For the latter, "checkForLazyLoad" should be false. - * @method hasChildren - * @param checkForLazyLoad {boolean} should we check for unloaded children? - * @return {boolean} true if this has children or if it might and we are - * checking for this condition. - */ - hasChildren: function(checkForLazyLoad) { - return ( this.children.length > 0 || - (checkForLazyLoad && this.isDynamic() && !this.dynamicLoadComplete) ); - }, - - /** - * Expands if node is collapsed, collapses otherwise. - * @method toggle - */ - toggle: function() { - if (!this.tree.locked && ( this.hasChildren(true) || this.isDynamic()) ) { - if (this.expanded) { this.collapse(); } else { this.expand(); } - } - }, - - /** - * Returns the markup for this node and its children. - * @method getHtml - * @return {string} the markup for this node and its expanded children. - */ - getHtml: function() { - - this.childrenRendered = false; - - var sb = []; - sb[sb.length] = '<div class="ygtvitem" id="' + this.getElId() + '">'; - sb[sb.length] = this.getNodeHtml(); - sb[sb.length] = this.getChildrenHtml(); - sb[sb.length] = '</div>'; - return sb.join(""); - }, - - /** - * Called when first rendering the tree. We always build the div that will - * contain this nodes children, but we don't render the children themselves - * unless this node is expanded. - * @method getChildrenHtml - * @return {string} the children container div html and any expanded children - * @private - */ - getChildrenHtml: function() { - - var sb = []; - sb[sb.length] = '<div class="ygtvchildren"'; - sb[sb.length] = ' id="' + this.getChildrenElId() + '"'; - if (!this.expanded) { - sb[sb.length] = ' style="display:none;"'; - } - sb[sb.length] = '>'; - - // Don't render the actual child node HTML unless this node is expanded. - if ( (this.hasChildren(true) && this.expanded) || - (this.renderHidden && !this.isDynamic()) ) { - sb[sb.length] = this.renderChildren(); - } - - sb[sb.length] = '</div>'; - - return sb.join(""); - }, - - /** - * Generates the markup for the child nodes. This is not done until the node - * is expanded. - * @method renderChildren - * @return {string} the html for this node's children - * @private - */ - renderChildren: function() { - - this.logger.log("rendering children for " + this.index); - - var node = this; - - if (this.isDynamic() && !this.dynamicLoadComplete) { - this.isLoading = true; - this.tree.locked = true; - - if (this.dataLoader) { - this.logger.log("Using dynamic loader defined for this node"); - - setTimeout( - function() { - node.dataLoader(node, - function() { - node.loadComplete(); - }); - }, 10); - - } else if (this.tree.root.dataLoader) { - this.logger.log("Using the tree-level dynamic loader"); - - setTimeout( - function() { - node.tree.root.dataLoader(node, - function() { - node.loadComplete(); - }); - }, 10); - - } else { - this.logger.log("no loader found"); - return "Error: data loader not found or not specified."; - } - - return ""; - - } else { - return this.completeRender(); - } - }, - - /** - * Called when we know we have all the child data. - * @method completeRender - * @return {string} children html - */ - completeRender: function() { - this.logger.log("completeRender: " + this.index + ", # of children: " + this.children.length); - var sb = []; - - for (var i=0; i < this.children.length; ++i) { - // this.children[i].childrenRendered = false; - sb[sb.length] = this.children[i].getHtml(); - } - - this.childrenRendered = true; - - return sb.join(""); - }, - - /** - * Load complete is the callback function we pass to the data provider - * in dynamic load situations. - * @method loadComplete - */ - loadComplete: function() { - this.logger.log("loadComplete: " + this.index); - this.getChildrenEl().innerHTML = this.completeRender(); - this.dynamicLoadComplete = true; - this.isLoading = false; - this.expand(); - this.tree.locked = false; - }, - - /** - * Returns this node's ancestor at the specified depth. - * @method getAncestor - * @param {int} depth the depth of the ancestor. - * @return {Node} the ancestor - */ - getAncestor: function(depth) { - if (depth >= this.depth || depth < 0) { - this.logger.log("illegal getAncestor depth: " + depth); - return null; - } - - var p = this.parent; - - while (p.depth > depth) { - p = p.parent; - } - - return p; - }, - - /** - * Returns the css class for the spacer at the specified depth for - * this node. If this node's ancestor at the specified depth - * has a next sibling the presentation is different than if it - * does not have a next sibling - * @method getDepthStyle - * @param {int} depth the depth of the ancestor. - * @return {string} the css class for the spacer - */ - getDepthStyle: function(depth) { - return (this.getAncestor(depth).nextSibling) ? - "ygtvdepthcell" : "ygtvblankdepthcell"; - }, - - /** - * Get the markup for the node. This is designed to be overrided so that we can - * support different types of nodes. - * @method getNodeHtml - * @return {string} The HTML that will render this node. - */ - getNodeHtml: function() { - this.logger.log("Generating html"); - return ""; - }, - - /** - * Regenerates the html for this node and its children. To be used when the - * node is expanded and new children have been added. - * @method refresh - */ - refresh: function() { - // this.loadComplete(); - this.getChildrenEl().innerHTML = this.completeRender(); - - if (this.hasIcon) { - var el = this.getToggleEl(); - if (el) { - el.className = this.getStyle(); - } - } - }, - - /** - * Node toString - * @method toString - * @return {string} string representation of the node - */ - toString: function() { - return "Node (" + this.index + ")"; - } - -}; - -YAHOO.augment(YAHOO.widget.Node, YAHOO.util.EventProvider); - -/** - * The default node presentation. The first parameter should be - * either a string that will be used as the node's label, or an object - * that has a string propery called label. By default, the clicking the - * label will toggle the expanded/collapsed state of the node. By - * changing the href property of the instance, this behavior can be - * changed so that the label will go to the specified href. - * @namespace YAHOO.widget - * @class TextNode - * @extends YAHOO.widget.Node - * @constructor - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {YAHOO.widget.Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - */ -YAHOO.widget.TextNode = function(oData, oParent, expanded) { - - if (oData) { - this.init(oData, oParent, expanded); - this.setUpLabel(oData); - } - - this.logger = new YAHOO.widget.LogWriter(this.toString()); -}; - -YAHOO.extend(YAHOO.widget.TextNode, YAHOO.widget.Node, { - - /** - * The CSS class for the label href. Defaults to ygtvlabel, but can be - * overridden to provide a custom presentation for a specific node. - * @property labelStyle - * @type string - */ - labelStyle: "ygtvlabel", - - /** - * The derived element id of the label for this node - * @property labelElId - * @type string - */ - labelElId: null, - - /** - * The text for the label. It is assumed that the oData parameter will - * either be a string that will be used as the label, or an object that - * has a property called "label" that we will use. - * @property label - * @type string - */ - label: null, - - textNodeParentChange: function() { - - /** - * Custom event that is fired when the text node label is clicked. The - * custom event is defined on the tree instance, so there is a single - * event that handles all nodes in the tree. The node clicked is - * provided as an argument - * - * @event labelClick - * @for YAHOO.widget.TreeView - * @param {YAHOO.widget.Node} node the node clicked - */ - if (this.tree && !this.tree.hasEvent("labelClick")) { - this.tree.createEvent("labelClick", this.tree); - } - - }, - - /** - * Sets up the node label - * @method setUpLabel - * @param oData string containing the label, or an object with a label property - */ - setUpLabel: function(oData) { - - // set up the custom event on the tree - this.textNodeParentChange(); - this.subscribe("parentChange", this.textNodeParentChange); - - if (typeof oData == "string") { - oData = { label: oData }; - } - this.label = oData.label; - this.data.label = oData.label; - - // update the link - if (oData.href) { - this.href = oData.href; - } - - // set the target - if (oData.target) { - this.target = oData.target; - } - - if (oData.style) { - this.labelStyle = oData.style; - } - - this.labelElId = "ygtvlabelel" + this.index; - }, - - /** - * Returns the label element - * @for YAHOO.widget.TextNode - * @method getLabelEl - * @return {object} the element - */ - getLabelEl: function() { - return document.getElementById(this.labelElId); - }, - - // overrides YAHOO.widget.Node - getNodeHtml: function() { - this.logger.log("Generating html"); - var sb = []; - - sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">'; - sb[sb.length] = '<tr>'; - - for (var i=0;i<this.depth;++i) { - //sb[sb.length] = '<td><div class="' + this.getDepthStyle(i) + '"> </div></td>'; - //sb[sb.length] = '<td><div class="' + this.getDepthStyle(i) + '"></div></td>'; - sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"><div class="ygtvspacer"></div></td>'; - } - - var getNode = 'YAHOO.widget.TreeView.getNode(\'' + - this.tree.id + '\',' + this.index + ')'; - - sb[sb.length] = '<td'; - // sb[sb.length] = ' onselectstart="return false"'; - sb[sb.length] = ' id="' + this.getToggleElId() + '"'; - sb[sb.length] = ' class="' + this.getStyle() + '"'; - if (this.hasChildren(true)) { - sb[sb.length] = ' onmouseover="this.className='; - sb[sb.length] = getNode + '.getHoverStyle()"'; - sb[sb.length] = ' onmouseout="this.className='; - sb[sb.length] = getNode + '.getStyle()"'; - } - sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '">'; - - sb[sb.length] = '<div class="ygtvspacer">'; - - /* - sb[sb.length] = '<img id="' + this.getSpacerId() + '"'; - sb[sb.length] = ' alt=""'; - sb[sb.length] = ' tabindex=0'; - sb[sb.length] = ' src="' + this.spacerPath + '"'; - sb[sb.length] = ' title="' + this.getStateText() + '"'; - sb[sb.length] = ' class="ygtvspacer"'; - // sb[sb.length] = ' onkeypress="return ' + getNode + '".onKeyPress()"'; - sb[sb.length] = ' />'; - */ - - //sb[sb.length] = ' '; - - sb[sb.length] = '</div>'; - sb[sb.length] = '</td>'; - sb[sb.length] = '<td '; - sb[sb.length] = (this.nowrap) ? ' nowrap="nowrap" ' : ''; - sb[sb.length] = ' >'; - sb[sb.length] = '<a'; - sb[sb.length] = ' id="' + this.labelElId + '"'; - sb[sb.length] = ' class="' + this.labelStyle + '"'; - sb[sb.length] = ' href="' + this.href + '"'; - sb[sb.length] = ' target="' + this.target + '"'; - sb[sb.length] = ' onclick="return ' + getNode + '.onLabelClick(' + getNode +')"'; - if (this.hasChildren(true)) { - sb[sb.length] = ' onmouseover="document.getElementById(\''; - sb[sb.length] = this.getToggleElId() + '\').className='; - sb[sb.length] = getNode + '.getHoverStyle()"'; - sb[sb.length] = ' onmouseout="document.getElementById(\''; - sb[sb.length] = this.getToggleElId() + '\').className='; - sb[sb.length] = getNode + '.getStyle()"'; - } - sb[sb.length] = ' >'; - sb[sb.length] = this.label; - sb[sb.length] = '</a>'; - sb[sb.length] = '</td>'; - sb[sb.length] = '</tr>'; - sb[sb.length] = '</table>'; - - return sb.join(""); - }, - - - /** - * Executed when the label is clicked. Fires the labelClick custom event. - * @method onLabelClick - * @param me {Node} this node - * @scope the anchor tag clicked - * @return false to cancel the anchor click - */ - onLabelClick: function(me) { - me.logger.log("onLabelClick " + me.label); - return me.tree.fireEvent("labelClick", me); - //return true; - }, - - toString: function() { - return "TextNode (" + this.index + ") " + this.label; - } - -}); -/** - * A custom YAHOO.widget.Node that handles the unique nature of - * the virtual, presentationless root node. - * @namespace YAHOO.widget - * @class RootNode - * @extends YAHOO.widget.Node - * @param oTree {YAHOO.widget.TreeView} The tree instance this node belongs to - * @constructor - */ -YAHOO.widget.RootNode = function(oTree) { - // Initialize the node with null params. The root node is a - // special case where the node has no presentation. So we have - // to alter the standard properties a bit. - this.init(null, null, true); - - /* - * For the root node, we get the tree reference from as a param - * to the constructor instead of from the parent element. - */ - this.tree = oTree; -}; - -YAHOO.extend(YAHOO.widget.RootNode, YAHOO.widget.Node, { - - // overrides YAHOO.widget.Node - getNodeHtml: function() { - return ""; - }, - - toString: function() { - return "RootNode"; - }, - - loadComplete: function() { - this.tree.draw(); - }, - - collapse: function() {}, - expand: function() {} - -}); -/** - * This implementation takes either a string or object for the - * oData argument. If is it a string, we will use it for the display - * of this node (and it can contain any html code). If the parameter - * is an object, we look for a parameter called "html" that will be - * used for this node's display. - * @namespace YAHOO.widget - * @class HTMLNode - * @extends YAHOO.widget.Node - * @constructor - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {YAHOO.widget.Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - * @param hasIcon {boolean} specifies whether or not leaf nodes should - * have an icon - */ -YAHOO.widget.HTMLNode = function(oData, oParent, expanded, hasIcon) { - if (oData) { - this.init(oData, oParent, expanded); - this.initContent(oData, hasIcon); - } -}; - -YAHOO.extend(YAHOO.widget.HTMLNode, YAHOO.widget.Node, { - - /** - * The CSS class for the html content container. Defaults to ygtvhtml, but - * can be overridden to provide a custom presentation for a specific node. - * @property contentStyle - * @type string - */ - contentStyle: "ygtvhtml", - - /** - * The generated id that will contain the data passed in by the implementer. - * @property contentElId - * @type string - */ - contentElId: null, - - /** - * The HTML content to use for this node's display - * @property content - * @type string - */ - content: null, - - /** - * Sets up the node label - * @property initContent - * @param {object} An html string or object containing an html property - * @param {boolean} hasIcon determines if the node will be rendered with an - * icon or not - */ - initContent: function(oData, hasIcon) { - if (typeof oData == "string") { - oData = { html: oData }; - } - - this.html = oData.html; - this.contentElId = "ygtvcontentel" + this.index; - this.hasIcon = hasIcon; - - this.logger = new YAHOO.widget.LogWriter(this.toString()); - }, - - /** - * Returns the outer html element for this node's content - * @method getContentEl - * @return {HTMLElement} the element - */ - getContentEl: function() { - return document.getElementById(this.contentElId); - }, - - // overrides YAHOO.widget.Node - getNodeHtml: function() { - this.logger.log("Generating html"); - var sb = []; - - sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">'; - sb[sb.length] = '<tr>'; - - for (var i=0;i<this.depth;++i) { - //sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"> </td>'; - sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"><div class="ygtvspacer"></div></td>'; - } - - if (this.hasIcon) { - sb[sb.length] = '<td'; - sb[sb.length] = ' id="' + this.getToggleElId() + '"'; - sb[sb.length] = ' class="' + this.getStyle() + '"'; - sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '"'; - if (this.hasChildren(true)) { - sb[sb.length] = ' onmouseover="this.className='; - sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\''; - sb[sb.length] = this.tree.id + '\',' + this.index + ').getHoverStyle()"'; - sb[sb.length] = ' onmouseout="this.className='; - sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\''; - sb[sb.length] = this.tree.id + '\',' + this.index + ').getStyle()"'; - } - //sb[sb.length] = '> </td>'; - sb[sb.length] = '><div class="ygtvspacer"></div></td>'; - } - - sb[sb.length] = '<td'; - sb[sb.length] = ' id="' + this.contentElId + '"'; - sb[sb.length] = ' class="' + this.contentStyle + '"'; - sb[sb.length] = (this.nowrap) ? ' nowrap="nowrap" ' : ''; - sb[sb.length] = ' >'; - sb[sb.length] = this.html; - sb[sb.length] = '</td>'; - sb[sb.length] = '</tr>'; - sb[sb.length] = '</table>'; - - return sb.join(""); - }, - - toString: function() { - return "HTMLNode (" + this.index + ")"; - } - -}); -/** - * A menu-specific implementation that differs from TextNode in that only - * one sibling can be expanded at a time. - * @namespace YAHOO.widget - * @class MenuNode - * @extends YAHOO.widget.TextNode - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {YAHOO.widget.Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - * @constructor - */ -YAHOO.widget.MenuNode = function(oData, oParent, expanded) { - if (oData) { - this.init(oData, oParent, expanded); - this.setUpLabel(oData); - } - - /* - * Menus usually allow only one branch to be open at a time. - */ - this.multiExpand = false; - - this.logger = new YAHOO.widget.LogWriter(this.toString()); - -}; - -YAHOO.extend(YAHOO.widget.MenuNode, YAHOO.widget.TextNode, { - - toString: function() { - return "MenuNode (" + this.index + ") " + this.label; - } - -}); -/** - * A static factory class for tree view expand/collapse animations - * @class TVAnim - * @static - */ -YAHOO.widget.TVAnim = function() { - return { - /** - * Constant for the fade in animation - * @property FADE_IN - * @type string - * @static - */ - FADE_IN: "TVFadeIn", - - /** - * Constant for the fade out animation - * @property FADE_OUT - * @type string - * @static - */ - FADE_OUT: "TVFadeOut", - - /** - * Returns a ygAnim instance of the given type - * @method getAnim - * @param type {string} the type of animation - * @param el {HTMLElement} the element to element (probably the children div) - * @param callback {function} function to invoke when the animation is done. - * @return {YAHOO.util.Animation} the animation instance - * @static - */ - getAnim: function(type, el, callback) { - if (YAHOO.widget[type]) { - return new YAHOO.widget[type](el, callback); - } else { - return null; - } - }, - - /** - * Returns true if the specified animation class is available - * @method isValid - * @param type {string} the type of animation - * @return {boolean} true if valid, false if not - * @static - */ - isValid: function(type) { - return (YAHOO.widget[type]); - } - }; -} (); - -/** - * A 1/2 second fade-in animation. - * @class TVFadeIn - * @constructor - * @param el {HTMLElement} the element to animate - * @param callback {function} function to invoke when the animation is finished - */ -YAHOO.widget.TVFadeIn = function(el, callback) { - /** - * The element to animate - * @property el - * @type HTMLElement - */ - this.el = el; - - /** - * the callback to invoke when the animation is complete - * @property callback - * @type function - */ - this.callback = callback; - - this.logger = new YAHOO.widget.LogWriter(this.toString()); -}; - -YAHOO.widget.TVFadeIn.prototype = { - /** - * Performs the animation - * @method animate - */ - animate: function() { - var tvanim = this; - - var s = this.el.style; - s.opacity = 0.1; - s.filter = "alpha(opacity=10)"; - s.display = ""; - - var dur = 0.4; - var a = new YAHOO.util.Anim(this.el, {opacity: {from: 0.1, to: 1, unit:""}}, dur); - a.onComplete.subscribe( function() { tvanim.onComplete(); } ); - a.animate(); - }, - - /** - * Clean up and invoke callback - * @method onComplete - */ - onComplete: function() { - this.callback(); - }, - - /** - * toString - * @method toString - * @return {string} the string representation of the instance - */ - toString: function() { - return "TVFadeIn"; - } -}; - -/** - * A 1/2 second fade out animation. - * @class TVFadeOut - * @constructor - * @param el {HTMLElement} the element to animate - * @param callback {Function} function to invoke when the animation is finished - */ -YAHOO.widget.TVFadeOut = function(el, callback) { - /** - * The element to animate - * @property el - * @type HTMLElement - */ - this.el = el; - - /** - * the callback to invoke when the animation is complete - * @property callback - * @type function - */ - this.callback = callback; - - this.logger = new YAHOO.widget.LogWriter(this.toString()); -}; - -YAHOO.widget.TVFadeOut.prototype = { - /** - * Performs the animation - * @method animate - */ - animate: function() { - var tvanim = this; - var dur = 0.4; - var a = new YAHOO.util.Anim(this.el, {opacity: {from: 1, to: 0.1, unit:""}}, dur); - a.onComplete.subscribe( function() { tvanim.onComplete(); } ); - a.animate(); - }, - - /** - * Clean up and invoke callback - * @method onComplete - */ - onComplete: function() { - var s = this.el.style; - s.display = "none"; - // s.opacity = 1; - s.filter = "alpha(opacity=100)"; - this.callback(); - }, - - /** - * toString - * @method toString - * @return {string} the string representation of the instance - */ - toString: function() { - return "TVFadeOut"; - } -}; - -YAHOO.register("treeview", YAHOO.widget.TreeView, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/treeview/treeview-min.js b/interface/web/js/yui/treeview/treeview-min.js deleted file mode 100644 index 76c41686e5..0000000000 --- a/interface/web/js/yui/treeview/treeview-min.js +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -YAHOO.widget.TreeView=function(id){if(id){this.init(id);}};YAHOO.widget.TreeView.prototype={id:null,_el:null,_nodes:null,locked:false,_expandAnim:null,_collapseAnim:null,_animCount:0,maxAnim:2,setExpandAnim:function(type){if(YAHOO.widget.TVAnim.isValid(type)){this._expandAnim=type;}},setCollapseAnim:function(type){if(YAHOO.widget.TVAnim.isValid(type)){this._collapseAnim=type;}},animateExpand:function(el,node){if(this._expandAnim&&this._animCount<this.maxAnim){var tree=this;var a=YAHOO.widget.TVAnim.getAnim(this._expandAnim,el,function(){tree.expandComplete(node);});if(a){++this._animCount;this.fireEvent("animStart",{"node":node,"type":"expand"});a.animate();} -return true;} -return false;},animateCollapse:function(el,node){if(this._collapseAnim&&this._animCount<this.maxAnim){var tree=this;var a=YAHOO.widget.TVAnim.getAnim(this._collapseAnim,el,function(){tree.collapseComplete(node);});if(a){++this._animCount;this.fireEvent("animStart",{"node":node,"type":"collapse"});a.animate();} -return true;} -return false;},expandComplete:function(node){--this._animCount;this.fireEvent("animComplete",{"node":node,"type":"expand"});},collapseComplete:function(node){--this._animCount;this.fireEvent("animComplete",{"node":node,"type":"collapse"});},init:function(id){this.id=id;if("string"!==typeof id){this._el=id;this.id=this.generateId(id);} -this.createEvent("animStart",this);this.createEvent("animComplete",this);this.createEvent("collapse",this);this.createEvent("collapseComplete",this);this.createEvent("expand",this);this.createEvent("expandComplete",this);this._nodes=[];YAHOO.widget.TreeView.trees[this.id]=this;this.root=new YAHOO.widget.RootNode(this);YAHOO.util.Event.on(this.id,"click",this.handleClick,this,true);},draw:function(){var html=this.root.getHtml();this.getEl().innerHTML=html;this.firstDraw=false;},getEl:function(){if(!this._el){this._el=document.getElementById(this.id);} -return this._el;},regNode:function(node){this._nodes[node.index]=node;},getRoot:function(){return this.root;},setDynamicLoad:function(fnDataLoader,iconMode){this.root.setDynamicLoad(fnDataLoader,iconMode);},expandAll:function(){if(!this.locked){this.root.expandAll();}},collapseAll:function(){if(!this.locked){this.root.collapseAll();}},getNodeByIndex:function(nodeIndex){var n=this._nodes[nodeIndex];return(n)?n:null;},getNodeByProperty:function(property,value){for(var i in this._nodes){var n=this._nodes[i];if(n.data&&value==n.data[property]){return n;}} -return null;},getNodesByProperty:function(property,value){var values=[];for(var i in this._nodes){var n=this._nodes[i];if(n.data&&value==n.data[property]){values.push(n);}} -return(values.length)?values:null;},removeNode:function(node,autoRefresh){if(node.isRoot()){return false;} -var p=node.parent;if(p.parent){p=p.parent;} -this._deleteNode(node);if(autoRefresh&&p&&p.childrenRendered){p.refresh();} -return true;},removeChildren:function(node){while(node.children.length){this._deleteNode(node.children[0]);} -node.childrenRendered=false;node.dynamicLoadComplete=false;if(node.expanded){node.collapse();}else{node.updateIcon();}},_deleteNode:function(node){this.removeChildren(node);this.popNode(node);},popNode:function(node){var p=node.parent;var a=[];for(var i=0,len=p.children.length;i<len;++i){if(p.children[i]!=node){a[a.length]=p.children[i];}} -p.children=a;p.childrenRendered=false;if(node.previousSibling){node.previousSibling.nextSibling=node.nextSibling;} -if(node.nextSibling){node.nextSibling.previousSibling=node.previousSibling;} -node.parent=null;node.previousSibling=null;node.nextSibling=null;node.tree=null;delete this._nodes[node.index];},toString:function(){return"TreeView "+this.id;},generateId:function(el){var id=el.id;if(!id){id="yui-tv-auto-id-"+YAHOO.widget.TreeView.counter;++YAHOO.widget.TreeView.counter;} -return id;},onExpand:function(node){},onCollapse:function(node){}};YAHOO.augment(YAHOO.widget.TreeView,YAHOO.util.EventProvider);YAHOO.widget.TreeView.nodeCount=0;YAHOO.widget.TreeView.trees=[];YAHOO.widget.TreeView.counter=0;YAHOO.widget.TreeView.getTree=function(treeId){var t=YAHOO.widget.TreeView.trees[treeId];return(t)?t:null;};YAHOO.widget.TreeView.getNode=function(treeId,nodeIndex){var t=YAHOO.widget.TreeView.getTree(treeId);return(t)?t.getNodeByIndex(nodeIndex):null;};YAHOO.widget.TreeView.addHandler=function(el,sType,fn){if(el.addEventListener){el.addEventListener(sType,fn,false);}else if(el.attachEvent){el.attachEvent("on"+sType,fn);}};YAHOO.widget.TreeView.removeHandler=function(el,sType,fn){if(el.removeEventListener){el.removeEventListener(sType,fn,false);}else if(el.detachEvent){el.detachEvent("on"+sType,fn);}};YAHOO.widget.TreeView.preload=function(prefix){prefix=prefix||"ygtv";var styles=["tn","tm","tmh","tp","tph","ln","lm","lmh","lp","lph","loading"];var sb=[];for(var i=0;i<styles.length;++i){sb[sb.length]='<span class="'+prefix+styles[i]+'"> </span>';} -var f=document.createElement("div");var s=f.style;s.position="absolute";s.top="-1000px";s.left="-1000px";f.innerHTML=sb.join("");document.body.appendChild(f);YAHOO.widget.TreeView.removeHandler(window,"load",YAHOO.widget.TreeView.preload);};YAHOO.widget.TreeView.addHandler(window,"load",YAHOO.widget.TreeView.preload);YAHOO.widget.Node=function(oData,oParent,expanded){if(oData){this.init(oData,oParent,expanded);}};YAHOO.widget.Node.prototype={index:0,children:null,tree:null,data:null,parent:null,depth:-1,href:null,target:"_self",expanded:false,multiExpand:true,renderHidden:false,childrenRendered:false,dynamicLoadComplete:false,previousSibling:null,nextSibling:null,_dynLoad:false,dataLoader:null,isLoading:false,hasIcon:true,iconMode:0,nowrap:false,_type:"Node",init:function(oData,oParent,expanded){this.data=oData;this.children=[];this.index=YAHOO.widget.TreeView.nodeCount;++YAHOO.widget.TreeView.nodeCount;this.expanded=expanded;this.createEvent("parentChange",this);if(oParent){oParent.appendChild(this);}},applyParent:function(parentNode){if(!parentNode){return false;} -this.tree=parentNode.tree;this.parent=parentNode;this.depth=parentNode.depth+1;if(!this.href){this.href="javascript:"+this.getToggleLink();} -this.tree.regNode(this);parentNode.childrenRendered=false;for(var i=0,len=this.children.length;i<len;++i){this.children[i].applyParent(this);} -this.fireEvent("parentChange");return true;},appendChild:function(childNode){if(this.hasChildren()){var sib=this.children[this.children.length-1];sib.nextSibling=childNode;childNode.previousSibling=sib;} -this.children[this.children.length]=childNode;childNode.applyParent(this);return childNode;},appendTo:function(parentNode){return parentNode.appendChild(this);},insertBefore:function(node){var p=node.parent;if(p){if(this.tree){this.tree.popNode(this);} -var refIndex=node.isChildOf(p);p.children.splice(refIndex,0,this);if(node.previousSibling){node.previousSibling.nextSibling=this;} -this.previousSibling=node.previousSibling;this.nextSibling=node;node.previousSibling=this;this.applyParent(p);} -return this;},insertAfter:function(node){var p=node.parent;if(p){if(this.tree){this.tree.popNode(this);} -var refIndex=node.isChildOf(p);if(!node.nextSibling){this.nextSibling=null;return this.appendTo(p);} -p.children.splice(refIndex+1,0,this);node.nextSibling.previousSibling=this;this.previousSibling=node;this.nextSibling=node.nextSibling;node.nextSibling=this;this.applyParent(p);} -return this;},isChildOf:function(parentNode){if(parentNode&&parentNode.children){for(var i=0,len=parentNode.children.length;i<len;++i){if(parentNode.children[i]===this){return i;}}} -return-1;},getSiblings:function(){return this.parent.children;},showChildren:function(){if(!this.tree.animateExpand(this.getChildrenEl(),this)){if(this.hasChildren()){this.getChildrenEl().style.display="";}}},hideChildren:function(){if(!this.tree.animateCollapse(this.getChildrenEl(),this)){this.getChildrenEl().style.display="none";}},getElId:function(){return"ygtv"+this.index;},getChildrenElId:function(){return"ygtvc"+this.index;},getToggleElId:function(){return"ygtvt"+this.index;},getEl:function(){return document.getElementById(this.getElId());},getChildrenEl:function(){return document.getElementById(this.getChildrenElId());},getToggleEl:function(){return document.getElementById(this.getToggleElId());},getToggleLink:function(){return"YAHOO.widget.TreeView.getNode(\'"+this.tree.id+"\',"+ -this.index+").toggle()";},collapse:function(){if(!this.expanded){return;} -var ret=this.tree.onCollapse(this);if(false===ret){return;} -ret=this.tree.fireEvent("collapse",this);if(false===ret){return;} -if(!this.getEl()){this.expanded=false;}else{this.hideChildren();this.expanded=false;this.updateIcon();} -ret=this.tree.fireEvent("collapseComplete",this);},expand:function(){if(this.expanded){return;} -var ret=this.tree.onExpand(this);if(false===ret){return;} -ret=this.tree.fireEvent("expand",this);if(false===ret){return;} -if(!this.getEl()){this.expanded=true;return;} -if(!this.childrenRendered){this.getChildrenEl().innerHTML=this.renderChildren();}else{} -this.expanded=true;this.updateIcon();if(this.isLoading){this.expanded=false;return;} -if(!this.multiExpand){var sibs=this.getSiblings();for(var i=0;i<sibs.length;++i){if(sibs[i]!=this&&sibs[i].expanded){sibs[i].collapse();}}} -this.showChildren();ret=this.tree.fireEvent("expandComplete",this);},updateIcon:function(){if(this.hasIcon){var el=this.getToggleEl();if(el){el.className=this.getStyle();}}},getStyle:function(){if(this.isLoading){return"ygtvloading";}else{var loc=(this.nextSibling)?"t":"l";var type="n";if(this.hasChildren(true)||(this.isDynamic()&&!this.getIconMode())){type=(this.expanded)?"m":"p";} -return"ygtv"+loc+type;}},getHoverStyle:function(){var s=this.getStyle();if(this.hasChildren(true)&&!this.isLoading){s+="h";} -return s;},expandAll:function(){for(var i=0;i<this.children.length;++i){var c=this.children[i];if(c.isDynamic()){alert("Not supported (lazy load + expand all)");break;}else if(!c.multiExpand){alert("Not supported (no multi-expand + expand all)");break;}else{c.expand();c.expandAll();}}},collapseAll:function(){for(var i=0;i<this.children.length;++i){this.children[i].collapse();this.children[i].collapseAll();}},setDynamicLoad:function(fnDataLoader,iconMode){if(fnDataLoader){this.dataLoader=fnDataLoader;this._dynLoad=true;}else{this.dataLoader=null;this._dynLoad=false;} -if(iconMode){this.iconMode=iconMode;}},isRoot:function(){return(this==this.tree.root);},isDynamic:function(){var lazy=(!this.isRoot()&&(this._dynLoad||this.tree.root._dynLoad));return lazy;},getIconMode:function(){return(this.iconMode||this.tree.root.iconMode);},hasChildren:function(checkForLazyLoad){return(this.children.length>0||(checkForLazyLoad&&this.isDynamic()&&!this.dynamicLoadComplete));},toggle:function(){if(!this.tree.locked&&(this.hasChildren(true)||this.isDynamic())){if(this.expanded){this.collapse();}else{this.expand();}}},getHtml:function(){this.childrenRendered=false;var sb=[];sb[sb.length]='<div class="ygtvitem" id="'+this.getElId()+'">';sb[sb.length]=this.getNodeHtml();sb[sb.length]=this.getChildrenHtml();sb[sb.length]='</div>';return sb.join("");},getChildrenHtml:function(){var sb=[];sb[sb.length]='<div class="ygtvchildren"';sb[sb.length]=' id="'+this.getChildrenElId()+'"';if(!this.expanded){sb[sb.length]=' style="display:none;"';} -sb[sb.length]='>';if((this.hasChildren(true)&&this.expanded)||(this.renderHidden&&!this.isDynamic())){sb[sb.length]=this.renderChildren();} -sb[sb.length]='</div>';return sb.join("");},renderChildren:function(){var node=this;if(this.isDynamic()&&!this.dynamicLoadComplete){this.isLoading=true;this.tree.locked=true;if(this.dataLoader){setTimeout(function(){node.dataLoader(node,function(){node.loadComplete();});},10);}else if(this.tree.root.dataLoader){setTimeout(function(){node.tree.root.dataLoader(node,function(){node.loadComplete();});},10);}else{return"Error: data loader not found or not specified.";} -return"";}else{return this.completeRender();}},completeRender:function(){var sb=[];for(var i=0;i<this.children.length;++i){sb[sb.length]=this.children[i].getHtml();} -this.childrenRendered=true;return sb.join("");},loadComplete:function(){this.getChildrenEl().innerHTML=this.completeRender();this.dynamicLoadComplete=true;this.isLoading=false;this.expand();this.tree.locked=false;},getAncestor:function(depth){if(depth>=this.depth||depth<0){return null;} -var p=this.parent;while(p.depth>depth){p=p.parent;} -return p;},getDepthStyle:function(depth){return(this.getAncestor(depth).nextSibling)?"ygtvdepthcell":"ygtvblankdepthcell";},getNodeHtml:function(){return"";},refresh:function(){this.getChildrenEl().innerHTML=this.completeRender();if(this.hasIcon){var el=this.getToggleEl();if(el){el.className=this.getStyle();}}},toString:function(){return"Node ("+this.index+")";}};YAHOO.augment(YAHOO.widget.Node,YAHOO.util.EventProvider);YAHOO.widget.TextNode=function(oData,oParent,expanded){if(oData){this.init(oData,oParent,expanded);this.setUpLabel(oData);}};YAHOO.extend(YAHOO.widget.TextNode,YAHOO.widget.Node,{labelStyle:"ygtvlabel",labelElId:null,label:null,textNodeParentChange:function(){if(this.tree&&!this.tree.hasEvent("labelClick")){this.tree.createEvent("labelClick",this.tree);}},setUpLabel:function(oData){this.textNodeParentChange();this.subscribe("parentChange",this.textNodeParentChange);if(typeof oData=="string"){oData={label:oData};} -this.label=oData.label;this.data.label=oData.label;if(oData.href){this.href=oData.href;} -if(oData.target){this.target=oData.target;} -if(oData.style){this.labelStyle=oData.style;} -this.labelElId="ygtvlabelel"+this.index;},getLabelEl:function(){return document.getElementById(this.labelElId);},getNodeHtml:function(){var sb=[];sb[sb.length]='<table border="0" cellpadding="0" cellspacing="0">';sb[sb.length]='<tr>';for(var i=0;i<this.depth;++i){sb[sb.length]='<td class="'+this.getDepthStyle(i)+'"><div class="ygtvspacer"></div></td>';} -var getNode='YAHOO.widget.TreeView.getNode(\''+ -this.tree.id+'\','+this.index+')';sb[sb.length]='<td';sb[sb.length]=' id="'+this.getToggleElId()+'"';sb[sb.length]=' class="'+this.getStyle()+'"';if(this.hasChildren(true)){sb[sb.length]=' onmouseover="this.className=';sb[sb.length]=getNode+'.getHoverStyle()"';sb[sb.length]=' onmouseout="this.className=';sb[sb.length]=getNode+'.getStyle()"';} -sb[sb.length]=' onclick="javascript:'+this.getToggleLink()+'">';sb[sb.length]='<div class="ygtvspacer">';sb[sb.length]='</div>';sb[sb.length]='</td>';sb[sb.length]='<td ';sb[sb.length]=(this.nowrap)?' nowrap="nowrap" ':'';sb[sb.length]=' >';sb[sb.length]='<a';sb[sb.length]=' id="'+this.labelElId+'"';sb[sb.length]=' class="'+this.labelStyle+'"';sb[sb.length]=' href="'+this.href+'"';sb[sb.length]=' target="'+this.target+'"';sb[sb.length]=' onclick="return '+getNode+'.onLabelClick('+getNode+')"';if(this.hasChildren(true)){sb[sb.length]=' onmouseover="document.getElementById(\'';sb[sb.length]=this.getToggleElId()+'\').className=';sb[sb.length]=getNode+'.getHoverStyle()"';sb[sb.length]=' onmouseout="document.getElementById(\'';sb[sb.length]=this.getToggleElId()+'\').className=';sb[sb.length]=getNode+'.getStyle()"';} -sb[sb.length]=' >';sb[sb.length]=this.label;sb[sb.length]='</a>';sb[sb.length]='</td>';sb[sb.length]='</tr>';sb[sb.length]='</table>';return sb.join("");},onLabelClick:function(me){return me.tree.fireEvent("labelClick",me);},toString:function(){return"TextNode ("+this.index+") "+this.label;}});YAHOO.widget.RootNode=function(oTree){this.init(null,null,true);this.tree=oTree;};YAHOO.extend(YAHOO.widget.RootNode,YAHOO.widget.Node,{getNodeHtml:function(){return"";},toString:function(){return"RootNode";},loadComplete:function(){this.tree.draw();},collapse:function(){},expand:function(){}});YAHOO.widget.HTMLNode=function(oData,oParent,expanded,hasIcon){if(oData){this.init(oData,oParent,expanded);this.initContent(oData,hasIcon);}};YAHOO.extend(YAHOO.widget.HTMLNode,YAHOO.widget.Node,{contentStyle:"ygtvhtml",contentElId:null,content:null,initContent:function(oData,hasIcon){if(typeof oData=="string"){oData={html:oData};} -this.html=oData.html;this.contentElId="ygtvcontentel"+this.index;this.hasIcon=hasIcon;},getContentEl:function(){return document.getElementById(this.contentElId);},getNodeHtml:function(){var sb=[];sb[sb.length]='<table border="0" cellpadding="0" cellspacing="0">';sb[sb.length]='<tr>';for(var i=0;i<this.depth;++i){sb[sb.length]='<td class="'+this.getDepthStyle(i)+'"><div class="ygtvspacer"></div></td>';} -if(this.hasIcon){sb[sb.length]='<td';sb[sb.length]=' id="'+this.getToggleElId()+'"';sb[sb.length]=' class="'+this.getStyle()+'"';sb[sb.length]=' onclick="javascript:'+this.getToggleLink()+'"';if(this.hasChildren(true)){sb[sb.length]=' onmouseover="this.className=';sb[sb.length]='YAHOO.widget.TreeView.getNode(\'';sb[sb.length]=this.tree.id+'\','+this.index+').getHoverStyle()"';sb[sb.length]=' onmouseout="this.className=';sb[sb.length]='YAHOO.widget.TreeView.getNode(\'';sb[sb.length]=this.tree.id+'\','+this.index+').getStyle()"';} -sb[sb.length]='><div class="ygtvspacer"></div></td>';} -sb[sb.length]='<td';sb[sb.length]=' id="'+this.contentElId+'"';sb[sb.length]=' class="'+this.contentStyle+'"';sb[sb.length]=(this.nowrap)?' nowrap="nowrap" ':'';sb[sb.length]=' >';sb[sb.length]=this.html;sb[sb.length]='</td>';sb[sb.length]='</tr>';sb[sb.length]='</table>';return sb.join("");},toString:function(){return"HTMLNode ("+this.index+")";}});YAHOO.widget.MenuNode=function(oData,oParent,expanded){if(oData){this.init(oData,oParent,expanded);this.setUpLabel(oData);} -this.multiExpand=false;};YAHOO.extend(YAHOO.widget.MenuNode,YAHOO.widget.TextNode,{toString:function(){return"MenuNode ("+this.index+") "+this.label;}});YAHOO.widget.TVAnim=function(){return{FADE_IN:"TVFadeIn",FADE_OUT:"TVFadeOut",getAnim:function(type,el,callback){if(YAHOO.widget[type]){return new YAHOO.widget[type](el,callback);}else{return null;}},isValid:function(type){return(YAHOO.widget[type]);}};}();YAHOO.widget.TVFadeIn=function(el,callback){this.el=el;this.callback=callback;};YAHOO.widget.TVFadeIn.prototype={animate:function(){var tvanim=this;var s=this.el.style;s.opacity=0.1;s.filter="alpha(opacity=10)";s.display="";var dur=0.4;var a=new YAHOO.util.Anim(this.el,{opacity:{from:0.1,to:1,unit:""}},dur);a.onComplete.subscribe(function(){tvanim.onComplete();});a.animate();},onComplete:function(){this.callback();},toString:function(){return"TVFadeIn";}};YAHOO.widget.TVFadeOut=function(el,callback){this.el=el;this.callback=callback;};YAHOO.widget.TVFadeOut.prototype={animate:function(){var tvanim=this;var dur=0.4;var a=new YAHOO.util.Anim(this.el,{opacity:{from:1,to:0.1,unit:""}},dur);a.onComplete.subscribe(function(){tvanim.onComplete();});a.animate();},onComplete:function(){var s=this.el.style;s.display="none";s.filter="alpha(opacity=100)";this.callback();},toString:function(){return"TVFadeOut";}};YAHOO.register("treeview",YAHOO.widget.TreeView,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/treeview/treeview.js b/interface/web/js/yui/treeview/treeview.js deleted file mode 100644 index 0e35292cca..0000000000 --- a/interface/web/js/yui/treeview/treeview.js +++ /dev/null @@ -1,2248 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The treeview widget is a generic tree building tool. - * @module treeview - * @title TreeView Widget - * @requires yahoo, event - * @optional animation - * @namespace YAHOO.widget - */ - -/** - * Contains the tree view state data and the root node. - * - * @class TreeView - * @uses YAHOO.util.EventProvider - * @constructor - * @param {string|HTMLElement} id The id of the element, or the element - * itself that the tree will be inserted into. - */ -YAHOO.widget.TreeView = function(id) { - if (id) { this.init(id); } -}; - -YAHOO.widget.TreeView.prototype = { - - /** - * The id of tree container element - * @property id - * @type String - */ - id: null, - - /** - * The host element for this tree - * @property _el - * @private - */ - _el: null, - - /** - * Flat collection of all nodes in this tree. This is a sparse - * array, so the length property can't be relied upon for a - * node count for the tree. - * @property _nodes - * @type Node[] - * @private - */ - _nodes: null, - - /** - * We lock the tree control while waiting for the dynamic loader to return - * @property locked - * @type boolean - */ - locked: false, - - /** - * The animation to use for expanding children, if any - * @property _expandAnim - * @type string - * @private - */ - _expandAnim: null, - - /** - * The animation to use for collapsing children, if any - * @property _collapseAnim - * @type string - * @private - */ - _collapseAnim: null, - - /** - * The current number of animations that are executing - * @property _animCount - * @type int - * @private - */ - _animCount: 0, - - /** - * The maximum number of animations to run at one time. - * @property maxAnim - * @type int - */ - maxAnim: 2, - - /** - * Sets up the animation for expanding children - * @method setExpandAnim - * @param {string} type the type of animation (acceptable values defined - * in YAHOO.widget.TVAnim) - */ - setExpandAnim: function(type) { - if (YAHOO.widget.TVAnim.isValid(type)) { - this._expandAnim = type; - } - }, - - /** - * Sets up the animation for collapsing children - * @method setCollapseAnim - * @param {string} the type of animation (acceptable values defined in - * YAHOO.widget.TVAnim) - */ - setCollapseAnim: function(type) { - if (YAHOO.widget.TVAnim.isValid(type)) { - this._collapseAnim = type; - } - }, - - /** - * Perform the expand animation if configured, or just show the - * element if not configured or too many animations are in progress - * @method animateExpand - * @param el {HTMLElement} the element to animate - * @param node {YAHOO.util.Node} the node that was expanded - * @return {boolean} true if animation could be invoked, false otherwise - */ - animateExpand: function(el, node) { - - if (this._expandAnim && this._animCount < this.maxAnim) { - // this.locked = true; - var tree = this; - var a = YAHOO.widget.TVAnim.getAnim(this._expandAnim, el, - function() { tree.expandComplete(node); }); - if (a) { - ++this._animCount; - this.fireEvent("animStart", { - "node": node, - "type": "expand" - }); - a.animate(); - } - - return true; - } - - return false; - }, - - /** - * Perform the collapse animation if configured, or just show the - * element if not configured or too many animations are in progress - * @method animateCollapse - * @param el {HTMLElement} the element to animate - * @param node {YAHOO.util.Node} the node that was expanded - * @return {boolean} true if animation could be invoked, false otherwise - */ - animateCollapse: function(el, node) { - - if (this._collapseAnim && this._animCount < this.maxAnim) { - // this.locked = true; - var tree = this; - var a = YAHOO.widget.TVAnim.getAnim(this._collapseAnim, el, - function() { tree.collapseComplete(node); }); - if (a) { - ++this._animCount; - this.fireEvent("animStart", { - "node": node, - "type": "collapse" - }); - a.animate(); - } - - return true; - } - - return false; - }, - - /** - * Function executed when the expand animation completes - * @method expandComplete - */ - expandComplete: function(node) { - --this._animCount; - this.fireEvent("animComplete", { - "node": node, - "type": "expand" - }); - // this.locked = false; - }, - - /** - * Function executed when the collapse animation completes - * @method collapseComplete - */ - collapseComplete: function(node) { - --this._animCount; - this.fireEvent("animComplete", { - "node": node, - "type": "collapse" - }); - // this.locked = false; - }, - - /** - * Initializes the tree - * @method init - * @parm {string|HTMLElement} id the id of the element that will hold the tree - * @private - */ - init: function(id) { - - this.id = id; - - if ("string" !== typeof id) { - this._el = id; - this.id = this.generateId(id); - } - - /** - * When animation is enabled, this event fires when the animation - * starts - * @event animStart - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that is expanding/collapsing - * @parm {String} type the type of animation ("expand" or "collapse") - */ - this.createEvent("animStart", this); - - /** - * When animation is enabled, this event fires when the animation - * completes - * @event animComplete - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that is expanding/collapsing - * @parm {String} type the type of animation ("expand" or "collapse") - */ - this.createEvent("animComplete", this); - - /** - * Fires when a node is going to be collapsed. Return false to stop - * the collapse. - * @event collapse - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that is collapsing - */ - this.createEvent("collapse", this); - - /** - * Fires after a node is successfully collapsed. This event will not fire - * if the "collapse" event was cancelled. - * @event collapseComplete - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that was collapsed - */ - this.createEvent("collapseComplete", this); - - /** - * Fires when a node is going to be expanded. Return false to stop - * the collapse. - * @event expand - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that is expanding - */ - this.createEvent("expand", this); - - /** - * Fires after a node is successfully expanded. This event will not fire - * if the "expand" event was cancelled. - * @event expandComplete - * @type CustomEvent - * @param {YAHOO.widget.Node} node the node that was expanded - */ - this.createEvent("expandComplete", this); - - this._nodes = []; - - // store a global reference - YAHOO.widget.TreeView.trees[this.id] = this; - - // Set up the root node - this.root = new YAHOO.widget.RootNode(this); - - - - //YAHOO.util.Event.onContentReady(this.id, this.handleAvailable, this, true); - YAHOO.util.Event.on(this.id, "click", this.handleClick, this, true); - }, - - - //handleAvailable: function() { - //var Event = YAHOO.util.Event; - //Event.on(this.id, - //}, - - /** - * Renders the tree boilerplate and visible nodes - * @method draw - */ - draw: function() { - var html = this.root.getHtml(); - this.getEl().innerHTML = html; - this.firstDraw = false; - }, - - /** - * Returns the tree's host element - * @method getEl - * @return {HTMLElement} the host element - */ - getEl: function() { - if (! this._el) { - this._el = document.getElementById(this.id); - } - return this._el; - }, - - /** - * Nodes register themselves with the tree instance when they are created. - * @method regNode - * @param node {Node} the node to register - * @private - */ - regNode: function(node) { - this._nodes[node.index] = node; - }, - - /** - * Returns the root node of this tree - * @method getRoot - * @return {Node} the root node - */ - getRoot: function() { - return this.root; - }, - - /** - * Configures this tree to dynamically load all child data - * @method setDynamicLoad - * @param {function} fnDataLoader the function that will be called to get the data - * @param iconMode {int} configures the icon that is displayed when a dynamic - * load node is expanded the first time without children. By default, the - * "collapse" icon will be used. If set to 1, the leaf node icon will be - * displayed. - */ - setDynamicLoad: function(fnDataLoader, iconMode) { - this.root.setDynamicLoad(fnDataLoader, iconMode); - }, - - /** - * Expands all child nodes. Note: this conflicts with the "multiExpand" - * node property. If expand all is called in a tree with nodes that - * do not allow multiple siblings to be displayed, only the last sibling - * will be expanded. - * @method expandAll - */ - expandAll: function() { - if (!this.locked) { - this.root.expandAll(); - } - }, - - /** - * Collapses all expanded child nodes in the entire tree. - * @method collapseAll - */ - collapseAll: function() { - if (!this.locked) { - this.root.collapseAll(); - } - }, - - /** - * Returns a node in the tree that has the specified index (this index - * is created internally, so this function probably will only be used - * in html generated for a given node.) - * @method getNodeByIndex - * @param {int} nodeIndex the index of the node wanted - * @return {Node} the node with index=nodeIndex, null if no match - */ - getNodeByIndex: function(nodeIndex) { - var n = this._nodes[nodeIndex]; - return (n) ? n : null; - }, - - /** - * Returns a node that has a matching property and value in the data - * object that was passed into its constructor. - * @method getNodeByProperty - * @param {object} property the property to search (usually a string) - * @param {object} value the value we want to find (usuall an int or string) - * @return {Node} the matching node, null if no match - */ - getNodeByProperty: function(property, value) { - for (var i in this._nodes) { - var n = this._nodes[i]; - if (n.data && value == n.data[property]) { - return n; - } - } - - return null; - }, - - /** - * Returns a collection of nodes that have a matching property - * and value in the data object that was passed into its constructor. - * @method getNodesByProperty - * @param {object} property the property to search (usually a string) - * @param {object} value the value we want to find (usuall an int or string) - * @return {Array} the matching collection of nodes, null if no match - */ - getNodesByProperty: function(property, value) { - var values = []; - for (var i in this._nodes) { - var n = this._nodes[i]; - if (n.data && value == n.data[property]) { - values.push(n); - } - } - - return (values.length) ? values : null; - }, - - /** - * Removes the node and its children, and optionally refreshes the - * branch of the tree that was affected. - * @method removeNode - * @param {Node} The node to remove - * @param {boolean} autoRefresh automatically refreshes branch if true - * @return {boolean} False is there was a problem, true otherwise. - */ - removeNode: function(node, autoRefresh) { - - // Don't delete the root node - if (node.isRoot()) { - return false; - } - - // Get the branch that we may need to refresh - var p = node.parent; - if (p.parent) { - p = p.parent; - } - - // Delete the node and its children - this._deleteNode(node); - - // Refresh the parent of the parent - if (autoRefresh && p && p.childrenRendered) { - p.refresh(); - } - - return true; - }, - - /** - * Deletes this nodes child collection, recursively. Also collapses - * the node, and resets the dynamic load flag. The primary use for - * this method is to purge a node and allow it to fetch its data - * dynamically again. - * @method removeChildren - * @param {Node} node the node to purge - */ - removeChildren: function(node) { - while (node.children.length) { - this._deleteNode(node.children[0]); - } - - node.childrenRendered = false; - node.dynamicLoadComplete = false; - if (node.expanded) { - node.collapse(); - } else { - node.updateIcon(); - } - }, - - /** - * Deletes the node and recurses children - * @method _deleteNode - * @private - */ - _deleteNode: function(node) { - // Remove all the child nodes first - this.removeChildren(node); - - // Remove the node from the tree - this.popNode(node); - }, - - /** - * Removes the node from the tree, preserving the child collection - * to make it possible to insert the branch into another part of the - * tree, or another tree. - * @method popNode - * @param {Node} the node to remove - */ - popNode: function(node) { - var p = node.parent; - - // Update the parent's collection of children - var a = []; - - for (var i=0, len=p.children.length;i<len;++i) { - if (p.children[i] != node) { - a[a.length] = p.children[i]; - } - } - - p.children = a; - - // reset the childrenRendered flag for the parent - p.childrenRendered = false; - - // Update the sibling relationship - if (node.previousSibling) { - node.previousSibling.nextSibling = node.nextSibling; - } - - if (node.nextSibling) { - node.nextSibling.previousSibling = node.previousSibling; - } - - node.parent = null; - node.previousSibling = null; - node.nextSibling = null; - node.tree = null; - - // Update the tree's node collection - delete this._nodes[node.index]; - }, - - - /** - * TreeView instance toString - * @method toString - * @return {string} string representation of the tree - */ - toString: function() { - return "TreeView " + this.id; - }, - - /** - * Generates an unique id for an element if it doesn't yet have one - * @method generateId - * @private - */ - generateId: function(el) { - var id = el.id; - - if (!id) { - id = "yui-tv-auto-id-" + YAHOO.widget.TreeView.counter; - ++YAHOO.widget.TreeView.counter; - } - - return id; - }, - - /** - * Abstract method that is executed when a node is expanded - * @method onExpand - * @param node {Node} the node that was expanded - * @deprecated use treeobj.subscribe("expand") instead - */ - onExpand: function(node) { }, - - /** - * Abstract method that is executed when a node is collapsed. - * @method onCollapse - * @param node {Node} the node that was collapsed. - * @deprecated use treeobj.subscribe("collapse") instead - */ - onCollapse: function(node) { } - -}; - -YAHOO.augment(YAHOO.widget.TreeView, YAHOO.util.EventProvider); - -/** - * Running count of all nodes created in all trees. This is - * used to provide unique identifies for all nodes. Deleting - * nodes does not change the nodeCount. - * @property YAHOO.widget.TreeView.nodeCount - * @type int - * @static - */ -YAHOO.widget.TreeView.nodeCount = 0; - -/** - * Global cache of tree instances - * @property YAHOO.widget.TreeView.trees - * @type Array - * @static - * @private - */ -YAHOO.widget.TreeView.trees = []; - -/** - * Counter for generating a new unique element id - * @property YAHOO.widget.TreeView.counter - * @static - * @private - */ -YAHOO.widget.TreeView.counter = 0; - -/** - * Global method for getting a tree by its id. Used in the generated - * tree html. - * @method YAHOO.widget.TreeView.getTree - * @param treeId {String} the id of the tree instance - * @return {TreeView} the tree instance requested, null if not found. - * @static - */ -YAHOO.widget.TreeView.getTree = function(treeId) { - var t = YAHOO.widget.TreeView.trees[treeId]; - return (t) ? t : null; -}; - - -/** - * Global method for getting a node by its id. Used in the generated - * tree html. - * @method YAHOO.widget.TreeView.getNode - * @param treeId {String} the id of the tree instance - * @param nodeIndex {String} the index of the node to return - * @return {Node} the node instance requested, null if not found - * @static - */ -YAHOO.widget.TreeView.getNode = function(treeId, nodeIndex) { - var t = YAHOO.widget.TreeView.getTree(treeId); - return (t) ? t.getNodeByIndex(nodeIndex) : null; -}; - -/** - * Add a DOM event - * @method YAHOO.widget.TreeView.addHandler - * @param el the elment to bind the handler to - * @param {string} sType the type of event handler - * @param {function} fn the callback to invoke - * @static - */ -YAHOO.widget.TreeView.addHandler = function (el, sType, fn) { - if (el.addEventListener) { - el.addEventListener(sType, fn, false); - } else if (el.attachEvent) { - el.attachEvent("on" + sType, fn); - } -}; - -/** - * Remove a DOM event - * @method YAHOO.widget.TreeView.removeHandler - * @param el the elment to bind the handler to - * @param {string} sType the type of event handler - * @param {function} fn the callback to invoke - * @static - */ - -YAHOO.widget.TreeView.removeHandler = function (el, sType, fn) { - if (el.removeEventListener) { - el.removeEventListener(sType, fn, false); - } else if (el.detachEvent) { - el.detachEvent("on" + sType, fn); - } -}; - -/** - * Attempts to preload the images defined in the styles used to draw the tree by - * rendering off-screen elements that use the styles. - * @method YAHOO.widget.TreeView.preload - * @param {string} prefix the prefix to use to generate the names of the - * images to preload, default is ygtv - * @static - */ -YAHOO.widget.TreeView.preload = function(prefix) { - prefix = prefix || "ygtv"; - var styles = ["tn","tm","tmh","tp","tph","ln","lm","lmh","lp","lph","loading"]; - - var sb = []; - - for (var i = 0; i < styles.length; ++i) { - sb[sb.length] = '<span class="' + prefix + styles[i] + '"> </span>'; - } - - var f = document.createElement("div"); - var s = f.style; - s.position = "absolute"; - s.top = "-1000px"; - s.left = "-1000px"; - f.innerHTML = sb.join(""); - - document.body.appendChild(f); - - YAHOO.widget.TreeView.removeHandler(window, - "load", YAHOO.widget.TreeView.preload); - -}; - -YAHOO.widget.TreeView.addHandler(window, - "load", YAHOO.widget.TreeView.preload); - -/** - * The base class for all tree nodes. The node's presentation and behavior in - * response to mouse events is handled in Node subclasses. - * @namespace YAHOO.widget - * @class Node - * @uses YAHOO.util.EventProvider - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - * @constructor - */ -YAHOO.widget.Node = function(oData, oParent, expanded) { - if (oData) { this.init(oData, oParent, expanded); } -}; - -YAHOO.widget.Node.prototype = { - - /** - * The index for this instance obtained from global counter in YAHOO.widget.TreeView. - * @property index - * @type int - */ - index: 0, - - /** - * This node's child node collection. - * @property children - * @type Node[] - */ - children: null, - - /** - * Tree instance this node is part of - * @property tree - * @type TreeView - */ - tree: null, - - /** - * The data linked to this node. This can be any object or primitive - * value, and the data can be used in getNodeHtml(). - * @property data - * @type object - */ - data: null, - - /** - * Parent node - * @property parent - * @type Node - */ - parent: null, - - /** - * The depth of this node. We start at -1 for the root node. - * @property depth - * @type int - */ - depth: -1, - - /** - * The href for the node's label. If one is not specified, the href will - * be set so that it toggles the node. - * @property href - * @type string - */ - href: null, - - /** - * The label href target, defaults to current window - * @property target - * @type string - */ - target: "_self", - - /** - * The node's expanded/collapsed state - * @property expanded - * @type boolean - */ - expanded: false, - - /** - * Can multiple children be expanded at once? - * @property multiExpand - * @type boolean - */ - multiExpand: true, - - /** - * Should we render children for a collapsed node? It is possible that the - * implementer will want to render the hidden data... @todo verify that we - * need this, and implement it if we do. - * @property renderHidden - * @type boolean - */ - renderHidden: false, - - /** - * This flag is set to true when the html is generated for this node's - * children, and set to false when new children are added. - * @property childrenRendered - * @type boolean - */ - childrenRendered: false, - - /** - * Dynamically loaded nodes only fetch the data the first time they are - * expanded. This flag is set to true once the data has been fetched. - * @property dynamicLoadComplete - * @type boolean - */ - dynamicLoadComplete: false, - - /** - * This node's previous sibling - * @property previousSibling - * @type Node - */ - previousSibling: null, - - /** - * This node's next sibling - * @property nextSibling - * @type Node - */ - nextSibling: null, - - /** - * We can set the node up to call an external method to get the child - * data dynamically. - * @property _dynLoad - * @type boolean - * @private - */ - _dynLoad: false, - - /** - * Function to execute when we need to get this node's child data. - * @property dataLoader - * @type function - */ - dataLoader: null, - - /** - * This is true for dynamically loading nodes while waiting for the - * callback to return. - * @property isLoading - * @type boolean - */ - isLoading: false, - - /** - * The toggle/branch icon will not show if this is set to false. This - * could be useful if the implementer wants to have the child contain - * extra info about the parent, rather than an actual node. - * @property hasIcon - * @type boolean - */ - hasIcon: true, - - /** - * Used to configure what happens when a dynamic load node is expanded - * and we discover that it does not have children. By default, it is - * treated as if it still could have children (plus/minus icon). Set - * iconMode to have it display like a leaf node instead. - * @property iconMode - * @type int - */ - iconMode: 0, - - /** - * Specifies whether or not the content area of the node should be allowed - * to wrap. - * @property nowrap - * @type boolean - * @default true - */ - nowrap: false, - - /** - * The node type - * @property _type - * @private - */ - _type: "Node", - - /* - spacerPath: "http://us.i1.yimg.com/us.yimg.com/i/space.gif", - expandedText: "Expanded", - collapsedText: "Collapsed", - loadingText: "Loading", - */ - - /** - * Initializes this node, gets some of the properties from the parent - * @method init - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - */ - init: function(oData, oParent, expanded) { - - this.data = oData; - this.children = []; - this.index = YAHOO.widget.TreeView.nodeCount; - ++YAHOO.widget.TreeView.nodeCount; - this.expanded = expanded; - - /** - * The parentChange event is fired when a parent element is applied - * to the node. This is useful if you need to apply tree-level - * properties to a tree that need to happen if a node is moved from - * one tree to another. - * - * @event parentChange - * @type CustomEvent - */ - this.createEvent("parentChange", this); - - // oParent should never be null except when we create the root node. - if (oParent) { - oParent.appendChild(this); - } - }, - - /** - * Certain properties for the node cannot be set until the parent - * is known. This is called after the node is inserted into a tree. - * the parent is also applied to this node's children in order to - * make it possible to move a branch from one tree to another. - * @method applyParent - * @param {Node} parentNode this node's parent node - * @return {boolean} true if the application was successful - */ - applyParent: function(parentNode) { - if (!parentNode) { - return false; - } - - this.tree = parentNode.tree; - this.parent = parentNode; - this.depth = parentNode.depth + 1; - - if (!this.href) { - this.href = "javascript:" + this.getToggleLink(); - } - - // @todo why was this put here. This causes new nodes added at the - // root level to lose the menu behavior. - // if (! this.multiExpand) { - // this.multiExpand = parentNode.multiExpand; - // } - - this.tree.regNode(this); - parentNode.childrenRendered = false; - - // cascade update existing children - for (var i=0, len=this.children.length;i<len;++i) { - this.children[i].applyParent(this); - } - - this.fireEvent("parentChange"); - - return true; - }, - - /** - * Appends a node to the child collection. - * @method appendChild - * @param childNode {Node} the new node - * @return {Node} the child node - * @private - */ - appendChild: function(childNode) { - if (this.hasChildren()) { - var sib = this.children[this.children.length - 1]; - sib.nextSibling = childNode; - childNode.previousSibling = sib; - } - this.children[this.children.length] = childNode; - childNode.applyParent(this); - - return childNode; - }, - - /** - * Appends this node to the supplied node's child collection - * @method appendTo - * @param parentNode {Node} the node to append to. - * @return {Node} The appended node - */ - appendTo: function(parentNode) { - return parentNode.appendChild(this); - }, - - /** - * Inserts this node before this supplied node - * @method insertBefore - * @param node {Node} the node to insert this node before - * @return {Node} the inserted node - */ - insertBefore: function(node) { - var p = node.parent; - if (p) { - - if (this.tree) { - this.tree.popNode(this); - } - - var refIndex = node.isChildOf(p); - p.children.splice(refIndex, 0, this); - if (node.previousSibling) { - node.previousSibling.nextSibling = this; - } - this.previousSibling = node.previousSibling; - this.nextSibling = node; - node.previousSibling = this; - - this.applyParent(p); - } - - return this; - }, - - /** - * Inserts this node after the supplied node - * @method insertAfter - * @param node {Node} the node to insert after - * @return {Node} the inserted node - */ - insertAfter: function(node) { - var p = node.parent; - if (p) { - - if (this.tree) { - this.tree.popNode(this); - } - - var refIndex = node.isChildOf(p); - - if (!node.nextSibling) { - this.nextSibling = null; - return this.appendTo(p); - } - - p.children.splice(refIndex + 1, 0, this); - - node.nextSibling.previousSibling = this; - this.previousSibling = node; - this.nextSibling = node.nextSibling; - node.nextSibling = this; - - this.applyParent(p); - } - - return this; - }, - - /** - * Returns true if the Node is a child of supplied Node - * @method isChildOf - * @param parentNode {Node} the Node to check - * @return {boolean} The node index if this Node is a child of - * supplied Node, else -1. - * @private - */ - isChildOf: function(parentNode) { - if (parentNode && parentNode.children) { - for (var i=0, len=parentNode.children.length; i<len ; ++i) { - if (parentNode.children[i] === this) { - return i; - } - } - } - - return -1; - }, - - /** - * Returns a node array of this node's siblings, null if none. - * @method getSiblings - * @return Node[] - */ - getSiblings: function() { - return this.parent.children; - }, - - /** - * Shows this node's children - * @method showChildren - */ - showChildren: function() { - if (!this.tree.animateExpand(this.getChildrenEl(), this)) { - if (this.hasChildren()) { - this.getChildrenEl().style.display = ""; - } - } - }, - - /** - * Hides this node's children - * @method hideChildren - */ - hideChildren: function() { - - if (!this.tree.animateCollapse(this.getChildrenEl(), this)) { - this.getChildrenEl().style.display = "none"; - } - }, - - /** - * Returns the id for this node's container div - * @method getElId - * @return {string} the element id - */ - getElId: function() { - return "ygtv" + this.index; - }, - - /** - * Returns the id for this node's children div - * @method getChildrenElId - * @return {string} the element id for this node's children div - */ - getChildrenElId: function() { - return "ygtvc" + this.index; - }, - - /** - * Returns the id for this node's toggle element - * @method getToggleElId - * @return {string} the toggel element id - */ - getToggleElId: function() { - return "ygtvt" + this.index; - }, - - - /* - * Returns the id for this node's spacer image. The spacer is positioned - * over the toggle and provides feedback for screen readers. - * @method getSpacerId - * @return {string} the id for the spacer image - */ - /* - getSpacerId: function() { - return "ygtvspacer" + this.index; - }, - */ - - /** - * Returns this node's container html element - * @method getEl - * @return {HTMLElement} the container html element - */ - getEl: function() { - return document.getElementById(this.getElId()); - }, - - /** - * Returns the div that was generated for this node's children - * @method getChildrenEl - * @return {HTMLElement} this node's children div - */ - getChildrenEl: function() { - return document.getElementById(this.getChildrenElId()); - }, - - /** - * Returns the element that is being used for this node's toggle. - * @method getToggleEl - * @return {HTMLElement} this node's toggle html element - */ - getToggleEl: function() { - return document.getElementById(this.getToggleElId()); - }, - - /* - * Returns the element that is being used for this node's spacer. - * @method getSpacer - * @return {HTMLElement} this node's spacer html element - */ - /* - getSpacer: function() { - return document.getElementById( this.getSpacerId() ) || {}; - }, - */ - - /* - getStateText: function() { - if (this.isLoading) { - return this.loadingText; - } else if (this.hasChildren(true)) { - if (this.expanded) { - return this.expandedText; - } else { - return this.collapsedText; - } - } else { - return ""; - } - }, - */ - - /** - * Generates the link that will invoke this node's toggle method - * @method getToggleLink - * @return {string} the javascript url for toggling this node - */ - getToggleLink: function() { - return "YAHOO.widget.TreeView.getNode(\'" + this.tree.id + "\'," + - this.index + ").toggle()"; - }, - - /** - * Hides this nodes children (creating them if necessary), changes the - * @method collapse - * toggle style. - */ - collapse: function() { - // Only collapse if currently expanded - if (!this.expanded) { return; } - - // fire the collapse event handler - var ret = this.tree.onCollapse(this); - - if (false === ret) { - return; - } - - ret = this.tree.fireEvent("collapse", this); - - if (false === ret) { - return; - } - - - if (!this.getEl()) { - this.expanded = false; - } else { - // hide the child div - this.hideChildren(); - this.expanded = false; - - this.updateIcon(); - } - - // this.getSpacer().title = this.getStateText(); - - ret = this.tree.fireEvent("collapseComplete", this); - - }, - - /** - * Shows this nodes children (creating them if necessary), changes the - * toggle style, and collapses its siblings if multiExpand is not set. - * @method expand - */ - expand: function() { - // Only expand if currently collapsed. - if (this.expanded) { return; } - - // fire the expand event handler - var ret = this.tree.onExpand(this); - - if (false === ret) { - return; - } - - ret = this.tree.fireEvent("expand", this); - - if (false === ret) { - return; - } - - if (!this.getEl()) { - this.expanded = true; - return; - } - - if (! this.childrenRendered) { - this.getChildrenEl().innerHTML = this.renderChildren(); - } else { - } - - this.expanded = true; - - this.updateIcon(); - - // this.getSpacer().title = this.getStateText(); - - // We do an extra check for children here because the lazy - // load feature can expose nodes that have no children. - - // if (!this.hasChildren()) { - if (this.isLoading) { - this.expanded = false; - return; - } - - if (! this.multiExpand) { - var sibs = this.getSiblings(); - for (var i=0; i<sibs.length; ++i) { - if (sibs[i] != this && sibs[i].expanded) { - sibs[i].collapse(); - } - } - } - - this.showChildren(); - - ret = this.tree.fireEvent("expandComplete", this); - }, - - updateIcon: function() { - if (this.hasIcon) { - var el = this.getToggleEl(); - if (el) { - el.className = this.getStyle(); - } - } - }, - - /** - * Returns the css style name for the toggle - * @method getStyle - * @return {string} the css class for this node's toggle - */ - getStyle: function() { - if (this.isLoading) { - return "ygtvloading"; - } else { - // location top or bottom, middle nodes also get the top style - var loc = (this.nextSibling) ? "t" : "l"; - - // type p=plus(expand), m=minus(collapase), n=none(no children) - var type = "n"; - if (this.hasChildren(true) || (this.isDynamic() && !this.getIconMode())) { - // if (this.hasChildren(true)) { - type = (this.expanded) ? "m" : "p"; - } - - return "ygtv" + loc + type; - } - }, - - /** - * Returns the hover style for the icon - * @return {string} the css class hover state - * @method getHoverStyle - */ - getHoverStyle: function() { - var s = this.getStyle(); - if (this.hasChildren(true) && !this.isLoading) { - s += "h"; - } - return s; - }, - - /** - * Recursively expands all of this node's children. - * @method expandAll - */ - expandAll: function() { - for (var i=0;i<this.children.length;++i) { - var c = this.children[i]; - if (c.isDynamic()) { - alert("Not supported (lazy load + expand all)"); - break; - } else if (! c.multiExpand) { - alert("Not supported (no multi-expand + expand all)"); - break; - } else { - c.expand(); - c.expandAll(); - } - } - }, - - /** - * Recursively collapses all of this node's children. - * @method collapseAll - */ - collapseAll: function() { - for (var i=0;i<this.children.length;++i) { - this.children[i].collapse(); - this.children[i].collapseAll(); - } - }, - - /** - * Configures this node for dynamically obtaining the child data - * when the node is first expanded. Calling it without the callback - * will turn off dynamic load for the node. - * @method setDynamicLoad - * @param fmDataLoader {function} the function that will be used to get the data. - * @param iconMode {int} configures the icon that is displayed when a dynamic - * load node is expanded the first time without children. By default, the - * "collapse" icon will be used. If set to 1, the leaf node icon will be - * displayed. - */ - setDynamicLoad: function(fnDataLoader, iconMode) { - if (fnDataLoader) { - this.dataLoader = fnDataLoader; - this._dynLoad = true; - } else { - this.dataLoader = null; - this._dynLoad = false; - } - - if (iconMode) { - this.iconMode = iconMode; - } - }, - - /** - * Evaluates if this node is the root node of the tree - * @method isRoot - * @return {boolean} true if this is the root node - */ - isRoot: function() { - return (this == this.tree.root); - }, - - /** - * Evaluates if this node's children should be loaded dynamically. Looks for - * the property both in this instance and the root node. If the tree is - * defined to load all children dynamically, the data callback function is - * defined in the root node - * @method isDynamic - * @return {boolean} true if this node's children are to be loaded dynamically - */ - isDynamic: function() { - var lazy = (!this.isRoot() && (this._dynLoad || this.tree.root._dynLoad)); - return lazy; - }, - - /** - * Returns the current icon mode. This refers to the way childless dynamic - * load nodes appear. - * @method getIconMode - * @return {int} 0 for collapse style, 1 for leaf node style - */ - getIconMode: function() { - return (this.iconMode || this.tree.root.iconMode); - }, - - /** - * Checks if this node has children. If this node is lazy-loading and the - * children have not been rendered, we do not know whether or not there - * are actual children. In most cases, we need to assume that there are - * children (for instance, the toggle needs to show the expandable - * presentation state). In other times we want to know if there are rendered - * children. For the latter, "checkForLazyLoad" should be false. - * @method hasChildren - * @param checkForLazyLoad {boolean} should we check for unloaded children? - * @return {boolean} true if this has children or if it might and we are - * checking for this condition. - */ - hasChildren: function(checkForLazyLoad) { - return ( this.children.length > 0 || - (checkForLazyLoad && this.isDynamic() && !this.dynamicLoadComplete) ); - }, - - /** - * Expands if node is collapsed, collapses otherwise. - * @method toggle - */ - toggle: function() { - if (!this.tree.locked && ( this.hasChildren(true) || this.isDynamic()) ) { - if (this.expanded) { this.collapse(); } else { this.expand(); } - } - }, - - /** - * Returns the markup for this node and its children. - * @method getHtml - * @return {string} the markup for this node and its expanded children. - */ - getHtml: function() { - - this.childrenRendered = false; - - var sb = []; - sb[sb.length] = '<div class="ygtvitem" id="' + this.getElId() + '">'; - sb[sb.length] = this.getNodeHtml(); - sb[sb.length] = this.getChildrenHtml(); - sb[sb.length] = '</div>'; - return sb.join(""); - }, - - /** - * Called when first rendering the tree. We always build the div that will - * contain this nodes children, but we don't render the children themselves - * unless this node is expanded. - * @method getChildrenHtml - * @return {string} the children container div html and any expanded children - * @private - */ - getChildrenHtml: function() { - - var sb = []; - sb[sb.length] = '<div class="ygtvchildren"'; - sb[sb.length] = ' id="' + this.getChildrenElId() + '"'; - if (!this.expanded) { - sb[sb.length] = ' style="display:none;"'; - } - sb[sb.length] = '>'; - - // Don't render the actual child node HTML unless this node is expanded. - if ( (this.hasChildren(true) && this.expanded) || - (this.renderHidden && !this.isDynamic()) ) { - sb[sb.length] = this.renderChildren(); - } - - sb[sb.length] = '</div>'; - - return sb.join(""); - }, - - /** - * Generates the markup for the child nodes. This is not done until the node - * is expanded. - * @method renderChildren - * @return {string} the html for this node's children - * @private - */ - renderChildren: function() { - - - var node = this; - - if (this.isDynamic() && !this.dynamicLoadComplete) { - this.isLoading = true; - this.tree.locked = true; - - if (this.dataLoader) { - - setTimeout( - function() { - node.dataLoader(node, - function() { - node.loadComplete(); - }); - }, 10); - - } else if (this.tree.root.dataLoader) { - - setTimeout( - function() { - node.tree.root.dataLoader(node, - function() { - node.loadComplete(); - }); - }, 10); - - } else { - return "Error: data loader not found or not specified."; - } - - return ""; - - } else { - return this.completeRender(); - } - }, - - /** - * Called when we know we have all the child data. - * @method completeRender - * @return {string} children html - */ - completeRender: function() { - var sb = []; - - for (var i=0; i < this.children.length; ++i) { - // this.children[i].childrenRendered = false; - sb[sb.length] = this.children[i].getHtml(); - } - - this.childrenRendered = true; - - return sb.join(""); - }, - - /** - * Load complete is the callback function we pass to the data provider - * in dynamic load situations. - * @method loadComplete - */ - loadComplete: function() { - this.getChildrenEl().innerHTML = this.completeRender(); - this.dynamicLoadComplete = true; - this.isLoading = false; - this.expand(); - this.tree.locked = false; - }, - - /** - * Returns this node's ancestor at the specified depth. - * @method getAncestor - * @param {int} depth the depth of the ancestor. - * @return {Node} the ancestor - */ - getAncestor: function(depth) { - if (depth >= this.depth || depth < 0) { - return null; - } - - var p = this.parent; - - while (p.depth > depth) { - p = p.parent; - } - - return p; - }, - - /** - * Returns the css class for the spacer at the specified depth for - * this node. If this node's ancestor at the specified depth - * has a next sibling the presentation is different than if it - * does not have a next sibling - * @method getDepthStyle - * @param {int} depth the depth of the ancestor. - * @return {string} the css class for the spacer - */ - getDepthStyle: function(depth) { - return (this.getAncestor(depth).nextSibling) ? - "ygtvdepthcell" : "ygtvblankdepthcell"; - }, - - /** - * Get the markup for the node. This is designed to be overrided so that we can - * support different types of nodes. - * @method getNodeHtml - * @return {string} The HTML that will render this node. - */ - getNodeHtml: function() { - return ""; - }, - - /** - * Regenerates the html for this node and its children. To be used when the - * node is expanded and new children have been added. - * @method refresh - */ - refresh: function() { - // this.loadComplete(); - this.getChildrenEl().innerHTML = this.completeRender(); - - if (this.hasIcon) { - var el = this.getToggleEl(); - if (el) { - el.className = this.getStyle(); - } - } - }, - - /** - * Node toString - * @method toString - * @return {string} string representation of the node - */ - toString: function() { - return "Node (" + this.index + ")"; - } - -}; - -YAHOO.augment(YAHOO.widget.Node, YAHOO.util.EventProvider); - -/** - * The default node presentation. The first parameter should be - * either a string that will be used as the node's label, or an object - * that has a string propery called label. By default, the clicking the - * label will toggle the expanded/collapsed state of the node. By - * changing the href property of the instance, this behavior can be - * changed so that the label will go to the specified href. - * @namespace YAHOO.widget - * @class TextNode - * @extends YAHOO.widget.Node - * @constructor - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {YAHOO.widget.Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - */ -YAHOO.widget.TextNode = function(oData, oParent, expanded) { - - if (oData) { - this.init(oData, oParent, expanded); - this.setUpLabel(oData); - } - -}; - -YAHOO.extend(YAHOO.widget.TextNode, YAHOO.widget.Node, { - - /** - * The CSS class for the label href. Defaults to ygtvlabel, but can be - * overridden to provide a custom presentation for a specific node. - * @property labelStyle - * @type string - */ - labelStyle: "ygtvlabel", - - /** - * The derived element id of the label for this node - * @property labelElId - * @type string - */ - labelElId: null, - - /** - * The text for the label. It is assumed that the oData parameter will - * either be a string that will be used as the label, or an object that - * has a property called "label" that we will use. - * @property label - * @type string - */ - label: null, - - textNodeParentChange: function() { - - /** - * Custom event that is fired when the text node label is clicked. The - * custom event is defined on the tree instance, so there is a single - * event that handles all nodes in the tree. The node clicked is - * provided as an argument - * - * @event labelClick - * @for YAHOO.widget.TreeView - * @param {YAHOO.widget.Node} node the node clicked - */ - if (this.tree && !this.tree.hasEvent("labelClick")) { - this.tree.createEvent("labelClick", this.tree); - } - - }, - - /** - * Sets up the node label - * @method setUpLabel - * @param oData string containing the label, or an object with a label property - */ - setUpLabel: function(oData) { - - // set up the custom event on the tree - this.textNodeParentChange(); - this.subscribe("parentChange", this.textNodeParentChange); - - if (typeof oData == "string") { - oData = { label: oData }; - } - this.label = oData.label; - this.data.label = oData.label; - - // update the link - if (oData.href) { - this.href = oData.href; - } - - // set the target - if (oData.target) { - this.target = oData.target; - } - - if (oData.style) { - this.labelStyle = oData.style; - } - - this.labelElId = "ygtvlabelel" + this.index; - }, - - /** - * Returns the label element - * @for YAHOO.widget.TextNode - * @method getLabelEl - * @return {object} the element - */ - getLabelEl: function() { - return document.getElementById(this.labelElId); - }, - - // overrides YAHOO.widget.Node - getNodeHtml: function() { - var sb = []; - - sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">'; - sb[sb.length] = '<tr>'; - - for (var i=0;i<this.depth;++i) { - //sb[sb.length] = '<td><div class="' + this.getDepthStyle(i) + '"> </div></td>'; - //sb[sb.length] = '<td><div class="' + this.getDepthStyle(i) + '"></div></td>'; - sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"><div class="ygtvspacer"></div></td>'; - } - - var getNode = 'YAHOO.widget.TreeView.getNode(\'' + - this.tree.id + '\',' + this.index + ')'; - - sb[sb.length] = '<td'; - // sb[sb.length] = ' onselectstart="return false"'; - sb[sb.length] = ' id="' + this.getToggleElId() + '"'; - sb[sb.length] = ' class="' + this.getStyle() + '"'; - if (this.hasChildren(true)) { - sb[sb.length] = ' onmouseover="this.className='; - sb[sb.length] = getNode + '.getHoverStyle()"'; - sb[sb.length] = ' onmouseout="this.className='; - sb[sb.length] = getNode + '.getStyle()"'; - } - sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '">'; - - sb[sb.length] = '<div class="ygtvspacer">'; - - /* - sb[sb.length] = '<img id="' + this.getSpacerId() + '"'; - sb[sb.length] = ' alt=""'; - sb[sb.length] = ' tabindex=0'; - sb[sb.length] = ' src="' + this.spacerPath + '"'; - sb[sb.length] = ' title="' + this.getStateText() + '"'; - sb[sb.length] = ' class="ygtvspacer"'; - // sb[sb.length] = ' onkeypress="return ' + getNode + '".onKeyPress()"'; - sb[sb.length] = ' />'; - */ - - //sb[sb.length] = ' '; - - sb[sb.length] = '</div>'; - sb[sb.length] = '</td>'; - sb[sb.length] = '<td '; - sb[sb.length] = (this.nowrap) ? ' nowrap="nowrap" ' : ''; - sb[sb.length] = ' >'; - sb[sb.length] = '<a'; - sb[sb.length] = ' id="' + this.labelElId + '"'; - sb[sb.length] = ' class="' + this.labelStyle + '"'; - sb[sb.length] = ' href="' + this.href + '"'; - sb[sb.length] = ' target="' + this.target + '"'; - sb[sb.length] = ' onclick="return ' + getNode + '.onLabelClick(' + getNode +')"'; - if (this.hasChildren(true)) { - sb[sb.length] = ' onmouseover="document.getElementById(\''; - sb[sb.length] = this.getToggleElId() + '\').className='; - sb[sb.length] = getNode + '.getHoverStyle()"'; - sb[sb.length] = ' onmouseout="document.getElementById(\''; - sb[sb.length] = this.getToggleElId() + '\').className='; - sb[sb.length] = getNode + '.getStyle()"'; - } - sb[sb.length] = ' >'; - sb[sb.length] = this.label; - sb[sb.length] = '</a>'; - sb[sb.length] = '</td>'; - sb[sb.length] = '</tr>'; - sb[sb.length] = '</table>'; - - return sb.join(""); - }, - - - /** - * Executed when the label is clicked. Fires the labelClick custom event. - * @method onLabelClick - * @param me {Node} this node - * @scope the anchor tag clicked - * @return false to cancel the anchor click - */ - onLabelClick: function(me) { - return me.tree.fireEvent("labelClick", me); - //return true; - }, - - toString: function() { - return "TextNode (" + this.index + ") " + this.label; - } - -}); -/** - * A custom YAHOO.widget.Node that handles the unique nature of - * the virtual, presentationless root node. - * @namespace YAHOO.widget - * @class RootNode - * @extends YAHOO.widget.Node - * @param oTree {YAHOO.widget.TreeView} The tree instance this node belongs to - * @constructor - */ -YAHOO.widget.RootNode = function(oTree) { - // Initialize the node with null params. The root node is a - // special case where the node has no presentation. So we have - // to alter the standard properties a bit. - this.init(null, null, true); - - /* - * For the root node, we get the tree reference from as a param - * to the constructor instead of from the parent element. - */ - this.tree = oTree; -}; - -YAHOO.extend(YAHOO.widget.RootNode, YAHOO.widget.Node, { - - // overrides YAHOO.widget.Node - getNodeHtml: function() { - return ""; - }, - - toString: function() { - return "RootNode"; - }, - - loadComplete: function() { - this.tree.draw(); - }, - - collapse: function() {}, - expand: function() {} - -}); -/** - * This implementation takes either a string or object for the - * oData argument. If is it a string, we will use it for the display - * of this node (and it can contain any html code). If the parameter - * is an object, we look for a parameter called "html" that will be - * used for this node's display. - * @namespace YAHOO.widget - * @class HTMLNode - * @extends YAHOO.widget.Node - * @constructor - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {YAHOO.widget.Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - * @param hasIcon {boolean} specifies whether or not leaf nodes should - * have an icon - */ -YAHOO.widget.HTMLNode = function(oData, oParent, expanded, hasIcon) { - if (oData) { - this.init(oData, oParent, expanded); - this.initContent(oData, hasIcon); - } -}; - -YAHOO.extend(YAHOO.widget.HTMLNode, YAHOO.widget.Node, { - - /** - * The CSS class for the html content container. Defaults to ygtvhtml, but - * can be overridden to provide a custom presentation for a specific node. - * @property contentStyle - * @type string - */ - contentStyle: "ygtvhtml", - - /** - * The generated id that will contain the data passed in by the implementer. - * @property contentElId - * @type string - */ - contentElId: null, - - /** - * The HTML content to use for this node's display - * @property content - * @type string - */ - content: null, - - /** - * Sets up the node label - * @property initContent - * @param {object} An html string or object containing an html property - * @param {boolean} hasIcon determines if the node will be rendered with an - * icon or not - */ - initContent: function(oData, hasIcon) { - if (typeof oData == "string") { - oData = { html: oData }; - } - - this.html = oData.html; - this.contentElId = "ygtvcontentel" + this.index; - this.hasIcon = hasIcon; - - }, - - /** - * Returns the outer html element for this node's content - * @method getContentEl - * @return {HTMLElement} the element - */ - getContentEl: function() { - return document.getElementById(this.contentElId); - }, - - // overrides YAHOO.widget.Node - getNodeHtml: function() { - var sb = []; - - sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">'; - sb[sb.length] = '<tr>'; - - for (var i=0;i<this.depth;++i) { - //sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"> </td>'; - sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"><div class="ygtvspacer"></div></td>'; - } - - if (this.hasIcon) { - sb[sb.length] = '<td'; - sb[sb.length] = ' id="' + this.getToggleElId() + '"'; - sb[sb.length] = ' class="' + this.getStyle() + '"'; - sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '"'; - if (this.hasChildren(true)) { - sb[sb.length] = ' onmouseover="this.className='; - sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\''; - sb[sb.length] = this.tree.id + '\',' + this.index + ').getHoverStyle()"'; - sb[sb.length] = ' onmouseout="this.className='; - sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\''; - sb[sb.length] = this.tree.id + '\',' + this.index + ').getStyle()"'; - } - //sb[sb.length] = '> </td>'; - sb[sb.length] = '><div class="ygtvspacer"></div></td>'; - } - - sb[sb.length] = '<td'; - sb[sb.length] = ' id="' + this.contentElId + '"'; - sb[sb.length] = ' class="' + this.contentStyle + '"'; - sb[sb.length] = (this.nowrap) ? ' nowrap="nowrap" ' : ''; - sb[sb.length] = ' >'; - sb[sb.length] = this.html; - sb[sb.length] = '</td>'; - sb[sb.length] = '</tr>'; - sb[sb.length] = '</table>'; - - return sb.join(""); - }, - - toString: function() { - return "HTMLNode (" + this.index + ")"; - } - -}); -/** - * A menu-specific implementation that differs from TextNode in that only - * one sibling can be expanded at a time. - * @namespace YAHOO.widget - * @class MenuNode - * @extends YAHOO.widget.TextNode - * @param oData {object} a string or object containing the data that will - * be used to render this node - * @param oParent {YAHOO.widget.Node} this node's parent node - * @param expanded {boolean} the initial expanded/collapsed state - * @constructor - */ -YAHOO.widget.MenuNode = function(oData, oParent, expanded) { - if (oData) { - this.init(oData, oParent, expanded); - this.setUpLabel(oData); - } - - /* - * Menus usually allow only one branch to be open at a time. - */ - this.multiExpand = false; - - -}; - -YAHOO.extend(YAHOO.widget.MenuNode, YAHOO.widget.TextNode, { - - toString: function() { - return "MenuNode (" + this.index + ") " + this.label; - } - -}); -/** - * A static factory class for tree view expand/collapse animations - * @class TVAnim - * @static - */ -YAHOO.widget.TVAnim = function() { - return { - /** - * Constant for the fade in animation - * @property FADE_IN - * @type string - * @static - */ - FADE_IN: "TVFadeIn", - - /** - * Constant for the fade out animation - * @property FADE_OUT - * @type string - * @static - */ - FADE_OUT: "TVFadeOut", - - /** - * Returns a ygAnim instance of the given type - * @method getAnim - * @param type {string} the type of animation - * @param el {HTMLElement} the element to element (probably the children div) - * @param callback {function} function to invoke when the animation is done. - * @return {YAHOO.util.Animation} the animation instance - * @static - */ - getAnim: function(type, el, callback) { - if (YAHOO.widget[type]) { - return new YAHOO.widget[type](el, callback); - } else { - return null; - } - }, - - /** - * Returns true if the specified animation class is available - * @method isValid - * @param type {string} the type of animation - * @return {boolean} true if valid, false if not - * @static - */ - isValid: function(type) { - return (YAHOO.widget[type]); - } - }; -} (); - -/** - * A 1/2 second fade-in animation. - * @class TVFadeIn - * @constructor - * @param el {HTMLElement} the element to animate - * @param callback {function} function to invoke when the animation is finished - */ -YAHOO.widget.TVFadeIn = function(el, callback) { - /** - * The element to animate - * @property el - * @type HTMLElement - */ - this.el = el; - - /** - * the callback to invoke when the animation is complete - * @property callback - * @type function - */ - this.callback = callback; - -}; - -YAHOO.widget.TVFadeIn.prototype = { - /** - * Performs the animation - * @method animate - */ - animate: function() { - var tvanim = this; - - var s = this.el.style; - s.opacity = 0.1; - s.filter = "alpha(opacity=10)"; - s.display = ""; - - var dur = 0.4; - var a = new YAHOO.util.Anim(this.el, {opacity: {from: 0.1, to: 1, unit:""}}, dur); - a.onComplete.subscribe( function() { tvanim.onComplete(); } ); - a.animate(); - }, - - /** - * Clean up and invoke callback - * @method onComplete - */ - onComplete: function() { - this.callback(); - }, - - /** - * toString - * @method toString - * @return {string} the string representation of the instance - */ - toString: function() { - return "TVFadeIn"; - } -}; - -/** - * A 1/2 second fade out animation. - * @class TVFadeOut - * @constructor - * @param el {HTMLElement} the element to animate - * @param callback {Function} function to invoke when the animation is finished - */ -YAHOO.widget.TVFadeOut = function(el, callback) { - /** - * The element to animate - * @property el - * @type HTMLElement - */ - this.el = el; - - /** - * the callback to invoke when the animation is complete - * @property callback - * @type function - */ - this.callback = callback; - -}; - -YAHOO.widget.TVFadeOut.prototype = { - /** - * Performs the animation - * @method animate - */ - animate: function() { - var tvanim = this; - var dur = 0.4; - var a = new YAHOO.util.Anim(this.el, {opacity: {from: 1, to: 0.1, unit:""}}, dur); - a.onComplete.subscribe( function() { tvanim.onComplete(); } ); - a.animate(); - }, - - /** - * Clean up and invoke callback - * @method onComplete - */ - onComplete: function() { - var s = this.el.style; - s.display = "none"; - // s.opacity = 1; - s.filter = "alpha(opacity=100)"; - this.callback(); - }, - - /** - * toString - * @method toString - * @return {string} the string representation of the instance - */ - toString: function() { - return "TVFadeOut"; - } -}; - -YAHOO.register("treeview", YAHOO.widget.TreeView, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/utilities/README b/interface/web/js/yui/utilities/README deleted file mode 100644 index 1f9ef036b5..0000000000 --- a/interface/web/js/yui/utilities/README +++ /dev/null @@ -1,36 +0,0 @@ -utilities.js - Release Notes - -*** NOTE *** - -This document is not updated with each release. Changes to -the utilities.js source are noted in the README -file for each component that comprises this aggregate: - -yahoo/README -dom/README -event/README -connection/README -animation/README -dragdrop/README - -************* - -*** version 0.12.0 *** - -The utilities.js file rolls up all of the YUI utility components into a single -file; it includes the following components: - -* Yahoo Global Object -* Event -* Dom -* Connection Manager -* Animation -* Drag & Drop - -For implementations that use a significant subset of these files, it may prove -more efficient to include utilities.js as opposed to including separate files -for each component. - -Note: If you are require only the Yahoo Global Object, Event Utility and Dom -collection, consider using the special yahoo-event-dom.js aggregate instead. - diff --git a/interface/web/js/yui/utilities/utilities.js b/interface/web/js/yui/utilities/utilities.js deleted file mode 100644 index 6f33f3f32e..0000000000 --- a/interface/web/js/yui/utilities/utilities.js +++ /dev/null @@ -1,418 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -if(typeof YAHOO=="undefined"){var YAHOO={};} -YAHOO.namespace=function(){var a=arguments,o=null,i,j,d;for(i=0;i<a.length;i=i+1){d=a[i].split(".");o=YAHOO;for(j=(d[0]=="YAHOO")?1:0;j<d.length;j=j+1){o[d[j]]=o[d[j]]||{};o=o[d[j]];}} -return o;};YAHOO.log=function(msg,cat,src){var l=YAHOO.widget.Logger;if(l&&l.log){return l.log(msg,cat,src);}else{return false;}};YAHOO.init=function(){this.namespace("util","widget","example");if(typeof YAHOO_config!="undefined"){var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i;if(l){for(i=0;i<ls.length;i=i+1){if(ls[i]==l){unique=false;break;}} -if(unique){ls.push(l);}}}};YAHOO.register=function(name,mainClass,data){var mods=YAHOO.env.modules;if(!mods[name]){mods[name]={versions:[],builds:[]};} -var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners;m.name=name;m.version=v;m.build=b;m.versions.push(v);m.builds.push(b);m.mainClass=mainClass;for(var i=0;i<ls.length;i=i+1){ls[i](m);} -if(mainClass){mainClass.VERSION=v;mainClass.BUILD=b;}else{YAHOO.log("mainClass is undefined for module "+name,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[],getVersion:function(name){return YAHOO.env.modules[name]||null;}};YAHOO.lang={isArray:function(obj){if(obj.constructor&&obj.constructor.toString().indexOf('Array')>-1){return true;}else{return YAHOO.lang.isObject(obj)&&obj.constructor==Array;}},isBoolean:function(obj){return typeof obj=='boolean';},isFunction:function(obj){return typeof obj=='function';},isNull:function(obj){return obj===null;},isNumber:function(obj){return typeof obj=='number'&&isFinite(obj);},isObject:function(obj){return typeof obj=='object'||YAHOO.lang.isFunction(obj);},isString:function(obj){return typeof obj=='string';},isUndefined:function(obj){return typeof obj=='undefined';},hasOwnProperty:function(obj,prop){if(Object.prototype.hasOwnProperty){return obj.hasOwnProperty(prop);} -return!YAHOO.lang.isUndefined(obj[prop])&&obj.constructor.prototype[prop]!==obj[prop];},extend:function(subc,superc,overrides){var F=function(){};F.prototype=superc.prototype;subc.prototype=new F();subc.prototype.constructor=subc;subc.superclass=superc.prototype;if(superc.prototype.constructor==Object.prototype.constructor){superc.prototype.constructor=superc;} -if(overrides){for(var i in overrides){subc.prototype[i]=overrides[i];}}},augment:function(r,s){var rp=r.prototype,sp=s.prototype,a=arguments,i,p;if(a[2]){for(i=2;i<a.length;i=i+1){rp[a[i]]=sp[a[i]];}}else{for(p in sp){if(!rp[p]){rp[p]=sp[p];}}}}};YAHOO.init();YAHOO.util.Lang=YAHOO.lang;YAHOO.augment=YAHOO.lang.augment;YAHOO.extend=YAHOO.lang.extend;YAHOO.register("yahoo",YAHOO,{version:"2.2.0",build:"127"}); -(function(){var Y=YAHOO.util,getStyle,setStyle,id_counter=0,propertyCache={};var ua=navigator.userAgent.toLowerCase(),isOpera=(ua.indexOf('opera')>-1),isSafari=(ua.indexOf('safari')>-1),isGecko=(!isOpera&&!isSafari&&ua.indexOf('gecko')>-1),isIE=(!isOpera&&ua.indexOf('msie')>-1);var patterns={HYPHEN:/(-[a-z])/i};var toCamel=function(property){if(!patterns.HYPHEN.test(property)){return property;} -if(propertyCache[property]){return propertyCache[property];} -while(patterns.HYPHEN.exec(property)){property=property.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());} -propertyCache[property]=property;return property;};if(document.defaultView&&document.defaultView.getComputedStyle){getStyle=function(el,property){var value=null;var computed=document.defaultView.getComputedStyle(el,'');if(computed){value=computed[toCamel(property)];} -return el.style[property]||value;};}else if(document.documentElement.currentStyle&&isIE){getStyle=function(el,property){switch(toCamel(property)){case'opacity':var val=100;try{val=el.filters['DXImageTransform.Microsoft.Alpha'].opacity;}catch(e){try{val=el.filters('alpha').opacity;}catch(e){}} -return val/100;break;default:var value=el.currentStyle?el.currentStyle[property]:null;return(el.style[property]||value);}};}else{getStyle=function(el,property){return el.style[property];};} -if(isIE){setStyle=function(el,property,val){switch(property){case'opacity':if(typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}} -break;default:el.style[property]=val;}};}else{setStyle=function(el,property,val){el.style[property]=val;};} -YAHOO.util.Dom={get:function(el){if(!el){return null;} -if(typeof el!='string'&&!(el instanceof Array)){return el;} -if(typeof el=='string'){return document.getElementById(el);} -else{var collection=[];for(var i=0,len=el.length;i<len;++i){collection[collection.length]=Y.Dom.get(el[i]);} -return collection;} -return null;},getStyle:function(el,property){property=toCamel(property);var f=function(element){return getStyle(element,property);};return Y.Dom.batch(el,f,Y.Dom,true);},setStyle:function(el,property,val){property=toCamel(property);var f=function(element){setStyle(element,property,val);};Y.Dom.batch(el,f,Y.Dom,true);},getXY:function(el){var f=function(el){if(el.parentNode===null||el.offsetParent===null||this.getStyle(el,'display')=='none'){return false;} -var parentNode=null;var pos=[];var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var doc=document;if(!this.inDocument(el)&&parent.document!=document){doc=parent.document;if(!this.isAncestor(doc.documentElement,el)){return false;}} -var scrollTop=Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);var scrollLeft=Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);return[box.left+scrollLeft,box.top+scrollTop];} -else{pos=[el.offsetLeft,el.offsetTop];parentNode=el.offsetParent;if(parentNode!=el){while(parentNode){pos[0]+=parentNode.offsetLeft;pos[1]+=parentNode.offsetTop;parentNode=parentNode.offsetParent;}} -if(isSafari&&this.getStyle(el,'position')=='absolute'){pos[0]-=document.body.offsetLeft;pos[1]-=document.body.offsetTop;}} -if(el.parentNode){parentNode=el.parentNode;} -else{parentNode=null;} -while(parentNode&&parentNode.tagName.toUpperCase()!='BODY'&&parentNode.tagName.toUpperCase()!='HTML') -{if(Y.Dom.getStyle(parentNode,'display')!='inline'){pos[0]-=parentNode.scrollLeft;pos[1]-=parentNode.scrollTop;} -if(parentNode.parentNode){parentNode=parentNode.parentNode;}else{parentNode=null;}} -return pos;};return Y.Dom.batch(el,f,Y.Dom,true);},getX:function(el){var f=function(el){return Y.Dom.getXY(el)[0];};return Y.Dom.batch(el,f,Y.Dom,true);},getY:function(el){var f=function(el){return Y.Dom.getXY(el)[1];};return Y.Dom.batch(el,f,Y.Dom,true);},setXY:function(el,pos,noRetry){var f=function(el){var style_pos=this.getStyle(el,'position');if(style_pos=='static'){this.setStyle(el,'position','relative');style_pos='relative';} -var pageXY=this.getXY(el);if(pageXY===false){return false;} -var delta=[parseInt(this.getStyle(el,'left'),10),parseInt(this.getStyle(el,'top'),10)];if(isNaN(delta[0])){delta[0]=(style_pos=='relative')?0:el.offsetLeft;} -if(isNaN(delta[1])){delta[1]=(style_pos=='relative')?0:el.offsetTop;} -if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+'px';} -if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+'px';} -if(!noRetry){var newXY=this.getXY(el);if((pos[0]!==null&&newXY[0]!=pos[0])||(pos[1]!==null&&newXY[1]!=pos[1])){this.setXY(el,pos,true);}}};Y.Dom.batch(el,f,Y.Dom,true);},setX:function(el,x){Y.Dom.setXY(el,[x,null]);},setY:function(el,y){Y.Dom.setXY(el,[null,y]);},getRegion:function(el){var f=function(el){var region=new Y.Region.getRegion(el);return region;};return Y.Dom.batch(el,f,Y.Dom,true);},getClientWidth:function(){return Y.Dom.getViewportWidth();},getClientHeight:function(){return Y.Dom.getViewportHeight();},getElementsByClassName:function(className,tag,root){var method=function(el){return Y.Dom.hasClass(el,className);};return Y.Dom.getElementsBy(method,tag,root);},hasClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');var f=function(el){return re.test(el['className']);};return Y.Dom.batch(el,f,Y.Dom,true);},addClass:function(el,className){var f=function(el){if(this.hasClass(el,className)){return;} -el['className']=[el['className'],className].join(' ');};Y.Dom.batch(el,f,Y.Dom,true);},removeClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,className)){return;} -var c=el['className'];el['className']=c.replace(re,' ');if(this.hasClass(el,className)){this.removeClass(el,className);}};Y.Dom.batch(el,f,Y.Dom,true);},replaceClass:function(el,oldClassName,newClassName){if(oldClassName===newClassName){return false;} -var re=new RegExp('(?:^|\\s+)'+oldClassName+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,oldClassName)){this.addClass(el,newClassName);return;} -el['className']=el['className'].replace(re,' '+newClassName+' ');if(this.hasClass(el,oldClassName)){this.replaceClass(el,oldClassName,newClassName);}};Y.Dom.batch(el,f,Y.Dom,true);},generateId:function(el,prefix){prefix=prefix||'yui-gen';el=el||{};var f=function(el){if(el){el=Y.Dom.get(el);}else{el={};} -if(!el.id){el.id=prefix+id_counter++;} -return el.id;};return Y.Dom.batch(el,f,Y.Dom,true);},isAncestor:function(haystack,needle){haystack=Y.Dom.get(haystack);if(!haystack||!needle){return false;} -var f=function(needle){if(haystack.contains&&!isSafari){return haystack.contains(needle);} -else if(haystack.compareDocumentPosition){return!!(haystack.compareDocumentPosition(needle)&16);} -else{var parent=needle.parentNode;while(parent){if(parent==haystack){return true;} -else if(!parent.tagName||parent.tagName.toUpperCase()=='HTML'){return false;} -parent=parent.parentNode;} -return false;}};return Y.Dom.batch(needle,f,Y.Dom,true);},inDocument:function(el){var f=function(el){return this.isAncestor(document.documentElement,el);};return Y.Dom.batch(el,f,Y.Dom,true);},getElementsBy:function(method,tag,root){tag=tag||'*';var nodes=[];if(root){root=Y.Dom.get(root);if(!root){return nodes;}}else{root=document;} -var elements=root.getElementsByTagName(tag);if(!elements.length&&(tag=='*'&&root.all)){elements=root.all;} -for(var i=0,len=elements.length;i<len;++i){if(method(elements[i])){nodes[nodes.length]=elements[i];}} -return nodes;},batch:function(el,method,o,override){var id=el;el=Y.Dom.get(el);var scope=(override)?o:window;if(!el||el.tagName||!el.length){if(!el){return false;} -return method.call(scope,el,o);} -var collection=[];for(var i=0,len=el.length;i<len;++i){if(!el[i]){id=el[i];} -collection[collection.length]=method.call(scope,el[i],o);} -return collection;},getDocumentHeight:function(){var scrollHeight=(document.compatMode!='CSS1Compat')?document.body.scrollHeight:document.documentElement.scrollHeight;var h=Math.max(scrollHeight,Y.Dom.getViewportHeight());return h;},getDocumentWidth:function(){var scrollWidth=(document.compatMode!='CSS1Compat')?document.body.scrollWidth:document.documentElement.scrollWidth;var w=Math.max(scrollWidth,Y.Dom.getViewportWidth());return w;},getViewportHeight:function(){var height=self.innerHeight;var mode=document.compatMode;if((mode||isIE)&&!isOpera){height=(mode=='CSS1Compat')?document.documentElement.clientHeight:document.body.clientHeight;} -return height;},getViewportWidth:function(){var width=self.innerWidth;var mode=document.compatMode;if(mode||isIE){width=(mode=='CSS1Compat')?document.documentElement.clientWidth:document.body.clientWidth;} -return width;}};})();YAHOO.util.Region=function(t,r,b,l){this.top=t;this[1]=t;this.right=r;this.bottom=b;this.left=l;this[0]=l;};YAHOO.util.Region.prototype.contains=function(region){return(region.left>=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];} -this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region();YAHOO.register("dom",YAHOO.util.Dom,{version:"2.2.0",build:"127"}); -if(!YAHOO.util.Event){YAHOO.util.Event=function(){var loadComplete=false;var listeners=[];var unloadListeners=[];var legacyEvents=[];var legacyHandlers=[];var retryCount=0;var onAvailStack=[];var legacyMap=[];var counter=0;var lastError=null;return{POLL_RETRYS:200,POLL_INTERVAL:20,EL:0,TYPE:1,FN:2,WFN:3,OBJ:3,ADJ_SCOPE:4,isSafari:(/KHTML/gi).test(navigator.userAgent),webkit:function(){var v=navigator.userAgent.match(/AppleWebKit\/([^ ]*)/);if(v&&v[1]){return v[1];} -return null;}(),isIE:(!this.webkit&&!navigator.userAgent.match(/opera/gi)&&navigator.userAgent.match(/msie/gi)),_interval:null,startInterval:function(){if(!this._interval){var self=this;var callback=function(){self._tryPreloadAttach();};this._interval=setInterval(callback,this.POLL_INTERVAL);}},onAvailable:function(p_id,p_fn,p_obj,p_override){onAvailStack.push({id:p_id,fn:p_fn,obj:p_obj,override:p_override,checkReady:false});retryCount=this.POLL_RETRYS;this.startInterval();},onContentReady:function(p_id,p_fn,p_obj,p_override){onAvailStack.push({id:p_id,fn:p_fn,obj:p_obj,override:p_override,checkReady:true});retryCount=this.POLL_RETRYS;this.startInterval();},addListener:function(el,sType,fn,obj,override){if(!fn||!fn.call){return false;} -if(this._isValidCollection(el)){var ok=true;for(var i=0,len=el.length;i<len;++i){ok=this.on(el[i],sType,fn,obj,override)&&ok;} -return ok;}else if(typeof el=="string"){var oEl=this.getEl(el);if(oEl){el=oEl;}else{this.onAvailable(el,function(){YAHOO.util.Event.on(el,sType,fn,obj,override);});return true;}} -if(!el){return false;} -if("unload"==sType&&obj!==this){unloadListeners[unloadListeners.length]=[el,sType,fn,obj,override];return true;} -var scope=el;if(override){if(override===true){scope=obj;}else{scope=override;}} -var wrappedFn=function(e){return fn.call(scope,YAHOO.util.Event.getEvent(e),obj);};var li=[el,sType,fn,wrappedFn,scope];var index=listeners.length;listeners[index]=li;if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);if(legacyIndex==-1||el!=legacyEvents[legacyIndex][0]){legacyIndex=legacyEvents.length;legacyMap[el.id+sType]=legacyIndex;legacyEvents[legacyIndex]=[el,sType,el["on"+sType]];legacyHandlers[legacyIndex]=[];el["on"+sType]=function(e){YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(e),legacyIndex);};} -legacyHandlers[legacyIndex].push(li);}else{try{this._simpleAdd(el,sType,wrappedFn,false);}catch(ex){this.lastError=ex;this.removeListener(el,sType,fn);return false;}} -return true;},fireLegacyEvent:function(e,legacyIndex){var ok=true,le,lh,li,scope,ret;lh=legacyHandlers[legacyIndex];for(var i=0,len=lh.length;i<len;++i){li=lh[i];if(li&&li[this.WFN]){scope=li[this.ADJ_SCOPE];ret=li[this.WFN].call(scope,e);ok=(ok&&ret);}} -le=legacyEvents[legacyIndex];if(le&&le[2]){le[2](e);} -return ok;},getLegacyIndex:function(el,sType){var key=this.generateId(el)+sType;if(typeof legacyMap[key]=="undefined"){return-1;}else{return legacyMap[key];}},useLegacyEvent:function(el,sType){if(this.webkit&&("click"==sType||"dblclick"==sType)){var v=parseInt(this.webkit,10);if(!isNaN(v)&&v<418){return true;}} -return false;},removeListener:function(el,sType,fn){var i,len;if(typeof el=="string"){el=this.getEl(el);}else if(this._isValidCollection(el)){var ok=true;for(i=0,len=el.length;i<len;++i){ok=(this.removeListener(el[i],sType,fn)&&ok);} -return ok;} -if(!fn||!fn.call){return this.purgeElement(el,false,sType);} -if("unload"==sType){for(i=0,len=unloadListeners.length;i<len;i++){var li=unloadListeners[i];if(li&&li[0]==el&&li[1]==sType&&li[2]==fn){unloadListeners.splice(i,1);return true;}} -return false;} -var cacheItem=null;var index=arguments[3];if("undefined"==typeof index){index=this._getCacheIndex(el,sType,fn);} -if(index>=0){cacheItem=listeners[index];} -if(!el||!cacheItem){return false;} -if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);var llist=legacyHandlers[legacyIndex];if(llist){for(i=0,len=llist.length;i<len;++i){li=llist[i];if(li&&li[this.EL]==el&&li[this.TYPE]==sType&&li[this.FN]==fn){llist.splice(i,1);break;}}}}else{try{this._simpleRemove(el,sType,cacheItem[this.WFN],false);}catch(ex){this.lastError=ex;return false;}} -delete listeners[index][this.WFN];delete listeners[index][this.FN];listeners.splice(index,1);return true;},getTarget:function(ev,resolveTextNode){var t=ev.target||ev.srcElement;return this.resolveTextNode(t);},resolveTextNode:function(node){if(node&&3==node.nodeType){return node.parentNode;}else{return node;}},getPageX:function(ev){var x=ev.pageX;if(!x&&0!==x){x=ev.clientX||0;if(this.isIE){x+=this._getScrollLeft();}} -return x;},getPageY:function(ev){var y=ev.pageY;if(!y&&0!==y){y=ev.clientY||0;if(this.isIE){y+=this._getScrollTop();}} -return y;},getXY:function(ev){return[this.getPageX(ev),this.getPageY(ev)];},getRelatedTarget:function(ev){var t=ev.relatedTarget;if(!t){if(ev.type=="mouseout"){t=ev.toElement;}else if(ev.type=="mouseover"){t=ev.fromElement;}} -return this.resolveTextNode(t);},getTime:function(ev){if(!ev.time){var t=new Date().getTime();try{ev.time=t;}catch(ex){this.lastError=ex;return t;}} -return ev.time;},stopEvent:function(ev){this.stopPropagation(ev);this.preventDefault(ev);},stopPropagation:function(ev){if(ev.stopPropagation){ev.stopPropagation();}else{ev.cancelBubble=true;}},preventDefault:function(ev){if(ev.preventDefault){ev.preventDefault();}else{ev.returnValue=false;}},getEvent:function(e){var ev=e||window.event;if(!ev){var c=this.getEvent.caller;while(c){ev=c.arguments[0];if(ev&&Event==ev.constructor){break;} -c=c.caller;}} -return ev;},getCharCode:function(ev){return ev.charCode||ev.keyCode||0;},_getCacheIndex:function(el,sType,fn){for(var i=0,len=listeners.length;i<len;++i){var li=listeners[i];if(li&&li[this.FN]==fn&&li[this.EL]==el&&li[this.TYPE]==sType){return i;}} -return-1;},generateId:function(el){var id=el.id;if(!id){id="yuievtautoid-"+counter;++counter;el.id=id;} -return id;},_isValidCollection:function(o){return(o&&o.length&&typeof o!="string"&&!o.tagName&&!o.alert&&typeof o[0]!="undefined");},elCache:{},getEl:function(id){return document.getElementById(id);},clearCache:function(){},_load:function(e){loadComplete=true;var EU=YAHOO.util.Event;if(this.isIE){EU._simpleRemove(window,"load",EU._load);}},_tryPreloadAttach:function(){if(this.locked){return false;} -this.locked=true;var tryAgain=!loadComplete;if(!tryAgain){tryAgain=(retryCount>0);} -var notAvail=[];for(var i=0,len=onAvailStack.length;i<len;++i){var item=onAvailStack[i];if(item){var el=this.getEl(item.id);if(el){if(!item.checkReady||loadComplete||el.nextSibling||(document&&document.body)){var scope=el;if(item.override){if(item.override===true){scope=item.obj;}else{scope=item.override;}} -item.fn.call(scope,item.obj);onAvailStack[i]=null;}}else{notAvail.push(item);}}} -retryCount=(notAvail.length===0)?0:retryCount-1;if(tryAgain){this.startInterval();}else{clearInterval(this._interval);this._interval=null;} -this.locked=false;return true;},purgeElement:function(el,recurse,sType){var elListeners=this.getListeners(el,sType);if(elListeners){for(var i=0,len=elListeners.length;i<len;++i){var l=elListeners[i];this.removeListener(el,l.type,l.fn);}} -if(recurse&&el&&el.childNodes){for(i=0,len=el.childNodes.length;i<len;++i){this.purgeElement(el.childNodes[i],recurse,sType);}}},getListeners:function(el,sType){var results=[],searchLists;if(!sType){searchLists=[listeners,unloadListeners];}else if(sType=="unload"){searchLists=[unloadListeners];}else{searchLists=[listeners];} -for(var j=0;j<searchLists.length;++j){var searchList=searchLists[j];if(searchList&&searchList.length>0){for(var i=0,len=searchList.length;i<len;++i){var l=searchList[i];if(l&&l[this.EL]===el&&(!sType||sType===l[this.TYPE])){results.push({type:l[this.TYPE],fn:l[this.FN],obj:l[this.OBJ],adjust:l[this.ADJ_SCOPE],index:i});}}}} -return(results.length)?results:null;},_unload:function(e){var EU=YAHOO.util.Event,i,j,l,len,index;for(i=0,len=unloadListeners.length;i<len;++i){l=unloadListeners[i];if(l){var scope=window;if(l[EU.ADJ_SCOPE]){if(l[EU.ADJ_SCOPE]===true){scope=l[EU.OBJ];}else{scope=l[EU.ADJ_SCOPE];}} -l[EU.FN].call(scope,EU.getEvent(e),l[EU.OBJ]);unloadListeners[i]=null;l=null;scope=null;}} -unloadListeners=null;if(listeners&&listeners.length>0){j=listeners.length;while(j){index=j-1;l=listeners[index];if(l){EU.removeListener(l[EU.EL],l[EU.TYPE],l[EU.FN],index);} -j=j-1;} -l=null;EU.clearCache();} -for(i=0,len=legacyEvents.length;i<len;++i){legacyEvents[i][0]=null;legacyEvents[i]=null;} -legacyEvents=null;EU._simpleRemove(window,"unload",EU._unload);},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var dd=document.documentElement,db=document.body;if(dd&&(dd.scrollTop||dd.scrollLeft)){return[dd.scrollTop,dd.scrollLeft];}else if(db){return[db.scrollTop,db.scrollLeft];}else{return[0,0];}},regCE:function(){},_simpleAdd:function(){if(window.addEventListener){return function(el,sType,fn,capture){el.addEventListener(sType,fn,(capture));};}else if(window.attachEvent){return function(el,sType,fn,capture){el.attachEvent("on"+sType,fn);};}else{return function(){};}}(),_simpleRemove:function(){if(window.removeEventListener){return function(el,sType,fn,capture){el.removeEventListener(sType,fn,(capture));};}else if(window.detachEvent){return function(el,sType,fn){el.detachEvent("on"+sType,fn);};}else{return function(){};}}()};}();(function(){var EU=YAHOO.util.Event;EU.on=EU.addListener;if(document&&document.body){EU._load();}else{EU._simpleAdd(window,"load",EU._load);} -EU._simpleAdd(window,"unload",EU._unload);EU._tryPreloadAttach();})();} -YAHOO.util.CustomEvent=function(type,oScope,silent,signature){this.type=type;this.scope=oScope||window;this.silent=silent;this.signature=signature||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){} -var onsubscribeType="_YUICEOnSubscribe";if(type!==onsubscribeType){this.subscribeEvent=new YAHOO.util.CustomEvent(onsubscribeType,this,true);}};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(fn,obj,override){if(this.subscribeEvent){this.subscribeEvent.fire(fn,obj,override);} -this.subscribers.push(new YAHOO.util.Subscriber(fn,obj,override));},unsubscribe:function(fn,obj){if(!fn){return this.unsubscribeAll();} -var found=false;for(var i=0,len=this.subscribers.length;i<len;++i){var s=this.subscribers[i];if(s&&s.contains(fn,obj)){this._delete(i);found=true;}} -return found;},fire:function(){var len=this.subscribers.length;if(!len&&this.silent){return true;} -var args=[],ret=true,i;for(i=0;i<arguments.length;++i){args.push(arguments[i]);} -var argslength=args.length;if(!this.silent){} -for(i=0;i<len;++i){var s=this.subscribers[i];if(s){if(!this.silent){} -var scope=s.getScope(this.scope);if(this.signature==YAHOO.util.CustomEvent.FLAT){var param=null;if(args.length>0){param=args[0];} -ret=s.fn.call(scope,param,s.obj);}else{ret=s.fn.call(scope,this.type,args,s.obj);} -if(false===ret){if(!this.silent){} -return false;}}} -return true;},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i<len;++i){this._delete(len-1-i);} -return i;},_delete:function(index){var s=this.subscribers[index];if(s){delete s.fn;delete s.obj;} -this.subscribers.splice(index,1);},toString:function(){return"CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(fn,obj,override){this.fn=fn;this.obj=obj||null;this.override=override;};YAHOO.util.Subscriber.prototype.getScope=function(defaultScope){if(this.override){if(this.override===true){return this.obj;}else{return this.override;}} -return defaultScope;};YAHOO.util.Subscriber.prototype.contains=function(fn,obj){if(obj){return(this.fn==fn&&this.obj==obj);}else{return(this.fn==fn);}};YAHOO.util.Subscriber.prototype.toString=function(){return"Subscriber { obj: "+(this.obj||"")+", override: "+(this.override||"no")+" }";};YAHOO.util.EventProvider=function(){};YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(p_type,p_fn,p_obj,p_override){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){ce.subscribe(p_fn,p_obj,p_override);}else{this.__yui_subscribers=this.__yui_subscribers||{};var subs=this.__yui_subscribers;if(!subs[p_type]){subs[p_type]=[];} -subs[p_type].push({fn:p_fn,obj:p_obj,override:p_override});}},unsubscribe:function(p_type,p_fn,p_obj){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){return ce.unsubscribe(p_fn,p_obj);}else{return false;}},unsubscribeAll:function(p_type){return this.unsubscribe(p_type);},createEvent:function(p_type,p_config){this.__yui_events=this.__yui_events||{};var opts=p_config||{};var events=this.__yui_events;if(events[p_type]){}else{var scope=opts.scope||this;var silent=opts.silent||null;var ce=new YAHOO.util.CustomEvent(p_type,scope,silent,YAHOO.util.CustomEvent.FLAT);events[p_type]=ce;if(opts.onSubscribeCallback){ce.subscribeEvent.subscribe(opts.onSubscribeCallback);} -this.__yui_subscribers=this.__yui_subscribers||{};var qs=this.__yui_subscribers[p_type];if(qs){for(var i=0;i<qs.length;++i){ce.subscribe(qs[i].fn,qs[i].obj,qs[i].override);}}} -return events[p_type];},fireEvent:function(p_type,arg1,arg2,etc){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){var args=[];for(var i=1;i<arguments.length;++i){args.push(arguments[i]);} -return ce.fire.apply(ce,args);}else{return null;}},hasEvent:function(type){if(this.__yui_events){if(this.__yui_events[type]){return true;}} -return false;}};YAHOO.util.KeyListener=function(attachTo,keyData,handler,event){if(!attachTo){}else if(!keyData){}else if(!handler){} -if(!event){event=YAHOO.util.KeyListener.KEYDOWN;} -var keyEvent=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof attachTo=='string'){attachTo=document.getElementById(attachTo);} -if(typeof handler=='function'){keyEvent.subscribe(handler);}else{keyEvent.subscribe(handler.fn,handler.scope,handler.correctScope);} -function handleKeyPress(e,obj){if(!keyData.shift){keyData.shift=false;} -if(!keyData.alt){keyData.alt=false;} -if(!keyData.ctrl){keyData.ctrl=false;} -if(e.shiftKey==keyData.shift&&e.altKey==keyData.alt&&e.ctrlKey==keyData.ctrl){var dataItem;var keyPressed;if(keyData.keys instanceof Array){for(var i=0;i<keyData.keys.length;i++){dataItem=keyData.keys[i];if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);break;}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);break;}}}else{dataItem=keyData.keys;if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);}}}} -this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(attachTo,event,handleKeyPress);this.enabledEvent.fire(keyData);} -this.enabled=true;};this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(attachTo,event,handleKeyPress);this.disabledEvent.fire(keyData);} -this.enabled=false;};this.toString=function(){return"KeyListener ["+keyData.keys+"] "+attachTo.tagName+ -(attachTo.id?"["+attachTo.id+"]":"");};};YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.register("event",YAHOO.util.Event,{version:"2.2.0",build:"127"});YAHOO.util.Connect={_msxml_progid:['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'],_http_headers:{},_has_http_headers:false,_use_default_post_header:true,_default_post_header:'application/x-www-form-urlencoded',_use_default_xhr_header:true,_default_xhr_header:'XMLHttpRequest',_has_default_headers:true,_default_headers:{},_isFormSubmit:false,_isFileUpload:false,_formNode:null,_sFormData:null,_poll:{},_timeOut:{},_polling_interval:50,_transaction_id:0,setProgId:function(id) -{this._msxml_progid.unshift(id);},setDefaultPostHeader:function(b) -{this._use_default_post_header=b;},setDefaultXhrHeader:function(b) -{this._use_default_xhr_header=b;},setPollingInterval:function(i) -{if(typeof i=='number'&&isFinite(i)){this._polling_interval=i;}},createXhrObject:function(transactionId) -{var obj,http;try -{http=new XMLHttpRequest();obj={conn:http,tId:transactionId};} -catch(e) -{for(var i=0;i<this._msxml_progid.length;++i){try -{http=new ActiveXObject(this._msxml_progid[i]);obj={conn:http,tId:transactionId};break;} -catch(e){}}} -finally -{return obj;}},getConnectionObject:function() -{var o;var tId=this._transaction_id;try -{o=this.createXhrObject(tId);if(o){this._transaction_id++;}} -catch(e){} -finally -{return o;}},asyncRequest:function(method,uri,callback,postData) -{var o=this.getConnectionObject();if(!o){return null;} -else{if(this._isFormSubmit){if(this._isFileUpload){this.uploadFile(o.tId,callback,uri,postData);this.releaseObject(o);return;} -if(method.toUpperCase()=='GET'){if(this._sFormData.length!=0){uri+=((uri.indexOf('?')==-1)?'?':'&')+this._sFormData;} -else{uri+="?"+this._sFormData;}} -else if(method.toUpperCase()=='POST'){postData=postData?this._sFormData+"&"+postData:this._sFormData;}} -o.conn.open(method,uri,true);if(this._use_default_xhr_header){if(!this._default_headers['X-Requested-With']){this.initHeader('X-Requested-With',this._default_xhr_header,true);}} -if(this._isFormSubmit||(postData&&this._use_default_post_header)){this.initHeader('Content-Type',this._default_post_header);if(this._isFormSubmit){this.resetFormState();}} -if(this._has_default_headers||this._has_http_headers){this.setHeader(o);} -this.handleReadyState(o,callback);o.conn.send(postData||null);return o;}},handleReadyState:function(o,callback) -{var oConn=this;if(callback&&callback.timeout){this._timeOut[o.tId]=window.setTimeout(function(){oConn.abort(o,callback,true);},callback.timeout);} -this._poll[o.tId]=window.setInterval(function(){if(o.conn&&o.conn.readyState==4){window.clearInterval(oConn._poll[o.tId]);delete oConn._poll[o.tId];if(callback&&callback.timeout){delete oConn._timeOut[o.tId];} -oConn.handleTransactionResponse(o,callback);}},this._polling_interval);},handleTransactionResponse:function(o,callback,isAbort) -{if(!callback){this.releaseObject(o);return;} -var httpStatus,responseObject;try -{if(o.conn.status!==undefined&&o.conn.status!=0){httpStatus=o.conn.status;} -else{httpStatus=13030;}} -catch(e){httpStatus=13030;} -if(httpStatus>=200&&httpStatus<300){responseObject=this.createResponseObject(o,callback.argument);if(callback.success){if(!callback.scope){callback.success(responseObject);} -else{callback.success.apply(callback.scope,[responseObject]);}}} -else{switch(httpStatus){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:responseObject=this.createExceptionObject(o.tId,callback.argument,(isAbort?isAbort:false));if(callback.failure){if(!callback.scope){callback.failure(responseObject);} -else{callback.failure.apply(callback.scope,[responseObject]);}} -break;default:responseObject=this.createResponseObject(o,callback.argument);if(callback.failure){if(!callback.scope){callback.failure(responseObject);} -else{callback.failure.apply(callback.scope,[responseObject]);}}}} -this.releaseObject(o);responseObject=null;},createResponseObject:function(o,callbackArg) -{var obj={};var headerObj={};try -{var headerStr=o.conn.getAllResponseHeaders();var header=headerStr.split('\n');for(var i=0;i<header.length;i++){var delimitPos=header[i].indexOf(':');if(delimitPos!=-1){headerObj[header[i].substring(0,delimitPos)]=header[i].substring(delimitPos+2);}}} -catch(e){} -obj.tId=o.tId;obj.status=o.conn.status;obj.statusText=o.conn.statusText;obj.getResponseHeader=headerObj;obj.getAllResponseHeaders=headerStr;obj.responseText=o.conn.responseText;obj.responseXML=o.conn.responseXML;if(typeof callbackArg!==undefined){obj.argument=callbackArg;} -return obj;},createExceptionObject:function(tId,callbackArg,isAbort) -{var COMM_CODE=0;var COMM_ERROR='communication failure';var ABORT_CODE=-1;var ABORT_ERROR='transaction aborted';var obj={};obj.tId=tId;if(isAbort){obj.status=ABORT_CODE;obj.statusText=ABORT_ERROR;} -else{obj.status=COMM_CODE;obj.statusText=COMM_ERROR;} -if(callbackArg){obj.argument=callbackArg;} -return obj;},initHeader:function(label,value,isDefault) -{var headerObj=(isDefault)?this._default_headers:this._http_headers;if(headerObj[label]===undefined){headerObj[label]=value;} -else{headerObj[label]=value+","+headerObj[label];} -if(isDefault){this._has_default_headers=true;} -else{this._has_http_headers=true;}},setHeader:function(o) -{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]);}}} -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]);}} -delete this._http_headers;this._http_headers={};this._has_http_headers=false;}},resetDefaultHeaders:function(){delete this._default_headers -this._default_headers={};this._has_default_headers=false;},setForm:function(formId,isUpload,secureUri) -{this.resetFormState();var oForm;if(typeof formId=='string'){oForm=(document.getElementById(formId)||document.forms[formId]);} -else if(typeof formId=='object'){oForm=formId;} -else{return;} -if(isUpload){this.createFrame(secureUri?secureUri:null);this._isFormSubmit=true;this._isFileUpload=true;this._formNode=oForm;return;} -var oElement,oName,oValue,oDisabled;var hasSubmit=false;for(var i=0;i<oForm.elements.length;i++){oElement=oForm.elements[i];oDisabled=oForm.elements[i].disabled;oName=oForm.elements[i].name;oValue=oForm.elements[i].value;if(!oDisabled&&oName) -{switch(oElement.type) -{case'select-one':case'select-multiple':for(var j=0;j<oElement.options.length;j++){if(oElement.options[j].selected){if(window.ActiveXObject){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oElement.options[j].attributes['value'].specified?oElement.options[j].value:oElement.options[j].text)+'&';} -else{this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text)+'&';}}} -break;case'radio':case'checkbox':if(oElement.checked){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';} -break;case'file':case undefined:case'reset':case'button':break;case'submit':if(hasSubmit==false){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';hasSubmit=true;} -break;default:this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';break;}}} -this._isFormSubmit=true;this._sFormData=this._sFormData.substr(0,this._sFormData.length-1);return this._sFormData;},resetFormState:function(){this._isFormSubmit=false;this._isFileUpload=false;this._formNode=null;this._sFormData="";},createFrame:function(secureUri){var frameId='yuiIO'+this._transaction_id;if(window.ActiveXObject){var io=document.createElement('<iframe id="'+frameId+'" name="'+frameId+'" />');if(typeof secureUri=='boolean'){io.src='javascript:false';} -else if(typeof secureURI=='string'){io.src=secureUri;}} -else{var io=document.createElement('iframe');io.id=frameId;io.name=frameId;} -io.style.position='absolute';io.style.top='-1000px';io.style.left='-1000px';document.body.appendChild(io);},appendPostData:function(postData) -{var formElements=[];var postMessage=postData.split('&');for(var i=0;i<postMessage.length;i++){var delimitPos=postMessage[i].indexOf('=');if(delimitPos!=-1){formElements[i]=document.createElement('input');formElements[i].type='hidden';formElements[i].name=postMessage[i].substring(0,delimitPos);formElements[i].value=postMessage[i].substring(delimitPos+1);this._formNode.appendChild(formElements[i]);}} -return formElements;},uploadFile:function(id,callback,uri,postData){var frameId='yuiIO'+id;var uploadEncoding='multipart/form-data';var io=document.getElementById(frameId);this._formNode.action=uri;this._formNode.method='POST';this._formNode.target=frameId;if(this._formNode.encoding){this._formNode.encoding=uploadEncoding;} -else{this._formNode.enctype=uploadEncoding;} -if(postData){var oElements=this.appendPostData(postData);} -this._formNode.submit();if(oElements&&oElements.length>0){for(var i=0;i<oElements.length;i++){this._formNode.removeChild(oElements[i]);}} -this.resetFormState();var uploadCallback=function() -{var obj={};obj.tId=id;obj.argument=callback.argument;try -{obj.responseText=io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;obj.responseXML=io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;} -catch(e){} -if(callback&&callback.upload){if(!callback.scope){callback.upload(obj);} -else{callback.upload.apply(callback.scope,[obj]);}} -if(YAHOO.util.Event){YAHOO.util.Event.removeListener(io,"load",uploadCallback);} -else if(window.detachEvent){io.detachEvent('onload',uploadCallback);} -else{io.removeEventListener('load',uploadCallback,false);} -setTimeout(function(){document.body.removeChild(io);},100);};if(YAHOO.util.Event){YAHOO.util.Event.addListener(io,"load",uploadCallback);} -else if(window.attachEvent){io.attachEvent('onload',uploadCallback);} -else{io.addEventListener('load',uploadCallback,false);}},abort:function(o,callback,isTimeout) -{if(this.isCallInProgress(o)){o.conn.abort();window.clearInterval(this._poll[o.tId]);delete this._poll[o.tId];if(isTimeout){delete this._timeOut[o.tId];} -this.handleTransactionResponse(o,callback,true);return true;} -else{return false;}},isCallInProgress:function(o) -{if(o.conn){return o.conn.readyState!=4&&o.conn.readyState!=0;} -else{return false;}},releaseObject:function(o) -{o.conn=null;o=null;}}; -YAHOO.register("connection", YAHOO.widget.Module, {version: "2.2.0", build: "127"}); -YAHOO.util.Anim=function(el,attributes,duration,method){if(el){this.init(el,attributes,duration,method);}};YAHOO.util.Anim.prototype={toString:function(){var el=this.getEl();var id=el.id||el.tagName;return("Anim "+id);},patterns:{noNegatives:/width|height|opacity|padding/i,offsetAttribute:/^((width|height)|(top|left))$/,defaultUnit:/width|height|top$|bottom$|left$|right$/i,offsetUnit:/\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i},doMethod:function(attr,start,end){return this.method(this.currentFrame,start,end-start,this.totalFrames);},setAttribute:function(attr,val,unit){if(this.patterns.noNegatives.test(attr)){val=(val>0)?val:0;} -YAHOO.util.Dom.setStyle(this.getEl(),attr,val+unit);},getAttribute:function(attr){var el=this.getEl();var val=YAHOO.util.Dom.getStyle(el,attr);if(val!=='auto'&&!this.patterns.offsetUnit.test(val)){return 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;i<len;++i){end[i]=start[i]+attributes[attr]['by'][i];}}else{end=start+attributes[attr]['by'];}} -this.runtimeAttributes[attr].start=start;this.runtimeAttributes[attr].end=end;this.runtimeAttributes[attr].unit=(isset(attributes[attr].unit))?attributes[attr]['unit']:this.getDefaultUnit(attr);},init:function(el,attributes,duration,method){var isAnimated=false;var startTime=null;var actualFrames=0;el=YAHOO.util.Dom.get(el);this.attributes=attributes||{};this.duration=duration||1;this.method=method||YAHOO.util.Easing.easeNone;this.useSeconds=true;this.currentFrame=0;this.totalFrames=YAHOO.util.AnimMgr.fps;this.getEl=function(){return el;};this.isAnimated=function(){return isAnimated;};this.getStartTime=function(){return startTime;};this.runtimeAttributes={};this.animate=function(){if(this.isAnimated()){return false;} -this.currentFrame=0;this.totalFrames=(this.useSeconds)?Math.ceil(YAHOO.util.AnimMgr.fps*this.duration):this.duration;YAHOO.util.AnimMgr.registerElement(this);};this.stop=function(finish){if(finish){this.currentFrame=this.totalFrames;this._onTween.fire();} -YAHOO.util.AnimMgr.stop(this);};var onStart=function(){this.onStart.fire();this.runtimeAttributes={};for(var attr in this.attributes){this.setRuntimeAttribute(attr);} -isAnimated=true;actualFrames=0;startTime=new Date();};var onTween=function(){var data={duration:new Date()-this.getStartTime(),currentFrame:this.currentFrame};data.toString=function(){return('duration: '+data.duration+', currentFrame: '+data.currentFrame);};this.onTween.fire(data);var runtimeAttributes=this.runtimeAttributes;for(var attr in runtimeAttributes){this.setAttribute(attr,this.doMethod(attr,runtimeAttributes[attr].start,runtimeAttributes[attr].end),runtimeAttributes[attr].unit);} -actualFrames+=1;};var onComplete=function(){var actual_duration=(new Date()-startTime)/1000;var data={duration:actual_duration,frames:actualFrames,fps:actualFrames/actual_duration};data.toString=function(){return('duration: '+data.duration+', frames: '+data.frames+', fps: '+data.fps);};isAnimated=false;actualFrames=0;this.onComplete.fire(data);};this._onStart=new YAHOO.util.CustomEvent('_start',this,true);this.onStart=new YAHOO.util.CustomEvent('start',this);this.onTween=new YAHOO.util.CustomEvent('tween',this);this._onTween=new YAHOO.util.CustomEvent('_tween',this,true);this.onComplete=new YAHOO.util.CustomEvent('complete',this);this._onComplete=new YAHOO.util.CustomEvent('_complete',this,true);this._onStart.subscribe(onStart);this._onTween.subscribe(onTween);this._onComplete.subscribe(onComplete);}};YAHOO.util.AnimMgr=new function(){var thread=null;var queue=[];var tweenCount=0;this.fps=1000;this.delay=1;this.registerElement=function(tween){queue[queue.length]=tween;tweenCount+=1;tween._onStart.fire();this.start();};this.unRegister=function(tween,index){tween._onComplete.fire();index=index||getIndex(tween);if(index!=-1){queue.splice(index,1);} -tweenCount-=1;if(tweenCount<=0){this.stop();}};this.start=function(){if(thread===null){thread=setInterval(this.run,this.delay);}};this.stop=function(tween){if(!tween){clearInterval(thread);for(var i=0,len=queue.length;i<len;++i){if(queue[0].isAnimated()){this.unRegister(queue[0],0);}} -queue=[];thread=null;tweenCount=0;} -else{this.unRegister(tween);}};this.run=function(){for(var i=0,len=queue.length;i<len;++i){var tween=queue[i];if(!tween||!tween.isAnimated()){continue;} -if(tween.currentFrame<tween.totalFrames||tween.totalFrames===null) -{tween.currentFrame+=1;if(tween.useSeconds){correctFrame(tween);} -tween._onTween.fire();} -else{YAHOO.util.AnimMgr.stop(tween,i);}}};var getIndex=function(anim){for(var i=0,len=queue.length;i<len;++i){if(queue[i]==anim){return i;}} -return-1;};var correctFrame=function(tween){var frames=tween.totalFrames;var frame=tween.currentFrame;var expected=(tween.currentFrame*tween.duration*1000/tween.totalFrames);var elapsed=(new Date()-tween.getStartTime());var tweak=0;if(elapsed<tween.duration*1000){tweak=Math.round((elapsed/expected-1)*tween.currentFrame);}else{tweak=frames-(frame+1);} -if(tweak>0&&isFinite(tweak)){if(tween.currentFrame+tweak>=frames){tweak=frames-(frame+1);} -tween.currentFrame+=tweak;}};};YAHOO.util.Bezier=new function(){this.getPosition=function(points,t){var n=points.length;var tmp=[];for(var i=0;i<n;++i){tmp[i]=[points[i][0],points[i][1]];} -for(var j=1;j<n;++j){for(i=0;i<n-j;++i){tmp[i][0]=(1-t)*tmp[i][0]+t*tmp[parseInt(i+1,10)][0];tmp[i][1]=(1-t)*tmp[i][1]+t*tmp[parseInt(i+1,10)][1];}} -return[tmp[0][0],tmp[0][1]];};};(function(){YAHOO.util.ColorAnim=function(el,attributes,duration,method){YAHOO.util.ColorAnim.superclass.constructor.call(this,el,attributes,duration,method);};YAHOO.extend(YAHOO.util.ColorAnim,YAHOO.util.Anim);var Y=YAHOO.util;var superclass=Y.ColorAnim.superclass;var proto=Y.ColorAnim.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("ColorAnim "+id);};proto.patterns.color=/color$/i;proto.patterns.rgb=/^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;proto.patterns.hex=/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;proto.patterns.hex3=/^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;proto.patterns.transparent=/^transparent|rgba\(0, 0, 0, 0\)$/;proto.parseColor=function(s){if(s.length==3){return s;} -var c=this.patterns.hex.exec(s);if(c&&c.length==4){return[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)];} -c=this.patterns.rgb.exec(s);if(c&&c.length==4){return[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)];} -c=this.patterns.hex3.exec(s);if(c&&c.length==4){return[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)];} -return null;};proto.getAttribute=function(attr){var el=this.getEl();if(this.patterns.color.test(attr)){var val=YAHOO.util.Dom.getStyle(el,attr);if(this.patterns.transparent.test(val)){var parent=el.parentNode;val=Y.Dom.getStyle(parent,attr);while(parent&&this.patterns.transparent.test(val)){parent=parent.parentNode;val=Y.Dom.getStyle(parent,attr);if(parent.tagName.toUpperCase()=='HTML'){val='#fff';}}}}else{val=superclass.getAttribute.call(this,attr);} -return val;};proto.doMethod=function(attr,start,end){var val;if(this.patterns.color.test(attr)){val=[];for(var i=0,len=start.length;i<len;++i){val[i]=superclass.doMethod.call(this,attr,start[i],end[i]);} -val='rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';} -else{val=superclass.doMethod.call(this,attr,start,end);} -return val;};proto.setRuntimeAttribute=function(attr){superclass.setRuntimeAttribute.call(this,attr);if(this.patterns.color.test(attr)){var attributes=this.attributes;var start=this.parseColor(this.runtimeAttributes[attr].start);var end=this.parseColor(this.runtimeAttributes[attr].end);if(typeof attributes[attr]['to']==='undefined'&&typeof attributes[attr]['by']!=='undefined'){end=this.parseColor(attributes[attr].by);for(var i=0,len=start.length;i<len;++i){end[i]=start[i]+end[i];}} -this.runtimeAttributes[attr].start=start;this.runtimeAttributes[attr].end=end;}};})();YAHOO.util.Easing={easeNone:function(t,b,c,d){return c*t/d+b;},easeIn:function(t,b,c,d){return c*(t/=d)*t+b;},easeOut:function(t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeBoth:function(t,b,c,d){if((t/=d/2)<1){return c/2*t*t+b;} -return-c/2*((--t)*(t-2)-1)+b;},easeInStrong:function(t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutStrong:function(t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeBothStrong:function(t,b,c,d){if((t/=d/2)<1){return c/2*t*t*t*t+b;} -return-c/2*((t-=2)*t*t*t-2)+b;},elasticIn:function(t,b,c,d,a,p){if(t==0){return b;} -if((t/=d)==1){return b+c;} -if(!p){p=d*.3;} -if(!a||a<Math.abs(c)){a=c;var s=p/4;} -else{var s=p/(2*Math.PI)*Math.asin(c/a);} -return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},elasticOut:function(t,b,c,d,a,p){if(t==0){return b;} -if((t/=d)==1){return b+c;} -if(!p){p=d*.3;} -if(!a||a<Math.abs(c)){a=c;var s=p/4;} -else{var s=p/(2*Math.PI)*Math.asin(c/a);} -return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b;},elasticBoth:function(t,b,c,d,a,p){if(t==0){return b;} -if((t/=d/2)==2){return b+c;} -if(!p){p=d*(.3*1.5);} -if(!a||a<Math.abs(c)){a=c;var s=p/4;} -else{var s=p/(2*Math.PI)*Math.asin(c/a);} -if(t<1){return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;} -return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},backIn:function(t,b,c,d,s){if(typeof s=='undefined'){s=1.70158;} -return c*(t/=d)*t*((s+1)*t-s)+b;},backOut:function(t,b,c,d,s){if(typeof s=='undefined'){s=1.70158;} -return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},backBoth:function(t,b,c,d,s){if(typeof s=='undefined'){s=1.70158;} -if((t/=d/2)<1){return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;} -return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},bounceIn:function(t,b,c,d){return c-YAHOO.util.Easing.bounceOut(d-t,0,c,d)+b;},bounceOut:function(t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;} -return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;},bounceBoth:function(t,b,c,d){if(t<d/2){return YAHOO.util.Easing.bounceIn(t*2,0,c,d)*.5+b;} -return YAHOO.util.Easing.bounceOut(t*2-d,0,c,d)*.5+c*.5+b;}};(function(){YAHOO.util.Motion=function(el,attributes,duration,method){if(el){YAHOO.util.Motion.superclass.constructor.call(this,el,attributes,duration,method);}};YAHOO.extend(YAHOO.util.Motion,YAHOO.util.ColorAnim);var Y=YAHOO.util;var superclass=Y.Motion.superclass;var proto=Y.Motion.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("Motion "+id);};proto.patterns.points=/^points$/i;proto.setAttribute=function(attr,val,unit){if(this.patterns.points.test(attr)){unit=unit||'px';superclass.setAttribute.call(this,'left',val[0],unit);superclass.setAttribute.call(this,'top',val[1],unit);}else{superclass.setAttribute.call(this,attr,val,unit);}};proto.getAttribute=function(attr){if(this.patterns.points.test(attr)){var val=[superclass.getAttribute.call(this,'left'),superclass.getAttribute.call(this,'top')];}else{val=superclass.getAttribute.call(this,attr);} -return val;};proto.doMethod=function(attr,start,end){var val=null;if(this.patterns.points.test(attr)){var t=this.method(this.currentFrame,0,100,this.totalFrames)/100;val=Y.Bezier.getPosition(this.runtimeAttributes[attr],t);}else{val=superclass.doMethod.call(this,attr,start,end);} -return val;};proto.setRuntimeAttribute=function(attr){if(this.patterns.points.test(attr)){var el=this.getEl();var attributes=this.attributes;var start;var control=attributes['points']['control']||[];var end;var i,len;if(control.length>0&&!(control[0]instanceof Array)){control=[control];}else{var tmp=[];for(i=0,len=control.length;i<len;++i){tmp[i]=control[i];} -control=tmp;} -if(Y.Dom.getStyle(el,'position')=='static'){Y.Dom.setStyle(el,'position','relative');} -if(isset(attributes['points']['from'])){Y.Dom.setXY(el,attributes['points']['from']);} -else{Y.Dom.setXY(el,Y.Dom.getXY(el));} -start=this.getAttribute('points');if(isset(attributes['points']['to'])){end=translateValues.call(this,attributes['points']['to'],start);var pageXY=Y.Dom.getXY(this.getEl());for(i=0,len=control.length;i<len;++i){control[i]=translateValues.call(this,control[i],start);}}else if(isset(attributes['points']['by'])){end=[start[0]+attributes['points']['by'][0],start[1]+attributes['points']['by'][1]];for(i=0,len=control.length;i<len;++i){control[i]=[start[0]+control[i][0],start[1]+control[i][1]];}} -this.runtimeAttributes[attr]=[start];if(control.length>0){this.runtimeAttributes[attr]=this.runtimeAttributes[attr].concat(control);} -this.runtimeAttributes[attr][this.runtimeAttributes[attr].length]=end;} -else{superclass.setRuntimeAttribute.call(this,attr);}};var translateValues=function(val,start){var 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);}};})();YAHOO.register("animation",YAHOO.util.Anim,{version:"2.2.0",build:"127"}); -if(!YAHOO.util.DragDropMgr){YAHOO.util.DragDropMgr=function(){var Event=YAHOO.util.Event;return{ids:{},handleIds:{},dragCurrent:null,dragOvers:{},deltaX:0,deltaY:0,preventDefault:true,stopPropagation:true,initalized:false,locked:false,init:function(){this.initialized=true;},POINT:0,INTERSECT:1,STRICT_INTERSECT:2,mode:0,_execOnAll:function(sMethod,args){for(var i in this.ids){for(var j in this.ids[i]){var oDD=this.ids[i][j];if(!this.isTypeOfDD(oDD)){continue;} -oDD[sMethod].apply(oDD,args);}}},_onLoad:function(){this.init();Event.on(document,"mouseup",this.handleMouseUp,this,true);Event.on(document,"mousemove",this.handleMouseMove,this,true);Event.on(window,"unload",this._onUnload,this,true);Event.on(window,"resize",this._onResize,this,true);},_onResize:function(e){this._execOnAll("resetConstraints",[]);},lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isLocked:function(){return this.locked;},locationCache:{},useCache:true,clickPixelThresh:3,clickTimeThresh:1000,dragThreshMet:false,clickTimeout:null,startX:0,startY:0,regDragDrop:function(oDD,sGroup){if(!this.initialized){this.init();} -if(!this.ids[sGroup]){this.ids[sGroup]={};} -this.ids[sGroup][oDD.id]=oDD;},removeDDFromGroup:function(oDD,sGroup){if(!this.ids[sGroup]){this.ids[sGroup]={};} -var obj=this.ids[sGroup];if(obj&&obj[oDD.id]){delete obj[oDD.id];}},_remove:function(oDD){for(var g in oDD.groups){if(g&&this.ids[g][oDD.id]){delete this.ids[g][oDD.id];}} -delete this.handleIds[oDD.id];},regHandle:function(sDDId,sHandleId){if(!this.handleIds[sDDId]){this.handleIds[sDDId]={};} -this.handleIds[sDDId][sHandleId]=sHandleId;},isDragDrop:function(id){return(this.getDDById(id))?true:false;},getRelated:function(p_oDD,bTargetsOnly){var oDDs=[];for(var i in p_oDD.groups){for(j in this.ids[i]){var dd=this.ids[i][j];if(!this.isTypeOfDD(dd)){continue;} -if(!bTargetsOnly||dd.isTarget){oDDs[oDDs.length]=dd;}}} -return oDDs;},isLegalTarget:function(oDD,oTargetDD){var targets=this.getRelated(oDD,true);for(var i=0,len=targets.length;i<len;++i){if(targets[i].id==oTargetDD.id){return true;}} -return false;},isTypeOfDD:function(oDD){return(oDD&&oDD.__ygDragDrop);},isHandle:function(sDDId,sHandleId){return(this.handleIds[sDDId]&&this.handleIds[sDDId][sHandleId]);},getDDById:function(id){for(var i in this.ids){if(this.ids[i][id]){return this.ids[i][id];}} -return null;},handleMouseDown:function(e,oDD){this.currentTarget=YAHOO.util.Event.getTarget(e);this.dragCurrent=oDD;var el=oDD.getEl();this.startX=YAHOO.util.Event.getPageX(e);this.startY=YAHOO.util.Event.getPageY(e);this.deltaX=this.startX-el.offsetLeft;this.deltaY=this.startY-el.offsetTop;this.dragThreshMet=false;this.clickTimeout=setTimeout(function(){var DDM=YAHOO.util.DDM;DDM.startDrag(DDM.startX,DDM.startY);},this.clickTimeThresh);},startDrag:function(x,y){clearTimeout(this.clickTimeout);if(this.dragCurrent){this.dragCurrent.b4StartDrag(x,y);this.dragCurrent.startDrag(x,y);} -this.dragThreshMet=true;},handleMouseUp:function(e){if(!this.dragCurrent){return;} -clearTimeout(this.clickTimeout);if(this.dragThreshMet){this.fireEvents(e,true);}else{} -this.stopDrag(e);this.stopEvent(e);},stopEvent:function(e){if(this.stopPropagation){YAHOO.util.Event.stopPropagation(e);} -if(this.preventDefault){YAHOO.util.Event.preventDefault(e);}},stopDrag:function(e){if(this.dragCurrent){if(this.dragThreshMet){this.dragCurrent.b4EndDrag(e);this.dragCurrent.endDrag(e);} -this.dragCurrent.onMouseUp(e);} -this.dragCurrent=null;this.dragOvers={};},handleMouseMove:function(e){if(!this.dragCurrent){return true;} -if(YAHOO.util.Event.isIE&&!e.button){this.stopEvent(e);return this.handleMouseUp(e);} -if(!this.dragThreshMet){var diffX=Math.abs(this.startX-YAHOO.util.Event.getPageX(e));var diffY=Math.abs(this.startY-YAHOO.util.Event.getPageY(e));if(diffX>this.clickPixelThresh||diffY>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}} -if(this.dragThreshMet){this.dragCurrent.b4Drag(e);this.dragCurrent.onDrag(e);this.fireEvents(e,false);} -this.stopEvent(e);return true;},fireEvents:function(e,isDrop){var dc=this.dragCurrent;if(!dc||dc.isLocked()){return;} -var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);var pt=new YAHOO.util.Point(x,y);var oldOvers=[];var outEvts=[];var overEvts=[];var dropEvts=[];var enterEvts=[];for(var i in this.dragOvers){var ddo=this.dragOvers[i];if(!this.isTypeOfDD(ddo)){continue;} -if(!this.isOverTarget(pt,ddo,this.mode)){outEvts.push(ddo);} -oldOvers[i]=true;delete this.dragOvers[i];} -for(var sGroup in dc.groups){if("string"!=typeof sGroup){continue;} -for(i in this.ids[sGroup]){var oDD=this.ids[sGroup][i];if(!this.isTypeOfDD(oDD)){continue;} -if(oDD.isTarget&&!oDD.isLocked()&&oDD!=dc){if(this.isOverTarget(pt,oDD,this.mode)){if(isDrop){dropEvts.push(oDD);}else{if(!oldOvers[oDD.id]){enterEvts.push(oDD);}else{overEvts.push(oDD);} -this.dragOvers[oDD.id]=oDD;}}}}} -if(this.mode){if(outEvts.length){dc.b4DragOut(e,outEvts);dc.onDragOut(e,outEvts);} -if(enterEvts.length){dc.onDragEnter(e,enterEvts);} -if(overEvts.length){dc.b4DragOver(e,overEvts);dc.onDragOver(e,overEvts);} -if(dropEvts.length){dc.b4DragDrop(e,dropEvts);dc.onDragDrop(e,dropEvts);}}else{var len=0;for(i=0,len=outEvts.length;i<len;++i){dc.b4DragOut(e,outEvts[i].id);dc.onDragOut(e,outEvts[i].id);} -for(i=0,len=enterEvts.length;i<len;++i){dc.onDragEnter(e,enterEvts[i].id);} -for(i=0,len=overEvts.length;i<len;++i){dc.b4DragOver(e,overEvts[i].id);dc.onDragOver(e,overEvts[i].id);} -for(i=0,len=dropEvts.length;i<len;++i){dc.b4DragDrop(e,dropEvts[i].id);dc.onDragDrop(e,dropEvts[i].id);}} -if(isDrop&&!dropEvts.length){dc.onInvalidDrop(e);}},getBestMatch:function(dds){var winner=null;var len=dds.length;if(len==1){winner=dds[0];}else{for(var i=0;i<len;++i){var dd=dds[i];if(this.mode==this.INTERSECT&&dd.cursorIsOver){winner=dd;break;}else{if(!winner||!winner.overlap||(dd.overlap&&winner.overlap.getArea()<dd.overlap.getArea())){winner=dd;}}}} -return winner;},refreshCache:function(groups){var g=groups||this.ids;for(var sGroup in g){if("string"!=typeof sGroup){continue;} -for(var i in this.ids[sGroup]){var oDD=this.ids[sGroup][i];if(this.isTypeOfDD(oDD)){var loc=this.getLocation(oDD);if(loc){this.locationCache[oDD.id]=loc;}else{delete this.locationCache[oDD.id];}}}}},verifyEl:function(el){try{if(el){var parent=el.offsetParent;if(parent){return true;}}}catch(e){} -return false;},getLocation:function(oDD){if(!this.isTypeOfDD(oDD)){return null;} -var el=oDD.getEl(),pos,x1,x2,y1,y2,t,r,b,l;try{pos=YAHOO.util.Dom.getXY(el);}catch(e){} -if(!pos){return null;} -x1=pos[0];x2=x1+el.offsetWidth;y1=pos[1];y2=y1+el.offsetHeight;t=y1-oDD.padding[0];r=x2+oDD.padding[1];b=y2+oDD.padding[2];l=x1-oDD.padding[3];return new YAHOO.util.Region(t,r,b,l);},isOverTarget:function(pt,oTarget,intersect){var loc=this.locationCache[oTarget.id];if(!loc||!this.useCache){loc=this.getLocation(oTarget);this.locationCache[oTarget.id]=loc;} -if(!loc){return false;} -oTarget.cursorIsOver=loc.contains(pt);var dc=this.dragCurrent;if(!dc||!dc.getTargetCoord||(!intersect&&!dc.constrainX&&!dc.constrainY)){return oTarget.cursorIsOver;} -oTarget.overlap=null;var pos=dc.getTargetCoord(pt.x,pt.y);var el=dc.getDragEl();var curRegion=new YAHOO.util.Region(pos.y,pos.x+el.offsetWidth,pos.y+el.offsetHeight,pos.x);var overlap=curRegion.intersect(loc);if(overlap){oTarget.overlap=overlap;return(intersect)?true:oTarget.cursorIsOver;}else{return false;}},_onUnload:function(e,me){this.unregAll();},unregAll:function(){if(this.dragCurrent){this.stopDrag();this.dragCurrent=null;} -this._execOnAll("unreg",[]);for(i in this.elementCache){delete this.elementCache[i];} -this.elementCache={};this.ids={};},elementCache:{},getElWrapper:function(id){var oWrapper=this.elementCache[id];if(!oWrapper||!oWrapper.el){oWrapper=this.elementCache[id]=new this.ElementWrapper(YAHOO.util.Dom.get(id));} -return oWrapper;},getElement:function(id){return YAHOO.util.Dom.get(id);},getCss:function(id){var el=YAHOO.util.Dom.get(id);return(el)?el.style:null;},ElementWrapper:function(el){this.el=el||null;this.id=this.el&&el.id;this.css=this.el&&el.style;},getPosX:function(el){return YAHOO.util.Dom.getX(el);},getPosY:function(el){return YAHOO.util.Dom.getY(el);},swapNode:function(n1,n2){if(n1.swapNode){n1.swapNode(n2);}else{var p=n2.parentNode;var s=n2.nextSibling;if(s==n1){p.insertBefore(n1,n2);}else if(n2==n1.nextSibling){p.insertBefore(n2,n1);}else{n1.parentNode.replaceChild(n2,n1);p.insertBefore(n1,s);}}},getScroll:function(){var t,l,dde=document.documentElement,db=document.body;if(dde&&(dde.scrollTop||dde.scrollLeft)){t=dde.scrollTop;l=dde.scrollLeft;}else if(db){t=db.scrollTop;l=db.scrollLeft;}else{} -return{top:t,left:l};},getStyle:function(el,styleProp){return YAHOO.util.Dom.getStyle(el,styleProp);},getScrollTop:function(){return this.getScroll().top;},getScrollLeft:function(){return this.getScroll().left;},moveToEl:function(moveEl,targetEl){var aCoord=YAHOO.util.Dom.getXY(targetEl);YAHOO.util.Dom.setXY(moveEl,aCoord);},getClientHeight:function(){return YAHOO.util.Dom.getViewportHeight();},getClientWidth:function(){return YAHOO.util.Dom.getViewportWidth();},numericSort:function(a,b){return(a-b);},_timeoutCount:0,_addListeners:function(){var DDM=YAHOO.util.DDM;if(YAHOO.util.Event&&document){DDM._onLoad();}else{if(DDM._timeoutCount>2000){}else{setTimeout(DDM._addListeners,10);if(document&&document.body){DDM._timeoutCount+=1;}}}},handleWasClicked:function(node,id){if(this.isHandle(id,node.id)){return true;}else{var p=node.parentNode;while(p){if(this.isHandle(id,p.id)){return true;}else{p=p.parentNode;}}} -return false;}};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();} -(function(){var Event=YAHOO.util.Event;var Dom=YAHOO.util.Dom;YAHOO.util.DragDrop=function(id,sGroup,config){if(id){this.init(id,sGroup,config);}};YAHOO.util.DragDrop.prototype={id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,hasOuterHandles:false,b4StartDrag:function(x,y){},startDrag:function(x,y){},b4Drag:function(e){},onDrag:function(e){},onDragEnter:function(e,id){},b4DragOver:function(e){},onDragOver:function(e,id){},b4DragOut:function(e){},onDragOut:function(e,id){},b4DragDrop:function(e){},onDragDrop:function(e,id){},onInvalidDrop:function(e){},b4EndDrag:function(e){},endDrag:function(e){},b4MouseDown:function(e){},onMouseDown:function(e){},onMouseUp:function(e){},onAvailable:function(){},getEl:function(){if(!this._domRef){this._domRef=Dom.get(this.id);} -return this._domRef;},getDragEl:function(){return Dom.get(this.dragElId);},init:function(id,sGroup,config){this.initTarget(id,sGroup,config);Event.on(this.id,"mousedown",this.handleMouseDown,this,true);},initTarget:function(id,sGroup,config){this.config=config||{};this.DDM=YAHOO.util.DDM;this.groups={};if(typeof id!=="string"){id=Dom.generateId(id);} -this.id=id;this.addToGroup((sGroup)?sGroup:"default");this.handleElId=id;Event.onAvailable(id,this.handleOnAvailable,this,true);this.setDragElId(id);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);},handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(iTop,iRight,iBot,iLeft){if(!iRight&&0!==iRight){this.padding=[iTop,iTop,iTop,iTop];}else if(!iBot&&0!==iBot){this.padding=[iTop,iRight,iTop,iRight];}else{this.padding=[iTop,iRight,iBot,iLeft];}},setInitPosition:function(diffX,diffY){var el=this.getEl();if(!this.DDM.verifyEl(el)){return;} -var dx=diffX||0;var dy=diffY||0;var p=Dom.getXY(el);this.initPageX=p[0]-dx;this.initPageY=p[1]-dy;this.lastPageX=p[0];this.lastPageY=p[1];this.setStartPosition(p);},setStartPosition:function(pos){var p=pos||Dom.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=p[0];this.startPageY=p[1];},addToGroup:function(sGroup){this.groups[sGroup]=true;this.DDM.regDragDrop(this,sGroup);},removeFromGroup:function(sGroup){if(this.groups[sGroup]){delete this.groups[sGroup];} -this.DDM.removeDDFromGroup(this,sGroup);},setDragElId:function(id){this.dragElId=id;},setHandleElId:function(id){if(typeof id!=="string"){id=Dom.generateId(id);} -this.handleElId=id;this.DDM.regHandle(this.id,id);},setOuterHandleElId:function(id){if(typeof id!=="string"){id=Dom.generateId(id);} -Event.on(id,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(id);this.hasOuterHandles=true;},unreg:function(){Event.removeListener(this.id,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return(this.DDM.isLocked()||this.locked);},handleMouseDown:function(e,oDD){var button=e.which||e.button;if(this.primaryButtonOnly&&button>1){return;} -if(this.isLocked()){return;} -this.b4MouseDown(e);this.onMouseDown(e);this.DDM.refreshCache(this.groups);var pt=new YAHOO.util.Point(Event.getPageX(e),Event.getPageY(e));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(pt,this)){}else{if(this.clickValidator(e)){this.setStartPosition();this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}else{}}},clickValidator:function(e){var target=Event.getTarget(e);return(this.isValidHandleChild(target)&&(this.id==this.handleElId||this.DDM.handleWasClicked(target,this.id)));},addInvalidHandleType:function(tagName){var type=tagName.toUpperCase();this.invalidHandleTypes[type]=type;},addInvalidHandleId:function(id){if(typeof id!=="string"){id=Dom.generateId(id);} -this.invalidHandleIds[id]=id;},addInvalidHandleClass:function(cssClass){this.invalidHandleClasses.push(cssClass);},removeInvalidHandleType:function(tagName){var type=tagName.toUpperCase();delete this.invalidHandleTypes[type];},removeInvalidHandleId:function(id){if(typeof id!=="string"){id=Dom.generateId(id);} -delete this.invalidHandleIds[id];},removeInvalidHandleClass:function(cssClass){for(var i=0,len=this.invalidHandleClasses.length;i<len;++i){if(this.invalidHandleClasses[i]==cssClass){delete this.invalidHandleClasses[i];}}},isValidHandleChild:function(node){var valid=true;var nodeName;try{nodeName=node.nodeName.toUpperCase();}catch(e){nodeName=node.nodeName;} -valid=valid&&!this.invalidHandleTypes[nodeName];valid=valid&&!this.invalidHandleIds[node.id];for(var i=0,len=this.invalidHandleClasses.length;valid&&i<len;++i){valid=!Dom.hasClass(node,this.invalidHandleClasses[i]);} -return valid;},setXTicks:function(iStartX,iTickSize){this.xTicks=[];this.xTickSize=iTickSize;var tickMap={};for(var i=this.initPageX;i>=this.minX;i=i-iTickSize){if(!tickMap[i]){this.xTicks[this.xTicks.length]=i;tickMap[i]=true;}} -for(i=this.initPageX;i<=this.maxX;i=i+iTickSize){if(!tickMap[i]){this.xTicks[this.xTicks.length]=i;tickMap[i]=true;}} -this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(iStartY,iTickSize){this.yTicks=[];this.yTickSize=iTickSize;var tickMap={};for(var i=this.initPageY;i>=this.minY;i=i-iTickSize){if(!tickMap[i]){this.yTicks[this.yTicks.length]=i;tickMap[i]=true;}} -for(i=this.initPageY;i<=this.maxY;i=i+iTickSize){if(!tickMap[i]){this.yTicks[this.yTicks.length]=i;tickMap[i]=true;}} -this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(iLeft,iRight,iTickSize){this.leftConstraint=parseInt(iLeft,10);this.rightConstraint=parseInt(iRight,10);this.minX=this.initPageX-this.leftConstraint;this.maxX=this.initPageX+this.rightConstraint;if(iTickSize){this.setXTicks(this.initPageX,iTickSize);} -this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(iUp,iDown,iTickSize){this.topConstraint=parseInt(iUp,10);this.bottomConstraint=parseInt(iDown,10);this.minY=this.initPageY-this.topConstraint;this.maxY=this.initPageY+this.bottomConstraint;if(iTickSize){this.setYTicks(this.initPageY,iTickSize);} -this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var dx=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var dy=(this.maintainOffset)?this.lastPageY-this.initPageY:0;this.setInitPosition(dx,dy);}else{this.setInitPosition();} -if(this.constrainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);} -if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(val,tickArray){if(!tickArray){return val;}else if(tickArray[0]>=val){return tickArray[0];}else{for(var i=0,len=tickArray.length;i<len;++i){var next=i+1;if(tickArray[next]&&tickArray[next]>=val){var diff1=val-tickArray[i];var diff2=tickArray[next]-val;return(diff2>diff1)?tickArray[i]:tickArray[next];}} -return tickArray[tickArray.length-1];}},toString:function(){return("DragDrop "+this.id);}};})();YAHOO.util.DD=function(id,sGroup,config){if(id){this.init(id,sGroup,config);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop,{scroll:true,autoOffset:function(iPageX,iPageY){var x=iPageX-this.startPageX;var y=iPageY-this.startPageY;this.setDelta(x,y);},setDelta:function(iDeltaX,iDeltaY){this.deltaX=iDeltaX;this.deltaY=iDeltaY;},setDragElPos:function(iPageX,iPageY){var el=this.getDragEl();this.alignElWithMouse(el,iPageX,iPageY);},alignElWithMouse:function(el,iPageX,iPageY){var oCoord=this.getTargetCoord(iPageX,iPageY);if(!this.deltaSetXY){var aCoord=[oCoord.x,oCoord.y];YAHOO.util.Dom.setXY(el,aCoord);var newLeft=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var newTop=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);this.deltaSetXY=[newLeft-oCoord.x,newTop-oCoord.y];}else{YAHOO.util.Dom.setStyle(el,"left",(oCoord.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(el,"top",(oCoord.y+this.deltaSetXY[1])+"px");} -this.cachePosition(oCoord.x,oCoord.y);this.autoScroll(oCoord.x,oCoord.y,el.offsetHeight,el.offsetWidth);},cachePosition:function(iPageX,iPageY){if(iPageX){this.lastPageX=iPageX;this.lastPageY=iPageY;}else{var aCoord=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=aCoord[0];this.lastPageY=aCoord[1];}},autoScroll:function(x,y,h,w){if(this.scroll){var clientH=this.DDM.getClientHeight();var clientW=this.DDM.getClientWidth();var st=this.DDM.getScrollTop();var sl=this.DDM.getScrollLeft();var bot=h+y;var right=w+x;var toBot=(clientH+st-y-this.deltaY);var toRight=(clientW+sl-x-this.deltaX);var thresh=40;var scrAmt=(document.all)?80:30;if(bot>clientH&&toBot<thresh){window.scrollTo(sl,st+scrAmt);} -if(y<st&&st>0&&y-st<thresh){window.scrollTo(sl,st-scrAmt);} -if(right>clientW&&toRight<thresh){window.scrollTo(sl+scrAmt,st);} -if(x<sl&&sl>0&&x-sl<thresh){window.scrollTo(sl-scrAmt,st);}}},getTargetCoord:function(iPageX,iPageY){var x=iPageX-this.deltaX;var y=iPageY-this.deltaY;if(this.constrainX){if(x<this.minX){x=this.minX;} -if(x>this.maxX){x=this.maxX;}} -if(this.constrainY){if(y<this.minY){y=this.minY;} -if(y>this.maxY){y=this.maxY;}} -x=this.getTick(x,this.xTicks);y=this.getTick(y,this.yTicks);return{x:x,y:y};},applyConfig:function(){YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll=(this.config.scroll!==false);},b4MouseDown:function(e){this.setStartPosition();this.autoOffset(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));},b4Drag:function(e){this.setDragElPos(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));},toString:function(){return("DD "+this.id);}});YAHOO.util.DDProxy=function(id,sGroup,config){if(id){this.init(id,sGroup,config);this.initFrame();}};YAHOO.util.DDProxy.dragElId="ygddfdiv";YAHOO.extend(YAHOO.util.DDProxy,YAHOO.util.DD,{resizeFrame:true,centerFrame:false,createFrame:function(){var self=this;var body=document.body;if(!body||!body.firstChild){setTimeout(function(){self.createFrame();},50);return;} -var div=this.getDragEl();if(!div){div=document.createElement("div");div.id=this.dragElId;var s=div.style;s.position="absolute";s.visibility="hidden";s.cursor="move";s.border="2px solid #aaa";s.zIndex=999;body.insertBefore(div,body.firstChild);}},initFrame:function(){this.createFrame();},applyConfig:function(){YAHOO.util.DDProxy.superclass.applyConfig.call(this);this.resizeFrame=(this.config.resizeFrame!==false);this.centerFrame=(this.config.centerFrame);this.setDragElId(this.config.dragElId||YAHOO.util.DDProxy.dragElId);},showFrame:function(iPageX,iPageY){var el=this.getEl();var dragEl=this.getDragEl();var s=dragEl.style;this._resizeProxy();if(this.centerFrame){this.setDelta(Math.round(parseInt(s.width,10)/2),Math.round(parseInt(s.height,10)/2));} -this.setDragElPos(iPageX,iPageY);YAHOO.util.Dom.setStyle(dragEl,"visibility","visible");},_resizeProxy:function(){if(this.resizeFrame){var DOM=YAHOO.util.Dom;var el=this.getEl();var dragEl=this.getDragEl();var bt=parseInt(DOM.getStyle(dragEl,"borderTopWidth"),10);var br=parseInt(DOM.getStyle(dragEl,"borderRightWidth"),10);var bb=parseInt(DOM.getStyle(dragEl,"borderBottomWidth"),10);var bl=parseInt(DOM.getStyle(dragEl,"borderLeftWidth"),10);if(isNaN(bt)){bt=0;} -if(isNaN(br)){br=0;} -if(isNaN(bb)){bb=0;} -if(isNaN(bl)){bl=0;} -var newWidth=Math.max(0,el.offsetWidth-br-bl);var newHeight=Math.max(0,el.offsetHeight-bt-bb);DOM.setStyle(dragEl,"width",newWidth+"px");DOM.setStyle(dragEl,"height",newHeight+"px");}},b4MouseDown:function(e){this.setStartPosition();var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.autoOffset(x,y);this.setDragElPos(x,y);},b4StartDrag:function(x,y){this.showFrame(x,y);},b4EndDrag:function(e){YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden");},endDrag:function(e){var DOM=YAHOO.util.Dom;var lel=this.getEl();var del=this.getDragEl();DOM.setStyle(del,"visibility","");DOM.setStyle(lel,"visibility","hidden");YAHOO.util.DDM.moveToEl(lel,del);DOM.setStyle(del,"visibility","hidden");DOM.setStyle(lel,"visibility","");},toString:function(){return("DDProxy "+this.id);}});YAHOO.util.DDTarget=function(id,sGroup,config){if(id){this.initTarget(id,sGroup,config);}};YAHOO.extend(YAHOO.util.DDTarget,YAHOO.util.DragDrop,{toString:function(){return("DDTarget "+this.id);}});YAHOO.register("dragdrop",YAHOO.util.DragDropMgr,{version:"2.2.0",build:"127"}); -YAHOO.util.Attribute=function(hash,owner){if(owner){this.owner=owner;this.configure(hash,true);}};YAHOO.util.Attribute.prototype={name:undefined,value:null,owner:null,readOnly:false,writeOnce:false,_initialConfig:null,_written:false,method:null,validator:null,getValue:function(){return this.value;},setValue:function(value,silent){var beforeRetVal;var owner=this.owner;var name=this.name;var event={type:name,prevValue:this.getValue(),newValue:value};if(this.readOnly||(this.writeOnce&&this._written)){return false;} -if(this.validator&&!this.validator.call(owner,value)){return false;} -if(!silent){beforeRetVal=owner.fireBeforeChangeEvent(event);if(beforeRetVal===false){return false;}} -if(this.method){this.method.call(owner,value);} -this.value=value;this._written=true;event.type=name;if(!silent){this.owner.fireChangeEvent(event);} -return true;},configure:function(map,init){map=map||{};this._written=false;this._initialConfig=this._initialConfig||{};for(var key in map){if(key&&YAHOO.lang.hasOwnProperty(map,key)){this[key]=map[key];if(init){this._initialConfig[key]=map[key];}}}},resetValue:function(){return this.setValue(this._initialConfig.value);},resetConfig:function(){this.configure(this._initialConfig);},refresh:function(silent){this.setValue(this.value,silent);}};(function(){var Lang=YAHOO.util.Lang;YAHOO.util.AttributeProvider=function(){};YAHOO.util.AttributeProvider.prototype={_configs:null,get:function(key){var configs=this._configs||{};var config=configs[key];if(!config){return undefined;} -return config.value;},set:function(key,value,silent){var configs=this._configs||{};var config=configs[key];if(!config){return false;} -return config.setValue(value,silent);},getAttributeKeys:function(){var configs=this._configs;var keys=[];var config;for(var key in configs){config=configs[key];if(Lang.hasOwnProperty(configs,key)&&!Lang.isUndefined(config)){keys[keys.length]=key;}} -return keys;},setAttributes:function(map,silent){for(var key in map){if(Lang.hasOwnProperty(map,key)){this.set(key,map[key],silent);}}},resetValue:function(key,silent){var configs=this._configs||{};if(configs[key]){this.set(key,configs[key]._initialConfig.value,silent);return true;} -return false;},refresh:function(key,silent){var configs=this._configs;key=((Lang.isString(key))?[key]:key)||this.getAttributeKeys();for(var i=0,len=key.length;i<len;++i){if(configs[key[i]]&&!Lang.isUndefined(configs[key[i]].value)&&!Lang.isNull(configs[key[i]].value)){configs[key[i]].refresh(silent);}}},register:function(key,map){this.setAttributeConfig(key,map);},getAttributeConfig:function(key){var configs=this._configs||{};var config=configs[key]||{};var map={};for(key in config){if(Lang.hasOwnProperty(config,key)){map[key]=config[key];}} -return map;},setAttributeConfig:function(key,map,init){var configs=this._configs||{};map=map||{};if(!configs[key]){map.name=key;configs[key]=new YAHOO.util.Attribute(map,this);}else{configs[key].configure(map,init);}},configureAttribute:function(key,map,init){this.setAttributeConfig(key,map,init);},resetAttributeConfig:function(key){var configs=this._configs||{};configs[key].resetConfig();},fireBeforeChangeEvent:function(e){var type='before';type+=e.type.charAt(0).toUpperCase()+e.type.substr(1)+'Change';e.type=type;return this.fireEvent(e.type,e);},fireChangeEvent:function(e){e.type+='Change';return this.fireEvent(e.type,e);}};YAHOO.augment(YAHOO.util.AttributeProvider,YAHOO.util.EventProvider);})();(function(){var Dom=YAHOO.util.Dom,EventPublisher=YAHOO.util.EventPublisher,AttributeProvider=YAHOO.util.AttributeProvider;YAHOO.util.Element=function(el,map){if(arguments.length){this.init(el,map);}};YAHOO.util.Element.prototype={DOM_EVENTS:null,appendChild:function(child){child=child.get?child.get('element'):child;this.get('element').appendChild(child);},getElementsByTagName:function(tag){return this.get('element').getElementsByTagName(tag);},hasChildNodes:function(){return this.get('element').hasChildNodes();},insertBefore:function(element,before){element=element.get?element.get('element'):element;before=(before&&before.get)?before.get('element'):before;this.get('element').insertBefore(element,before);},removeChild:function(child){child=child.get?child.get('element'):child;this.get('element').removeChild(child);return true;},replaceChild:function(newNode,oldNode){newNode=newNode.get?newNode.get('element'):newNode;oldNode=oldNode.get?oldNode.get('element'):oldNode;return this.get('element').replaceChild(newNode,oldNode);},initAttributes:function(map){map=map||{};var element=Dom.get(map.element)||null;this.setAttributeConfig('element',{value:element,readOnly:true});},addListener:function(type,fn,obj,scope){var el=this.get('element');var scope=scope||this;el=this.get('id')||el;if(!this._events[type]){if(this.DOM_EVENTS[type]){YAHOO.util.Event.addListener(el,type,function(e){if(e.srcElement&&!e.target){e.target=e.srcElement;} -this.fireEvent(type,e);},obj,scope);} -this.createEvent(type,this);this._events[type]=true;} -this.subscribe.apply(this,arguments);},on:function(){this.addListener.apply(this,arguments);},removeListener:function(type,fn){this.unsubscribe.apply(this,arguments);},addClass:function(className){Dom.addClass(this.get('element'),className);},getElementsByClassName:function(className,tag){return Dom.getElementsByClassName(className,tag,this.get('element'));},hasClass:function(className){return Dom.hasClass(this.get('element'),className);},removeClass:function(className){return Dom.removeClass(this.get('element'),className);},replaceClass:function(oldClassName,newClassName){return Dom.replaceClass(this.get('element'),oldClassName,newClassName);},setStyle:function(property,value){var el=this.get('element');if(!el){this._queue[this._queue.length]=['setStyle',arguments];return false;} -return Dom.setStyle(this.get('element'),property,value);},getStyle:function(property){return Dom.getStyle(this.get('element'),property);},fireQueue:function(){var queue=this._queue;for(var i=0,len=queue.length;i<len;++i){this[queue[i][0]].apply(this,queue[i][1]);}},appendTo:function(parent,before){parent=(parent.get)?parent.get('element'):Dom.get(parent);this.fireEvent('beforeAppendTo',{type:'beforeAppendTo',target:parent});before=(before&&before.get)?before.get('element'):Dom.get(before);var element=this.get('element');if(!element){return false;} -if(!parent){return false;} -if(element.parent!=parent){if(before){parent.insertBefore(element,before);}else{parent.appendChild(element);}} -this.fireEvent('appendTo',{type:'appendTo',target:parent});},get:function(key){var configs=this._configs||{};var el=configs.element;if(el&&!configs[key]&&!YAHOO.lang.isUndefined(el.value[key])){return el.value[key];} -return AttributeProvider.prototype.get.call(this,key);},set:function(key,value,silent){var el=this.get('element');if(!el){this._queue[this._queue.length]=['set',arguments];if(this._configs[key]){this._configs[key].value=value;} -return;} -if(!this._configs[key]&&!YAHOO.lang.isUndefined(el[key])){_registerHTMLAttr.call(this,key);} -return AttributeProvider.prototype.set.apply(this,arguments);},setAttributeConfig:function(key,map,init){var el=this.get('element');if(el&&!this._configs[key]&&!YAHOO.lang.isUndefined(el[key])){_registerHTMLAttr.call(this,key,map);}else{AttributeProvider.prototype.setAttributeConfig.apply(this,arguments);}},getAttributeKeys:function(){var el=this.get('element');var keys=AttributeProvider.prototype.getAttributeKeys.call(this);for(var key in el){if(!this._configs[key]){keys[key]=keys[key]||el[key];}} -return keys;},init:function(el,attr){this._queue=this._queue||[];this._events=this._events||{};this._configs=this._configs||{};attr=attr||{};attr.element=attr.element||el||null;this.DOM_EVENTS={'click':true,'keydown':true,'keypress':true,'keyup':true,'mousedown':true,'mousemove':true,'mouseout':true,'mouseover':true,'mouseup':true};var readyHandler=function(){this.initAttributes(attr);this.setAttributes(attr,true);this.fireQueue();this.fireEvent('contentReady',{type:'contentReady',target:attr.element});};if(YAHOO.lang.isString(el)){_registerHTMLAttr.call(this,'id',{value:el});YAHOO.util.Event.onAvailable(el,function(){attr.element=Dom.get(el);this.fireEvent('available',{type:'available',target:attr.element});},this,true);YAHOO.util.Event.onContentReady(el,function(){readyHandler.call(this);},this,true);}else{readyHandler.call(this);}}};var _registerHTMLAttr=function(key,map){var el=this.get('element');map=map||{};map.name=key;map.method=map.method||function(value){el[key]=value;};map.value=map.value||el[key];this._configs[key]=new YAHOO.util.Attribute(map,this);};YAHOO.augment(YAHOO.util.Element,AttributeProvider);})();YAHOO.register("element",YAHOO.util.Element,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/yahoo-dom-event/README b/interface/web/js/yui/yahoo-dom-event/README deleted file mode 100644 index 155203814e..0000000000 --- a/interface/web/js/yui/yahoo-dom-event/README +++ /dev/null @@ -1,35 +0,0 @@ -yahoo-event-dom.js Release Notes - -*** NOTE *** - -This document is not updated with each release. Changes to -the yahoo-dom-event.js source are noted in the README -file for each component that comprises this aggregate: - -yahoo/README -dom/README -event/README - -************ - -*** version 0.12.0 *** - -The yahoo-event-dom.js file rolls up the three most commonly-used YUI Utilities -into a single file; it includes the following files: - -* Yahoo Global Object -* Dom -* Event - -These three files serve as a common foundation for most YUI components and -third-party implementations. On pages where you do not need additional YUI -Utilities (Connection Manager, Animation Utility, Drag & Drop Utility), the -yahoo-event-dom.js aggregate will often be an optimal choice. - -Note: If you do require additional utilities, the full utilities.js file is -provided in this distribution; utilities.js includes all YUI Utilities in a -single file. - -Please see the blog article on www.yuiblog.com titled "YUI: Weighing in on -Pageweights" at http://yuiblog.com/blog/2006/10/16/pageweight-yui0114/ for more -details. diff --git a/interface/web/js/yui/yahoo-dom-event/yahoo-dom-event.js b/interface/web/js/yui/yahoo-dom-event/yahoo-dom-event.js deleted file mode 100644 index b5a6446a35..0000000000 --- a/interface/web/js/yui/yahoo-dom-event/yahoo-dom-event.js +++ /dev/null @@ -1,144 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -if(typeof YAHOO=="undefined"){var YAHOO={};} -YAHOO.namespace=function(){var a=arguments,o=null,i,j,d;for(i=0;i<a.length;i=i+1){d=a[i].split(".");o=YAHOO;for(j=(d[0]=="YAHOO")?1:0;j<d.length;j=j+1){o[d[j]]=o[d[j]]||{};o=o[d[j]];}} -return o;};YAHOO.log=function(msg,cat,src){var l=YAHOO.widget.Logger;if(l&&l.log){return l.log(msg,cat,src);}else{return false;}};YAHOO.init=function(){this.namespace("util","widget","example");if(typeof YAHOO_config!="undefined"){var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i;if(l){for(i=0;i<ls.length;i=i+1){if(ls[i]==l){unique=false;break;}} -if(unique){ls.push(l);}}}};YAHOO.register=function(name,mainClass,data){var mods=YAHOO.env.modules;if(!mods[name]){mods[name]={versions:[],builds:[]};} -var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners;m.name=name;m.version=v;m.build=b;m.versions.push(v);m.builds.push(b);m.mainClass=mainClass;for(var i=0;i<ls.length;i=i+1){ls[i](m);} -if(mainClass){mainClass.VERSION=v;mainClass.BUILD=b;}else{YAHOO.log("mainClass is undefined for module "+name,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[],getVersion:function(name){return YAHOO.env.modules[name]||null;}};YAHOO.lang={isArray:function(obj){if(obj.constructor&&obj.constructor.toString().indexOf('Array')>-1){return true;}else{return YAHOO.lang.isObject(obj)&&obj.constructor==Array;}},isBoolean:function(obj){return typeof obj=='boolean';},isFunction:function(obj){return typeof obj=='function';},isNull:function(obj){return obj===null;},isNumber:function(obj){return typeof obj=='number'&&isFinite(obj);},isObject:function(obj){return typeof obj=='object'||YAHOO.lang.isFunction(obj);},isString:function(obj){return typeof obj=='string';},isUndefined:function(obj){return typeof obj=='undefined';},hasOwnProperty:function(obj,prop){if(Object.prototype.hasOwnProperty){return obj.hasOwnProperty(prop);} -return!YAHOO.lang.isUndefined(obj[prop])&&obj.constructor.prototype[prop]!==obj[prop];},extend:function(subc,superc,overrides){var F=function(){};F.prototype=superc.prototype;subc.prototype=new F();subc.prototype.constructor=subc;subc.superclass=superc.prototype;if(superc.prototype.constructor==Object.prototype.constructor){superc.prototype.constructor=superc;} -if(overrides){for(var i in overrides){subc.prototype[i]=overrides[i];}}},augment:function(r,s){var rp=r.prototype,sp=s.prototype,a=arguments,i,p;if(a[2]){for(i=2;i<a.length;i=i+1){rp[a[i]]=sp[a[i]];}}else{for(p in sp){if(!rp[p]){rp[p]=sp[p];}}}}};YAHOO.init();YAHOO.util.Lang=YAHOO.lang;YAHOO.augment=YAHOO.lang.augment;YAHOO.extend=YAHOO.lang.extend;YAHOO.register("yahoo",YAHOO,{version:"2.2.0",build:"127"}); -(function(){var Y=YAHOO.util,getStyle,setStyle,id_counter=0,propertyCache={};var ua=navigator.userAgent.toLowerCase(),isOpera=(ua.indexOf('opera')>-1),isSafari=(ua.indexOf('safari')>-1),isGecko=(!isOpera&&!isSafari&&ua.indexOf('gecko')>-1),isIE=(!isOpera&&ua.indexOf('msie')>-1);var patterns={HYPHEN:/(-[a-z])/i};var toCamel=function(property){if(!patterns.HYPHEN.test(property)){return property;} -if(propertyCache[property]){return propertyCache[property];} -while(patterns.HYPHEN.exec(property)){property=property.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());} -propertyCache[property]=property;return property;};if(document.defaultView&&document.defaultView.getComputedStyle){getStyle=function(el,property){var value=null;var computed=document.defaultView.getComputedStyle(el,'');if(computed){value=computed[toCamel(property)];} -return el.style[property]||value;};}else if(document.documentElement.currentStyle&&isIE){getStyle=function(el,property){switch(toCamel(property)){case'opacity':var val=100;try{val=el.filters['DXImageTransform.Microsoft.Alpha'].opacity;}catch(e){try{val=el.filters('alpha').opacity;}catch(e){}} -return val/100;break;default:var value=el.currentStyle?el.currentStyle[property]:null;return(el.style[property]||value);}};}else{getStyle=function(el,property){return el.style[property];};} -if(isIE){setStyle=function(el,property,val){switch(property){case'opacity':if(typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}} -break;default:el.style[property]=val;}};}else{setStyle=function(el,property,val){el.style[property]=val;};} -YAHOO.util.Dom={get:function(el){if(!el){return null;} -if(typeof el!='string'&&!(el instanceof Array)){return el;} -if(typeof el=='string'){return document.getElementById(el);} -else{var collection=[];for(var i=0,len=el.length;i<len;++i){collection[collection.length]=Y.Dom.get(el[i]);} -return collection;} -return null;},getStyle:function(el,property){property=toCamel(property);var f=function(element){return getStyle(element,property);};return Y.Dom.batch(el,f,Y.Dom,true);},setStyle:function(el,property,val){property=toCamel(property);var f=function(element){setStyle(element,property,val);};Y.Dom.batch(el,f,Y.Dom,true);},getXY:function(el){var f=function(el){if(el.parentNode===null||el.offsetParent===null||this.getStyle(el,'display')=='none'){return false;} -var parentNode=null;var pos=[];var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var doc=document;if(!this.inDocument(el)&&parent.document!=document){doc=parent.document;if(!this.isAncestor(doc.documentElement,el)){return false;}} -var scrollTop=Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);var scrollLeft=Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);return[box.left+scrollLeft,box.top+scrollTop];} -else{pos=[el.offsetLeft,el.offsetTop];parentNode=el.offsetParent;if(parentNode!=el){while(parentNode){pos[0]+=parentNode.offsetLeft;pos[1]+=parentNode.offsetTop;parentNode=parentNode.offsetParent;}} -if(isSafari&&this.getStyle(el,'position')=='absolute'){pos[0]-=document.body.offsetLeft;pos[1]-=document.body.offsetTop;}} -if(el.parentNode){parentNode=el.parentNode;} -else{parentNode=null;} -while(parentNode&&parentNode.tagName.toUpperCase()!='BODY'&&parentNode.tagName.toUpperCase()!='HTML') -{if(Y.Dom.getStyle(parentNode,'display')!='inline'){pos[0]-=parentNode.scrollLeft;pos[1]-=parentNode.scrollTop;} -if(parentNode.parentNode){parentNode=parentNode.parentNode;}else{parentNode=null;}} -return pos;};return Y.Dom.batch(el,f,Y.Dom,true);},getX:function(el){var f=function(el){return Y.Dom.getXY(el)[0];};return Y.Dom.batch(el,f,Y.Dom,true);},getY:function(el){var f=function(el){return Y.Dom.getXY(el)[1];};return Y.Dom.batch(el,f,Y.Dom,true);},setXY:function(el,pos,noRetry){var f=function(el){var style_pos=this.getStyle(el,'position');if(style_pos=='static'){this.setStyle(el,'position','relative');style_pos='relative';} -var pageXY=this.getXY(el);if(pageXY===false){return false;} -var delta=[parseInt(this.getStyle(el,'left'),10),parseInt(this.getStyle(el,'top'),10)];if(isNaN(delta[0])){delta[0]=(style_pos=='relative')?0:el.offsetLeft;} -if(isNaN(delta[1])){delta[1]=(style_pos=='relative')?0:el.offsetTop;} -if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+'px';} -if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+'px';} -if(!noRetry){var newXY=this.getXY(el);if((pos[0]!==null&&newXY[0]!=pos[0])||(pos[1]!==null&&newXY[1]!=pos[1])){this.setXY(el,pos,true);}}};Y.Dom.batch(el,f,Y.Dom,true);},setX:function(el,x){Y.Dom.setXY(el,[x,null]);},setY:function(el,y){Y.Dom.setXY(el,[null,y]);},getRegion:function(el){var f=function(el){var region=new Y.Region.getRegion(el);return region;};return Y.Dom.batch(el,f,Y.Dom,true);},getClientWidth:function(){return Y.Dom.getViewportWidth();},getClientHeight:function(){return Y.Dom.getViewportHeight();},getElementsByClassName:function(className,tag,root){var method=function(el){return Y.Dom.hasClass(el,className);};return Y.Dom.getElementsBy(method,tag,root);},hasClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');var f=function(el){return re.test(el['className']);};return Y.Dom.batch(el,f,Y.Dom,true);},addClass:function(el,className){var f=function(el){if(this.hasClass(el,className)){return;} -el['className']=[el['className'],className].join(' ');};Y.Dom.batch(el,f,Y.Dom,true);},removeClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,className)){return;} -var c=el['className'];el['className']=c.replace(re,' ');if(this.hasClass(el,className)){this.removeClass(el,className);}};Y.Dom.batch(el,f,Y.Dom,true);},replaceClass:function(el,oldClassName,newClassName){if(oldClassName===newClassName){return false;} -var re=new RegExp('(?:^|\\s+)'+oldClassName+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,oldClassName)){this.addClass(el,newClassName);return;} -el['className']=el['className'].replace(re,' '+newClassName+' ');if(this.hasClass(el,oldClassName)){this.replaceClass(el,oldClassName,newClassName);}};Y.Dom.batch(el,f,Y.Dom,true);},generateId:function(el,prefix){prefix=prefix||'yui-gen';el=el||{};var f=function(el){if(el){el=Y.Dom.get(el);}else{el={};} -if(!el.id){el.id=prefix+id_counter++;} -return el.id;};return Y.Dom.batch(el,f,Y.Dom,true);},isAncestor:function(haystack,needle){haystack=Y.Dom.get(haystack);if(!haystack||!needle){return false;} -var f=function(needle){if(haystack.contains&&!isSafari){return haystack.contains(needle);} -else if(haystack.compareDocumentPosition){return!!(haystack.compareDocumentPosition(needle)&16);} -else{var parent=needle.parentNode;while(parent){if(parent==haystack){return true;} -else if(!parent.tagName||parent.tagName.toUpperCase()=='HTML'){return false;} -parent=parent.parentNode;} -return false;}};return Y.Dom.batch(needle,f,Y.Dom,true);},inDocument:function(el){var f=function(el){return this.isAncestor(document.documentElement,el);};return Y.Dom.batch(el,f,Y.Dom,true);},getElementsBy:function(method,tag,root){tag=tag||'*';var nodes=[];if(root){root=Y.Dom.get(root);if(!root){return nodes;}}else{root=document;} -var elements=root.getElementsByTagName(tag);if(!elements.length&&(tag=='*'&&root.all)){elements=root.all;} -for(var i=0,len=elements.length;i<len;++i){if(method(elements[i])){nodes[nodes.length]=elements[i];}} -return nodes;},batch:function(el,method,o,override){var id=el;el=Y.Dom.get(el);var scope=(override)?o:window;if(!el||el.tagName||!el.length){if(!el){return false;} -return method.call(scope,el,o);} -var collection=[];for(var i=0,len=el.length;i<len;++i){if(!el[i]){id=el[i];} -collection[collection.length]=method.call(scope,el[i],o);} -return collection;},getDocumentHeight:function(){var scrollHeight=(document.compatMode!='CSS1Compat')?document.body.scrollHeight:document.documentElement.scrollHeight;var h=Math.max(scrollHeight,Y.Dom.getViewportHeight());return h;},getDocumentWidth:function(){var scrollWidth=(document.compatMode!='CSS1Compat')?document.body.scrollWidth:document.documentElement.scrollWidth;var w=Math.max(scrollWidth,Y.Dom.getViewportWidth());return w;},getViewportHeight:function(){var height=self.innerHeight;var mode=document.compatMode;if((mode||isIE)&&!isOpera){height=(mode=='CSS1Compat')?document.documentElement.clientHeight:document.body.clientHeight;} -return height;},getViewportWidth:function(){var width=self.innerWidth;var mode=document.compatMode;if(mode||isIE){width=(mode=='CSS1Compat')?document.documentElement.clientWidth:document.body.clientWidth;} -return width;}};})();YAHOO.util.Region=function(t,r,b,l){this.top=t;this[1]=t;this.right=r;this.bottom=b;this.left=l;this[0]=l;};YAHOO.util.Region.prototype.contains=function(region){return(region.left>=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];} -this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region();YAHOO.register("dom",YAHOO.util.Dom,{version:"2.2.0",build:"127"}); -if(!YAHOO.util.Event){YAHOO.util.Event=function(){var loadComplete=false;var listeners=[];var unloadListeners=[];var legacyEvents=[];var legacyHandlers=[];var retryCount=0;var onAvailStack=[];var legacyMap=[];var counter=0;var lastError=null;return{POLL_RETRYS:200,POLL_INTERVAL:20,EL:0,TYPE:1,FN:2,WFN:3,OBJ:3,ADJ_SCOPE:4,isSafari:(/KHTML/gi).test(navigator.userAgent),webkit:function(){var v=navigator.userAgent.match(/AppleWebKit\/([^ ]*)/);if(v&&v[1]){return v[1];} -return null;}(),isIE:(!this.webkit&&!navigator.userAgent.match(/opera/gi)&&navigator.userAgent.match(/msie/gi)),_interval:null,startInterval:function(){if(!this._interval){var self=this;var callback=function(){self._tryPreloadAttach();};this._interval=setInterval(callback,this.POLL_INTERVAL);}},onAvailable:function(p_id,p_fn,p_obj,p_override){onAvailStack.push({id:p_id,fn:p_fn,obj:p_obj,override:p_override,checkReady:false});retryCount=this.POLL_RETRYS;this.startInterval();},onContentReady:function(p_id,p_fn,p_obj,p_override){onAvailStack.push({id:p_id,fn:p_fn,obj:p_obj,override:p_override,checkReady:true});retryCount=this.POLL_RETRYS;this.startInterval();},addListener:function(el,sType,fn,obj,override){if(!fn||!fn.call){return false;} -if(this._isValidCollection(el)){var ok=true;for(var i=0,len=el.length;i<len;++i){ok=this.on(el[i],sType,fn,obj,override)&&ok;} -return ok;}else if(typeof el=="string"){var oEl=this.getEl(el);if(oEl){el=oEl;}else{this.onAvailable(el,function(){YAHOO.util.Event.on(el,sType,fn,obj,override);});return true;}} -if(!el){return false;} -if("unload"==sType&&obj!==this){unloadListeners[unloadListeners.length]=[el,sType,fn,obj,override];return true;} -var scope=el;if(override){if(override===true){scope=obj;}else{scope=override;}} -var wrappedFn=function(e){return fn.call(scope,YAHOO.util.Event.getEvent(e),obj);};var li=[el,sType,fn,wrappedFn,scope];var index=listeners.length;listeners[index]=li;if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);if(legacyIndex==-1||el!=legacyEvents[legacyIndex][0]){legacyIndex=legacyEvents.length;legacyMap[el.id+sType]=legacyIndex;legacyEvents[legacyIndex]=[el,sType,el["on"+sType]];legacyHandlers[legacyIndex]=[];el["on"+sType]=function(e){YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(e),legacyIndex);};} -legacyHandlers[legacyIndex].push(li);}else{try{this._simpleAdd(el,sType,wrappedFn,false);}catch(ex){this.lastError=ex;this.removeListener(el,sType,fn);return false;}} -return true;},fireLegacyEvent:function(e,legacyIndex){var ok=true,le,lh,li,scope,ret;lh=legacyHandlers[legacyIndex];for(var i=0,len=lh.length;i<len;++i){li=lh[i];if(li&&li[this.WFN]){scope=li[this.ADJ_SCOPE];ret=li[this.WFN].call(scope,e);ok=(ok&&ret);}} -le=legacyEvents[legacyIndex];if(le&&le[2]){le[2](e);} -return ok;},getLegacyIndex:function(el,sType){var key=this.generateId(el)+sType;if(typeof legacyMap[key]=="undefined"){return-1;}else{return legacyMap[key];}},useLegacyEvent:function(el,sType){if(this.webkit&&("click"==sType||"dblclick"==sType)){var v=parseInt(this.webkit,10);if(!isNaN(v)&&v<418){return true;}} -return false;},removeListener:function(el,sType,fn){var i,len;if(typeof el=="string"){el=this.getEl(el);}else if(this._isValidCollection(el)){var ok=true;for(i=0,len=el.length;i<len;++i){ok=(this.removeListener(el[i],sType,fn)&&ok);} -return ok;} -if(!fn||!fn.call){return this.purgeElement(el,false,sType);} -if("unload"==sType){for(i=0,len=unloadListeners.length;i<len;i++){var li=unloadListeners[i];if(li&&li[0]==el&&li[1]==sType&&li[2]==fn){unloadListeners.splice(i,1);return true;}} -return false;} -var cacheItem=null;var index=arguments[3];if("undefined"==typeof index){index=this._getCacheIndex(el,sType,fn);} -if(index>=0){cacheItem=listeners[index];} -if(!el||!cacheItem){return false;} -if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);var llist=legacyHandlers[legacyIndex];if(llist){for(i=0,len=llist.length;i<len;++i){li=llist[i];if(li&&li[this.EL]==el&&li[this.TYPE]==sType&&li[this.FN]==fn){llist.splice(i,1);break;}}}}else{try{this._simpleRemove(el,sType,cacheItem[this.WFN],false);}catch(ex){this.lastError=ex;return false;}} -delete listeners[index][this.WFN];delete listeners[index][this.FN];listeners.splice(index,1);return true;},getTarget:function(ev,resolveTextNode){var t=ev.target||ev.srcElement;return this.resolveTextNode(t);},resolveTextNode:function(node){if(node&&3==node.nodeType){return node.parentNode;}else{return node;}},getPageX:function(ev){var x=ev.pageX;if(!x&&0!==x){x=ev.clientX||0;if(this.isIE){x+=this._getScrollLeft();}} -return x;},getPageY:function(ev){var y=ev.pageY;if(!y&&0!==y){y=ev.clientY||0;if(this.isIE){y+=this._getScrollTop();}} -return y;},getXY:function(ev){return[this.getPageX(ev),this.getPageY(ev)];},getRelatedTarget:function(ev){var t=ev.relatedTarget;if(!t){if(ev.type=="mouseout"){t=ev.toElement;}else if(ev.type=="mouseover"){t=ev.fromElement;}} -return this.resolveTextNode(t);},getTime:function(ev){if(!ev.time){var t=new Date().getTime();try{ev.time=t;}catch(ex){this.lastError=ex;return t;}} -return ev.time;},stopEvent:function(ev){this.stopPropagation(ev);this.preventDefault(ev);},stopPropagation:function(ev){if(ev.stopPropagation){ev.stopPropagation();}else{ev.cancelBubble=true;}},preventDefault:function(ev){if(ev.preventDefault){ev.preventDefault();}else{ev.returnValue=false;}},getEvent:function(e){var ev=e||window.event;if(!ev){var c=this.getEvent.caller;while(c){ev=c.arguments[0];if(ev&&Event==ev.constructor){break;} -c=c.caller;}} -return ev;},getCharCode:function(ev){return ev.charCode||ev.keyCode||0;},_getCacheIndex:function(el,sType,fn){for(var i=0,len=listeners.length;i<len;++i){var li=listeners[i];if(li&&li[this.FN]==fn&&li[this.EL]==el&&li[this.TYPE]==sType){return i;}} -return-1;},generateId:function(el){var id=el.id;if(!id){id="yuievtautoid-"+counter;++counter;el.id=id;} -return id;},_isValidCollection:function(o){return(o&&o.length&&typeof o!="string"&&!o.tagName&&!o.alert&&typeof o[0]!="undefined");},elCache:{},getEl:function(id){return document.getElementById(id);},clearCache:function(){},_load:function(e){loadComplete=true;var EU=YAHOO.util.Event;if(this.isIE){EU._simpleRemove(window,"load",EU._load);}},_tryPreloadAttach:function(){if(this.locked){return false;} -this.locked=true;var tryAgain=!loadComplete;if(!tryAgain){tryAgain=(retryCount>0);} -var notAvail=[];for(var i=0,len=onAvailStack.length;i<len;++i){var item=onAvailStack[i];if(item){var el=this.getEl(item.id);if(el){if(!item.checkReady||loadComplete||el.nextSibling||(document&&document.body)){var scope=el;if(item.override){if(item.override===true){scope=item.obj;}else{scope=item.override;}} -item.fn.call(scope,item.obj);onAvailStack[i]=null;}}else{notAvail.push(item);}}} -retryCount=(notAvail.length===0)?0:retryCount-1;if(tryAgain){this.startInterval();}else{clearInterval(this._interval);this._interval=null;} -this.locked=false;return true;},purgeElement:function(el,recurse,sType){var elListeners=this.getListeners(el,sType);if(elListeners){for(var i=0,len=elListeners.length;i<len;++i){var l=elListeners[i];this.removeListener(el,l.type,l.fn);}} -if(recurse&&el&&el.childNodes){for(i=0,len=el.childNodes.length;i<len;++i){this.purgeElement(el.childNodes[i],recurse,sType);}}},getListeners:function(el,sType){var results=[],searchLists;if(!sType){searchLists=[listeners,unloadListeners];}else if(sType=="unload"){searchLists=[unloadListeners];}else{searchLists=[listeners];} -for(var j=0;j<searchLists.length;++j){var searchList=searchLists[j];if(searchList&&searchList.length>0){for(var i=0,len=searchList.length;i<len;++i){var l=searchList[i];if(l&&l[this.EL]===el&&(!sType||sType===l[this.TYPE])){results.push({type:l[this.TYPE],fn:l[this.FN],obj:l[this.OBJ],adjust:l[this.ADJ_SCOPE],index:i});}}}} -return(results.length)?results:null;},_unload:function(e){var EU=YAHOO.util.Event,i,j,l,len,index;for(i=0,len=unloadListeners.length;i<len;++i){l=unloadListeners[i];if(l){var scope=window;if(l[EU.ADJ_SCOPE]){if(l[EU.ADJ_SCOPE]===true){scope=l[EU.OBJ];}else{scope=l[EU.ADJ_SCOPE];}} -l[EU.FN].call(scope,EU.getEvent(e),l[EU.OBJ]);unloadListeners[i]=null;l=null;scope=null;}} -unloadListeners=null;if(listeners&&listeners.length>0){j=listeners.length;while(j){index=j-1;l=listeners[index];if(l){EU.removeListener(l[EU.EL],l[EU.TYPE],l[EU.FN],index);} -j=j-1;} -l=null;EU.clearCache();} -for(i=0,len=legacyEvents.length;i<len;++i){legacyEvents[i][0]=null;legacyEvents[i]=null;} -legacyEvents=null;EU._simpleRemove(window,"unload",EU._unload);},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var dd=document.documentElement,db=document.body;if(dd&&(dd.scrollTop||dd.scrollLeft)){return[dd.scrollTop,dd.scrollLeft];}else if(db){return[db.scrollTop,db.scrollLeft];}else{return[0,0];}},regCE:function(){},_simpleAdd:function(){if(window.addEventListener){return function(el,sType,fn,capture){el.addEventListener(sType,fn,(capture));};}else if(window.attachEvent){return function(el,sType,fn,capture){el.attachEvent("on"+sType,fn);};}else{return function(){};}}(),_simpleRemove:function(){if(window.removeEventListener){return function(el,sType,fn,capture){el.removeEventListener(sType,fn,(capture));};}else if(window.detachEvent){return function(el,sType,fn){el.detachEvent("on"+sType,fn);};}else{return function(){};}}()};}();(function(){var EU=YAHOO.util.Event;EU.on=EU.addListener;if(document&&document.body){EU._load();}else{EU._simpleAdd(window,"load",EU._load);} -EU._simpleAdd(window,"unload",EU._unload);EU._tryPreloadAttach();})();} -YAHOO.util.CustomEvent=function(type,oScope,silent,signature){this.type=type;this.scope=oScope||window;this.silent=silent;this.signature=signature||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){} -var onsubscribeType="_YUICEOnSubscribe";if(type!==onsubscribeType){this.subscribeEvent=new YAHOO.util.CustomEvent(onsubscribeType,this,true);}};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(fn,obj,override){if(this.subscribeEvent){this.subscribeEvent.fire(fn,obj,override);} -this.subscribers.push(new YAHOO.util.Subscriber(fn,obj,override));},unsubscribe:function(fn,obj){if(!fn){return this.unsubscribeAll();} -var found=false;for(var i=0,len=this.subscribers.length;i<len;++i){var s=this.subscribers[i];if(s&&s.contains(fn,obj)){this._delete(i);found=true;}} -return found;},fire:function(){var len=this.subscribers.length;if(!len&&this.silent){return true;} -var args=[],ret=true,i;for(i=0;i<arguments.length;++i){args.push(arguments[i]);} -var argslength=args.length;if(!this.silent){} -for(i=0;i<len;++i){var s=this.subscribers[i];if(s){if(!this.silent){} -var scope=s.getScope(this.scope);if(this.signature==YAHOO.util.CustomEvent.FLAT){var param=null;if(args.length>0){param=args[0];} -ret=s.fn.call(scope,param,s.obj);}else{ret=s.fn.call(scope,this.type,args,s.obj);} -if(false===ret){if(!this.silent){} -return false;}}} -return true;},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i<len;++i){this._delete(len-1-i);} -return i;},_delete:function(index){var s=this.subscribers[index];if(s){delete s.fn;delete s.obj;} -this.subscribers.splice(index,1);},toString:function(){return"CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(fn,obj,override){this.fn=fn;this.obj=obj||null;this.override=override;};YAHOO.util.Subscriber.prototype.getScope=function(defaultScope){if(this.override){if(this.override===true){return this.obj;}else{return this.override;}} -return defaultScope;};YAHOO.util.Subscriber.prototype.contains=function(fn,obj){if(obj){return(this.fn==fn&&this.obj==obj);}else{return(this.fn==fn);}};YAHOO.util.Subscriber.prototype.toString=function(){return"Subscriber { obj: "+(this.obj||"")+", override: "+(this.override||"no")+" }";};YAHOO.util.EventProvider=function(){};YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(p_type,p_fn,p_obj,p_override){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){ce.subscribe(p_fn,p_obj,p_override);}else{this.__yui_subscribers=this.__yui_subscribers||{};var subs=this.__yui_subscribers;if(!subs[p_type]){subs[p_type]=[];} -subs[p_type].push({fn:p_fn,obj:p_obj,override:p_override});}},unsubscribe:function(p_type,p_fn,p_obj){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){return ce.unsubscribe(p_fn,p_obj);}else{return false;}},unsubscribeAll:function(p_type){return this.unsubscribe(p_type);},createEvent:function(p_type,p_config){this.__yui_events=this.__yui_events||{};var opts=p_config||{};var events=this.__yui_events;if(events[p_type]){}else{var scope=opts.scope||this;var silent=opts.silent||null;var ce=new YAHOO.util.CustomEvent(p_type,scope,silent,YAHOO.util.CustomEvent.FLAT);events[p_type]=ce;if(opts.onSubscribeCallback){ce.subscribeEvent.subscribe(opts.onSubscribeCallback);} -this.__yui_subscribers=this.__yui_subscribers||{};var qs=this.__yui_subscribers[p_type];if(qs){for(var i=0;i<qs.length;++i){ce.subscribe(qs[i].fn,qs[i].obj,qs[i].override);}}} -return events[p_type];},fireEvent:function(p_type,arg1,arg2,etc){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){var args=[];for(var i=1;i<arguments.length;++i){args.push(arguments[i]);} -return ce.fire.apply(ce,args);}else{return null;}},hasEvent:function(type){if(this.__yui_events){if(this.__yui_events[type]){return true;}} -return false;}};YAHOO.util.KeyListener=function(attachTo,keyData,handler,event){if(!attachTo){}else if(!keyData){}else if(!handler){} -if(!event){event=YAHOO.util.KeyListener.KEYDOWN;} -var keyEvent=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof attachTo=='string'){attachTo=document.getElementById(attachTo);} -if(typeof handler=='function'){keyEvent.subscribe(handler);}else{keyEvent.subscribe(handler.fn,handler.scope,handler.correctScope);} -function handleKeyPress(e,obj){if(!keyData.shift){keyData.shift=false;} -if(!keyData.alt){keyData.alt=false;} -if(!keyData.ctrl){keyData.ctrl=false;} -if(e.shiftKey==keyData.shift&&e.altKey==keyData.alt&&e.ctrlKey==keyData.ctrl){var dataItem;var keyPressed;if(keyData.keys instanceof Array){for(var i=0;i<keyData.keys.length;i++){dataItem=keyData.keys[i];if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);break;}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);break;}}}else{dataItem=keyData.keys;if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);}}}} -this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(attachTo,event,handleKeyPress);this.enabledEvent.fire(keyData);} -this.enabled=true;};this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(attachTo,event,handleKeyPress);this.disabledEvent.fire(keyData);} -this.enabled=false;};this.toString=function(){return"KeyListener ["+keyData.keys+"] "+attachTo.tagName+ -(attachTo.id?"["+attachTo.id+"]":"");};};YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.register("event",YAHOO.util.Event,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/yahoo/README b/interface/web/js/yui/yahoo/README deleted file mode 100644 index 3eebc56260..0000000000 --- a/interface/web/js/yui/yahoo/README +++ /dev/null @@ -1,64 +0,0 @@ -YAHOO Global - Release Notes - -2.2.0a - - * Fixed a typo that prevented the proper detection of multiple YAHOO_config listeners - -2.2.0 - - * Added configuration of the library via a YAHOO_config object defined - prior to the reference to the library. Currently it supports a listener - parameter that will execute every time a new module YUI module is loaded. - - * Added YAHOO.register & YAHOO.getVersion for version stamping modules. - - * Added YAHOO.env which is the home for the information about the loaded - YUI modules, and will host more info later. - - * YAHOO.util.Lang was relocated to this package and is now YAHOO.lang. - YAHOO.extend and YAHOO.augment have moved to env (the original - functions still work). - -0.12.2 - - * No change - -0.12.1 - - * No change - -0.12.0 - - * Added YAHOO.augment, which copies all or part of the prototype of one - object to another. - - * YAHOO.namespace now can create multiple namespaces. - - * Added an optional third parameter to YAHOO.extend: overrides. It takes - an object literal of properties/methods to apply to the subclass - prototype, overriding the superclass if present. - -0.11.4 - - * Changed window.YAHOO = window.YAHOO || {} to - if (typeof YAHOO == "undefined") YAHOO = {} because the previous statement - contributed to a memory leak in IE6 when the library was hosted in an - iframe. - -0.11.3 - - * Changed var YAHOO = window.YAHOO || {} to window.YAHOO = window.YAHOO || {}. - This fixes an issue in IE where YAHOO would get overwritten if previously - defined via array notation (window["YAHOO"]). - -0.11.0 - - * Added YAHOO.extend, which provides an easy way to assign the prototype, - constructor, and superclass properties inheritance properties. It also - prevents the constructor of the superclass from being exectuted twice. - -0.10.0 - - * Added YAHOO.log that provides a safe way to plumb logging statements in - code that will work if the logging component isn't available. - diff --git a/interface/web/js/yui/yahoo/yahoo-debug.js b/interface/web/js/yui/yahoo/yahoo-debug.js deleted file mode 100644 index b6cf372b2a..0000000000 --- a/interface/web/js/yui/yahoo/yahoo-debug.js +++ /dev/null @@ -1,433 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The YAHOO object is the single global object used by YUI Library. It - * contains utility function for setting up namespaces, inheritance, and - * logging. YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces - * created automatically for and used by the library. - * @module yahoo - * @title YAHOO Global - */ - -/** - * YAHOO_config is not included part of the library. Instead it is an object - * that can be defined by the implementer immediately before including the - * YUI library. The properties included in this object will be used to - * configure global properties needed as soon as the library begins to load. - * @class YAHOO_config - * @static - */ - -/** - * A reference to a function that will be executed every time a YAHOO module - * is loaded. As parameter, this function will receive the version - * information for the module. See <a href="YAHOO.env.html#getVersion"> - * YAHOO.env.getVersion</a> for the description of the version data structure. - * @property listener - * @static - */ -if (typeof YAHOO == "undefined") { - /** - * The YAHOO global namespace object. If YAHOO is already defined, the - * existing YAHOO object will not be overwritten so that defined - * namespaces are preserved. - * @class YAHOO - * @static - */ - var YAHOO = {}; -} - -/** - * Returns the namespace specified and creates it if it doesn't exist - * <pre> - * YAHOO.namespace("property.package"); - * YAHOO.namespace("YAHOO.property.package"); - * </pre> - * Either of the above would create YAHOO.property, then - * YAHOO.property.package - * - * Be careful when naming packages. Reserved words may work in some browsers - * and not others. For instance, the following will fail in Safari: - * <pre> - * YAHOO.namespace("really.long.nested.namespace"); - * </pre> - * This fails because "long" is a future reserved word in ECMAScript - * - * @method namespace - * @static - * @param {String*} arguments 1-n namespaces to create - * @return {Object} A reference to the last namespace object created - */ -YAHOO.namespace = function() { - var a=arguments, o=null, i, j, d; - for (i=0; i<a.length; i=i+1) { - d=a[i].split("."); - o=YAHOO; - - // YAHOO is implied, so it is ignored if it is included - for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) { - o[d[j]]=o[d[j]] || {}; - o=o[d[j]]; - } - } - - return o; -}; - -/** - * Uses YAHOO.widget.Logger to output a log message, if the widget is - * available. - * - * @method log - * @static - * @param {String} msg The message to log. - * @param {String} cat The log category for the message. Default - * categories are "info", "warn", "error", time". - * Custom categories can be used as well. (opt) - * @param {String} src The source of the the message (opt) - * @return {Boolean} True if the log operation was successful. - */ -YAHOO.log = function(msg, cat, src) { - var l=YAHOO.widget.Logger; - if(l && l.log) { - return l.log(msg, cat, src); - } else { - return false; - } -}; - - -/** - * Initializes the global by creating the default namespaces and applying - * any new configuration information that is detected. - * @method init - * @static - */ -YAHOO.init = function() { - this.namespace("util", "widget", "example"); - if (typeof YAHOO_config != "undefined") { - var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i; - if (l) { - // if YAHOO is loaded multiple times we need to check to see if - // this is a new config object. If it is, add the new component - // load listener to the stack - for (i=0;i<ls.length;i=i+1) { - if (ls[i]==l) { - unique=false; - break; - } - } - if (unique) { - ls.push(l); - } - } - } -}; - -/** - * Registers a module with the YAHOO object - * @method register - * @static - * @param {String} name the name of the module (event, slider, etc) - * @param {Function} mainClass a reference to class in the module. This - * class will be tagged with the version info - * so that it will be possible to identify the - * version that is in use when multiple versions - * have loaded - * @param {Object} data metadata object for the module. Currently it - * is expected to contain a "version" property - * and a "build" property at minimum. - */ -YAHOO.register = function(name, mainClass, data) { - var mods = YAHOO.env.modules; - if (!mods[name]) { - mods[name] = { versions:[], builds:[] }; - } - var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners; - m.name = name; - m.version = v; - m.build = b; - m.versions.push(v); - m.builds.push(b); - m.mainClass = mainClass; - // fire the module load listeners - for (var i=0;i<ls.length;i=i+1) { - ls[i](m); - } - // label the main class - if (mainClass) { - mainClass.VERSION = v; - mainClass.BUILD = b; - } else { - YAHOO.log("mainClass is undefined for module " + name, "warn"); - } -}; - -/** - * YAHOO.env is used to keep track of what is known about the YUI library and - * the browsing environment - * @class YAHOO.env - * @type Object - * @static - */ -YAHOO.env = YAHOO.env || { - /** - * Keeps the version info for all YUI modules that have reported themselves - * @property modules - * @type Object[] - */ - modules: [], - - /** - * List of functions that should be executed every time a YUI module - * reports itself. - * @property listeners - * @type Function[] - */ - listeners: [], - - /** - * Returns the version data for the specified module: - * <dl> - * <dt>name:</dt> <dd>The name of the module</dd> - * <dt>version:</dt> <dd>The version in use</dd> - * <dt>build:</dt> <dd>The build number in use</dd> - * <dt>versions:</dt> <dd>All versions that were registered</dd> - * <dt>builds:</dt> <dd>All builds that were registered.</dd> - * <dt>mainClass:</dt> <dd>An object that was was stamped with the - * current version and build. If - * mainClass.VERSION != version or mainClass.BUILD != build, - * multiple versions of pieces of the library have been - * loaded, potentially causing issues.</dd> - * </dl> - * - * @method getVersion - * @static - * @param {String} name the name of the module (event, slider, etc) - * @return {Object} The version info - */ - getVersion: function(name) { - return YAHOO.env.modules[name] || null; - } -}; - -/** - * Provides the language utilites and extensions used by the library - * @class YAHOO.lang - */ -YAHOO.lang = { - /** - * Determines whether or not the provided object is an array - * @method isArray - * @param {any} obj The object being testing - * @return Boolean - */ - isArray: function(obj) { // frames lose type, so test constructor string - if (obj.constructor && obj.constructor.toString().indexOf('Array') > -1) { - return true; - } else { - return YAHOO.lang.isObject(obj) && obj.constructor == Array; - } - }, - - /** - * Determines whether or not the provided object is a boolean - * @method isBoolean - * @param {any} obj The object being testing - * @return Boolean - */ - isBoolean: function(obj) { - return typeof obj == 'boolean'; - }, - - /** - * Determines whether or not the provided object is a function - * @method isFunction - * @param {any} obj The object being testing - * @return Boolean - */ - isFunction: function(obj) { - return typeof obj == 'function'; - }, - - /** - * Determines whether or not the provided object is null - * @method isNull - * @param {any} obj The object being testing - * @return Boolean - */ - isNull: function(obj) { - return obj === null; - }, - - /** - * Determines whether or not the provided object is a legal number - * @method isNumber - * @param {any} obj The object being testing - * @return Boolean - */ - isNumber: function(obj) { - return typeof obj == 'number' && isFinite(obj); - }, - - /** - * Determines whether or not the provided object is of type object - * or function - * @method isObject - * @param {any} obj The object being testing - * @return Boolean - */ - isObject: function(obj) { - return typeof obj == 'object' || YAHOO.lang.isFunction(obj); - }, - - /** - * Determines whether or not the provided object is a string - * @method isString - * @param {any} obj The object being testing - * @return Boolean - */ - isString: function(obj) { - return typeof obj == 'string'; - }, - - /** - * Determines whether or not the provided object is undefined - * @method isUndefined - * @param {any} obj The object being testing - * @return Boolean - */ - isUndefined: function(obj) { - return typeof obj == 'undefined'; - }, - - /** - * Determines whether or not the property was added - * to the object instance. Returns false if the property is not present - * in the object, or was inherited from the prototype. - * This abstraction is provided to enable hasOwnProperty for Safari 1.3.x. - * There is a discrepancy between YAHOO.lang.hasOwnProperty and - * Object.prototype.hasOwnProperty when the property is a primitive added to - * both the instance AND prototype with the same value: - * <pre> - * var A = function() {}; - * A.prototype.foo = 'foo'; - * var a = new A(); - * a.foo = 'foo'; - * alert(a.hasOwnProperty('foo')); // true - * alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback - * </pre> - * @method hasOwnProperty - * @param {any} obj The object being testing - * @return Boolean - */ - hasOwnProperty: function(obj, prop) { - if (Object.prototype.hasOwnProperty) { - return obj.hasOwnProperty(prop); - } - - return !YAHOO.lang.isUndefined(obj[prop]) && - obj.constructor.prototype[prop] !== obj[prop]; - }, - - /** - * Utility to set up the prototype, constructor and superclass properties to - * support an inheritance strategy that can chain constructors and methods. - * - * @method extend - * @static - * @param {Function} subc the object to modify - * @param {Function} superc the object to inherit - * @param {Object} overrides additional properties/methods to add to the - * subclass prototype. These will override the - * matching items obtained from the superclass - * if present. - */ - extend: function(subc, superc, overrides) { - var F = function() {}; - F.prototype=superc.prototype; - subc.prototype=new F(); - subc.prototype.constructor=subc; - subc.superclass=superc.prototype; - if (superc.prototype.constructor == Object.prototype.constructor) { - superc.prototype.constructor=superc; - } - - if (overrides) { - for (var i in overrides) { - subc.prototype[i]=overrides[i]; - } - } - }, - - /** - * Applies all prototype properties in the supplier to the receiver if the - * receiver does not have these properties yet. Optionally, one or more - * methods/properties can be specified (as additional parameters). This - * option will overwrite the property if receiver has it already. - * - * @method augment - * @static - * @param {Function} r the object to receive the augmentation - * @param {Function} s the object that supplies the properties to augment - * @param {String*} arguments zero or more properties methods to augment the - * receiver with. If none specified, everything - * in the supplier will be used unless it would - * overwrite an existing property in the receiver - */ - augment: function(r, s) { - var rp=r.prototype, sp=s.prototype, a=arguments, i, p; - if (a[2]) { - for (i=2; i<a.length; i=i+1) { - rp[a[i]] = sp[a[i]]; - } - } else { - for (p in sp) { - if (!rp[p]) { - rp[p] = sp[p]; - } - } - } - } -}; - -YAHOO.init(); - -/* - * An alias for <a href="YAHOO.lang.html">YAHOO.lang</a> - * @class YAHOO.util.Lang - */ -YAHOO.util.Lang = YAHOO.lang; - -/** - * An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a> - * @for YAHOO - * @method augment - * @static - * @param {Function} r the object to receive the augmentation - * @param {Function} s the object that supplies the properties to augment - * @param {String*} arguments zero or more properties methods to augment the - * receiver with. If none specified, everything - * in the supplier will be used unless it would - * overwrite an existing property in the receiver - */ -YAHOO.augment = YAHOO.lang.augment; - -/** - * An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a> - * @method extend - * @static - * @param {Function} subc the object to modify - * @param {Function} superc the object to inherit - * @param {Object} overrides additional properties/methods to add to the - * subclass prototype. These will override the - * matching items obtained from the superclass - * if present. - */ -YAHOO.extend = YAHOO.lang.extend; - -YAHOO.register("yahoo", YAHOO, {version: "2.2.0", build: "127"}); diff --git a/interface/web/js/yui/yahoo/yahoo-min.js b/interface/web/js/yui/yahoo/yahoo-min.js deleted file mode 100644 index 08e6ad9375..0000000000 --- a/interface/web/js/yui/yahoo/yahoo-min.js +++ /dev/null @@ -1,15 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ - -if(typeof YAHOO=="undefined"){var YAHOO={};} -YAHOO.namespace=function(){var a=arguments,o=null,i,j,d;for(i=0;i<a.length;i=i+1){d=a[i].split(".");o=YAHOO;for(j=(d[0]=="YAHOO")?1:0;j<d.length;j=j+1){o[d[j]]=o[d[j]]||{};o=o[d[j]];}} -return o;};YAHOO.log=function(msg,cat,src){var l=YAHOO.widget.Logger;if(l&&l.log){return l.log(msg,cat,src);}else{return false;}};YAHOO.init=function(){this.namespace("util","widget","example");if(typeof YAHOO_config!="undefined"){var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i;if(l){for(i=0;i<ls.length;i=i+1){if(ls[i]==l){unique=false;break;}} -if(unique){ls.push(l);}}}};YAHOO.register=function(name,mainClass,data){var mods=YAHOO.env.modules;if(!mods[name]){mods[name]={versions:[],builds:[]};} -var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners;m.name=name;m.version=v;m.build=b;m.versions.push(v);m.builds.push(b);m.mainClass=mainClass;for(var i=0;i<ls.length;i=i+1){ls[i](m);} -if(mainClass){mainClass.VERSION=v;mainClass.BUILD=b;}else{YAHOO.log("mainClass is undefined for module "+name,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[],getVersion:function(name){return YAHOO.env.modules[name]||null;}};YAHOO.lang={isArray:function(obj){if(obj.constructor&&obj.constructor.toString().indexOf('Array')>-1){return true;}else{return YAHOO.lang.isObject(obj)&&obj.constructor==Array;}},isBoolean:function(obj){return typeof obj=='boolean';},isFunction:function(obj){return typeof obj=='function';},isNull:function(obj){return obj===null;},isNumber:function(obj){return typeof obj=='number'&&isFinite(obj);},isObject:function(obj){return typeof obj=='object'||YAHOO.lang.isFunction(obj);},isString:function(obj){return typeof obj=='string';},isUndefined:function(obj){return typeof obj=='undefined';},hasOwnProperty:function(obj,prop){if(Object.prototype.hasOwnProperty){return obj.hasOwnProperty(prop);} -return!YAHOO.lang.isUndefined(obj[prop])&&obj.constructor.prototype[prop]!==obj[prop];},extend:function(subc,superc,overrides){var F=function(){};F.prototype=superc.prototype;subc.prototype=new F();subc.prototype.constructor=subc;subc.superclass=superc.prototype;if(superc.prototype.constructor==Object.prototype.constructor){superc.prototype.constructor=superc;} -if(overrides){for(var i in overrides){subc.prototype[i]=overrides[i];}}},augment:function(r,s){var rp=r.prototype,sp=s.prototype,a=arguments,i,p;if(a[2]){for(i=2;i<a.length;i=i+1){rp[a[i]]=sp[a[i]];}}else{for(p in sp){if(!rp[p]){rp[p]=sp[p];}}}}};YAHOO.init();YAHOO.util.Lang=YAHOO.lang;YAHOO.augment=YAHOO.lang.augment;YAHOO.extend=YAHOO.lang.extend;YAHOO.register("yahoo",YAHOO,{version:"2.2.0",build:"127"}); \ No newline at end of file diff --git a/interface/web/js/yui/yahoo/yahoo.js b/interface/web/js/yui/yahoo/yahoo.js deleted file mode 100644 index b6cf372b2a..0000000000 --- a/interface/web/js/yui/yahoo/yahoo.js +++ /dev/null @@ -1,433 +0,0 @@ -/* -Copyright (c) 2007, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 2.2.0 -*/ -/** - * The YAHOO object is the single global object used by YUI Library. It - * contains utility function for setting up namespaces, inheritance, and - * logging. YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces - * created automatically for and used by the library. - * @module yahoo - * @title YAHOO Global - */ - -/** - * YAHOO_config is not included part of the library. Instead it is an object - * that can be defined by the implementer immediately before including the - * YUI library. The properties included in this object will be used to - * configure global properties needed as soon as the library begins to load. - * @class YAHOO_config - * @static - */ - -/** - * A reference to a function that will be executed every time a YAHOO module - * is loaded. As parameter, this function will receive the version - * information for the module. See <a href="YAHOO.env.html#getVersion"> - * YAHOO.env.getVersion</a> for the description of the version data structure. - * @property listener - * @static - */ -if (typeof YAHOO == "undefined") { - /** - * The YAHOO global namespace object. If YAHOO is already defined, the - * existing YAHOO object will not be overwritten so that defined - * namespaces are preserved. - * @class YAHOO - * @static - */ - var YAHOO = {}; -} - -/** - * Returns the namespace specified and creates it if it doesn't exist - * <pre> - * YAHOO.namespace("property.package"); - * YAHOO.namespace("YAHOO.property.package"); - * </pre> - * Either of the above would create YAHOO.property, then - * YAHOO.property.package - * - * Be careful when naming packages. Reserved words may work in some browsers - * and not others. For instance, the following will fail in Safari: - * <pre> - * YAHOO.namespace("really.long.nested.namespace"); - * </pre> - * This fails because "long" is a future reserved word in ECMAScript - * - * @method namespace - * @static - * @param {String*} arguments 1-n namespaces to create - * @return {Object} A reference to the last namespace object created - */ -YAHOO.namespace = function() { - var a=arguments, o=null, i, j, d; - for (i=0; i<a.length; i=i+1) { - d=a[i].split("."); - o=YAHOO; - - // YAHOO is implied, so it is ignored if it is included - for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) { - o[d[j]]=o[d[j]] || {}; - o=o[d[j]]; - } - } - - return o; -}; - -/** - * Uses YAHOO.widget.Logger to output a log message, if the widget is - * available. - * - * @method log - * @static - * @param {String} msg The message to log. - * @param {String} cat The log category for the message. Default - * categories are "info", "warn", "error", time". - * Custom categories can be used as well. (opt) - * @param {String} src The source of the the message (opt) - * @return {Boolean} True if the log operation was successful. - */ -YAHOO.log = function(msg, cat, src) { - var l=YAHOO.widget.Logger; - if(l && l.log) { - return l.log(msg, cat, src); - } else { - return false; - } -}; - - -/** - * Initializes the global by creating the default namespaces and applying - * any new configuration information that is detected. - * @method init - * @static - */ -YAHOO.init = function() { - this.namespace("util", "widget", "example"); - if (typeof YAHOO_config != "undefined") { - var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i; - if (l) { - // if YAHOO is loaded multiple times we need to check to see if - // this is a new config object. If it is, add the new component - // load listener to the stack - for (i=0;i<ls.length;i=i+1) { - if (ls[i]==l) { - unique=false; - break; - } - } - if (unique) { - ls.push(l); - } - } - } -}; - -/** - * Registers a module with the YAHOO object - * @method register - * @static - * @param {String} name the name of the module (event, slider, etc) - * @param {Function} mainClass a reference to class in the module. This - * class will be tagged with the version info - * so that it will be possible to identify the - * version that is in use when multiple versions - * have loaded - * @param {Object} data metadata object for the module. Currently it - * is expected to contain a "version" property - * and a "build" property at minimum. - */ -YAHOO.register = function(name, mainClass, data) { - var mods = YAHOO.env.modules; - if (!mods[name]) { - mods[name] = { versions:[], builds:[] }; - } - var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners; - m.name = name; - m.version = v; - m.build = b; - m.versions.push(v); - m.builds.push(b); - m.mainClass = mainClass; - // fire the module load listeners - for (var i=0;i<ls.length;i=i+1) { - ls[i](m); - } - // label the main class - if (mainClass) { - mainClass.VERSION = v; - mainClass.BUILD = b; - } else { - YAHOO.log("mainClass is undefined for module " + name, "warn"); - } -}; - -/** - * YAHOO.env is used to keep track of what is known about the YUI library and - * the browsing environment - * @class YAHOO.env - * @type Object - * @static - */ -YAHOO.env = YAHOO.env || { - /** - * Keeps the version info for all YUI modules that have reported themselves - * @property modules - * @type Object[] - */ - modules: [], - - /** - * List of functions that should be executed every time a YUI module - * reports itself. - * @property listeners - * @type Function[] - */ - listeners: [], - - /** - * Returns the version data for the specified module: - * <dl> - * <dt>name:</dt> <dd>The name of the module</dd> - * <dt>version:</dt> <dd>The version in use</dd> - * <dt>build:</dt> <dd>The build number in use</dd> - * <dt>versions:</dt> <dd>All versions that were registered</dd> - * <dt>builds:</dt> <dd>All builds that were registered.</dd> - * <dt>mainClass:</dt> <dd>An object that was was stamped with the - * current version and build. If - * mainClass.VERSION != version or mainClass.BUILD != build, - * multiple versions of pieces of the library have been - * loaded, potentially causing issues.</dd> - * </dl> - * - * @method getVersion - * @static - * @param {String} name the name of the module (event, slider, etc) - * @return {Object} The version info - */ - getVersion: function(name) { - return YAHOO.env.modules[name] || null; - } -}; - -/** - * Provides the language utilites and extensions used by the library - * @class YAHOO.lang - */ -YAHOO.lang = { - /** - * Determines whether or not the provided object is an array - * @method isArray - * @param {any} obj The object being testing - * @return Boolean - */ - isArray: function(obj) { // frames lose type, so test constructor string - if (obj.constructor && obj.constructor.toString().indexOf('Array') > -1) { - return true; - } else { - return YAHOO.lang.isObject(obj) && obj.constructor == Array; - } - }, - - /** - * Determines whether or not the provided object is a boolean - * @method isBoolean - * @param {any} obj The object being testing - * @return Boolean - */ - isBoolean: function(obj) { - return typeof obj == 'boolean'; - }, - - /** - * Determines whether or not the provided object is a function - * @method isFunction - * @param {any} obj The object being testing - * @return Boolean - */ - isFunction: function(obj) { - return typeof obj == 'function'; - }, - - /** - * Determines whether or not the provided object is null - * @method isNull - * @param {any} obj The object being testing - * @return Boolean - */ - isNull: function(obj) { - return obj === null; - }, - - /** - * Determines whether or not the provided object is a legal number - * @method isNumber - * @param {any} obj The object being testing - * @return Boolean - */ - isNumber: function(obj) { - return typeof obj == 'number' && isFinite(obj); - }, - - /** - * Determines whether or not the provided object is of type object - * or function - * @method isObject - * @param {any} obj The object being testing - * @return Boolean - */ - isObject: function(obj) { - return typeof obj == 'object' || YAHOO.lang.isFunction(obj); - }, - - /** - * Determines whether or not the provided object is a string - * @method isString - * @param {any} obj The object being testing - * @return Boolean - */ - isString: function(obj) { - return typeof obj == 'string'; - }, - - /** - * Determines whether or not the provided object is undefined - * @method isUndefined - * @param {any} obj The object being testing - * @return Boolean - */ - isUndefined: function(obj) { - return typeof obj == 'undefined'; - }, - - /** - * Determines whether or not the property was added - * to the object instance. Returns false if the property is not present - * in the object, or was inherited from the prototype. - * This abstraction is provided to enable hasOwnProperty for Safari 1.3.x. - * There is a discrepancy between YAHOO.lang.hasOwnProperty and - * Object.prototype.hasOwnProperty when the property is a primitive added to - * both the instance AND prototype with the same value: - * <pre> - * var A = function() {}; - * A.prototype.foo = 'foo'; - * var a = new A(); - * a.foo = 'foo'; - * alert(a.hasOwnProperty('foo')); // true - * alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback - * </pre> - * @method hasOwnProperty - * @param {any} obj The object being testing - * @return Boolean - */ - hasOwnProperty: function(obj, prop) { - if (Object.prototype.hasOwnProperty) { - return obj.hasOwnProperty(prop); - } - - return !YAHOO.lang.isUndefined(obj[prop]) && - obj.constructor.prototype[prop] !== obj[prop]; - }, - - /** - * Utility to set up the prototype, constructor and superclass properties to - * support an inheritance strategy that can chain constructors and methods. - * - * @method extend - * @static - * @param {Function} subc the object to modify - * @param {Function} superc the object to inherit - * @param {Object} overrides additional properties/methods to add to the - * subclass prototype. These will override the - * matching items obtained from the superclass - * if present. - */ - extend: function(subc, superc, overrides) { - var F = function() {}; - F.prototype=superc.prototype; - subc.prototype=new F(); - subc.prototype.constructor=subc; - subc.superclass=superc.prototype; - if (superc.prototype.constructor == Object.prototype.constructor) { - superc.prototype.constructor=superc; - } - - if (overrides) { - for (var i in overrides) { - subc.prototype[i]=overrides[i]; - } - } - }, - - /** - * Applies all prototype properties in the supplier to the receiver if the - * receiver does not have these properties yet. Optionally, one or more - * methods/properties can be specified (as additional parameters). This - * option will overwrite the property if receiver has it already. - * - * @method augment - * @static - * @param {Function} r the object to receive the augmentation - * @param {Function} s the object that supplies the properties to augment - * @param {String*} arguments zero or more properties methods to augment the - * receiver with. If none specified, everything - * in the supplier will be used unless it would - * overwrite an existing property in the receiver - */ - augment: function(r, s) { - var rp=r.prototype, sp=s.prototype, a=arguments, i, p; - if (a[2]) { - for (i=2; i<a.length; i=i+1) { - rp[a[i]] = sp[a[i]]; - } - } else { - for (p in sp) { - if (!rp[p]) { - rp[p] = sp[p]; - } - } - } - } -}; - -YAHOO.init(); - -/* - * An alias for <a href="YAHOO.lang.html">YAHOO.lang</a> - * @class YAHOO.util.Lang - */ -YAHOO.util.Lang = YAHOO.lang; - -/** - * An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a> - * @for YAHOO - * @method augment - * @static - * @param {Function} r the object to receive the augmentation - * @param {Function} s the object that supplies the properties to augment - * @param {String*} arguments zero or more properties methods to augment the - * receiver with. If none specified, everything - * in the supplier will be used unless it would - * overwrite an existing property in the receiver - */ -YAHOO.augment = YAHOO.lang.augment; - -/** - * An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a> - * @method extend - * @static - * @param {Function} subc the object to modify - * @param {Function} superc the object to inherit - * @param {Object} overrides additional properties/methods to add to the - * subclass prototype. These will override the - * matching items obtained from the superclass - * if present. - */ -YAHOO.extend = YAHOO.lang.extend; - -YAHOO.register("yahoo", YAHOO, {version: "2.2.0", build: "127"}); diff --git a/interface/web/sites/ajax_get_json.php b/interface/web/sites/ajax_get_json.php new file mode 100644 index 0000000000..a910dce9f0 --- /dev/null +++ b/interface/web/sites/ajax_get_json.php @@ -0,0 +1,66 @@ +<?php + +/* +Copyright (c) 2005, Till Brehm, projektfarm Gmbh +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +require_once('../../lib/config.inc.php'); +require_once('../../lib/app.inc.php'); + +//* Check permissions for module +$app->auth->check_module_permissions('sites'); + +$server_id = intval($_GET["server_id"]); +$web_id = intval($_GET["web_id"]); +$type = $_GET["type"]; + +if($_SESSION["s"]["user"]["typ"] == 'admin') { + + if($type == 'getservertype'){ + $json = '{"servertype":"'; + $server_type = 'apache'; + $app->uses('getconf'); + $web_config = $app->getconf->get_server_config($server_id, 'web'); + if(!empty($web_config['server_type'])) $server_type = $web_config['server_type']; + $json .= $server_type; + unset($webconfig); + $json .= '"}'; + } + + if($type == 'getserverid'){ + $json = '{"serverid":"'; + $sql = "SELECT server_id FROM web_domain WHERE domain_id = $web_id"; + $server = $app->db->queryOneRecord($sql); + $json .= $server['server_id']; + unset($server); + $json .= '"}'; + } + +} + +echo $json; +?> \ No newline at end of file diff --git a/interface/web/sites/lib/lang/de_web_domain.lng b/interface/web/sites/lib/lang/de_web_domain.lng index ba9f4f113a..5f18f93f87 100644 --- a/interface/web/sites/lib/lang/de_web_domain.lng +++ b/interface/web/sites/lib/lang/de_web_domain.lng @@ -72,4 +72,5 @@ $wb['no_flag_txt'] = 'No flag'; $wb['save_certificate_txt'] = 'Save certificate'; $wb['create_certificate_txt'] = 'Create certificate'; $wb['delete_certificate_txt'] = 'Delete certificate'; +$wb['nginx_directives_txt'] = 'nginx Direktiven'; ?> diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng index d709cc50fe..8e202b02c6 100644 --- a/interface/web/sites/lib/lang/en_web_domain.lng +++ b/interface/web/sites/lib/lang/en_web_domain.lng @@ -36,7 +36,7 @@ $wb["client_txt"] = 'Client'; $wb["limit_web_domain_txt"] = 'The max. number of web domains for your account is reached.'; $wb["limit_web_aliasdomain_txt"] = 'The max. number of aliasdomains for your account is reached.'; $wb["limit_web_subdomain_txt"] = 'The max. number of web subdomains for your account is reached.'; -$wb["apache_directives_txt"] = 'Apache directives'; +$wb["apache_directives_txt"] = 'Apache Directives'; $wb["domain_error_empty"] = 'Domain is empty.'; $wb["domain_error_unique"] = 'There is already a website or sub / aliasdomain with this domain name.'; $wb["domain_error_regex"] = 'Domain name invalid.'; @@ -72,4 +72,5 @@ $wb['no_flag_txt'] = 'No flag'; $wb['save_certificate_txt'] = 'Save certificate'; $wb['create_certificate_txt'] = 'Create certificate'; $wb['delete_certificate_txt'] = 'Delete certificate'; +$wb["nginx_directives_txt"] = 'nginx Directives'; ?> \ No newline at end of file diff --git a/interface/web/sites/templates/web_domain_advanced.htm b/interface/web/sites/templates/web_domain_advanced.htm index 488fff2a6a..f29d1e2554 100644 --- a/interface/web/sites/templates/web_domain_advanced.htm +++ b/interface/web/sites/templates/web_domain_advanced.htm @@ -47,3 +47,28 @@ </div> </div> +<script language="JavaScript" type="text/javascript"> + var webId = jQuery('input[name="id"]').val(); + var serverId; + getServerId(webId); + serverType(serverId); + + function getServerId(webId){ + jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id : webId, type : "getserverid"}, function(data) { + serverId = data.serverid; + }); + } + + function serverType(serverId){ + jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) { + if(data.servertype == "nginx"){ + jQuery('#allow_override').closest('div.ctrlHolder').hide(); + jQuery('#apache_directives').closest('div.ctrlHolder').hide(); + } else { + jQuery('#allow_override').closest('div.ctrlHolder').show(); + jQuery('#apache_directives').closest('div.ctrlHolder').show(); + } + }); + } + +</script> \ No newline at end of file diff --git a/interface/web/sites/templates/web_domain_edit.htm b/interface/web/sites/templates/web_domain_edit.htm index 42c9ed192e..b748afe143 100644 --- a/interface/web/sites/templates/web_domain_edit.htm +++ b/interface/web/sites/templates/web_domain_edit.htm @@ -89,12 +89,7 @@ {tmpl_var name='errordocs'} </div> </div> - <div class="ctrlHolder"> - <p class="label">{tmpl_var name='is_subdomainwww_txt'}</p> - <div class="multiField"> - {tmpl_var name='is_subdomainwww'} - </div> - </div> + <div class="ctrlHolder"> <label for="subdomain">{tmpl_var name='subdomain_txt'}</label> <select name="subdomain" id="subdomain" class="selectInput formLengthHalf"> @@ -130,3 +125,38 @@ </div> </div> +<script language="JavaScript" type="text/javascript"> + var serverId; + var serverIdDisabled = jQuery('#server_id_disabled').val(); + if(serverIdDisabled > 0){ + serverId = serverIdDisabled; + } else { + serverId = jQuery('#server_id').val(); + jQuery('#server_id').change(function(){ + serverId = $(this).val(); + serverType(serverId); + }); + } + serverType(serverId); + + function serverType(serverId){ + jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getservertype"}, function(data) { + if(data.servertype == "nginx"){ + var selected = jQuery('#php').val(); + jQuery('#ruby').closest('div.ctrlHolder').hide(); + jQuery('#suexec').closest('div.ctrlHolder').hide(); + jQuery('#php option[value="cgi"]').hide(); + jQuery('#php option[value="mod"]').hide(); + jQuery('#php option[value="suphp"]').hide(); + if(selected != "no" && selected != "fast-cgi") jQuery('#php option[value="fast-cgi"]').attr('selected', 'selected'); + } else { + jQuery('#ruby').closest('div.ctrlHolder').show(); + jQuery('#suexec').closest('div.ctrlHolder').show(); + jQuery('#php option[value="cgi"]').show(); + jQuery('#php option[value="mod"]').show(); + jQuery('#php option[value="suphp"]').show(); + } + }); + } + +</script> diff --git a/server/conf/nginx_rewrites.conf.master b/server/conf/nginx_reverseproxy_rewrites.conf.master similarity index 100% rename from server/conf/nginx_rewrites.conf.master rename to server/conf/nginx_reverseproxy_rewrites.conf.master diff --git a/server/conf/nginx_reverseproxy_vhost.conf.master b/server/conf/nginx_reverseproxy_vhost.conf.master new file mode 100644 index 0000000000..40df895090 --- /dev/null +++ b/server/conf/nginx_reverseproxy_vhost.conf.master @@ -0,0 +1,69 @@ +server { + listen 80; + server_name <tmpl_var name='alias'> <tmpl_var name='domain'>; + + access_log /var/log/ispconfig/nginx/<tmpl_var name='domain'>/access.log; + error_log /var/log/ispconfig/nginx/<tmpl_var name='domain'>/error.log; + + include /etc/nginx/proxy.conf; + + location / { + proxy_pass http://<tmpl_var name='ip_address'>:80; + } + + location ~* \.(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ { + # Cache static-looking files for 120 minutes, setting a 10 day expiry time in the HTTP header, + # whether logged in or not (may be too heavy-handed). + proxy_cache_valid 200 120m; + expires 864000; + proxy_pass http://<tmpl_var name='ip_address'>:80; + } + + <tmpl_if name='nginx_directives'> + <tmpl_var name='nginx_directives'> + </tmpl_if> + + + +} + + +<tmpl_if name='ssl_enabled'> +########################################################### +# SSL Vhost +########################################################### +server { + listen 443; + server_name <tmpl_var name='ssl_domain'> <tmpl_var name='alias'>; + + access_log /var/log/ispconfig/nginx/<tmpl_var name='domain'>/access.log + error_log /var/log/ispconfig/nginx/<tmpl_var name='domain'>/error.log + + ### SSL cert files ### + ssl_certificate <tmpl_var name='config_dir'>/ssl/<tmpl_var name='ssl_domain'>.crt + ssl_certificate_key <tmpl_var name='config_dir'>/ssl/<tmpl_var name='ssl_domain'>.crt + + <tmpl_if name='has_bundle_cert'> + ssl_client_certificate <tmpl_var name='config_dir'>/ssl/<tmpl_var name='ssl_domain'>.bundle + </tmpl_if> + + ### Add SSL specific settings here ### + keepalive_timeout 60; + + ### Limiting Ciphers ######################## + # Uncomment as per your setup + #ssl_ciphers HIGH:!ADH; + #ssl_perfer_server_ciphers on; + #ssl_protocols SSLv3; + ############################################## + + include /etc/nginx/proxy.conf; + + ### Most PHP, Python, Rails, Java App can use this header ### + proxy_set_header X-Forwarded-Proto https; + + location / { + proxy_pass https://<tmpl_var name='ip_address'>:443; + } +} +</tmpl_if> diff --git a/server/conf/nginx_vhost.conf.master b/server/conf/nginx_vhost.conf.master index 40df895090..7bbf187e0d 100644 --- a/server/conf/nginx_vhost.conf.master +++ b/server/conf/nginx_vhost.conf.master @@ -1,69 +1,99 @@ server { - listen 80; - server_name <tmpl_var name='alias'> <tmpl_var name='domain'>; - - access_log /var/log/ispconfig/nginx/<tmpl_var name='domain'>/access.log; - error_log /var/log/ispconfig/nginx/<tmpl_var name='domain'>/error.log; + listen <tmpl_var name='ip_address'>:80; + <tmpl_if name='ssl_enabled'> + + listen <tmpl_var name='ip_address'>:443 ssl; + ssl_certificate <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.crt; + ssl_certificate_key <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.key; + </tmpl_if> + + server_name <tmpl_var name='domain'> <tmpl_var name='alias'>; - include /etc/nginx/proxy.conf; + root <tmpl_var name='web_document_root_www'>; location / { - proxy_pass http://<tmpl_var name='ip_address'>:80; + index index.html index.php; } - - location ~* \.(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ { - # Cache static-looking files for 120 minutes, setting a 10 day expiry time in the HTTP header, - # whether logged in or not (may be too heavy-handed). - proxy_cache_valid 200 120m; - expires 864000; - proxy_pass http://<tmpl_var name='ip_address'>:80; + + <tmpl_if name='ssi' op='==' value='y'> + + location ~ \.shtml$ { + ssi on; } + </tmpl_if> - <tmpl_if name='nginx_directives'> - <tmpl_var name='nginx_directives'> + <tmpl_if name='errordocs'> + + error_page 400 /error/400.html; + error_page 401 /error/401.html; + error_page 403 /error/403.html; + error_page 404 /error/404.html; + error_page 405 /error/405.html; + error_page 500 /error/500.html; + error_page 503 /error/503.html; </tmpl_if> + + error_log /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log; + # serve static files directly + location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { + access_log off; + } + ## Disable .htaccess and other hidden files + location ~ /\. { + deny all; + access_log off; + log_not_found off; + } + + location = /favicon.ico { + log_not_found off; + access_log off; + } -} - - -<tmpl_if name='ssl_enabled'> -########################################################### -# SSL Vhost -########################################################### -server { - listen 443; - server_name <tmpl_var name='ssl_domain'> <tmpl_var name='alias'>; + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location /stats { + index index.html index.php; + auth_basic "Members Only"; + auth_basic_user_file <tmpl_var name='stats_auth_passwd_file'>; + } - access_log /var/log/ispconfig/nginx/<tmpl_var name='domain'>/access.log - error_log /var/log/ispconfig/nginx/<tmpl_var name='domain'>/error.log - - ### SSL cert files ### - ssl_certificate <tmpl_var name='config_dir'>/ssl/<tmpl_var name='ssl_domain'>.crt - ssl_certificate_key <tmpl_var name='config_dir'>/ssl/<tmpl_var name='ssl_domain'>.crt - - <tmpl_if name='has_bundle_cert'> - ssl_client_certificate <tmpl_var name='config_dir'>/ssl/<tmpl_var name='ssl_domain'>.bundle + <tmpl_if name='php' op='==' value='fast-cgi'> + + location ~ \.php$ { + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_script_name; + include /etc/nginx/fastcgi_params; + } + </tmpl_else> + + location ~ \.php$ { + deny all; + } </tmpl_if> - - ### Add SSL specific settings here ### - keepalive_timeout 60; - - ### Limiting Ciphers ######################## - # Uncomment as per your setup - #ssl_ciphers HIGH:!ADH; - #ssl_perfer_server_ciphers on; - #ssl_protocols SSLv3; - ############################################## - - include /etc/nginx/proxy.conf; - - ### Most PHP, Python, Rails, Java App can use this header ### - proxy_set_header X-Forwarded-Proto https; - - location / { - proxy_pass https://<tmpl_var name='ip_address'>:443; + + <tmpl_if name='cgi' op='==' value='y'> + + location /cgi-bin/ { + root <tmpl_var name='document_root'>; + gzip off; + fastcgi_pass unix:/var/run/fcgiwrap.socket; + fastcgi_index index.cgi; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include /etc/nginx/fastcgi_params; } -} -</tmpl_if> + </tmpl_if> + + <tmpl_if name='nginx_directives'> + <tmpl_var name='nginx_directives'> + </tmpl_if> + +} \ No newline at end of file diff --git a/server/mods-available/web_module.inc.php b/server/mods-available/web_module.inc.php index 01c8b4d25d..643c7a17c3 100644 --- a/server/mods-available/web_module.inc.php +++ b/server/mods-available/web_module.inc.php @@ -129,11 +129,21 @@ class web_module { function restartHttpd($action = 'restart') { global $app,$conf; + // load the server configuration options + $app->uses('getconf'); + $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); + $daemon = ''; - if(is_file($conf['init_scripts'] . '/' . 'httpd')) { - $daemon = 'httpd'; - } else { - $daemon = 'apache2'; + switch ($web_config['server_type']) { + case 'nginx': + $daemon = $web_config['server_type']; + break; + default: + if(is_file($conf['init_scripts'] . '/' . 'httpd')) { + $daemon = 'httpd'; + } else { + $daemon = 'apache2'; + } } if($action == 'restart') { diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 7016ad1bde..cd2b351a10 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -1,5 +1,33 @@ <?php +/* +Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + class nginx_plugin { var $plugin_name = 'nginx_plugin'; @@ -13,7 +41,7 @@ class nginx_plugin { function onInstall() { global $conf; - if($conf['services']['proxy'] == true && $conf['nginx']['installed'] == true) { + if($conf['services']['web'] == true) { return true; } else { return false; @@ -32,7 +60,6 @@ class nginx_plugin { /* Register for the events */ - $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'ssl'); $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'ssl'); $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'ssl'); @@ -40,24 +67,177 @@ class nginx_plugin { $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert'); $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update'); $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete'); + + $app->plugins->registerEvent('server_ip_insert',$this->plugin_name,'server_ip'); + $app->plugins->registerEvent('server_ip_update',$this->plugin_name,'server_ip'); + $app->plugins->registerEvent('server_ip_delete',$this->plugin_name,'server_ip'); + + /* + $app->plugins->registerEvent('webdav_user_insert',$this->plugin_name,'webdav'); + $app->plugins->registerEvent('webdav_user_update',$this->plugin_name,'webdav'); + $app->plugins->registerEvent('webdav_user_delete',$this->plugin_name,'webdav'); + */ - // $app->plugins->registerEvent('proxy_reverse_insert',$this->plugin_name,'rewrite_insert'); - // $app->plugins->registerEvent('proxy_reverse_update',$this->plugin_name,'rewrite_update'); - // $app->plugins->registerEvent('proxy_reverse_delete',$this->plugin_name,'rewrite_delete'); - + $app->plugins->registerEvent('client_delete',$this->plugin_name,'client_delete'); + } + + // Handle the creation of SSL certificates + function ssl($event_name,$data) { + global $app, $conf; + + // load the server configuration options + $app->uses('getconf'); + $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); + if ($web_config['CA_path']!='' && !file_exists($web_config['CA_path'].'/openssl.cnf')) + $app->log("CA path error, file does not exist:".$web_config['CA_path'].'/openssl.conf',LOGLEVEL_ERROR); + + //* Only vhosts can have a ssl cert + if($data["new"]["type"] != "vhost") return; + + if(!is_dir($data['new']['document_root'].'/ssl')) exec('mkdir -p '.$data['new']['document_root'].'/ssl'); + $ssl_dir = $data['new']['document_root'].'/ssl'; + $domain = $data['new']['ssl_domain']; + $key_file = $ssl_dir.'/'.$domain.'.key.org'; + $key_file2 = $ssl_dir.'/'.$domain.'.key'; + $csr_file = $ssl_dir.'/'.$domain.'.csr'; + $crt_file = $ssl_dir.'/'.$domain.'.crt'; + + //* Create a SSL Certificate + if($data['new']['ssl_action'] == 'create') { + $rand_file = $ssl_dir.'/random_file'; + $rand_data = md5(uniqid(microtime(),1)); + for($i=0; $i<1000; $i++) { + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + } + file_put_contents($rand_file, $rand_data); + + $ssl_password = substr(md5(uniqid(microtime(),1)), 0, 15); + + $ssl_cnf = " RANDFILE = $rand_file + + [ req ] + default_bits = 2048 + default_keyfile = keyfile.pem + distinguished_name = req_distinguished_name + attributes = req_attributes + prompt = no + output_password = $ssl_password + + [ req_distinguished_name ] + C = ".$data['new']['ssl_country']." + ST = ".$data['new']['ssl_state']." + L = ".$data['new']['ssl_locality']." + O = ".$data['new']['ssl_organisation']." + OU = ".$data['new']['ssl_organisation_unit']." + CN = $domain + emailAddress = webmaster@".$data['new']['domain']." + + [ req_attributes ] + challengePassword = A challenge password"; + + $ssl_cnf_file = $ssl_dir.'/openssl.conf'; + file_put_contents($ssl_cnf_file,$ssl_cnf); + + $rand_file = escapeshellcmd($rand_file); + $key_file = escapeshellcmd($key_file); + $key_file2 = escapeshellcmd($key_file2); + $ssl_days = 3650; + $csr_file = escapeshellcmd($csr_file); + $config_file = escapeshellcmd($ssl_cnf_file); + $crt_file = escapeshellcmd($crt_file); + + if(is_file($ssl_cnf_file)) { + + exec("openssl genrsa -des3 -rand $rand_file -passout pass:$ssl_password -out $key_file 2048"); + exec("openssl req -new -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -out $csr_file -days $ssl_days -config $config_file"); + exec("openssl rsa -passin pass:$ssl_password -in $key_file -out $key_file2"); + + if(file_exists($web_config['CA_path'].'/openssl.cnf')) + { + exec("openssl ca -batch -out $crt_file -config ".$web_config['CA_path']."/openssl.cnf -passin pass:".$web_config['CA_pass']." -in $csr_file"); + $app->log("Creating CA-signed SSL Cert for: $domain",LOGLEVEL_DEBUG); + if (filesize($crt_file)==0 || !file_exists($crt_file)) $app->log("CA-Certificate signing failed. openssl ca -out $crt_file -config ".$web_config['CA_path']."/openssl.cnf -passin pass:".$web_config['CA_pass']." -in $csr_file",LOGLEVEL_ERROR); + }; + if (filesize($crt_file)==0 || !file_exists($crt_file)){ + exec("openssl req -x509 -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -in $csr_file -out $crt_file -days $ssl_days -config $config_file "); + $app->log("Creating self-signed SSL Cert for: $domain",LOGLEVEL_DEBUG); + }; + + } + + exec('chmod 400 '.$key_file2); + @unlink($config_file); + @unlink($rand_file); + $ssl_request = $app->db->quote(file_get_contents($csr_file)); + $ssl_cert = $app->db->quote(file_get_contents($crt_file)); + /* Update the DB of the (local) Server */ + $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + /* Update also the master-DB of the Server-Farm */ + $app->dbmaster->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + } + + //* Save a SSL certificate to disk + if($data["new"]["ssl_action"] == 'save') { + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["ssl_domain"]; + $csr_file = $ssl_dir.'/'.$domain.".csr"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + //$bundle_file = $ssl_dir.'/'.$domain.".bundle"; + if(trim($data["new"]["ssl_request"]) != '') file_put_contents($csr_file,$data["new"]["ssl_request"]); + if(trim($data["new"]["ssl_cert"]) != '') file_put_contents($crt_file,$data["new"]["ssl_cert"]); + // for nginx, bundle files have to be appended to the certificate file + if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($crt_file,$data["new"]["ssl_bundle"], FILE_APPEND); + /* Update the DB of the (local) Server */ + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + /* Update also the master-DB of the Server-Farm */ + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->log('Saving SSL Cert for: '.$domain,LOGLEVEL_DEBUG); + } + + //* Delete a SSL certificate + if($data['new']['ssl_action'] == 'del') { + $ssl_dir = $data['new']['document_root'].'/ssl'; + $domain = $data['new']['ssl_domain']; + $csr_file = $ssl_dir.'/'.$domain.'.csr'; + $crt_file = $ssl_dir.'/'.$domain.'.crt'; + //$bundle_file = $ssl_dir.'/'.$domain.'.bundle'; + if(file_exists($web_config['CA_path'].'/openssl.cnf')) + { + exec("openssl ca -batch -config ".$web_config['CA_path']."/openssl.cnf -passin pass:".$web_config['CA_pass']." -revoke $crt_file"); + $app->log("Revoking CA-signed SSL Cert for: $domain",LOGLEVEL_DEBUG); + }; + unlink($csr_file); + unlink($crt_file); + //unlink($bundle_file); + /* Update the DB of the (local) Server */ + $app->db->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + /* Update also the master-DB of the Server-Farm */ + $app->dbmaster->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->log('Deleting SSL Cert for: '.$domain,LOGLEVEL_DEBUG); + } } - - + + function insert($event_name,$data) { global $app, $conf; - + + $this->action = 'insert'; // just run the update function $this->update($event_name,$data); + + } - - + + function update($event_name,$data) { global $app, $conf; @@ -68,9 +248,9 @@ class nginx_plugin { $old_parent_domain_id = intval($data['old']['parent_domain_id']); $new_parent_domain_id = intval($data['new']['parent_domain_id']); - // If the parent_domain_id has been chenged, we will have to update the old site as well. + // If the parent_domain_id has been changed, we will have to update the old site as well. if($this->action == 'update' && $data['new']['parent_domain_id'] != $data['old']['parent_domain_id']) { - $tmp = $app->dbmaster->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$old_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$old_parent_domain_id." AND active = 'y'"); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -78,22 +258,376 @@ class nginx_plugin { } // This is not a vhost, so we need to update the parent record instead. - $tmp = $app->dbmaster->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$new_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$new_parent_domain_id." AND active = 'y'"); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; } - - - - + // load the server configuration options $app->uses('getconf'); - $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); + $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); + + //* Check if this is a chrooted setup + if($web_config['website_basedir'] != '' && @is_file($web_config['website_basedir'].'/etc/passwd')) { + $nginx_chrooted = true; + $app->log('Info: nginx is chrooted.',LOGLEVEL_DEBUG); + } else { + $nginx_chrooted = false; + } + + if($data['new']['document_root'] == '') { + $app->log('document_root not set',LOGLEVEL_WARN); + return 0; + } + if($data['new']['system_user'] == 'root' or $data['new']['system_group'] == 'root') { + $app->log('Websites cannot be owned by the root user or group.',LOGLEVEL_WARN); + return 0; + } + + //* If the client of the site has been changed, we have a change of the document root + if($this->action == 'update' && $data['new']['document_root'] != $data['old']['document_root']) { + + //* Get the old client ID + $old_client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid'])); + $old_client_id = intval($old_client['client_id']); + unset($old_client); + + //* Remove the old symlinks + $tmp_symlinks_array = explode(':',$web_config['website_symlinks']); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace('[client_id]',$old_client_id,$tmp_symlink); + $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + // create the symlinks, if not exist + if(is_link($tmp_symlink)) { + exec('rm -f '.escapeshellcmd($tmp_symlink)); + $app->log('Removed symlink: rm -f '.$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + + //* Move the site data + $tmp_docroot = explode('/',$data['new']['document_root']); + unset($tmp_docroot[count($tmp_docroot)-1]); + $new_dir = implode('/',$tmp_docroot); + + $tmp_docroot = explode('/',$data['old']['document_root']); + unset($tmp_docroot[count($tmp_docroot)-1]); + $old_dir = implode('/',$tmp_docroot); + + exec('rm -rf '.$data['new']['document_root']); + if(!is_dir($new_dir)) exec('mkdir -p '.$new_dir); + exec('mv '.$data['old']['document_root'].' '.$new_dir); + $app->log('Moving site to new document root: mv '.$data['old']['document_root'].' '.$new_dir,LOGLEVEL_DEBUG); + + // Handle the change in php_open_basedir + $data['new']['php_open_basedir'] = str_replace($data['old']['document_root'],$data['new']['document_root'],$data['old']['php_open_basedir']); + + //* Change the owner of the website files to the new website owner + exec('chown --recursive --from='.escapeshellcmd($data['old']['system_user']).':'.escapeshellcmd($data['old']['system_group']).' '.escapeshellcmd($data['new']['system_user']).':'.escapeshellcmd($data['new']['system_group']).' '.$new_dir); + + //* Change the home directory and group of the website user + $command = 'usermod'; + $command .= ' --home '.escapeshellcmd($data['new']['document_root']); + $command .= ' --gid '.escapeshellcmd($data['new']['system_group']); + $command .= ' '.escapeshellcmd($data['new']['system_user']); + exec($command); + + if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command); + + + } + + //print_r($data); + + // Check if the directories are there and create them if necessary. + if(!is_dir($data['new']['document_root'].'/web')) exec('mkdir -p '.$data['new']['document_root'].'/web'); + if(!is_dir($data['new']['document_root'].'/web/error') and $data['new']['errordocs']) exec('mkdir -p '.$data['new']['document_root'].'/web/error'); + //if(!is_dir($data['new']['document_root'].'/log')) exec('mkdir -p '.$data['new']['document_root'].'/log'); + if(!is_dir($data['new']['document_root'].'/ssl')) exec('mkdir -p '.$data['new']['document_root'].'/ssl'); + if(!is_dir($data['new']['document_root'].'/cgi-bin')) exec('mkdir -p '.$data['new']['document_root'].'/cgi-bin'); + if(!is_dir($data['new']['document_root'].'/tmp')) exec('mkdir -p '.$data['new']['document_root'].'/tmp'); + + // Remove the symlink for the site, if site is renamed + if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) { + if(is_dir('/var/log/ispconfig/httpd/'.$data['old']['domain'])) exec('rm -rf /var/log/ispconfig/httpd/'.$data['old']['domain']); + if(is_link($data['old']['document_root'].'/log')) unlink($data['old']['document_root'].'/log'); + } + + // Create the symlink for the logfiles + if(!is_dir('/var/log/ispconfig/httpd/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data['new']['domain']); + if(!is_link($data['new']['document_root'].'/log')) { + exec('ln -s /var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/log'); + $app->log('Creating symlink: ln -s /var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/log',LOGLEVEL_DEBUG); + } + /* + // Create the symlink for the logfiles + // This does not work as vlogger cannot log trough symlinks. + if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) { + if(is_dir($data['old']['document_root'].'/log')) exec('rm -rf '.$data['old']['document_root'].'/log'); + if(is_link('/var/log/ispconfig/httpd/'.$data['old']['domain'])) unlink('/var/log/ispconfig/httpd/'.$data['old']['domain']); + } + + // Create the symlink for the logfiles + if(!is_dir($data['new']['document_root'].'/log')) exec('mkdir -p '.$data['new']['document_root'].'/log'); + if(!is_link('/var/log/ispconfig/httpd/'.$data['new']['domain'])) { + exec('ln -s '.$data['new']['document_root'].'/log /var/log/ispconfig/httpd/'.$data['new']['domain']); + $app->log('Creating symlink: ln -s '.$data['new']['document_root'].'/log /var/log/ispconfig/httpd/'.$data['new']['domain'],LOGLEVEL_DEBUG); + } + */ + + // Get the client ID + $client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['new']['sys_groupid'])); + $client_id = intval($client['client_id']); + unset($client); + + // Remove old symlinks, if site is renamed + if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) { + $tmp_symlinks_array = explode(':',$web_config['website_symlinks']); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink); + $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + // remove the symlinks, if not exist + if(is_link($tmp_symlink)) { + exec('rm -f '.escapeshellcmd($tmp_symlink)); + $app->log('Removed symlink: rm -f '.$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + } + + // Create the symlinks for the sites + $tmp_symlinks_array = explode(':',$web_config['website_symlinks']); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink); + $tmp_symlink = str_replace('[website_domain]',$data['new']['domain'],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + //* Remove symlink if target folder has been changed. + if($data['old']['document_root'] != '' && $data['old']['document_root'] != $data['new']['document_root'] && is_link($tmp_symlink)) { + unlink($tmp_symlink); + } + // create the symlinks, if not exist + if(!is_link($tmp_symlink)) { + exec('ln -s '.escapeshellcmd($data['new']['document_root']).'/ '.escapeshellcmd($tmp_symlink)); + $app->log('Creating symlink: ln -s '.$data['new']['document_root'].'/ '.$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + + + + // Install the Standard or Custom Error, Index and other related files + // /usr/local/ispconfig/server/conf is for the standard files + // /usr/local/ispconfig/server/conf-custom is for the custom files + // setting a local var here + + // normally $conf['templates'] = "/usr/local/ispconfig/server/conf"; + + if($this->action == 'insert' && $data['new']['type'] == 'vhost') { + // Copy the error pages + if($data['new']['errordocs']) { + $error_page_path = escapeshellcmd($data['new']['document_root']).'/web/error/'; + if (file_exists($conf['templates'] . '-custom/error/'.substr(escapeshellcmd($conf['language']),0,2))) { + exec('cp ' . $conf['templates'] . '-custom/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path); + } + else { + if (file_exists($conf['templates'] . '-custom/error/400.html')) { + exec('cp '. $conf['templates'] .'-custom/error/*.html '.$error_page_path); + } + else { + exec('cp ' . $conf['templates'] . '/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path); + } + } + exec('chmod -R a+r '.$error_page_path); + } + + if (file_exists($conf['templates'] . '-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2))) { + exec('cp ' . $conf['templates'] . '-custom/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/web/index.html'); + + if(is_file($conf['templates'] . '-custom/index/favicon.ico')) { + exec('cp ' . $conf['templates'] . '-custom/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/web/'); + } + if(is_file($conf['templates'] . '-custom/index/robots.txt')) { + exec('cp ' . $conf['templates'] . '-custom/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/web/'); + } + if(is_file($conf['templates'] . '-custom/index/.htaccess')) { + exec('cp ' . $conf['templates'] . '-custom/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/web/'); + } + } + else { + if (file_exists($conf['templates'] . '-custom/index/standard_index.html')) { + exec('cp ' . $conf['templates'] . '-custom/index/standard_index.html '.escapeshellcmd($data['new']['document_root']).'/web/index.html'); + } + else { + exec('cp ' . $conf['templates'] . '/index/standard_index.html_'.substr(escapeshellcmd($conf['language']),0,2).' '.escapeshellcmd($data['new']['document_root']).'/web/index.html'); + if(is_file($conf['templates'] . '/index/favicon.ico')) exec('cp ' . $conf['templates'] . '/index/favicon.ico '.escapeshellcmd($data['new']['document_root']).'/web/'); + if(is_file($conf['templates'] . '/index/robots.txt')) exec('cp ' . $conf['templates'] . '/index/robots.txt '.escapeshellcmd($data['new']['document_root']).'/web/'); + if(is_file($conf['templates'] . '/index/.htaccess')) exec('cp ' . $conf['templates'] . '/index/.htaccess '.escapeshellcmd($data['new']['document_root']).'/web/'); + } + } + exec('chmod -R a+r '.escapeshellcmd($data['new']['document_root']).'/web/'); + + //** Copy the error documents on update when the error document checkbox has been activated and was deactivated before + } elseif ($this->action == 'update' && $data['new']['type'] == 'vhost' && $data['old']['errordocs'] == 0 && $data['new']['errordocs'] == 1) { + + $error_page_path = escapeshellcmd($data['new']['document_root']).'/web/error/'; + if (file_exists($conf['templates'] . '-custom/error/'.substr(escapeshellcmd($conf['language']),0,2))) { + exec('cp ' . $conf['templates'] . '-custom/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path); + } + else { + if (file_exists($conf['templates'] . '-custom/error/400.html')) { + exec('cp ' . $conf['templates'] . '-custom/error/*.html '.$error_page_path); + } + else { + exec('cp ' . $conf['templates'] . '/error/'.substr(escapeshellcmd($conf['language']),0,2).'/* '.$error_page_path); + } + } + exec('chmod -R a+r '.$error_page_path); + exec('chown -R '.$data['new']['system_user'].':'.$data['new']['system_group'].' '.$error_page_path); + } // end copy error docs // Create group and user, if not exist $app->uses('system'); + $groupname = escapeshellcmd($data['new']['system_group']); + if($data['new']['system_group'] != '' && !$app->system->is_group($data['new']['system_group'])) { + exec('groupadd '.$groupname); + if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' groupadd '.$groupname); + $app->log('Adding the group: '.$groupname,LOGLEVEL_DEBUG); + } + + $username = escapeshellcmd($data['new']['system_user']); + if($data['new']['system_user'] != '' && !$app->system->is_user($data['new']['system_user'])) { + exec('useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname -G sshusers $username -s /bin/false"); + if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' useradd -d '.escapeshellcmd($data['new']['document_root'])." -g $groupname -G sshusers $username -s /bin/false"); + $app->log('Adding the user: '.$username,LOGLEVEL_DEBUG); + } + + // Set the quota for the user + if($username != '' && $app->system->is_user($username)) { + if($data['new']['hd_quota'] > 0) { + $blocks_soft = $data['new']['hd_quota'] * 1024; + $blocks_hard = $blocks_soft + 1024; + } else { + $blocks_soft = $blocks_hard = 0; + } + exec("setquota -u $username $blocks_soft $blocks_hard 0 0 -a &> /dev/null"); + exec('setquota -T -u '.$username.' 604800 604800 -a &> /dev/null'); + } + + if($this->action == 'insert' || $data["new"]["system_user"] != $data["old"]["system_user"]) { + // Chown and chmod the directories below the document root + $this->_exec('chown -R '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'])); + // The document root itself has to be owned by root in normal level and by the web owner in security level 20 + if($web_config['security_level'] == 20) { + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'])); + } else { + $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root'])); + } + } + + + + //* If the security level is set to high + if($web_config['security_level'] == 20) { + + $this->_exec('chmod 751 '.escapeshellcmd($data['new']['document_root'])); + $this->_exec('chmod 751 '.escapeshellcmd($data['new']['document_root']).'/*'); + $this->_exec('chmod 710 '.escapeshellcmd($data['new']['document_root'].'/web')); + + // make tmp directory writable for nginx and the website users + $this->_exec('chmod 777 '.escapeshellcmd($data['new']['document_root'].'/tmp')); + + // Set Log symlink to 755 to make the logs accessible by the FTP user + $this->_exec("chmod 755 ".escapeshellcmd($data["new"]["document_root"])."/log"); + + $command = 'usermod'; + $command .= ' --groups sshusers'; + $command .= ' '.escapeshellcmd($data['new']['system_user']); + $this->_exec($command); + + //* if we have a chrooted nginx environment + if($nginx_chrooted) { + $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command); + + //* add the nginx user to the client group in the chroot environment + $tmp_groupfile = $app->system->server_conf['group_datei']; + $app->system->server_conf['group_datei'] = $web_config['website_basedir'].'/etc/group'; + $app->system->add_user_to_group($groupname, escapeshellcmd($web_config['user'])); + $app->system->server_conf['group_datei'] = $tmp_groupfile; + unset($tmp_groupfile); + } + + //* add the nginx user to the client group + $app->system->add_user_to_group($groupname, escapeshellcmd($web_config['user'])); + + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root'])); + + /* + * Workaround for jailkit: If jailkit is enabled for the site, the + * website root has to be owned by the root user and we have to chmod it to 755 then + */ + + //* Check if there is a jailkit user for this site + $tmp = $app->db->queryOneRecord('SELECT count(shell_user_id) as number FROM shell_user WHERE parent_domain_id = '.$data['new']['domain_id']." AND chroot = 'jailkit'"); + if($tmp['number'] > 0) { + $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'])); + $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root'])); + } + unset($tmp); + + // If the security Level is set to medium + } else { + + $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'])); + $this->_exec('chmod 755 '.escapeshellcmd($data['new']['document_root'].'/*')); + $this->_exec('chown root:root '.escapeshellcmd($data['new']['document_root'])); + + // make temp directory writable for nginx and the website users + $this->_exec('chmod 777 '.escapeshellcmd($data['new']['document_root'].'/tmp')); + } + + // Change the ownership of the error log to the owner of the website + if(!@is_file($data['new']['document_root'].'/log/error.log')) exec('touch '.escapeshellcmd($data['new']['document_root']).'/log/error.log'); + $this->_exec('chown '.$username.':'.$groupname.' '.escapeshellcmd($data['new']['document_root']).'/log/error.log'); + + + /* + //* Write the custom php.ini file, if custom_php_ini filed is not empty + $custom_php_ini_dir = $web_config['website_basedir'].'/conf/'.$data['new']['system_user']; + if(!is_dir($web_config['website_basedir'].'/conf')) mkdir($web_config['website_basedir'].'/conf'); + if(trim($data['new']['custom_php_ini']) != '') { + $has_custom_php_ini = true; + if(!is_dir($custom_php_ini_dir)) mkdir($custom_php_ini_dir); + $php_ini_content = ''; + if($data['new']['php'] == 'mod') { + $master_php_ini_path = $web_config['php_ini_path_apache']; + } else { + if($data["new"]['php'] == 'fast-cgi' && file_exists($fastcgi_config["fastcgi_phpini_path"])) { + $master_php_ini_path = $fastcgi_config["fastcgi_phpini_path"]; + } else { + $master_php_ini_path = $web_config['php_ini_path_cgi']; + } + } + if($master_php_ini_path != '' && substr($master_php_ini_path,-7) == 'php.ini' && is_file($master_php_ini_path)) { + $php_ini_content .= file_get_contents($master_php_ini_path)."\n"; + } + $php_ini_content .= trim($data['new']['custom_php_ini']); + file_put_contents($custom_php_ini_dir.'/php.ini',$php_ini_content); + } else { + $has_custom_php_ini = false; + if(is_file($custom_php_ini_dir.'/php.ini')) unlink($custom_php_ini_dir.'/php.ini'); + } + */ + //* Create the vhost config file $app->load('tpl'); @@ -101,36 +635,67 @@ class nginx_plugin { $tpl->newTemplate('nginx_vhost.conf.master'); $vhost_data = $data['new']; - $vhost_data['config_dir'] = $config['nginx']['config_dir']; - + $vhost_data['web_document_root'] = $data['new']['document_root'].'/web'; + $vhost_data['web_document_root_www'] = $web_config['website_basedir'].'/'.$data['new']['domain'].'/web'; + $vhost_data['web_basedir'] = $web_config['website_basedir']; + $vhost_data['security_level'] = $web_config['security_level']; + $vhost_data['allow_override'] = ($data['new']['allow_override'] == '')?'All':$data['new']['allow_override']; + //$vhost_data['php_open_basedir'] = ($data['new']['php_open_basedir'] == '')?$data['new']['document_root']:$data['new']['php_open_basedir']; $vhost_data['ssl_domain'] = $data['new']['ssl_domain']; + //$vhost_data['has_custom_php_ini'] = $has_custom_php_ini; + //$vhost_data['custom_php_ini_dir'] = escapeshellcmd($custom_php_ini_dir); + // Check if a SSL cert exists - $ssl_dir = $config['nginx']['config_dir'].'/ssl'; + $ssl_dir = $data['new']['document_root'].'/ssl'; $domain = $data['new']['ssl_domain']; $key_file = $ssl_dir.'/'.$domain.'.key'; $crt_file = $ssl_dir.'/'.$domain.'.crt'; - $bundle_file = $ssl_dir.'/'.$domain.'.bundle'; - - $vhost_data['nginx_directives'] = preg_replace("/\[IP\]/", $vhost_data['ip_address'], $vhost_data['nginx_directives']); + //$bundle_file = $ssl_dir.'/'.$domain.'.bundle'; - - if($data['new']['ssl'] == 'y' && @is_file($crt_file) && @is_file($key_file)) { + if($domain!='' && $data['new']['ssl'] == 'y' && @is_file($crt_file) && @is_file($key_file) && (@filesize($crt_file)>0) && (@filesize($key_file)>0)) { $vhost_data['ssl_enabled'] = 1; $app->log('Enable SSL for: '.$domain,LOGLEVEL_DEBUG); } else { $vhost_data['ssl_enabled'] = 0; - $app->log('Disable SSL for: '.$domain,LOGLEVEL_DEBUG); + $app->log('SSL Disabled. '.$domain,LOGLEVEL_DEBUG); } - if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1; - + //if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1; + //$vhost_data['document_root'] = $data['new']['document_root'].'/web'; $tpl->setVar($vhost_data); - + // Rewrite rules + $rewrite_rules = array(); + if($data['new']['redirect_type'] != '') { + if(substr($data['new']['redirect_path'],-1) != '/') $data['new']['redirect_path'] .= '/'; + /* Disabled path extension + if($data['new']['redirect_type'] == 'no' && substr($data['new']['redirect_path'],0,4) != 'http') { + $data['new']['redirect_path'] = $data['new']['document_root'].'/web'.realpath($data['new']['redirect_path']).'/'; + } + */ + + $rewrite_rules[] = array( 'rewrite_domain' => $data['new']['domain'], + 'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']', + 'rewrite_target' => $data['new']['redirect_path']); + + switch($data['new']['subdomain']) { + case 'www': + $rewrite_rules[] = array( 'rewrite_domain' => 'www.'.$data['new']['domain'], + 'rewrite_type' => ($data['new']['redirect_type'] == 'no')?'':'['.$data['new']['redirect_type'].']', + 'rewrite_target' => $data['new']['redirect_path']); + break; + case '*': + // TODO + //$rewrite_rules[] = array( 'rewrite_domain' => '*'.$alias['domain'], + // 'rewrite_type' => $alias['redirect_type'], + // 'rewrite_target' => $alias['redirect_path']); + break; + } + } // get alias domains (co-domains and subdomains) - $aliases = $app->dbmaster->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'"); + $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'"); $server_alias = array(); switch($data['new']['subdomain']) { case 'www': @@ -154,7 +719,31 @@ class nginx_plugin { break; } $app->log('Add server alias: '.$alias['domain'],LOGLEVEL_DEBUG); - + // Rewriting + if($alias['redirect_type'] != '') { + if(substr($data['new']['redirect_path'],-1) != '/') $data['new']['redirect_path'] .= '/'; + /* Disabled the path extension + if($data['new']['redirect_type'] == 'no' && substr($data['new']['redirect_path'],0,4) != 'http') { + $data['new']['redirect_path'] = $data['new']['document_root'].'/web'.realpath($data['new']['redirect_path']).'/'; + } + */ + $rewrite_rules[] = array( 'rewrite_domain' => $alias['domain'], + 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']', + 'rewrite_target' => $alias['redirect_path']); + switch($alias['subdomain']) { + case 'www': + $rewrite_rules[] = array( 'rewrite_domain' => 'www.'.$alias['domain'], + 'rewrite_type' => ($alias['redirect_type'] == 'no')?'':'['.$alias['redirect_type'].']', + 'rewrite_target' => $alias['redirect_path']); + break; + case '*': + // TODO + //$rewrite_rules[] = array( 'rewrite_domain' => '*'.$alias['domain'], + // 'rewrite_type' => $alias['redirect_type'], + // 'rewrite_target' => $alias['redirect_path']); + break; + } + } } } @@ -163,9 +752,7 @@ class nginx_plugin { $server_alias_str = ''; $n = 0; - // begin a new ServerAlias line after 30 alias domains foreach($server_alias as $tmp_alias) { - if($n % 30 == 0) $server_alias_str .= " "; $server_alias_str .= $tmp_alias; } unset($tmp_alias); @@ -174,48 +761,117 @@ class nginx_plugin { } else { $tpl->setVar('alias',''); } + + if(count($rewrite_rules) > 0) { + $tpl->setVar('rewrite_enabled',1); + } else { + $tpl->setVar('rewrite_enabled',0); + } + $tpl->setLoop('redirects',$rewrite_rules); + //* Create basic http auth for website statistics + $tpl->setVar('stats_auth_passwd_file', $data['new']['document_root']."/.htpasswd_stats"); - $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['new']['domain'].'.vhost'); + $vhost_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/'.$data['new']['domain'].'.vhost'); //* Make a backup copy of vhost file - copy($vhost_file,$vhost_file.'~'); + if(file_exists($vhost_file)) copy($vhost_file,$vhost_file.'~'); //* Write vhost file file_put_contents($vhost_file,$tpl->grab()); $app->log('Writing the vhost file: '.$vhost_file,LOGLEVEL_DEBUG); unset($tpl); - - // Set the symlink to enable the vhost - $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['new']['domain'].'.vhost'); + //* Set the symlink to enable the vhost + //* First we check if there is a old type of symlink and remove it + $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/'.$data['new']['domain'].'.vhost'); + if(is_link($vhost_symlink)) unlink($vhost_symlink); + + //* Remove old or changed symlinks + if($data['new']['subdomain'] != $data['old']['subdomain'] or $data['new']['active'] == 'n') { + $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/900-'.$data['new']['domain'].'.vhost'); + if(is_link($vhost_symlink)) { + unlink($vhost_symlink); + $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); + } + $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/100-'.$data['new']['domain'].'.vhost'); + if(is_link($vhost_symlink)) { + unlink($vhost_symlink); + $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); + } + } + + //* New symlink + if($data['new']['subdomain'] == '*') { + $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/900-'.$data['new']['domain'].'.vhost'); + } else { + $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/100-'.$data['new']['domain'].'.vhost'); + } if($data['new']['active'] == 'y' && !is_link($vhost_symlink)) { symlink($vhost_file,$vhost_symlink); $app->log('Creating symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); } - // Remove the symlink, if site is inactive - if($data['new']['active'] == 'n' && is_link($vhost_symlink)) { - unlink($vhost_symlink); - $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); - } - - if(!is_dir('/var/log/ispconfig/nginx/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/nginx/'.$data['new']['domain']); - // remove old symlink and vhost file, if domain name of the site has changed if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) { - $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); - unlink($vhost_symlink); - $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); - $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); + $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/900-'.$data['old']['domain'].'.vhost'); + if(is_link($vhost_symlink)) { + unlink($vhost_symlink); + $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); + } + $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/100-'.$data['old']['domain'].'.vhost'); + if(is_link($vhost_symlink)) { + unlink($vhost_symlink); + $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); + } + $vhost_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); unlink($vhost_file); $app->log('Removing file: '.$vhost_file,LOGLEVEL_DEBUG); - - if(is_dir('/var/log/ispconfig/nginx/'.$data['old']['domain'])) exec('rm -rf /var/log/ispconfig/nginx/'.$data['old']['domain']); } - // request a httpd reload when all records have been processed - $app->services->restartServiceDelayed('nginx','restart'); + // create password file for stats directory + if(!is_file($data['new']['document_root'].'/.htpasswd_stats') || $data['new']['stats_password'] != $data['old']['stats_password']) { + if(trim($data['new']['stats_password']) != '') { + $htp_file = 'admin:'.trim($data['new']['stats_password']); + file_put_contents($data['new']['document_root'].'/.htpasswd_stats',$htp_file); + chmod($data['new']['document_root'].'/.htpasswd_stats',0755); + unset($htp_file); + } + } + + //* Create awstats configuration + if($data['new']['stats_type'] == 'awstats' && $data['new']['type'] == 'vhost') { + $this->awstats_update($data,$web_config); + } + + if($web_config['check_apache_config'] == 'y') { + //* Test if nginx starts with the new configuration file + $nginx_online_status_before_restart = $this->_checkTcp('localhost',80); + $app->log('nginx status is: '.$nginx_online_status_before_restart,LOGLEVEL_DEBUG); + + $app->services->restartService('httpd','restart'); + // wait a few seconds, before we test the apache status again + sleep(2); + + //* Check if nginx restarted successfully if it was online before + $nginx_online_status_after_restart = $this->_checkTcp('localhost',80); + $app->log('nginx online status after restart is: '.$nginx_online_status_after_restart,LOGLEVEL_DEBUG); + if($nginx_online_status_before_restart && !$nginx_online_status_after_restart) { + $app->log('nginx did not restart after the configuration change for website '.$data['new']['domain'].' Reverting the configuration. Saved non-working config as '.$vhost_file.'.err',LOGLEVEL_WARN); + copy($vhost_file,$vhost_file.'.err'); + copy($vhost_file.'~',$vhost_file); + $app->services->restartService('httpd','restart'); + } + } else { + //* We do not check the nginx config after changes (is faster) + if($nginx_chrooted) { + $app->services->restartServiceDelayed('httpd','reload'); + } else { + // request a httpd reload when all records have been processed + $app->services->restartServiceDelayed('httpd','reload'); + } + } + // Remove the backup copy of the config file. if(@is_file($vhost_file.'~')) unlink($vhost_file.'~'); @@ -224,145 +880,206 @@ class nginx_plugin { $this->action = ''; } - - - - - // Handle the creation of SSL certificates - function ssl($event_name,$data) { - global $app, $conf; - - if(!is_dir($conf['nginx']['config_dir'].'/ssl')) exec('mkdir -p '.$conf['nginx']['config_dir'].'/ssl'); - $ssl_dir = $conf['nginx']['config_dir'].'/ssl'; - $domain = $data['new']['ssl_domain']; - $key_file = $ssl_dir.'/'.$domain.'.key.org'; - $key_file2 = $ssl_dir.'/'.$domain.'.key'; - $csr_file = $ssl_dir.'/'.$domain.'.csr'; - $crt_file = $ssl_dir.'/'.$domain.'.crt'; - - - //* Save a SSL certificate to disk - if($data["new"]["ssl_action"] == 'save') { - $web = $app->masterdb->queryOneRecord("select wd.document_root, sp.ip_address from web_domain wd INNER JOIN server_ip sp USING(server_id) WHERE domain = '".$data['new']['domain']."'"); - - $src_ssl_dir = $web["document_root"]."/ssl"; - //$domain = $data["new"]["ssl_domain"]; - //$csr_file = $ssl_dir.'/'.$domain.".csr"; - //$crt_file = $ssl_dir.'/'.$domain.".crt"; - //$bundle_file = $ssl_dir.'/'.$domain.".bundle"; - $this->_exec('rsync -v -e ssh root@'.$web['ip_address'].':~/$src_ssl_dir '.$ssl_dir); - - $app->log('Syncing SSL Cert for: '.$domain,LOGLEVEL_DEBUG); - } - - //* Delete a SSL certificate - if($data['new']['ssl_action'] == 'del') { - //$ssl_dir = $data['new']['document_root'].'/ssl'; - $domain = $data['new']['ssl_domain']; - $csr_file = $ssl_dir.'/'.$domain.'.csr'; - $crt_file = $ssl_dir.'/'.$domain.'.crt'; - $bundle_file = $ssl_dir.'/'.$domain.'.bundle'; - unlink($csr_file); - unlink($crt_file); - unlink($bundle_file); - $app->log('Deleting SSL Cert for: '.$domain,LOGLEVEL_DEBUG); - } - - - } - function delete($event_name,$data) { global $app, $conf; // load the server configuration options $app->uses('getconf'); - $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); + $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); + //* Check if this is a chrooted setup + if($web_config['website_basedir'] != '' && @is_file($web_config['website_basedir'].'/etc/passwd')) { + $apache_chrooted = true; + } else { + $apache_chrooted = false; + } - if($data['old']['type'] == 'vhost') { + if($data['old']['type'] != 'vhost' && $data['old']['parent_domain_id'] > 0) { + //* This is a alias domain or subdomain, so we have to update the website instead + $parent_domain_id = intval($data['old']['parent_domain_id']); + $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$parent_domain_id." AND active = 'y'"); + $data['new'] = $tmp; + $data['old'] = $tmp; + $this->action = 'update'; + // just run the update function + $this->update($event_name,$data); + } else { //* This is a website // Deleting the vhost file, symlink and the data directory - $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); + $vhost_symlink = escapeshellcmd($web_config['nginx_vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); unlink($vhost_symlink); $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); - $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); + $vhost_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); unlink($vhost_file); $app->log('Removing vhost file: '.$vhost_file,LOGLEVEL_DEBUG); - - + + $docroot = escapeshellcmd($data['old']['document_root']); + if($docroot != '' && !stristr($docroot,'..')) exec('rm -rf '.$docroot); + + + //remove the php fastgi starter script if available + if ($data['old']['php'] == 'fast-cgi') { + $fastcgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['fastcgi_starter_path']); + if (is_dir($fastcgi_starter_path)) { + exec('rm -rf '.$fastcgi_starter_path); + } + } + + //remove the php cgi starter script if available + if ($data['old']['php'] == 'cgi') { + // TODO: fetch the date from the server-settings + $web_config['cgi_starter_path'] = $web_config['website_basedir'].'/php-cgi-scripts/[system_user]/'; + + $cgi_starter_path = str_replace('[system_user]',$data['old']['system_user'],$web_config['cgi_starter_path']); + if (is_dir($cgi_starter_path)) { + exec('rm -rf '.$cgi_starter_path); + } + } + + $app->log('Removing website: '.$docroot,LOGLEVEL_DEBUG); + + // Delete the symlinks for the sites + $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid'])); + $client_id = intval($client['client_id']); + unset($client); + $tmp_symlinks_array = explode(':',$web_config['website_symlinks']); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace('[client_id]',$client_id,$tmp_symlink); + $tmp_symlink = str_replace('[website_domain]',$data['old']['domain'],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + // create the symlinks, if not exist + if(is_link($tmp_symlink)) { + unlink($tmp_symlink); + $app->log('Removing symlink: '.$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + // end removing symlinks // Delete the log file directory - $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/nginx/'.$data['old']['domain']); + $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/httpd/'.$data['old']['domain']); if($data['old']['domain'] != '' && !stristr($vhost_logfile_dir,'..')) exec('rm -rf '.$vhost_logfile_dir); $app->log('Removing website logfile directory: '.$vhost_logfile_dir,LOGLEVEL_DEBUG); + //delete the web user + $command = 'userdel'; + $command .= ' '.$data['old']['system_user']; + exec($command); + if($apache_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command); + + //* Remove the awstats configuration file + if($data['old']['stats_type'] == 'awstats') { + $this->awstats_delete($data,$web_config); + } + } } - - //* Wrapper for exec function for easier debugging - private function _exec($command) { - global $app; - $app->log('exec: '.$command,LOGLEVEL_DEBUG); - exec($command); - } - - function rewrite_insert($event_name,$data) { - global $app, $conf; - // just run the update function - $this->update($event_name,$data); - } - - function rewrite_update($event_name,$data) { + //* This function is called when a IP on the server is inserted, updated or deleted + function server_ip($event_name,$data) { global $app, $conf; - - $rules = $this->_getRewriteRules($app); - + + // load the server configuration options $app->uses('getconf'); - $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); - + $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); + $app->load('tpl'); + $tpl = new tpl(); - $tpl->newTemplate("nginx-rewrites.conf.master"); - if (!empty($rules))$tpl->setLoop('nginx_rewrite_rules',$rules); - - $rewrites_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/default.rewrites.conf'); - //* Make a backup copy of vhost file - copy($rewrites_file,$rewrites_file.'~'); - - //* Write vhost file - file_put_contents($rewrites_file,$tpl->grab()); - $app->log('Writing the nginx rewrites file: '.$rewrites_file,LOGLEVEL_DEBUG); - unset($tpl); + $tpl->newTemplate('apache_ispconfig.conf.master'); + $records = $app->db->queryAllRecords('SELECT * FROM server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + if(count($records) > 0) { + $tpl->setLoop('ip_adresses',$records); + } - // Set the symlink to enable the vhost - $rewrite_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/default.rewrites.conf'); + $vhost_file = escapeshellcmd($web_config['nginx_vhost_conf_dir'].'/ispconfig.conf'); + file_put_contents($vhost_file,$tpl->grab()); + $app->log('Writing the conf file: '.$vhost_file,LOGLEVEL_DEBUG); + unset($tpl); + + } + + //* Update the awstats configuration file + private function awstats_update ($data,$web_config) { + global $app; + + $awstats_conf_dir = $web_config['awstats_conf_dir']; + + if(!@is_file($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf') || ($data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain'])) { + if ( @is_file($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf') ) { + unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf'); + } + + $content = ''; + $content .= "Include \"".$awstats_conf_dir."/awstats.conf\"\n"; + $content .= "LogFile=\"/var/log/ispconfig/httpd/".$data['new']['domain']."/access.log\"\n"; + $content .= "SiteDomain=\"".$data['new']['domain']."\"\n"; + $content .= "HostAliases=\"www.".$data['new']['domain']." localhost 127.0.0.1\"\n"; + + file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf',$content); + $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf',LOGLEVEL_DEBUG); + } + } + + //* Delete the awstats configuration file + private function awstats_delete ($data,$web_config) { + global $app; + + $awstats_conf_dir = $web_config['awstats_conf_dir']; - if(!is_link($rewrite_symlink)) { - symlink($rewrites_file,$rewrite_symlink); - $app->log('Creating symlink for nginx rewrites: '.$rewrite_symlink.'->'.$rewrites_file,LOGLEVEL_DEBUG); - } + if ( @is_file($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf') ) { + unlink($awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf'); + $app->log('Removed AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['old']['domain'].'.conf',LOGLEVEL_DEBUG); + } } - function rewrite_delete($event_name,$data) { + function client_delete($event_name,$data) { global $app, $conf; - // just run the update function - $this->rewrite_update($event_name,$data); + $app->uses("getconf"); + $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); + + $client_id = intval($data['old']['client_id']); + if($client_id > 0) { + + $client_dir = $web_config['website_basedir'].'/clients/client'.$client_id; + if(is_dir($client_dir) && !stristr($client_dir,'..')) { + @rmdir($client_dir); + $app->log('Removed client directory: '.$client_dir,LOGLEVEL_DEBUG); + } + + $this->_exec('groupdel client'.$client_id); + $app->log('Removed group client'.$client_id,LOGLEVEL_DEBUG); + } + + } + + //* Wrapper for exec function for easier debugging + private function _exec($command) { + global $app; + $app->log('exec: '.$command,LOGLEVEL_DEBUG); + exec($command); } + private function _checkTcp ($host,$port) { + + $fp = @fsockopen ($host, $port, $errno, $errstr, 2); - function _getRewriteRules($app) - { - $rules = array(); - $rules = $app->db->queryAllRecords("SELECT rewrite_url_src, rewrite_url_dst FROM proxy_reverse ORDER BY rewrite_id ASC"); - return $rules; + if ($fp) { + fclose($fp); + return true; + } else { + return false; + } } + } // end class -?> +?> \ No newline at end of file diff --git a/server/plugins-available/nginx_reverseproxy_plugin.inc.php b/server/plugins-available/nginx_reverseproxy_plugin.inc.php new file mode 100644 index 0000000000..e725d7b85c --- /dev/null +++ b/server/plugins-available/nginx_reverseproxy_plugin.inc.php @@ -0,0 +1,368 @@ +<?php + +class nginx_reverseproxy_plugin { + + var $plugin_name = 'nginx_reverseproxy_plugin'; + var $class_name = 'nginx_reverseproxy_plugin'; + + // private variables + var $action = ''; + + //* This function is called during ispconfig installation to determine + // if a symlink shall be created for this plugin. + function onInstall() { + global $conf; + + if($conf['services']['proxy'] == true && $conf['nginx']['installed'] == true) { + return true; + } else { + return false; + } + + } + + + /* + This function is called when the plugin is loaded + */ + + function onLoad() { + global $app; + + /* + Register for the events + */ + + $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'ssl'); + $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'ssl'); + $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'ssl'); + + $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert'); + $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update'); + $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete'); + + // $app->plugins->registerEvent('proxy_reverse_insert',$this->plugin_name,'rewrite_insert'); + // $app->plugins->registerEvent('proxy_reverse_update',$this->plugin_name,'rewrite_update'); + // $app->plugins->registerEvent('proxy_reverse_delete',$this->plugin_name,'rewrite_delete'); + + + + } + + + function insert($event_name,$data) { + global $app, $conf; + + // just run the update function + $this->update($event_name,$data); + } + + + function update($event_name,$data) { + global $app, $conf; + + if($this->action != 'insert') $this->action = 'update'; + + if($data['new']['type'] != 'vhost' && $data['new']['parent_domain_id'] > 0) { + + $old_parent_domain_id = intval($data['old']['parent_domain_id']); + $new_parent_domain_id = intval($data['new']['parent_domain_id']); + + // If the parent_domain_id has been chenged, we will have to update the old site as well. + if($this->action == 'update' && $data['new']['parent_domain_id'] != $data['old']['parent_domain_id']) { + $tmp = $app->dbmaster->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$old_parent_domain_id." AND active = 'y'"); + $data['new'] = $tmp; + $data['old'] = $tmp; + $this->action = 'update'; + $this->update($event_name,$data); + } + + // This is not a vhost, so we need to update the parent record instead. + $tmp = $app->dbmaster->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$new_parent_domain_id." AND active = 'y'"); + $data['new'] = $tmp; + $data['old'] = $tmp; + $this->action = 'update'; + } + + + + + // load the server configuration options + $app->uses('getconf'); + $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); + + // Create group and user, if not exist + $app->uses('system'); + + //* Create the vhost config file + $app->load('tpl'); + + $tpl = new tpl(); + $tpl->newTemplate('nginx_reverseproxy_vhost.conf.master'); + + $vhost_data = $data['new']; + $vhost_data['config_dir'] = $config['nginx']['config_dir']; + + $vhost_data['ssl_domain'] = $data['new']['ssl_domain']; + // Check if a SSL cert exists + $ssl_dir = $config['nginx']['config_dir'].'/ssl'; + $domain = $data['new']['ssl_domain']; + $key_file = $ssl_dir.'/'.$domain.'.key'; + $crt_file = $ssl_dir.'/'.$domain.'.crt'; + $bundle_file = $ssl_dir.'/'.$domain.'.bundle'; + + $vhost_data['nginx_directives'] = preg_replace("/\[IP\]/", $vhost_data['ip_address'], $vhost_data['nginx_directives']); + + + if($data['new']['ssl'] == 'y' && @is_file($crt_file) && @is_file($key_file)) { + $vhost_data['ssl_enabled'] = 1; + $app->log('Enable SSL for: '.$domain,LOGLEVEL_DEBUG); + } else { + $vhost_data['ssl_enabled'] = 0; + $app->log('Disable SSL for: '.$domain,LOGLEVEL_DEBUG); + } + + if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1; + + + $tpl->setVar($vhost_data); + + + + // get alias domains (co-domains and subdomains) + $aliases = $app->dbmaster->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y'"); + $server_alias = array(); + switch($data['new']['subdomain']) { + case 'www': + $server_alias[] .= 'www.'.$data['new']['domain'].' '; + break; + case '*': + $server_alias[] .= '*.'.$data['new']['domain'].' '; + break; + } + if(is_array($aliases)) { + foreach($aliases as $alias) { + switch($alias['subdomain']) { + case 'www': + $server_alias[] .= 'www.'.$alias['domain'].' '.$alias['domain'].' '; + break; + case '*': + $server_alias[] .= '*.'.$alias['domain'].' '.$alias['domain'].' '; + break; + default: + $server_alias[] .= $alias['domain'].' '; + break; + } + $app->log('Add server alias: '.$alias['domain'],LOGLEVEL_DEBUG); + + } + } + + //* If we have some alias records + if(count($server_alias) > 0) { + $server_alias_str = ''; + $n = 0; + + // begin a new ServerAlias line after 30 alias domains + foreach($server_alias as $tmp_alias) { + if($n % 30 == 0) $server_alias_str .= " "; + $server_alias_str .= $tmp_alias; + } + unset($tmp_alias); + + $tpl->setVar('alias',trim($server_alias_str)); + } else { + $tpl->setVar('alias',''); + } + + + $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['new']['domain'].'.vhost'); + //* Make a backup copy of vhost file + copy($vhost_file,$vhost_file.'~'); + + //* Write vhost file + file_put_contents($vhost_file,$tpl->grab()); + $app->log('Writing the vhost file: '.$vhost_file,LOGLEVEL_DEBUG); + unset($tpl); + + + // Set the symlink to enable the vhost + $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['new']['domain'].'.vhost'); + if($data['new']['active'] == 'y' && !is_link($vhost_symlink)) { + symlink($vhost_file,$vhost_symlink); + $app->log('Creating symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); + } + + // Remove the symlink, if site is inactive + if($data['new']['active'] == 'n' && is_link($vhost_symlink)) { + unlink($vhost_symlink); + $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); + } + + if(!is_dir('/var/log/ispconfig/nginx/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/nginx/'.$data['new']['domain']); + + // remove old symlink and vhost file, if domain name of the site has changed + if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) { + $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); + unlink($vhost_symlink); + $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); + $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); + unlink($vhost_file); + $app->log('Removing file: '.$vhost_file,LOGLEVEL_DEBUG); + + if(is_dir('/var/log/ispconfig/nginx/'.$data['old']['domain'])) exec('rm -rf /var/log/ispconfig/nginx/'.$data['old']['domain']); + } + + // request a httpd reload when all records have been processed + $app->services->restartServiceDelayed('nginx','restart'); + + // Remove the backup copy of the config file. + if(@is_file($vhost_file.'~')) unlink($vhost_file.'~'); + + + //* Unset action to clean it for next processed vhost. + $this->action = ''; + + } + + + + + // Handle the creation of SSL certificates + function ssl($event_name,$data) { + global $app, $conf; + + if(!is_dir($conf['nginx']['config_dir'].'/ssl')) exec('mkdir -p '.$conf['nginx']['config_dir'].'/ssl'); + $ssl_dir = $conf['nginx']['config_dir'].'/ssl'; + $domain = $data['new']['ssl_domain']; + $key_file = $ssl_dir.'/'.$domain.'.key.org'; + $key_file2 = $ssl_dir.'/'.$domain.'.key'; + $csr_file = $ssl_dir.'/'.$domain.'.csr'; + $crt_file = $ssl_dir.'/'.$domain.'.crt'; + + + //* Save a SSL certificate to disk + if($data["new"]["ssl_action"] == 'save') { + $web = $app->masterdb->queryOneRecord("select wd.document_root, sp.ip_address from web_domain wd INNER JOIN server_ip sp USING(server_id) WHERE domain = '".$data['new']['domain']."'"); + + $src_ssl_dir = $web["document_root"]."/ssl"; + //$domain = $data["new"]["ssl_domain"]; + //$csr_file = $ssl_dir.'/'.$domain.".csr"; + //$crt_file = $ssl_dir.'/'.$domain.".crt"; + //$bundle_file = $ssl_dir.'/'.$domain.".bundle"; + $this->_exec('rsync -v -e ssh root@'.$web['ip_address'].':~/$src_ssl_dir '.$ssl_dir); + + $app->log('Syncing SSL Cert for: '.$domain,LOGLEVEL_DEBUG); + } + + //* Delete a SSL certificate + if($data['new']['ssl_action'] == 'del') { + //$ssl_dir = $data['new']['document_root'].'/ssl'; + $domain = $data['new']['ssl_domain']; + $csr_file = $ssl_dir.'/'.$domain.'.csr'; + $crt_file = $ssl_dir.'/'.$domain.'.crt'; + $bundle_file = $ssl_dir.'/'.$domain.'.bundle'; + unlink($csr_file); + unlink($crt_file); + unlink($bundle_file); + $app->log('Deleting SSL Cert for: '.$domain,LOGLEVEL_DEBUG); + } + + + } + + + function delete($event_name,$data) { + global $app, $conf; + + // load the server configuration options + $app->uses('getconf'); + $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); + + + if($data['old']['type'] == 'vhost') { + + //* This is a website + // Deleting the vhost file, symlink and the data directory + $vhost_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/'.$data['old']['domain'].'.vhost'); + unlink($vhost_symlink); + $app->log('Removing symlink: '.$vhost_symlink.'->'.$vhost_file,LOGLEVEL_DEBUG); + + $vhost_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/'.$data['old']['domain'].'.vhost'); + unlink($vhost_file); + $app->log('Removing vhost file: '.$vhost_file,LOGLEVEL_DEBUG); + + + + // Delete the log file directory + $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/nginx/'.$data['old']['domain']); + if($data['old']['domain'] != '' && !stristr($vhost_logfile_dir,'..')) exec('rm -rf '.$vhost_logfile_dir); + $app->log('Removing website logfile directory: '.$vhost_logfile_dir,LOGLEVEL_DEBUG); + + } + } + + //* Wrapper for exec function for easier debugging + private function _exec($command) { + global $app; + $app->log('exec: '.$command,LOGLEVEL_DEBUG); + exec($command); + } + + function rewrite_insert($event_name,$data) { + global $app, $conf; + + // just run the update function + $this->update($event_name,$data); + } + + function rewrite_update($event_name,$data) { + global $app, $conf; + + $rules = $this->_getRewriteRules($app); + + $app->uses('getconf'); + $nginx_config = $app->getconf->get_server_config($conf['server_id'], 'nginx'); + + $app->load('tpl'); + $tpl = new tpl(); + $tpl->newTemplate("nginx_reverseproxy_rewrites.conf.master"); + if (!empty($rules))$tpl->setLoop('nginx_rewrite_rules',$rules); + + $rewrites_file = escapeshellcmd($nginx_config['vhost_conf_dir'].'/default.rewrites.conf'); + //* Make a backup copy of vhost file + copy($rewrites_file,$rewrites_file.'~'); + + //* Write vhost file + file_put_contents($rewrites_file,$tpl->grab()); + $app->log('Writing the nginx rewrites file: '.$rewrites_file,LOGLEVEL_DEBUG); + unset($tpl); + + + // Set the symlink to enable the vhost + $rewrite_symlink = escapeshellcmd($nginx_config['vhost_conf_enabled_dir'].'/default.rewrites.conf'); + + if(!is_link($rewrite_symlink)) { + symlink($rewrites_file,$rewrite_symlink); + $app->log('Creating symlink for nginx rewrites: '.$rewrite_symlink.'->'.$rewrites_file,LOGLEVEL_DEBUG); + } + } + + function rewrite_delete($event_name,$data) { + global $app, $conf; + + // just run the update function + $this->rewrite_update($event_name,$data); + } + + + function _getRewriteRules($app) + { + $rules = array(); + $rules = $app->db->queryAllRecords("SELECT rewrite_url_src, rewrite_url_dst FROM proxy_reverse ORDER BY rewrite_id ASC"); + return $rules; + } + +} // end class + +?> -- GitLab