activeldap 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +454 -0
- data/COPYING +340 -0
- data/LICENSE +58 -0
- data/README +101 -0
- data/Rakefile +175 -0
- data/TODO +25 -0
- data/benchmark/bench-al.rb +202 -0
- data/benchmark/config.yaml.sample +5 -0
- data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
- data/examples/al-admin/README +182 -0
- data/examples/al-admin/Rakefile +10 -0
- data/examples/al-admin/app/controllers/account_controller.rb +59 -0
- data/examples/al-admin/app/controllers/application.rb +34 -0
- data/examples/al-admin/app/controllers/attributes_controller.rb +17 -0
- data/examples/al-admin/app/controllers/directory_controller.rb +47 -0
- data/examples/al-admin/app/controllers/object_classes_controller.rb +17 -0
- data/examples/al-admin/app/controllers/syntaxes_controller.rb +17 -0
- data/examples/al-admin/app/controllers/users_controller.rb +51 -0
- data/examples/al-admin/app/controllers/welcome_controller.rb +10 -0
- data/examples/al-admin/app/helpers/account_helper.rb +2 -0
- data/examples/al-admin/app/helpers/application_helper.rb +42 -0
- data/examples/al-admin/app/helpers/attributes_helper.rb +15 -0
- data/examples/al-admin/app/helpers/directory_helper.rb +7 -0
- data/examples/al-admin/app/helpers/object_classes_helper.rb +10 -0
- data/examples/al-admin/app/helpers/syntaxes_helper.rb +10 -0
- data/examples/al-admin/app/helpers/url_helper.rb +13 -0
- data/examples/al-admin/app/helpers/users_helper.rb +17 -0
- data/examples/al-admin/app/helpers/welcome_helper.rb +2 -0
- data/examples/al-admin/app/models/entry.rb +23 -0
- data/examples/al-admin/app/models/ldap_user.rb +54 -0
- data/examples/al-admin/app/models/user.rb +91 -0
- data/examples/al-admin/app/views/_entry/_attributes_information.rhtml +23 -0
- data/examples/al-admin/app/views/_entry/_entry.rhtml +15 -0
- data/examples/al-admin/app/views/_schema/_aliases.rhtml +7 -0
- data/examples/al-admin/app/views/_switcher/_after.rhtml +2 -0
- data/examples/al-admin/app/views/_switcher/_before.rhtml +5 -0
- data/examples/al-admin/app/views/account/login.rhtml +26 -0
- data/examples/al-admin/app/views/account/sign_up.rhtml +28 -0
- data/examples/al-admin/app/views/attributes/_attributes.rhtml +19 -0
- data/examples/al-admin/app/views/attributes/_detail.rhtml +29 -0
- data/examples/al-admin/app/views/attributes/index.rhtml +3 -0
- data/examples/al-admin/app/views/attributes/show.rhtml +31 -0
- data/examples/al-admin/app/views/directory/_tree.rhtml +10 -0
- data/examples/al-admin/app/views/directory/_tree_view_js.rhtml +26 -0
- data/examples/al-admin/app/views/directory/index.rhtml +13 -0
- data/examples/al-admin/app/views/directory/populate.rhtml +2 -0
- data/examples/al-admin/app/views/layouts/_flash_box.rhtml +4 -0
- data/examples/al-admin/app/views/layouts/_footer.rhtml +9 -0
- data/examples/al-admin/app/views/layouts/_header_menu.rhtml +10 -0
- data/examples/al-admin/app/views/layouts/_main_menu.rhtml +18 -0
- data/examples/al-admin/app/views/layouts/application.rhtml +56 -0
- data/examples/al-admin/app/views/object_classes/_attributes.rhtml +28 -0
- data/examples/al-admin/app/views/object_classes/_object_classes.rhtml +19 -0
- data/examples/al-admin/app/views/object_classes/index.rhtml +3 -0
- data/examples/al-admin/app/views/object_classes/show.rhtml +39 -0
- data/examples/al-admin/app/views/syntaxes/_detail.rhtml +14 -0
- data/examples/al-admin/app/views/syntaxes/_syntaxes.rhtml +19 -0
- data/examples/al-admin/app/views/syntaxes/index.rhtml +3 -0
- data/examples/al-admin/app/views/syntaxes/show.rhtml +22 -0
- data/examples/al-admin/app/views/users/_attributes_update_form.rhtml +30 -0
- data/examples/al-admin/app/views/users/_form.rhtml +13 -0
- data/examples/al-admin/app/views/users/_object_classes_update_form.rhtml +40 -0
- data/examples/al-admin/app/views/users/_password_change_form.rhtml +20 -0
- data/examples/al-admin/app/views/users/edit.rhtml +15 -0
- data/examples/al-admin/app/views/users/index.rhtml +10 -0
- data/examples/al-admin/app/views/users/show.rhtml +11 -0
- data/examples/al-admin/app/views/welcome/index.rhtml +13 -0
- data/examples/al-admin/config/boot.rb +45 -0
- data/examples/al-admin/config/database.yml.example +19 -0
- data/examples/al-admin/config/environment.rb +70 -0
- data/examples/al-admin/config/environments/development.rb +21 -0
- data/examples/al-admin/config/environments/production.rb +18 -0
- data/examples/al-admin/config/environments/test.rb +19 -0
- data/examples/al-admin/config/ldap.yml.example +21 -0
- data/examples/al-admin/config/routes.rb +46 -0
- data/examples/al-admin/db/migrate/001_create_users.rb +16 -0
- data/examples/al-admin/lib/accept_http_rails_relative_url_root.rb +9 -0
- data/examples/al-admin/lib/authenticated_system.rb +124 -0
- data/examples/al-admin/lib/authenticated_test_helper.rb +113 -0
- data/examples/al-admin/lib/tasks/gettext.rake +35 -0
- data/examples/al-admin/po/en/al-admin.po +341 -0
- data/examples/al-admin/po/ja/al-admin.po +341 -0
- data/examples/al-admin/po/nl/al-admin.po +373 -0
- data/examples/al-admin/public/.htaccess +40 -0
- data/examples/al-admin/public/404.html +30 -0
- data/examples/al-admin/public/500.html +30 -0
- data/examples/al-admin/public/dispatch.cgi +10 -0
- data/examples/al-admin/public/dispatch.fcgi +24 -0
- data/examples/al-admin/public/dispatch.rb +10 -0
- data/examples/al-admin/public/favicon.ico +0 -0
- data/examples/al-admin/public/images/active-ldap.svg +6351 -0
- data/examples/al-admin/public/images/al-admin.png +0 -0
- data/examples/al-admin/public/images/al-admin.svg +6371 -0
- data/examples/al-admin/public/images/header-background.png +0 -0
- data/examples/al-admin/public/images/header-background.svg +99 -0
- data/examples/al-admin/public/images/rails.png +0 -0
- data/examples/al-admin/public/images/spinelz/accordion_tab_left_active.gif +0 -0
- data/examples/al-admin/public/images/spinelz/accordion_tab_left_inactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/accordion_tab_middle_active.gif +0 -0
- data/examples/al-admin/public/images/spinelz/accordion_tab_middle_inactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/accordion_tab_right_active.gif +0 -0
- data/examples/al-admin/public/images/spinelz/accordion_tab_right_inactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_back.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_bottom_left.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_bottom_middle.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_bottom_right.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_left_down_arrow.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_left_up_arrow.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_middle_left.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_middle_right.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_right_down_arrow.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_right_up_arrow.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_top_left.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_top_middle.gif +0 -0
- data/examples/al-admin/public/images/spinelz/balloon_top_right.gif +0 -0
- data/examples/al-admin/public/images/spinelz/barchart_h.gif +0 -0
- data/examples/al-admin/public/images/spinelz/barchart_v.gif +0 -0
- data/examples/al-admin/public/images/spinelz/button.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calendar_default_handler.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calendar_delete.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calendar_next.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calendar_next_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calendar_pre.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calendar_pre_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calendar_private_icon.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calendar_schedule.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calender_back.gif +0 -0
- data/examples/al-admin/public/images/spinelz/calender_back_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker2_back.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker2_back_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker2_next.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker2_next_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker2_pre.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker2_pre_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker_back.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker_back_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker_next.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker_next_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker_pre.gif +0 -0
- data/examples/al-admin/public/images/spinelz/datepicker_pre_second.gif +0 -0
- data/examples/al-admin/public/images/spinelz/grid_down.gif +0 -0
- data/examples/al-admin/public/images/spinelz/grid_state.gif +0 -0
- data/examples/al-admin/public/images/spinelz/grid_up.gif +0 -0
- data/examples/al-admin/public/images/spinelz/icon_day.gif +0 -0
- data/examples/al-admin/public/images/spinelz/icon_month.gif +0 -0
- data/examples/al-admin/public/images/spinelz/icon_week.gif +0 -0
- data/examples/al-admin/public/images/spinelz/menubar_back.gif +0 -0
- data/examples/al-admin/public/images/spinelz/menubar_subcontents_back.gif +0 -0
- data/examples/al-admin/public/images/spinelz/navPanel_tab_left_active.gif +0 -0
- data/examples/al-admin/public/images/spinelz/navPanel_tab_left_inactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/navPanel_tab_middle_active.gif +0 -0
- data/examples/al-admin/public/images/spinelz/navPanel_tab_middle_inactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/navPanel_tab_right_active.gif +0 -0
- data/examples/al-admin/public/images/spinelz/navPanel_tab_right_inactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/select_date.gif +0 -0
- data/examples/al-admin/public/images/spinelz/selectabletable_selected.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_about.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_menu.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_sample.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabBottomActive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabBottomInactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleActive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleActive2.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleInactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabMiddleInactive2.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabTopActive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabTopInactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sideBarBox_tabbar.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sortableTable_down.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sortableTable_normal.gif +0 -0
- data/examples/al-admin/public/images/spinelz/sortableTable_up.gif +0 -0
- data/examples/al-admin/public/images/spinelz/switcher_close.gif +0 -0
- data/examples/al-admin/public/images/spinelz/switcher_open.gif +0 -0
- data/examples/al-admin/public/images/spinelz/tabBox_close.gif +0 -0
- data/examples/al-admin/public/images/spinelz/tabBox_tabLeftActive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/tabBox_tabLeftInactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/tabBox_tabMiddleActive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/tabBox_tabMiddleInactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/tabBox_tabRightActive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/tabBox_tabRightInactive.gif +0 -0
- data/examples/al-admin/public/images/spinelz/tab_bar.gif +0 -0
- data/examples/al-admin/public/images/spinelz/table_back.gif +0 -0
- data/examples/al-admin/public/images/spinelz/timepicker_clock.gif +0 -0
- data/examples/al-admin/public/images/spinelz/toolbar_close.gif +0 -0
- data/examples/al-admin/public/images/spinelz/toolbar_left.gif +0 -0
- data/examples/al-admin/public/images/spinelz/toolbar_max.gif +0 -0
- data/examples/al-admin/public/images/spinelz/toolbar_middle.gif +0 -0
- data/examples/al-admin/public/images/spinelz/toolbar_min.gif +0 -0
- data/examples/al-admin/public/images/spinelz/toolbar_next.gif +0 -0
- data/examples/al-admin/public/images/spinelz/toolbar_right.gif +0 -0
- data/examples/al-admin/public/images/spinelz/treeview_dir.gif +0 -0
- data/examples/al-admin/public/images/spinelz/treeview_file.gif +0 -0
- data/examples/al-admin/public/images/spinelz/treeview_group.gif +0 -0
- data/examples/al-admin/public/images/spinelz/treeview_group_special.gif +0 -0
- data/examples/al-admin/public/images/spinelz/treeview_state.gif +0 -0
- data/examples/al-admin/public/images/spinelz/treeview_user.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_bottom_left.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_bottom_middle.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_bottom_right.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_close.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_max.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_middle_left.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_middle_right.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_min.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_top_left.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_top_middle.gif +0 -0
- data/examples/al-admin/public/images/spinelz/window_top_right.gif +0 -0
- data/examples/al-admin/public/javascripts/application.js +2 -0
- data/examples/al-admin/public/javascripts/controls.js +833 -0
- data/examples/al-admin/public/javascripts/dragdrop.js +942 -0
- data/examples/al-admin/public/javascripts/effects.js +1088 -0
- data/examples/al-admin/public/javascripts/prototype.js +2515 -0
- data/examples/al-admin/public/javascripts/spinelz/accordion.js +185 -0
- data/examples/al-admin/public/javascripts/spinelz/ajaxHistory.js +157 -0
- data/examples/al-admin/public/javascripts/spinelz/balloon.js +287 -0
- data/examples/al-admin/public/javascripts/spinelz/barchart.js +524 -0
- data/examples/al-admin/public/javascripts/spinelz/calendar.js +3012 -0
- data/examples/al-admin/public/javascripts/spinelz/colorpicker.js +128 -0
- data/examples/al-admin/public/javascripts/spinelz/datepicker.js +438 -0
- data/examples/al-admin/public/javascripts/spinelz/grid.js +1391 -0
- data/examples/al-admin/public/javascripts/spinelz/grid_resizeEx.js +100 -0
- data/examples/al-admin/public/javascripts/spinelz/grid_sortabletableEx.js +129 -0
- data/examples/al-admin/public/javascripts/spinelz/inplaceEditorEx.js +148 -0
- data/examples/al-admin/public/javascripts/spinelz/menubar.js +232 -0
- data/examples/al-admin/public/javascripts/spinelz/navPanel.js +170 -0
- data/examples/al-admin/public/javascripts/spinelz/selectableTable.js +433 -0
- data/examples/al-admin/public/javascripts/spinelz/sideBarBox.js +282 -0
- data/examples/al-admin/public/javascripts/spinelz/sideBarBox_effects.js +83 -0
- data/examples/al-admin/public/javascripts/spinelz/sortableTable.js +270 -0
- data/examples/al-admin/public/javascripts/spinelz/switcher.js +78 -0
- data/examples/al-admin/public/javascripts/spinelz/tabBox.js +469 -0
- data/examples/al-admin/public/javascripts/spinelz/timepicker.js +384 -0
- data/examples/al-admin/public/javascripts/spinelz/toolbar.js +152 -0
- data/examples/al-admin/public/javascripts/spinelz/treeview.js +703 -0
- data/examples/al-admin/public/javascripts/spinelz/window.js +641 -0
- data/examples/al-admin/public/javascripts/spinelz/window_resizeEx.js +130 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/builder.js +131 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/controls.js +835 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/dragdrop.js +944 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/effects.js +1090 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/json.js +139 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/prototype.js +2515 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/resize.js +215 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/scriptaculous.js +51 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/slider.js +278 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/spinelz_util.js +1266 -0
- data/examples/al-admin/public/javascripts/spinelz_lib/unittest.js +564 -0
- data/examples/al-admin/public/robots.txt +1 -0
- data/examples/al-admin/public/stylesheets/account.css +41 -0
- data/examples/al-admin/public/stylesheets/attributes.css +1 -0
- data/examples/al-admin/public/stylesheets/base.css +99 -0
- data/examples/al-admin/public/stylesheets/common.css +2 -0
- data/examples/al-admin/public/stylesheets/detail.css +36 -0
- data/examples/al-admin/public/stylesheets/directory.css +22 -0
- data/examples/al-admin/public/stylesheets/object-classes.css +6 -0
- data/examples/al-admin/public/stylesheets/rails.css +35 -0
- data/examples/al-admin/public/stylesheets/spinelz/accordion.css +59 -0
- data/examples/al-admin/public/stylesheets/spinelz/balloon.css +151 -0
- data/examples/al-admin/public/stylesheets/spinelz/calendar.css +564 -0
- data/examples/al-admin/public/stylesheets/spinelz/datepicker.css +175 -0
- data/examples/al-admin/public/stylesheets/spinelz/grid.css +137 -0
- data/examples/al-admin/public/stylesheets/spinelz/menubar.css +78 -0
- data/examples/al-admin/public/stylesheets/spinelz/modal.css +22 -0
- data/examples/al-admin/public/stylesheets/spinelz/navPanel.css +58 -0
- data/examples/al-admin/public/stylesheets/spinelz/selectableTable.css +28 -0
- data/examples/al-admin/public/stylesheets/spinelz/sideBarBox.css +82 -0
- data/examples/al-admin/public/stylesheets/spinelz/sortableTable.css +51 -0
- data/examples/al-admin/public/stylesheets/spinelz/switcher.css +23 -0
- data/examples/al-admin/public/stylesheets/spinelz/tabBox.css +94 -0
- data/examples/al-admin/public/stylesheets/spinelz/timepicker.css +508 -0
- data/examples/al-admin/public/stylesheets/spinelz/toolbar.css +82 -0
- data/examples/al-admin/public/stylesheets/spinelz/treeview.css +121 -0
- data/examples/al-admin/public/stylesheets/spinelz/window.css +140 -0
- data/examples/al-admin/public/stylesheets/structure.css +81 -0
- data/examples/al-admin/public/stylesheets/syntaxes.css +1 -0
- data/examples/al-admin/public/stylesheets/users.css +13 -0
- data/examples/al-admin/public/stylesheets/welcome.css +0 -0
- data/examples/al-admin/script/about +3 -0
- data/examples/al-admin/script/breakpointer +3 -0
- data/examples/al-admin/script/console +3 -0
- data/examples/al-admin/script/destroy +3 -0
- data/examples/al-admin/script/generate +3 -0
- data/examples/al-admin/script/performance/benchmarker +3 -0
- data/examples/al-admin/script/performance/profiler +3 -0
- data/examples/al-admin/script/plugin +3 -0
- data/examples/al-admin/script/process/inspector +3 -0
- data/examples/al-admin/script/process/reaper +3 -0
- data/examples/al-admin/script/process/spawner +3 -0
- data/examples/al-admin/script/runner +3 -0
- data/examples/al-admin/script/server +3 -0
- data/examples/al-admin/test/fixtures/users.yml +9 -0
- data/examples/al-admin/test/functional/account_controller_test.rb +24 -0
- data/examples/al-admin/test/functional/attributes_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/directory_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/object_classes_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/syntaxes_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/users_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/welcome_controller_test.rb +18 -0
- data/examples/al-admin/test/run-test.sh +3 -0
- data/examples/al-admin/test/test_helper.rb +28 -0
- data/examples/al-admin/test/unit/user_test.rb +13 -0
- data/examples/al-admin/vendor/plugins/exception_notification/README +111 -0
- data/examples/al-admin/vendor/plugins/exception_notification/init.rb +1 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifiable.rb +99 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +67 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +77 -0
- data/examples/al-admin/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +61 -0
- data/examples/al-admin/vendor/plugins/exception_notification/test/test_helper.rb +7 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +1 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +7 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +16 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +3 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +2 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +3 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +6 -0
- data/examples/config.yaml.example +5 -0
- data/examples/example.der +0 -0
- data/examples/example.jpg +0 -0
- data/examples/groupadd +41 -0
- data/examples/groupdel +35 -0
- data/examples/groupls +49 -0
- data/examples/groupmod +42 -0
- data/examples/lpasswd +55 -0
- data/examples/objects/group.rb +13 -0
- data/examples/objects/ou.rb +4 -0
- data/examples/objects/user.rb +20 -0
- data/examples/ouadd +38 -0
- data/examples/useradd +45 -0
- data/examples/useradd-binary +50 -0
- data/examples/userdel +34 -0
- data/examples/userls +50 -0
- data/examples/usermod +42 -0
- data/examples/usermod-binary-add +47 -0
- data/examples/usermod-binary-add-time +51 -0
- data/examples/usermod-binary-del +48 -0
- data/examples/usermod-lang-add +43 -0
- data/lib/active_ldap/acts/tree.rb +75 -0
- data/lib/active_ldap/adapter/base.rb +531 -0
- data/lib/active_ldap/adapter/ldap.rb +231 -0
- data/lib/active_ldap/adapter/ldap_ext.rb +69 -0
- data/lib/active_ldap/adapter/net_ldap.rb +292 -0
- data/lib/active_ldap/adapter/net_ldap_ext.rb +29 -0
- data/lib/active_ldap/association/belongs_to.rb +47 -0
- data/lib/active_ldap/association/belongs_to_many.rb +42 -0
- data/lib/active_ldap/association/children.rb +21 -0
- data/lib/active_ldap/association/collection.rb +83 -0
- data/lib/active_ldap/association/has_many.rb +31 -0
- data/lib/active_ldap/association/has_many_utils.rb +35 -0
- data/lib/active_ldap/association/has_many_wrap.rb +46 -0
- data/lib/active_ldap/association/proxy.rb +102 -0
- data/lib/active_ldap/associations.rb +172 -0
- data/lib/active_ldap/attributes.rb +211 -0
- data/lib/active_ldap/base.rb +1273 -0
- data/lib/active_ldap/callbacks.rb +19 -0
- data/lib/active_ldap/command.rb +49 -0
- data/lib/active_ldap/configuration.rb +147 -0
- data/lib/active_ldap/connection.rb +237 -0
- data/lib/active_ldap/distinguished_name.rb +251 -0
- data/lib/active_ldap/escape.rb +12 -0
- data/lib/active_ldap/get_text/parser.rb +159 -0
- data/lib/active_ldap/get_text.rb +8 -0
- data/lib/active_ldap/get_text_fallback.rb +53 -0
- data/lib/active_ldap/get_text_support.rb +26 -0
- data/lib/active_ldap/helper.rb +33 -0
- data/lib/active_ldap/human_readable.rb +112 -0
- data/lib/active_ldap/ldap_error.rb +74 -0
- data/lib/active_ldap/ldif.rb +52 -0
- data/lib/active_ldap/object_class.rb +93 -0
- data/lib/active_ldap/operations.rb +429 -0
- data/lib/active_ldap/populate.rb +44 -0
- data/lib/active_ldap/schema/syntaxes.rb +386 -0
- data/lib/active_ldap/schema.rb +530 -0
- data/lib/active_ldap/timeout.rb +75 -0
- data/lib/active_ldap/timeout_stub.rb +17 -0
- data/lib/active_ldap/user_password.rb +93 -0
- data/lib/active_ldap/validations.rb +171 -0
- data/lib/active_ldap.rb +982 -0
- data/po/en/active-ldap.po +3677 -0
- data/po/ja/active-ldap.po +3713 -0
- data/rails/plugin/active_ldap/README +54 -0
- data/rails/plugin/active_ldap/generators/model_active_ldap/USAGE +17 -0
- data/rails/plugin/active_ldap/generators/model_active_ldap/model_active_ldap_generator.rb +70 -0
- data/rails/plugin/active_ldap/generators/model_active_ldap/templates/fixtures.yml +11 -0
- data/rails/plugin/active_ldap/generators/model_active_ldap/templates/model_active_ldap.rb +3 -0
- data/rails/plugin/active_ldap/generators/model_active_ldap/templates/unit_test.rb +10 -0
- data/rails/plugin/active_ldap/generators/scaffold_active_ldap/scaffold_active_ldap_generator.rb +7 -0
- data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +20 -0
- data/rails/plugin/active_ldap/init.rb +26 -0
- data/test/al-test-utils.rb +362 -0
- data/test/command.rb +62 -0
- data/test/config.yaml.sample +6 -0
- data/test/run-test.rb +31 -0
- data/test/test-unit-ext/always-show-result.rb +28 -0
- data/test/test-unit-ext/backtrace-filter.rb +17 -0
- data/test/test-unit-ext/long-display-for-emacs.rb +25 -0
- data/test/test-unit-ext/priority.rb +163 -0
- data/test/test-unit-ext.rb +4 -0
- data/test/test_acts_as_tree.rb +57 -0
- data/test/test_adapter.rb +98 -0
- data/test/test_associations.rb +353 -0
- data/test/test_attributes.rb +79 -0
- data/test/test_base.rb +547 -0
- data/test/test_base_per_instance.rb +55 -0
- data/test/test_bind.rb +62 -0
- data/test/test_callback.rb +35 -0
- data/test/test_configuration.rb +40 -0
- data/test/test_connection.rb +59 -0
- data/test/test_connection_per_class.rb +58 -0
- data/test/test_connection_per_dn.rb +78 -0
- data/test/test_dn.rb +160 -0
- data/test/test_find.rb +96 -0
- data/test/test_groupadd.rb +50 -0
- data/test/test_groupdel.rb +46 -0
- data/test/test_groupls.rb +107 -0
- data/test/test_groupmod.rb +51 -0
- data/test/test_ldif.rb +35 -0
- data/test/test_lpasswd.rb +75 -0
- data/test/test_object_class.rb +56 -0
- data/test/test_reflection.rb +179 -0
- data/test/test_schema.rb +433 -0
- data/test/test_syntax.rb +329 -0
- data/test/test_user.rb +227 -0
- data/test/test_user_password.rb +93 -0
- data/test/test_useradd-binary.rb +61 -0
- data/test/test_useradd.rb +57 -0
- data/test/test_userdel.rb +48 -0
- data/test/test_userls.rb +91 -0
- data/test/test_usermod-binary-add-time.rb +64 -0
- data/test/test_usermod-binary-add.rb +63 -0
- data/test/test_usermod-binary-del.rb +66 -0
- data/test/test_usermod-lang-add.rb +59 -0
- data/test/test_usermod.rb +58 -0
- data/test/test_validation.rb +110 -0
- metadata +536 -0
@@ -0,0 +1,3012 @@
|
|
1
|
+
// Copyright (c) 2006 spinelz.org (http://script.spinelz.org/)
|
2
|
+
//
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
// a copy of this software and associated documentation files (the
|
5
|
+
// "Software"), to deal in the Software without restriction, including
|
6
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
// the following conditions:
|
10
|
+
//
|
11
|
+
// The above copyright notice and this permission notice shall be
|
12
|
+
// included in all copies or substantial portions of the Software.
|
13
|
+
//
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
var Calendar = Class.create();
|
23
|
+
Calendar.className = {
|
24
|
+
container: 'calendar',
|
25
|
+
header: 'calendar_header',
|
26
|
+
preYears: 'calendar_preYears',
|
27
|
+
nextYears: 'calendar_nextYears',
|
28
|
+
years: 'calendar_years',
|
29
|
+
mark: 'calendar_mark',
|
30
|
+
ym: 'calendar_ym',
|
31
|
+
table: 'calendar_table',
|
32
|
+
thRight: 'right',
|
33
|
+
tdRight: 'right',
|
34
|
+
tdBottom: 'bottom',
|
35
|
+
date: 'calendar_date',
|
36
|
+
holiday: 'calendar_holiday',
|
37
|
+
regularHoliday: 'calendar_regularHoliday',
|
38
|
+
schedule: 'calendar_schedule',
|
39
|
+
highlightDay: 'calendar_highlightDay',
|
40
|
+
highlightTime: 'calendar_highlightTime',
|
41
|
+
scheduleListContainer: 'calendar_scheduleListContainer',
|
42
|
+
scheduleItem: 'calendar_scheduleItem',
|
43
|
+
scheduleTimeArea: 'calendar_scheduleItemTimeArea',
|
44
|
+
scheduleHandler: 'calendar_scheduleHandler',
|
45
|
+
holidayName: 'calendar_holidayName',
|
46
|
+
// holidayContainer: 'calendar_holidayContainer',
|
47
|
+
dateContainer: 'calendar_dateContainer',
|
48
|
+
tableHeader: 'calendar_tableHeader',
|
49
|
+
rowContent: 'calendar_rowContent',
|
50
|
+
selected: 'calendar_selected',
|
51
|
+
|
52
|
+
nextYearMark: 'calendar_nextYearMark',
|
53
|
+
nextMonthMark: 'calendar_nextMonthMark',
|
54
|
+
nextWeekMark: 'calendar_nextWeekMark',
|
55
|
+
preYearMark: 'calendar_preYearMark',
|
56
|
+
preMonthMark: 'calendar_preMonthMark',
|
57
|
+
preWeekMark: 'calendar_preWeekMark',
|
58
|
+
|
59
|
+
weekTable: 'calendar_weekContainerTable',
|
60
|
+
weekMainTable: 'calendar_weekMainTable',
|
61
|
+
timeLine: 'calendar_timeline',
|
62
|
+
timeLineTimeTop: 'calendar_timelineTimeTop',
|
63
|
+
timeLineTime: 'calendar_timelineTime',
|
64
|
+
headerColumn: 'calendar_headerColumn',
|
65
|
+
columnTopDate: 'calendar_columnTopDate',
|
66
|
+
columnDate: 'calendar_columnDate',
|
67
|
+
columnDateOdd: 'calendar_columnOddDate',
|
68
|
+
scheduleItemSamll: 'calendar_scheduleItemSmall',
|
69
|
+
scheduleItemLarge: 'calendar_scheduleItemLarge',
|
70
|
+
scheduleItemNoBorder: 'calendar_scheduleItemNoBorder',
|
71
|
+
scheduleItemSelect: 'calendar_scheduleItemSelect',
|
72
|
+
skipNode: 'calendar_skipNode',
|
73
|
+
deleteImg: 'calendar_deleteImage',
|
74
|
+
privateImg: 'calendar_privateImage',
|
75
|
+
scheduleContainer: 'calendar_weekScheduleContainer',
|
76
|
+
selector: 'calendar_selector',
|
77
|
+
cover: 'calendar_cover'
|
78
|
+
}
|
79
|
+
|
80
|
+
Calendar.smallClassName = {
|
81
|
+
container: 'calendar_small',
|
82
|
+
header: 'calendar_header_small',
|
83
|
+
calendar: 'calendar_calendar_small',
|
84
|
+
table: 'calendar_tableSmall'
|
85
|
+
}
|
86
|
+
|
87
|
+
Calendar.size = {
|
88
|
+
large: 'large',
|
89
|
+
small: 'small'
|
90
|
+
}
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Calendar Class
|
94
|
+
*/
|
95
|
+
Calendar.prototype = {
|
96
|
+
|
97
|
+
initialize: function(element) {
|
98
|
+
this.building = true;
|
99
|
+
this.element = $(element);
|
100
|
+
|
101
|
+
this.options = Object.extend({
|
102
|
+
initDate: new Date(),
|
103
|
+
cssPrefix: 'custom_',
|
104
|
+
holidays: [],
|
105
|
+
schedules: [],
|
106
|
+
size: Calendar.size.large,
|
107
|
+
regularHoliday: [0, 6],
|
108
|
+
displayIndexes: [0, 1, 2, 3, 4, 5, 6],
|
109
|
+
displayTime: [{hour: 0, min: 0}, {hour: 24, min: 0}],
|
110
|
+
weekIndex: 0,
|
111
|
+
dblclickListener: null,
|
112
|
+
afterSelect: Prototype.emptyFunction,
|
113
|
+
beforeRefresh: Prototype.emptyFunction,
|
114
|
+
changeSchedule: Prototype.emptyFunction,
|
115
|
+
changeCalendar: Prototype.emptyFunction,
|
116
|
+
displayType: 'month',
|
117
|
+
highlightDay: true,
|
118
|
+
beforeRemoveSchedule: function() { return true; },
|
119
|
+
dblclickSchedule: null,
|
120
|
+
updateTirm: Prototype.emptyFunction,
|
121
|
+
displayTimeLine: true,
|
122
|
+
clickDateText: null,
|
123
|
+
monthHeaderFormat: null,
|
124
|
+
weekHeaderFormat: null,
|
125
|
+
weekSubHeaderFormat: null,
|
126
|
+
dayHeaderFormat: null,
|
127
|
+
dayOfWeek: DateUtil.dayOfWeek,
|
128
|
+
skipString: '... more',
|
129
|
+
noEvent: false,
|
130
|
+
build: true
|
131
|
+
}, arguments[1] || {});
|
132
|
+
|
133
|
+
this.date = this.options.initDate;
|
134
|
+
this.options.holidays = this.toHolidayHash(this.options.holidays);
|
135
|
+
|
136
|
+
if (this.options.build) {
|
137
|
+
Element.setStyle(this.element, {visibility: 'hidden'});
|
138
|
+
Element.hide(this.element);
|
139
|
+
|
140
|
+
this.setIndex();
|
141
|
+
|
142
|
+
this.makeCss();
|
143
|
+
this.element.innerHTML = this.build();
|
144
|
+
|
145
|
+
Element.setStyle(this.element, {visibility: 'visible'});
|
146
|
+
Element.show(this.element);
|
147
|
+
this.builder.afterBuild();
|
148
|
+
this.builder.setEvent();
|
149
|
+
} else {
|
150
|
+
this.makeCss();
|
151
|
+
this.build();
|
152
|
+
this.builder.afterBuild();
|
153
|
+
}
|
154
|
+
|
155
|
+
Event.observe(document, "mouseup", this.onMouseUp.bindAsEventListener(this));
|
156
|
+
this.building = false;
|
157
|
+
this.windowResize = this.onResize.bind(this);
|
158
|
+
if (this.options.size != 'small') Event.observe(window, "resize", this.windowResize);
|
159
|
+
},
|
160
|
+
|
161
|
+
makeCss: function() {
|
162
|
+
this.classNames = null;
|
163
|
+
if (this.options.size == Calendar.size.large) {
|
164
|
+
this.classNames = Calendar.className;
|
165
|
+
} else {
|
166
|
+
this.classNames = $H({}).merge(Calendar.className);
|
167
|
+
this.classNames = this.classNames.merge(Calendar.smallClassName);
|
168
|
+
}
|
169
|
+
this.css = CssUtil.getInstance(this.options.cssPrefix, this.classNames);
|
170
|
+
this.classNames = this.css.allJoinClassNames();
|
171
|
+
},
|
172
|
+
|
173
|
+
onResize: function() {
|
174
|
+
try {
|
175
|
+
var oldDimentions = this.builder.containerDimensions;
|
176
|
+
var dimentions = Element.getDimensions(this.builder.container);
|
177
|
+
if (dimentions.height != oldDimentions.height || dimentions.width != oldDimentions.width) {
|
178
|
+
this.refresh();
|
179
|
+
}
|
180
|
+
} catch(e) {}
|
181
|
+
},
|
182
|
+
|
183
|
+
destroy: function() {
|
184
|
+
Event.stopObserving(window, 'resize', this.windowResize);
|
185
|
+
},
|
186
|
+
|
187
|
+
setIndex: function() {
|
188
|
+
var options = this.options;
|
189
|
+
options.displayIndexes = this.sortWeekIndex(options.displayIndexes);
|
190
|
+
this.setLastWday();
|
191
|
+
},
|
192
|
+
|
193
|
+
sortWeekIndex: function(indexes) {
|
194
|
+
var options = this.options;
|
195
|
+
var bottom = [];
|
196
|
+
var up = [];
|
197
|
+
var index = null;
|
198
|
+
indexes.sort();
|
199
|
+
indexes.each(function(i) {
|
200
|
+
if (index == null) {
|
201
|
+
if (options.weekIndex <= i) {
|
202
|
+
index = i;
|
203
|
+
up.push(i);
|
204
|
+
} else {
|
205
|
+
bottom.push(i);
|
206
|
+
}
|
207
|
+
} else {
|
208
|
+
up.push(i);
|
209
|
+
}
|
210
|
+
});
|
211
|
+
return up.concat(bottom);
|
212
|
+
},
|
213
|
+
|
214
|
+
setLastWday: function() {
|
215
|
+
var firstIndex = this.options.weekIndex;
|
216
|
+
var sat = 6;
|
217
|
+
var sun = 0;
|
218
|
+
var week = $R(firstIndex, sat, false).toArray();
|
219
|
+
if (firstIndex != sun) {
|
220
|
+
week = week.concat($R(sun, firstIndex - 1, false).toArray());
|
221
|
+
}
|
222
|
+
this.lastWday = week.last();
|
223
|
+
this.wdays = week;
|
224
|
+
},
|
225
|
+
|
226
|
+
build: function() {
|
227
|
+
if (this.builder) {
|
228
|
+
this.builder.destroy();
|
229
|
+
}
|
230
|
+
|
231
|
+
if (this.options.displayType == 'week') {
|
232
|
+
this.builder = new CalendarWeek(this);
|
233
|
+
} else if (this.options.displayType == 'day') {
|
234
|
+
this.builder = new CalendarDay(this);
|
235
|
+
} else {
|
236
|
+
this.builder = new CalendarMonth(this);
|
237
|
+
}
|
238
|
+
|
239
|
+
this.builder.beforeBuild();
|
240
|
+
if (this.options.build) return this.builder.build();
|
241
|
+
},
|
242
|
+
|
243
|
+
/*** Calendar ***/
|
244
|
+
/********************************** public method **********************************/
|
245
|
+
undo: function() {
|
246
|
+
if (this.cached) {
|
247
|
+
this.cached.start = this.cached.start_old;
|
248
|
+
this.cached.finish = this.cached.finish_old;
|
249
|
+
this.cached = null;
|
250
|
+
this.refreshSchedule();
|
251
|
+
}
|
252
|
+
},
|
253
|
+
|
254
|
+
hideSatSun: function() {
|
255
|
+
var sun = 0;
|
256
|
+
var sat = 6;
|
257
|
+
this.options.displayIndexes = this.options.displayIndexes.without(sun, sat);
|
258
|
+
this.setIndex();
|
259
|
+
this.refresh();
|
260
|
+
},
|
261
|
+
|
262
|
+
showSatSun: function() {
|
263
|
+
var sun = 0;
|
264
|
+
var sat = 6;
|
265
|
+
var indexes = this.options.displayIndexes;
|
266
|
+
if (!indexes.include(sun)) {
|
267
|
+
indexes.push(sun);
|
268
|
+
}
|
269
|
+
if (!indexes.include(sat)) {
|
270
|
+
indexes.push(sat);
|
271
|
+
}
|
272
|
+
this.setIndex();
|
273
|
+
this.refresh();
|
274
|
+
},
|
275
|
+
|
276
|
+
changeDisplayIndexes: function(indexes) {
|
277
|
+
this.options.displayIndexes = indexes;
|
278
|
+
this.setIndex();
|
279
|
+
this.refresh();
|
280
|
+
},
|
281
|
+
|
282
|
+
changeDisplayTime: function(time) {
|
283
|
+
this.options.displayTime = time;
|
284
|
+
this.refresh();
|
285
|
+
},
|
286
|
+
|
287
|
+
refresh: function() {
|
288
|
+
try {
|
289
|
+
if (!this.building) {
|
290
|
+
this.building = true;
|
291
|
+
this.options.build = true;
|
292
|
+
this.options.beforeRefresh(this);
|
293
|
+
this.destroy();
|
294
|
+
this.selectedBase = null;
|
295
|
+
this.element.innerHTML = this.build();
|
296
|
+
this.builder.afterBuild();
|
297
|
+
this.builder.setEvent();
|
298
|
+
if (this.options.size != 'small') Event.observe(window, 'resize', this.windowResize);
|
299
|
+
this.building = false;
|
300
|
+
}
|
301
|
+
} catch (e) {
|
302
|
+
// do nothing
|
303
|
+
}
|
304
|
+
},
|
305
|
+
|
306
|
+
changeCalendar: function(event) {
|
307
|
+
this.builder.changeCalendar(event);
|
308
|
+
},
|
309
|
+
|
310
|
+
changeDisplayType: function(type) {
|
311
|
+
this.options.displayType = type;
|
312
|
+
this.refresh();
|
313
|
+
},
|
314
|
+
|
315
|
+
selectDate: function(event) {
|
316
|
+
var calendar = this;
|
317
|
+
this.abstractSelect(event, function(date, element) {
|
318
|
+
if (calendar.selectedBase || calendar.hasSelectedDate()) {
|
319
|
+
if (event.ctrlKey) {
|
320
|
+
if (Element.hasClassName(element, Calendar.className.selected)) {
|
321
|
+
calendar.addSelectedClass(element);
|
322
|
+
return;
|
323
|
+
}
|
324
|
+
} else if (calendar.selectedBase) {
|
325
|
+
var selectedId = calendar.selectedBase.id;
|
326
|
+
$(selectedId).className = calendar.selectedBase.className;
|
327
|
+
calendar.clearSelected();
|
328
|
+
if (selectedId == element.id) {
|
329
|
+
calendar.selectedBase = null;
|
330
|
+
return;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
}
|
334
|
+
|
335
|
+
calendar.selectedBase = {id: element.id, date: date, className: element.className};
|
336
|
+
calendar.addSelectedClass(element);
|
337
|
+
if (date && calendar.options.displayType == 'month' && calendar.options.size == Calendar.size.small) {
|
338
|
+
calendar.options.afterSelect(date, calendar);
|
339
|
+
}
|
340
|
+
});
|
341
|
+
|
342
|
+
if (calendar.options.displayType != 'month' || calendar.options.size != Calendar.size.small) {
|
343
|
+
this.mouseDown = true;
|
344
|
+
}
|
345
|
+
},
|
346
|
+
|
347
|
+
clearSelect: function() {
|
348
|
+
this.selectedBase = null;
|
349
|
+
this.clearSelected();
|
350
|
+
},
|
351
|
+
|
352
|
+
showDayOfWeek: function(dayOfWeek) {
|
353
|
+
var indexes = this.options.displayIndexes;
|
354
|
+
this.recurrence(dayOfWeek, function(d) {
|
355
|
+
if (!indexes.include(d)) {
|
356
|
+
indexes.push(d);
|
357
|
+
}
|
358
|
+
});
|
359
|
+
this.setIndex();
|
360
|
+
this.refresh();
|
361
|
+
},
|
362
|
+
|
363
|
+
hideDayOfWeek: function(dayOfWeek) {
|
364
|
+
var indexes = this.options.displayIndexes;
|
365
|
+
var self = this;
|
366
|
+
this.recurrence(dayOfWeek, function(d) {
|
367
|
+
var index = self.findIndex(indexes, d);
|
368
|
+
if (index) {
|
369
|
+
indexes.remove(index);
|
370
|
+
} else if (!index.isNaN) {
|
371
|
+
indexes.shift();
|
372
|
+
}
|
373
|
+
});
|
374
|
+
this.refresh();
|
375
|
+
},
|
376
|
+
|
377
|
+
addHoliday: function(object) {
|
378
|
+
object = this.inspectArgument(object);
|
379
|
+
var newHash = this.toHolidayHash(object);
|
380
|
+
this.options.holidays = this.options.holidays.merge(newHash);
|
381
|
+
this.refresh();
|
382
|
+
},
|
383
|
+
|
384
|
+
removeHoliday: function(date) {
|
385
|
+
var calendar = this;
|
386
|
+
date = calendar.inspectDateArgument(date);
|
387
|
+
if (!date) return;
|
388
|
+
|
389
|
+
this.recurrence(date, function(d) {
|
390
|
+
var key = d.toDateString();
|
391
|
+
if (calendar.options.holidays[key])
|
392
|
+
delete calendar.options.holidays[key];
|
393
|
+
});
|
394
|
+
this.refresh();
|
395
|
+
},
|
396
|
+
|
397
|
+
refreshHoliday: function(object, rebuild) {
|
398
|
+
object = this.inspectArgument(object);
|
399
|
+
this.options.holidays = this.toHolidayHash(object);
|
400
|
+
if (rebuild) this.refresh();
|
401
|
+
},
|
402
|
+
|
403
|
+
clearHoliday: function() {
|
404
|
+
this.refreshHoliday([], true);
|
405
|
+
},
|
406
|
+
|
407
|
+
getHoliday: function(date) {
|
408
|
+
date = this.inspectDateArgument(date);
|
409
|
+
if (!date) return;
|
410
|
+
|
411
|
+
var calendar = this;
|
412
|
+
var holidays = [];
|
413
|
+
this.recurrence(date, function(o) {
|
414
|
+
var h = calendar.options.holidays[o.toDateString()];
|
415
|
+
if (h) holidays.push(h);
|
416
|
+
});
|
417
|
+
|
418
|
+
return holidays;
|
419
|
+
},
|
420
|
+
|
421
|
+
addSchedule: function(schedule) {
|
422
|
+
var schedules = this.options.schedules;
|
423
|
+
if (schedule.constructor == Array) {
|
424
|
+
schedule.each(function(s) {
|
425
|
+
var find = schedules.detect(function(tmp) {return s.id == tmp.id});
|
426
|
+
if (!find) schedules.push(s);
|
427
|
+
});
|
428
|
+
} else {
|
429
|
+
var find = schedules.detect(function(tmp) {return tmp.id == schedule.id});
|
430
|
+
if (!find) schedules.push(schedule);
|
431
|
+
}
|
432
|
+
this.refreshSchedule();
|
433
|
+
},
|
434
|
+
|
435
|
+
replaceSchedule: function(schedules) {
|
436
|
+
this.options.schedules = schedules;
|
437
|
+
this.refreshSchedule();
|
438
|
+
},
|
439
|
+
|
440
|
+
removeSchedule: function(ids, refresh) {
|
441
|
+
if (ids.constructor != Array) ids = [ids];
|
442
|
+
var self = this;
|
443
|
+
ids.each(function(id) {
|
444
|
+
var index = null;
|
445
|
+
self.options.schedules.each(function(s, i) {
|
446
|
+
if (s.id == id) {
|
447
|
+
index = i;
|
448
|
+
throw $break;
|
449
|
+
}
|
450
|
+
});
|
451
|
+
|
452
|
+
if (index != null) {
|
453
|
+
var schedule = self.options.schedules[index];
|
454
|
+
if (schedule) {
|
455
|
+
self.options.schedules.remove(index);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
});
|
459
|
+
if (refresh) this.refreshSchedule();
|
460
|
+
},
|
461
|
+
|
462
|
+
refreshSchedule: function() {
|
463
|
+
this.builder.scheduleNodes.each(function(node) { Element.remove(node); });
|
464
|
+
(this.builder.skipNode || []).each(function(pair) { Element.remove(pair.value); });
|
465
|
+
this.builder.afterBuild();
|
466
|
+
},
|
467
|
+
|
468
|
+
mergeSchedule: function(schedule) {
|
469
|
+
var index = -1;
|
470
|
+
this.options.schedules.each(function(s, i) {
|
471
|
+
if (s.id == schedule.id) {
|
472
|
+
index = i;
|
473
|
+
throw $break;
|
474
|
+
}
|
475
|
+
});
|
476
|
+
if (index != -1) {
|
477
|
+
this.options.schedules[index] = schedule;
|
478
|
+
this.refreshSchedule();
|
479
|
+
} else {
|
480
|
+
this.addSchedule(schedule);
|
481
|
+
}
|
482
|
+
},
|
483
|
+
|
484
|
+
clearSchedule: function() {
|
485
|
+
this.options.schedules = [];
|
486
|
+
this.refreshSchedule();
|
487
|
+
},
|
488
|
+
|
489
|
+
getSchedule: function(object) {
|
490
|
+
var result = [];
|
491
|
+
var calendar = this;
|
492
|
+
object = this.inspectArgument(object || {});
|
493
|
+
|
494
|
+
this.recurrence(object, function(o) {
|
495
|
+
var schedule = calendar.options.schedules[o.date.toDateString()];
|
496
|
+
if (!schedule) return;
|
497
|
+
|
498
|
+
if (o.start) {
|
499
|
+
schedule = schedule.detect(function(s) {
|
500
|
+
return ((s.start.hour == o.start.hour) && (s.start.min == o.start.min));
|
501
|
+
});
|
502
|
+
if (schedule) result.push(schedule);
|
503
|
+
} else if (o.number) {
|
504
|
+
schedule = schedule[o.number];
|
505
|
+
if (schedule) result.push(schedule);
|
506
|
+
} else {
|
507
|
+
result = result.concat(schedule);
|
508
|
+
}
|
509
|
+
});
|
510
|
+
|
511
|
+
return result;
|
512
|
+
},
|
513
|
+
|
514
|
+
getSelected: function() {
|
515
|
+
return this.element.getElementsByClassName(Calendar.className.selected, this.element);
|
516
|
+
},
|
517
|
+
|
518
|
+
changeSchedule: function() {
|
519
|
+
var calendar = this;
|
520
|
+
return function(drag, drop) {
|
521
|
+
var array = drag.id.split('_');
|
522
|
+
var i = array.pop();
|
523
|
+
var date = array.pop();
|
524
|
+
|
525
|
+
date = calendar.getDate(date);
|
526
|
+
var newDate = calendar.getDate(drop);
|
527
|
+
|
528
|
+
var schedule = calendar.getSchedule({date: date, number: i});
|
529
|
+
if (schedule.length != 1) return;
|
530
|
+
|
531
|
+
schedule = schedule.pop();
|
532
|
+
schedule.date = newDate;
|
533
|
+
calendar.removeSchedule({date: date, number: i}, false);
|
534
|
+
calendar.addSchedule(schedule);
|
535
|
+
|
536
|
+
calendar.options.changeSchedule(schedule);
|
537
|
+
}
|
538
|
+
},
|
539
|
+
|
540
|
+
getSelectedDates: function() {
|
541
|
+
return this.builder.getSelectedDates();
|
542
|
+
},
|
543
|
+
|
544
|
+
getSelectedTerm: function() {
|
545
|
+
return this.builder.getSelectedTerm();
|
546
|
+
},
|
547
|
+
|
548
|
+
/********************************** private method **********************************/
|
549
|
+
abstractSelect: function(event, method) {
|
550
|
+
this.builder.abstractSelect(event, method);
|
551
|
+
},
|
552
|
+
|
553
|
+
createRange: function(a, b) {
|
554
|
+
var range = null;
|
555
|
+
if (a <= b)
|
556
|
+
range = $R(a, b);
|
557
|
+
else
|
558
|
+
range = $R(b, a);
|
559
|
+
return range;
|
560
|
+
},
|
561
|
+
|
562
|
+
formatTime: function(time) {
|
563
|
+
var hour = (time.hour < 10) ? '0' + time.hour : time.hour;
|
564
|
+
var min = (time.min < 10) ? '0' + time.min : time.min;
|
565
|
+
return hour + ':' + min;
|
566
|
+
},
|
567
|
+
|
568
|
+
clearSelected: function() {
|
569
|
+
var elements = this.getSelected();
|
570
|
+
var self = this;
|
571
|
+
elements.each(function(e) {
|
572
|
+
if (Element.hasClassName(e, Calendar.className.selected))
|
573
|
+
self.removeSelectedClass(e);
|
574
|
+
});
|
575
|
+
},
|
576
|
+
|
577
|
+
onDblClick: function(event) {
|
578
|
+
this.abstractSelect(event, this.options.dblclickListener);
|
579
|
+
},
|
580
|
+
|
581
|
+
onMouseUp: function(event) {
|
582
|
+
var e = event || window.event;
|
583
|
+
var calendar = this;
|
584
|
+
if (calendar.mouseDown) {
|
585
|
+
setTimeout(function() {
|
586
|
+
calendar.mouseDown = false;
|
587
|
+
calendar.options.afterSelect(event);
|
588
|
+
}, 10);
|
589
|
+
}
|
590
|
+
},
|
591
|
+
|
592
|
+
setRegularHolidayClass: function(node) {
|
593
|
+
this.classNames.refreshClassNames(node, 'regularHoliday');
|
594
|
+
},
|
595
|
+
|
596
|
+
// setHolidayClass: function(node) {
|
597
|
+
// this.classNames.refreshClassNames(node, 'holiday');
|
598
|
+
// },
|
599
|
+
|
600
|
+
getHolidayClass: function() {
|
601
|
+
this.classNames.refreshClassNames(node, 'holiday');
|
602
|
+
},
|
603
|
+
|
604
|
+
setWorkdayClass: function(node) {
|
605
|
+
this.classNames.refreshClassNames(node, 'date');
|
606
|
+
},
|
607
|
+
|
608
|
+
setScheduleClass: function(node) {
|
609
|
+
this.classNames.refreshClassNames(node, 'schedule');
|
610
|
+
},
|
611
|
+
|
612
|
+
// addHighlightClass: function(node) {
|
613
|
+
// Element.addClassName(node, Calendar.className.highlightDay);
|
614
|
+
// },
|
615
|
+
|
616
|
+
addSelectedClass: function(node) {
|
617
|
+
this.css.addClassNames(node, 'selected');
|
618
|
+
},
|
619
|
+
|
620
|
+
removeSelectedClass: function(node) {
|
621
|
+
this.css.removeClassNames(node, 'selected');
|
622
|
+
},
|
623
|
+
|
624
|
+
getDatasWithMonthAndYear: function(array) {
|
625
|
+
var calendar = this;
|
626
|
+
var result = array.findAll(function(h) {
|
627
|
+
return calendar.isSameYearAndMonth(h.date);
|
628
|
+
});
|
629
|
+
|
630
|
+
return result;
|
631
|
+
},
|
632
|
+
|
633
|
+
isSameYearAndMonth: function(a, b) {
|
634
|
+
if (a.constructor == Date) {
|
635
|
+
if (!b) b = this.date;
|
636
|
+
return ((a.getYear() == b.getYear()) && (a.getMonth() == b.getMonth()));
|
637
|
+
} else {
|
638
|
+
return (a.year == b.year && a.month == b.month && a.day == a.day);
|
639
|
+
}
|
640
|
+
},
|
641
|
+
|
642
|
+
isSameDate: function(a, b) {
|
643
|
+
if (a.constructor == Date) {
|
644
|
+
if (!b) b = this.date;
|
645
|
+
return (this.isSameYearAndMonth(a, b) && (a.getDate() == b.getDate()));
|
646
|
+
} else {
|
647
|
+
return (this.isSameYearAndMonth(a, b) && a.day == b.day);
|
648
|
+
}
|
649
|
+
},
|
650
|
+
|
651
|
+
isSameTime: function(a, b) {
|
652
|
+
return ((a.hour == b.hour) && (a.min == b.min));
|
653
|
+
},
|
654
|
+
|
655
|
+
betweenDate: function(schedule, date) {
|
656
|
+
var start = this.toDateNumber(schedule.start);
|
657
|
+
var finish = this.toDateNumber(schedule.finish);
|
658
|
+
date = this.toDateNumber(date);
|
659
|
+
return start <= date && date <= finish;
|
660
|
+
},
|
661
|
+
|
662
|
+
toDateNumber: function(date) {
|
663
|
+
if (date.constructor == Date) {
|
664
|
+
return date.getFullYear() * 10000 + date.getMonth() * 100 + date.getDate();
|
665
|
+
} else {
|
666
|
+
return date.year * 10000 + date.month * 100 + date.day;
|
667
|
+
}
|
668
|
+
},
|
669
|
+
|
670
|
+
getTimeDiff: function(a, b) {
|
671
|
+
var time = {hour: b.hour - a.hour, min: b.min - a.min};
|
672
|
+
if (time.min >= 60) {
|
673
|
+
time.hour++;
|
674
|
+
time.min -= 60;
|
675
|
+
} else if (time.min < 0) {
|
676
|
+
time.hour--;
|
677
|
+
time.min += 60;
|
678
|
+
}
|
679
|
+
return time;
|
680
|
+
},
|
681
|
+
|
682
|
+
findIndex: function(array, value) {
|
683
|
+
var index = null;
|
684
|
+
array.each(function(v, i) {
|
685
|
+
if (v == value) {
|
686
|
+
index = i;
|
687
|
+
throw $break;
|
688
|
+
}
|
689
|
+
});
|
690
|
+
return index;
|
691
|
+
},
|
692
|
+
|
693
|
+
recurrence: function(object, method) {
|
694
|
+
var calendar = this;
|
695
|
+
if (object.constructor == Array) {
|
696
|
+
object.each(function(o) {calendar.recurrence(o, method)});
|
697
|
+
} else if (object.keys) {
|
698
|
+
object.each(function(pair) {calendar.recurrence(pair[1], method)});
|
699
|
+
} else {
|
700
|
+
method(object);
|
701
|
+
}
|
702
|
+
},
|
703
|
+
|
704
|
+
toHolidayHash: function(object) {
|
705
|
+
var calendar = this;
|
706
|
+
var hash = {};
|
707
|
+
|
708
|
+
this.recurrence(object, function(o) {
|
709
|
+
if (!o.name) return;
|
710
|
+
if (o.date.constructor == Object)
|
711
|
+
o.date = new Date(o.date.year, o.date.month, o.date.day);
|
712
|
+
|
713
|
+
hash[o.date.toDateString()] = o;
|
714
|
+
});
|
715
|
+
return $H(hash);
|
716
|
+
},
|
717
|
+
|
718
|
+
inspectArgument: function(object, time) {
|
719
|
+
return this.builder.inspectArgument(object, time);
|
720
|
+
},
|
721
|
+
|
722
|
+
inspectDateArgument: function(date) {
|
723
|
+
return this.builder.inspectDateArgument(date);
|
724
|
+
},
|
725
|
+
|
726
|
+
sortSchedule: function(a, b) {
|
727
|
+
if (a.start.hour == b.start.hour) {
|
728
|
+
if (a.start.min == b.start.min)
|
729
|
+
return 0;
|
730
|
+
if (a.start.min < b.start.min)
|
731
|
+
return -1;
|
732
|
+
return 1;
|
733
|
+
}
|
734
|
+
if (a.start.hour < b.start.hour) return -1;
|
735
|
+
|
736
|
+
return 1;
|
737
|
+
},
|
738
|
+
|
739
|
+
hasSelectedDate: function() {
|
740
|
+
return (this.getSelected().length != 0);
|
741
|
+
},
|
742
|
+
|
743
|
+
getDate: function(element) {
|
744
|
+
return this.builder.getDate(element);
|
745
|
+
},
|
746
|
+
|
747
|
+
isRegularHoliday: function(day) {
|
748
|
+
return this.options.regularHoliday.include(day);
|
749
|
+
},
|
750
|
+
|
751
|
+
isHoliday: function(date) {
|
752
|
+
return this.options.holidays[date.toDateString()];
|
753
|
+
},
|
754
|
+
|
755
|
+
isScheduleDay: function(date) {
|
756
|
+
return this.options.schedules[date.toDateString()];
|
757
|
+
},
|
758
|
+
|
759
|
+
cacheSchedule: function(schedule) {
|
760
|
+
this.cached = schedule;
|
761
|
+
schedule.start_old = Object.clone(schedule.start);
|
762
|
+
schedule.finish_old = Object.clone(schedule.finish);
|
763
|
+
}
|
764
|
+
}
|
765
|
+
|
766
|
+
|
767
|
+
/**
|
768
|
+
* AbstractCalendar Class
|
769
|
+
*/
|
770
|
+
var AbstractCalendar = Class.create();
|
771
|
+
AbstractCalendar.id = {
|
772
|
+
container: 'container',
|
773
|
+
scheduleContainer: 'scheduleContainer',
|
774
|
+
selector: 'selector'
|
775
|
+
}
|
776
|
+
AbstractCalendar.prototype = {
|
777
|
+
destroy: Prototype.emptyFunction,
|
778
|
+
beforeBuild: Prototype.emptyFunction,
|
779
|
+
|
780
|
+
build: function() {
|
781
|
+
return "<div id='" + this.getContainerId() + "' class='" + this.calendar.classNames.container + "'>" +
|
782
|
+
this.buildHeader() +
|
783
|
+
this.buildCalendar() +
|
784
|
+
"</div>";
|
785
|
+
},
|
786
|
+
|
787
|
+
buildHeader: function() {
|
788
|
+
var noEvent = this.calendar.options.noEvent;
|
789
|
+
return "<table class='" + this.calendar.classNames.header + "'>" +
|
790
|
+
"<tr>" +
|
791
|
+
(noEvent ? '' : this.buildHeaderLeft()) +
|
792
|
+
this.buildHeaderCenter() +
|
793
|
+
(noEvent ? '' : this.buildHeaderRight()) +
|
794
|
+
"</tr>" +
|
795
|
+
"</table>";
|
796
|
+
},
|
797
|
+
|
798
|
+
buildSelector: function() {
|
799
|
+
var style = "display: none; zindex:" + ZindexManager.getIndex();
|
800
|
+
return "<div id='" + this.getSelectorId() + "' class='" + this.calendar.classNames.selector + "' style='" + style + "'>" + "</div>";
|
801
|
+
},
|
802
|
+
|
803
|
+
buildCover: function() {
|
804
|
+
this.cover = Builder.node('div', {id: this.calendar.element.id.appendSuffix('cover')});
|
805
|
+
this.calendar.css.addClassNames(this.cover, 'cover');
|
806
|
+
if (!this.calendar.options.noEvent) {
|
807
|
+
Event.observe(this.cover, 'mousedown', this.calendar.selectDate.bindAsEventListener(this.calendar));
|
808
|
+
if (this.calendar.options.displayType != 'month' || this.calendar.options.size != 'samll') {
|
809
|
+
Event.observe(this.cover, 'mousemove', this.multipleSelection.bindAsEventListener(this));
|
810
|
+
}
|
811
|
+
}
|
812
|
+
return this.cover;
|
813
|
+
},
|
814
|
+
|
815
|
+
changeCalendar: function(event) {
|
816
|
+
var element = Event.element(event);
|
817
|
+
var date = this.calendar.date;
|
818
|
+
var oldDate = new Date(date.toDateString());
|
819
|
+
|
820
|
+
if (this.hasClassName(element, Calendar.className.preYearMark)) {
|
821
|
+
date.setDate(1);
|
822
|
+
date.setFullYear(date.getFullYear() - 1);
|
823
|
+
} else if (this.hasClassName(element, Calendar.className.preMonthMark)) {
|
824
|
+
date.setDate(1);
|
825
|
+
date.setMonth(date.getMonth() - 1);
|
826
|
+
} else if (this.hasClassName(element, Calendar.className.preWeekMark)) {
|
827
|
+
date.setDate(date.getDate() - 7);
|
828
|
+
} else if (this.hasClassName(element, Calendar.className.nextYearMark)) {
|
829
|
+
date.setDate(1);
|
830
|
+
date.setFullYear(date.getFullYear() + 1);
|
831
|
+
} else if (this.hasClassName(element, Calendar.className.nextMonthMark)) {
|
832
|
+
date.setDate(1);
|
833
|
+
date.setMonth(date.getMonth() + 1);
|
834
|
+
} else if (this.hasClassName(element, Calendar.className.nextWeekMark)) {
|
835
|
+
date.setDate(date.getDate() + 7);
|
836
|
+
}
|
837
|
+
|
838
|
+
this.calendar.options.changeCalendar(date, oldDate);
|
839
|
+
this.calendar.refresh();
|
840
|
+
},
|
841
|
+
|
842
|
+
hasClassName: function(element, className) {
|
843
|
+
return Element.hasClassName(element, className) || Element.hasClassName(element, className + 'Hover')
|
844
|
+
},
|
845
|
+
|
846
|
+
clickDeleteImage: function(schedule) {
|
847
|
+
if (this.calendar.options.beforeRemoveSchedule(schedule)) {
|
848
|
+
this.calendar.removeSchedule(schedule.id, true);
|
849
|
+
}
|
850
|
+
},
|
851
|
+
|
852
|
+
showDeleteImage: function(img) {
|
853
|
+
Element.show(img);
|
854
|
+
},
|
855
|
+
|
856
|
+
hideDeleteImage: function(img) {
|
857
|
+
Element.hide(img);
|
858
|
+
},
|
859
|
+
|
860
|
+
_constrain: function(n, lower, upper) {
|
861
|
+
if (n > upper) return upper;
|
862
|
+
else if (n < lower) return lower;
|
863
|
+
else return n;
|
864
|
+
},
|
865
|
+
|
866
|
+
getContainerId: function() {
|
867
|
+
return this.calendar.element.id.appendSuffix(AbstractCalendar.id.container);
|
868
|
+
},
|
869
|
+
|
870
|
+
getScheduleContainerId: function() {
|
871
|
+
return this.calendar.element.id.appendSuffix(AbstractCalendar.id.scheduleContainer);
|
872
|
+
},
|
873
|
+
|
874
|
+
setColumnWidth: function() {
|
875
|
+
var adjustSize = this.getAdjustSize();
|
876
|
+
var container = $(this.getScheduleContainerId()) || this.container;
|
877
|
+
var indexes = this.calendar.options.displayIndexes;
|
878
|
+
this.column.width = container.offsetWidth / indexes.length - adjustSize;
|
879
|
+
if (this.column.width < 0) this.column.width = 0;
|
880
|
+
},
|
881
|
+
|
882
|
+
setCover: function() {
|
883
|
+
var container = $(this.getScheduleContainerId()) || this.container;
|
884
|
+
this.cover = this.cover || $(this.calendar.element.id.appendSuffix('cover'));
|
885
|
+
if (!this.cover) {
|
886
|
+
container.appendChild(this.buildCover());
|
887
|
+
}
|
888
|
+
Element.setStyle(this.cover, {height: Element.getHeight(container) + 'px'});
|
889
|
+
},
|
890
|
+
|
891
|
+
getDragDistance: function() {
|
892
|
+
var adjustSize = this.getAdjustSize();
|
893
|
+
// return [this.column.width + adjustSize, this.column.height];
|
894
|
+
return [this.column.width + adjustSize, this.column.height / 2];
|
895
|
+
},
|
896
|
+
|
897
|
+
getWeek: function() {
|
898
|
+
var date = this.calendar.date;
|
899
|
+
var indexes = this.calendar.sortWeekIndex([0, 1, 2, 3, 4, 5, 6]);
|
900
|
+
var baseWday = date.getDay();
|
901
|
+
var baseWdayIndex = indexes.indexOf(baseWday);
|
902
|
+
|
903
|
+
return this.calendar.options.displayIndexes.map(function(wday) {
|
904
|
+
var diff = wday - baseWday;
|
905
|
+
var index = indexes.indexOf(wday);
|
906
|
+
if ((index < baseWdayIndex) && (diff > 0)) {
|
907
|
+
diff -= 7;
|
908
|
+
} else if ((index > baseWdayIndex) && (diff < 0)) {
|
909
|
+
diff += 7;
|
910
|
+
}
|
911
|
+
return DateUtil.afterDays(date, diff);
|
912
|
+
});
|
913
|
+
},
|
914
|
+
|
915
|
+
isSameStartDate: function(schedule, date) {
|
916
|
+
return ((date.getFullYear() == schedule.start.year) &&
|
917
|
+
(date.getMonth() == schedule.start.month) && (date.getDate() == schedule.start.day));
|
918
|
+
},
|
919
|
+
|
920
|
+
isSameFinishDate: function(schedule, date) {
|
921
|
+
return ((date.getFullYear() == schedule.finish.year) &&
|
922
|
+
(date.getMonth() == schedule.finish.month) && (date.getDate() == schedule.finish.day));
|
923
|
+
},
|
924
|
+
|
925
|
+
getSelectorId: function() {
|
926
|
+
return this.calendar.element.id.appendSuffix(AbstractCalendar.id.selector);
|
927
|
+
},
|
928
|
+
|
929
|
+
clickDateText: function(event, date) {
|
930
|
+
Event.stop(event);
|
931
|
+
this.calendar.date = date;
|
932
|
+
this.calendar.options.displayType = 'day';
|
933
|
+
this.calendar.refresh();
|
934
|
+
},
|
935
|
+
|
936
|
+
getAdjustSize: function() {
|
937
|
+
// return UserAgent.isIE() ? 3 : 3;
|
938
|
+
return 3;
|
939
|
+
},
|
940
|
+
|
941
|
+
setContainerInfo: function() {
|
942
|
+
this.container = $(this.getScheduleContainerId());
|
943
|
+
this.containerDimensions = Element.getDimensions(this.container);
|
944
|
+
this.containerOffset = Position.cumulativeOffset(this.container);
|
945
|
+
},
|
946
|
+
|
947
|
+
mouseOverSubSchedule: function(items) {
|
948
|
+
items.each(function(item) {
|
949
|
+
Element.addClassName(item, Calendar.className.scheduleItemSelect);
|
950
|
+
});
|
951
|
+
},
|
952
|
+
|
953
|
+
mouseOutSubSchedule: function(items) {
|
954
|
+
items.each(function(item) {
|
955
|
+
Element.removeClassName(item, Calendar.className.scheduleItemSelect);
|
956
|
+
});
|
957
|
+
},
|
958
|
+
|
959
|
+
toDate: function(hash) {
|
960
|
+
return DateUtil.toDate(hash);
|
961
|
+
},
|
962
|
+
|
963
|
+
getCalendarTableId: function() {
|
964
|
+
return this.ids.calTable;
|
965
|
+
}
|
966
|
+
}
|
967
|
+
|
968
|
+
|
969
|
+
/**
|
970
|
+
* CalenderMonth Class
|
971
|
+
*/
|
972
|
+
var CalendarMonth = Class.create();
|
973
|
+
CalendarMonth.id = [
|
974
|
+
'year',
|
975
|
+
'month',
|
976
|
+
'column',
|
977
|
+
'nextYear',
|
978
|
+
'nextMonth',
|
979
|
+
'preYear',
|
980
|
+
'preMonth',
|
981
|
+
'calTable',
|
982
|
+
'scheduleContainer',
|
983
|
+
'container',
|
984
|
+
'emptyRow'
|
985
|
+
]
|
986
|
+
|
987
|
+
Object.extend(CalendarMonth.prototype, AbstractCalendar.prototype);
|
988
|
+
Object.extend(CalendarMonth.prototype, {
|
989
|
+
|
990
|
+
initialize: function(calendar) {
|
991
|
+
this.calendar = calendar;
|
992
|
+
this.week = this.getWeek();
|
993
|
+
this.ids = SpinelzUtil.concat(this.calendar.element.id, CalendarMonth.id);
|
994
|
+
this.columnIds = [];
|
995
|
+
},
|
996
|
+
|
997
|
+
/*** Month ***/
|
998
|
+
/********************************** build functions **********************************/
|
999
|
+
buildHeaderLeft: function() {
|
1000
|
+
return "<td class='" + this.calendar.classNames.preYears + "'>" +
|
1001
|
+
"<div id='" + this.ids.preYear + "' class='" + this.calendar.classNames.preYearMark + "'></div>" +
|
1002
|
+
"<div id='" + this.ids.preMonth + "' class='" + this.calendar.classNames.preMonthMark + "'></div>" +
|
1003
|
+
"</td>";
|
1004
|
+
},
|
1005
|
+
|
1006
|
+
buildHeaderCenter: function() {
|
1007
|
+
var text = [];
|
1008
|
+
if (this.calendar.options.monthHeaderFormat) {
|
1009
|
+
var date = this.calendar.date;
|
1010
|
+
var headerText = new Template(this.calendar.options.monthHeaderFormat).evaluate({
|
1011
|
+
year: date.getFullYear(),
|
1012
|
+
month: date.getMonth() + 1
|
1013
|
+
});
|
1014
|
+
text = [headerText, ' '];
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
return "<td class='" + this.calendar.classNames.years + "'>" +
|
1018
|
+
"<span id='" + this.ids.month + "' class='" + this.calendar.classNames.ym + "'>" +
|
1019
|
+
(text[0] || DateUtil.months[this.calendar.date.getMonth()]) +
|
1020
|
+
"</span>" +
|
1021
|
+
"<span id='" + this.ids.year + "' class='" + this.calendar.classNames.ym + "'>" +
|
1022
|
+
(text[1] || this.calendar.date.getFullYear()) +
|
1023
|
+
"</span>" +
|
1024
|
+
"</td>";
|
1025
|
+
},
|
1026
|
+
|
1027
|
+
buildHeaderRight: function() {
|
1028
|
+
return "<td class='" + this.calendar.classNames.nextYears + "'>" +
|
1029
|
+
"<div id='" + this.ids.nextMonth + "' class='" + this.calendar.classNames.nextMonthMark + "'></div>" +
|
1030
|
+
"<div id='" + this.ids.nextYear + "' class='" + this.calendar.classNames.nextYearMark + "'></div>" +
|
1031
|
+
"</td>";
|
1032
|
+
},
|
1033
|
+
|
1034
|
+
buildCalendar: function() {
|
1035
|
+
return "<div>" +
|
1036
|
+
this.buildTableHeader() +
|
1037
|
+
this.buildScheduleContainer() +
|
1038
|
+
"</div>";
|
1039
|
+
},
|
1040
|
+
|
1041
|
+
buildTableHeader: function() {
|
1042
|
+
var width = 100 / this.calendar.options.displayIndexes.length + '%';
|
1043
|
+
var lastIndex = this.calendar.options.displayIndexes.last();
|
1044
|
+
var columnId = this.ids.column;
|
1045
|
+
|
1046
|
+
var headers = this.calendar.options.displayIndexes.inject('', function(html, i) {
|
1047
|
+
var id = columnId.appendSuffix(i);
|
1048
|
+
this.columnIds.push(id);
|
1049
|
+
var className = (lastIndex == i) ? this.calendar.classNames.thRight : '';
|
1050
|
+
html += "<th id='" + id + "' class='" + className + "' width='" + width + "'>" +
|
1051
|
+
this.calendar.options.dayOfWeek[i] +
|
1052
|
+
"</th>";
|
1053
|
+
return html;
|
1054
|
+
}.bind(this));
|
1055
|
+
|
1056
|
+
return "<table class='" + this.calendar.classNames.table + "'>" +
|
1057
|
+
"<tr>" + headers + "</tr>" +
|
1058
|
+
"</table>";
|
1059
|
+
},
|
1060
|
+
|
1061
|
+
buildScheduleContainer: function() {
|
1062
|
+
var style = (this.calendar.options.size == 'large') ? 'position: relative' : '';
|
1063
|
+
return "<div id='" + this.getScheduleContainerId() + "' style='" + style + ";'>" +
|
1064
|
+
this.buildTableData() +
|
1065
|
+
this.buildSelector() +
|
1066
|
+
"</div>";
|
1067
|
+
},
|
1068
|
+
|
1069
|
+
buildTableData: function() {
|
1070
|
+
var indexes = this.calendar.options.displayIndexes;
|
1071
|
+
var today = new Date();
|
1072
|
+
var year = this.calendar.date.getFullYear();
|
1073
|
+
var month = this.calendar.date.getMonth();
|
1074
|
+
var firstDay = DateUtil.getFirstDate(year, month).getDay();
|
1075
|
+
var lastDate = DateUtil.getLastDate(year, month).getDate();
|
1076
|
+
var trs = [];
|
1077
|
+
var tds = '';
|
1078
|
+
var width = 100 / indexes.length + '%';
|
1079
|
+
var lastIndex = indexes.last();
|
1080
|
+
var node, hday, sday, tmp_date, isOutside, i = null;
|
1081
|
+
this.dateMap = {};
|
1082
|
+
|
1083
|
+
// set start index
|
1084
|
+
var weekIndex = this.calendar.options.weekIndex;
|
1085
|
+
var length = DateUtil.dayOfWeek.length * 5;
|
1086
|
+
var i = null;
|
1087
|
+
var day = 1;
|
1088
|
+
if (weekIndex <= firstDay) {
|
1089
|
+
i = weekIndex;
|
1090
|
+
length += i;
|
1091
|
+
} else {
|
1092
|
+
i = weekIndex - 7;
|
1093
|
+
length -= i;
|
1094
|
+
}
|
1095
|
+
|
1096
|
+
var diff = firstDay - weekIndex;
|
1097
|
+
if (diff < 0) diff + indexes.length;
|
1098
|
+
if ((lastDate + diff) > length) {
|
1099
|
+
length += indexes.length;
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
var wday = weekIndex;
|
1103
|
+
var find = 0;
|
1104
|
+
for (; i < length; i++) {
|
1105
|
+
if (indexes.include(wday)) {
|
1106
|
+
var tdClass = (wday == lastIndex) ? this.calendar.classNames.tdRight : '';
|
1107
|
+
if (i < firstDay) {
|
1108
|
+
var idSuffx = i - firstDay + 1;
|
1109
|
+
tmp_date = new Date(
|
1110
|
+
this.calendar.date.getFullYear(),
|
1111
|
+
this.calendar.date.getMonth(),
|
1112
|
+
idSuffx
|
1113
|
+
);
|
1114
|
+
tds += this.buildEmptyRow(tmp_date, width, tdClass, idSuffx);
|
1115
|
+
} else if (day > lastDate) {
|
1116
|
+
tmp_date = new Date(
|
1117
|
+
this.calendar.date.getFullYear(),
|
1118
|
+
this.calendar.date.getMonth(),
|
1119
|
+
day
|
1120
|
+
);
|
1121
|
+
tds += this.buildEmptyRow(tmp_date, width, tdClass, day);
|
1122
|
+
} else {
|
1123
|
+
if (i == firstDay) length += find;
|
1124
|
+
tmp_date = new Date(
|
1125
|
+
this.calendar.date.getFullYear(),
|
1126
|
+
this.calendar.date.getMonth(),
|
1127
|
+
day
|
1128
|
+
);
|
1129
|
+
hday = this.calendar.options.holidays[tmp_date.toDateString()];
|
1130
|
+
|
1131
|
+
if (this.calendar.options.size == Calendar.size.large) {
|
1132
|
+
tds += this.buildLargeRow(tmp_date, hday, today, width, tdClass);
|
1133
|
+
} else {
|
1134
|
+
sday = this.calendar.options.schedules.detect(function(schedule) {
|
1135
|
+
var startDate = DateUtil.toDate(schedule.start);
|
1136
|
+
return tmp_date.sameDate(startDate)
|
1137
|
+
});
|
1138
|
+
tds += this.buildSmallRow(tmp_date, hday, sday, today, width, tdClass);
|
1139
|
+
}
|
1140
|
+
}
|
1141
|
+
find++;
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
if (i >= firstDay) day++;
|
1145
|
+
if (wday == lastIndex) {
|
1146
|
+
trs.push("<tr>" + tds + "</tr>");
|
1147
|
+
tds = '';
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
if (wday >= 6) {
|
1151
|
+
wday = 0;
|
1152
|
+
} else {
|
1153
|
+
wday++;
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
this.rowMax = trs.length - 1;
|
1157
|
+
return "<table id='" + this.getCalendarTableId() + "' class='" + this.calendar.classNames.table + "'>" + trs.join('') + "</table>";
|
1158
|
+
},
|
1159
|
+
|
1160
|
+
buildEmptyRow: function(date, width, className, idSuffix) {
|
1161
|
+
var id = this.ids.emptyRow.appendSuffix(idSuffix);
|
1162
|
+
this.dateMap[id] = date;
|
1163
|
+
return "<td id='" + id + "' class='" + className + "' width='" + width + "'> </td>";
|
1164
|
+
},
|
1165
|
+
|
1166
|
+
buildLargeRow: function(date, holiday, today, width, className) {
|
1167
|
+
var dateNode = null;
|
1168
|
+
var dateNodeClass = (date.days() == today.days()) ? this.calendar.classNames.highlightDay : '';
|
1169
|
+
var clickDateText = this.calendar.options.clickDateText;
|
1170
|
+
if (clickDateText || (clickDateText == null)) {
|
1171
|
+
dateNode = "<a href='#' class='" + dateNodeClass + "'>" + date.getDate() + "</a>";
|
1172
|
+
} else {
|
1173
|
+
dateNode = "<span class='" + dateNodeClass + "' style='text-decoration: none;'>" + date.getDate() + "</span>";
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
var rowClass = "";
|
1177
|
+
var name = "";
|
1178
|
+
if (holiday) {
|
1179
|
+
rowClass = this.calendar.classNames.holiday;
|
1180
|
+
name = "<span class='" + this.calendar.classNames.holidayName + "'>" + holiday.name + "</span>";
|
1181
|
+
// if (holiday.onclick) {
|
1182
|
+
// Event.observe(name, "click", holiday.onclick.bindAsEventListener(this));
|
1183
|
+
// }
|
1184
|
+
} else if (this.calendar.isRegularHoliday(date.getDay())) {
|
1185
|
+
rowClass = this.calendar.classNames.regularHoliday;
|
1186
|
+
} else {
|
1187
|
+
rowClass = this.calendar.classNames.date;
|
1188
|
+
}
|
1189
|
+
className = [rowClass, className];
|
1190
|
+
|
1191
|
+
var id = this.getDateId(date);
|
1192
|
+
this.dateMap[id] = date;
|
1193
|
+
return "<td id='" + id + "' class='" + className.join(' ') + "' width='" + width + "'>" +
|
1194
|
+
"<div class='" + this.calendar.classNames.dateContainer + "'>" +
|
1195
|
+
dateNode + name +
|
1196
|
+
"</div>" +
|
1197
|
+
"</td>";
|
1198
|
+
},
|
1199
|
+
|
1200
|
+
buildSmallRow: function(date, holiday, schedule, today, width, className) {
|
1201
|
+
var id = this.getDateId(date);
|
1202
|
+
this.dateMap[id] = date;
|
1203
|
+
var attributes = $H({
|
1204
|
+
id: id,
|
1205
|
+
width: width
|
1206
|
+
});
|
1207
|
+
className = [];
|
1208
|
+
|
1209
|
+
if (schedule) {
|
1210
|
+
className.push(this.calendar.classNames.schedule);
|
1211
|
+
var first = schedule[0];
|
1212
|
+
if (first) attributes.title = first.description;
|
1213
|
+
} else if (holiday) {
|
1214
|
+
className.push(this.calendar.classNames.holiday);
|
1215
|
+
attributes.title = holiday.name.stripTags();
|
1216
|
+
} else if (this.calendar.isRegularHoliday(date.getDay())) {
|
1217
|
+
className.push(this.calendar.classNames.regularHoliday);
|
1218
|
+
} else {
|
1219
|
+
className.push(this.calendar.classNames.date);
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
if (date.days() == today.days()) {
|
1223
|
+
className.push(Calendar.className.highlightDay);
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
className.push(className);
|
1227
|
+
className = className.join(' ');
|
1228
|
+
attributes = attributes.inject('', function(html, pair) {
|
1229
|
+
return html + " " + pair.key + "='" + pair.value + "'";
|
1230
|
+
});
|
1231
|
+
return "<td class='" + className + "'" + attributes + ">" + date.getDate() + "</td>";
|
1232
|
+
},
|
1233
|
+
|
1234
|
+
beforeBuild: function() {
|
1235
|
+
this.column = {};
|
1236
|
+
var rule = CssUtil.getCssRuleBySelectorText('.' + Calendar.className.table + ' td');
|
1237
|
+
this.column.height = parseInt(rule.style['height'], 10);
|
1238
|
+
|
1239
|
+
rule = CssUtil.getCssRuleBySelectorText('.' + Calendar.className.dateContainer);
|
1240
|
+
this.column.dateTextHeight = parseInt(rule.style['height'], 10);
|
1241
|
+
},
|
1242
|
+
|
1243
|
+
/**********************************
|
1244
|
+
***** for make schedule item *****
|
1245
|
+
**********************************/
|
1246
|
+
buildSchedule: function(schedule) {
|
1247
|
+
var id = 'scheduleItem_' + schedule.id;
|
1248
|
+
var canEdit = (schedule.edit == undefined || schedule.edit);
|
1249
|
+
var item = Builder.node('DIV', {id: id});
|
1250
|
+
var start = DateUtil.toDate(schedule.start);
|
1251
|
+
var finish = DateUtil.toDate(schedule.finish);
|
1252
|
+
var noEvent = this.calendar.options.noEvent;
|
1253
|
+
|
1254
|
+
var styles = {};
|
1255
|
+
if (noEvent) styles.cursor = 'default';
|
1256
|
+
if (start.sameDate(finish)) {
|
1257
|
+
this.calendar.css.addClassNames(item, 'scheduleItemNoBorder');
|
1258
|
+
} else {
|
1259
|
+
if (schedule.background_color) styles.backgroundColor = schedule.background_color;
|
1260
|
+
if (schedule.frame_color) styles.border = '2px solid ' + schedule.frame_color;
|
1261
|
+
this.calendar.css.addClassNames(item, 'scheduleItemLarge');
|
1262
|
+
}
|
1263
|
+
Element.setStyle(item, styles);
|
1264
|
+
|
1265
|
+
if (canEdit) {
|
1266
|
+
var deleteImg = Builder.node('DIV',
|
1267
|
+
{
|
1268
|
+
id: 'scheduleDeleteImg_' + schedule.id,
|
1269
|
+
className: this.calendar.css.joinClassNames('deleteImg')
|
1270
|
+
}
|
1271
|
+
);
|
1272
|
+
Element.hide(deleteImg);
|
1273
|
+
item.appendChild(deleteImg);
|
1274
|
+
|
1275
|
+
// set click event on a image.
|
1276
|
+
if (!noEvent) {
|
1277
|
+
Event.observe(deleteImg, 'click', this.clickDeleteImage.bind(this, schedule));
|
1278
|
+
Event.observe(item, 'mouseover', this.showDeleteImage.bind(this, deleteImg));
|
1279
|
+
Event.observe(item, 'mouseout', this.hideDeleteImage.bind(this, deleteImg));
|
1280
|
+
}
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
// set dblclick event on a schedule item.
|
1284
|
+
if (!noEvent && this.calendar.options.dblclickSchedule) {
|
1285
|
+
Event.observe(
|
1286
|
+
item, 'dblclick', this.calendar.options.dblclickSchedule.bind(this, schedule));
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
// drag handler
|
1290
|
+
var handler = null;
|
1291
|
+
if (canEdit) {
|
1292
|
+
handler = Builder.node('DIV', {className: this.calendar.css.joinClassNames('scheduleHandler')});
|
1293
|
+
if (noEvent) Element.hide(handler);
|
1294
|
+
item.appendChild(handler);
|
1295
|
+
}
|
1296
|
+
|
1297
|
+
var icon = null;
|
1298
|
+
if (schedule.icon) {
|
1299
|
+
icon = Builder.node('IMG', {src: schedule.icon, alt: 'icon', style: 'float: left;', width: 16, height: 16});
|
1300
|
+
item.appendChild(icon);
|
1301
|
+
}
|
1302
|
+
|
1303
|
+
// private mark
|
1304
|
+
if (!schedule.publicity) {
|
1305
|
+
icon = Builder.node('DIV', {id: 'private_img_' + schedule.id});
|
1306
|
+
this.calendar.css.addClassNames(icon, 'privateImg');
|
1307
|
+
item.appendChild(icon);
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
var body = Builder.node('DIV');
|
1311
|
+
var text = this.getTimeText(schedule.start, schedule.finish);
|
1312
|
+
text = Builder.node('DIV', {id: id + '_text', style: 'float: left;'}, [text]);
|
1313
|
+
this.calendar.css.addClassNames(text, 'scheduleTimeArea');
|
1314
|
+
item.appendChild(text);
|
1315
|
+
var description = schedule.description.unescapeHTML();
|
1316
|
+
item.appendChild(Builder.node('DIV', {id: id + '_description'}, [description]));
|
1317
|
+
|
1318
|
+
item.title = description;
|
1319
|
+
item.schedule = schedule;
|
1320
|
+
|
1321
|
+
return [item, handler];
|
1322
|
+
},
|
1323
|
+
|
1324
|
+
adjustScheduleStyle: function(item, rowIndex, cellIndex, holder) {
|
1325
|
+
var self = this;
|
1326
|
+
var height = parseInt(Element.getStyle(item, 'height'), 10);
|
1327
|
+
var top = parseInt(Element.getStyle(item, 'top'), 10);
|
1328
|
+
var range = this.getScheduleRange(item);
|
1329
|
+
var tops = [];
|
1330
|
+
var displayMax = 3;
|
1331
|
+
|
1332
|
+
holder.each(function(holded) {
|
1333
|
+
var holdedRange = self.getScheduleRange(holded);
|
1334
|
+
if (range.any(function(r) {return holdedRange.include(r)})) {
|
1335
|
+
tops.push(holded.topIndex);
|
1336
|
+
}
|
1337
|
+
});
|
1338
|
+
|
1339
|
+
var index = $R(0, tops.length, true).detect(function(i) {return !tops.include(i)});
|
1340
|
+
if (isNaN(index)) index = tops.length;
|
1341
|
+
item.topIndex = index;
|
1342
|
+
Element.setStyle(item, {top: top + (height + 2) * index + 'px'});
|
1343
|
+
if (index >= displayMax) {
|
1344
|
+
Element.hide(item);
|
1345
|
+
var node = this.buildSkipSchedule(rowIndex + '_' + cellIndex);
|
1346
|
+
if (node) {
|
1347
|
+
var left = Element.getStyle(item, 'left');
|
1348
|
+
Element.setStyle(node, {top: top + (height + 2) * index + 'px', left: left});
|
1349
|
+
}
|
1350
|
+
return node;
|
1351
|
+
}
|
1352
|
+
},
|
1353
|
+
|
1354
|
+
buildSkipSchedule: function(idSuffix) {
|
1355
|
+
var id = this.calendar.element.id.appendSuffix(idSuffix);
|
1356
|
+
if (!this.skipNode[id]) {
|
1357
|
+
var node = Builder.node('div', {id: id}, [this.calendar.options.skipString]);
|
1358
|
+
this.calendar.css.addClassNames(node, 'skipNode');
|
1359
|
+
this.skipNode[id] = node;
|
1360
|
+
return node;
|
1361
|
+
}
|
1362
|
+
},
|
1363
|
+
|
1364
|
+
getScheduleRange: function(item) {
|
1365
|
+
return $R(0, item.length, true).map(function(i) {return item.cellIndex + i});
|
1366
|
+
},
|
1367
|
+
|
1368
|
+
setScheduleBaseStyle: function(item, rowIndex, cellIndex, length) {
|
1369
|
+
var oneDay = this.column.height;
|
1370
|
+
var top = oneDay * rowIndex + this.column.dateTextHeight;
|
1371
|
+
var adjustSize = this.getAdjustSize() + (UserAgent.isIE() ? 0.5 : 0);
|
1372
|
+
Element.setStyle(item, {
|
1373
|
+
top: top + 'px',
|
1374
|
+
width: this.column.width * length + adjustSize * (length - 1) + 'px',
|
1375
|
+
left: this.column.width * cellIndex + cellIndex * adjustSize + 'px'
|
1376
|
+
});
|
1377
|
+
},
|
1378
|
+
|
1379
|
+
afterBuild: function() {
|
1380
|
+
this.scheduleNodes = [];
|
1381
|
+
this.skipNode = $H({});
|
1382
|
+
if (this.calendar.options.size != Calendar.size.small) {
|
1383
|
+
this.calendarTable = $(this.getCalendarTableId());
|
1384
|
+
this.setContainerInfo();
|
1385
|
+
this.setColumnWidth();
|
1386
|
+
this.setCover();
|
1387
|
+
this.setSelector();
|
1388
|
+
|
1389
|
+
var self = this;
|
1390
|
+
var indexes = this.calendar.options.displayIndexes;
|
1391
|
+
var distance = this.getDragDistance();
|
1392
|
+
var holders = $R(0, $(this.getCalendarTableId()).rows.length).map(function() {return []});
|
1393
|
+
var date = this.calendar.date;
|
1394
|
+
var calStartDate = DateUtil.getFirstDate(date.getFullYear(), date.getMonth());
|
1395
|
+
var calStart = calStartDate.days();
|
1396
|
+
var calFinish = DateUtil.getLastDate(date.getFullYear(), date.getMonth()).days();
|
1397
|
+
|
1398
|
+
self.calendar.options.schedules.each(function(schedule, index) {
|
1399
|
+
var startDate = self.toDate(schedule.start);
|
1400
|
+
var start = startDate.days();
|
1401
|
+
var finishDate = self.toDate(schedule.finish);
|
1402
|
+
var finish = finishDate.days();
|
1403
|
+
var days = self.getDayDiff(schedule);
|
1404
|
+
|
1405
|
+
if ((start >= calStart && start <= calFinish) || (finish >= calStart && finish <= calFinish)) {
|
1406
|
+
if (!calStartDate.sameMonth(startDate)) startDate = calStartDate;
|
1407
|
+
self.setSchedule(schedule, holders, distance, days);
|
1408
|
+
}
|
1409
|
+
});
|
1410
|
+
}
|
1411
|
+
},
|
1412
|
+
|
1413
|
+
setEvent: function() {
|
1414
|
+
if (!this.calendar.options.noEvent) {
|
1415
|
+
Event.observe(this.ids.preYear, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
|
1416
|
+
Event.observe(this.ids.preMonth, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
|
1417
|
+
Event.observe(this.ids.nextMonth, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
|
1418
|
+
Event.observe(this.ids.nextYear, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
|
1419
|
+
new Hover(this.ids.preYear);
|
1420
|
+
new Hover(this.ids.preMonth);
|
1421
|
+
new Hover(this.ids.nextMonth);
|
1422
|
+
new Hover(this.ids.nextYear);
|
1423
|
+
if (this.calendar.options.size == 'small') {
|
1424
|
+
$H(this.dateMap).each(function(pair) {
|
1425
|
+
var node = $(pair.key);
|
1426
|
+
if (node) Event.observe(node, 'mousedown', this.calendar.selectDate.bindAsEventListener(this.calendar));
|
1427
|
+
}.bind(this));
|
1428
|
+
}
|
1429
|
+
}
|
1430
|
+
},
|
1431
|
+
|
1432
|
+
setSchedule: function(schedule, holders, distance, days) {
|
1433
|
+
var items = [];
|
1434
|
+
var rowMax = 6;
|
1435
|
+
var startDate = DateUtil.toDate(schedule.start);
|
1436
|
+
var date = startDate;
|
1437
|
+
var indexes = this.calendar.options.displayIndexes;
|
1438
|
+
var targetDate = this.calendar.date;
|
1439
|
+
var noEvent = this.calendar.options.noEvent;
|
1440
|
+
|
1441
|
+
while (days >= 0) {
|
1442
|
+
var lastWday = this.getLastWday(date);
|
1443
|
+
|
1444
|
+
var length = days + 1;
|
1445
|
+
var firstDay = date.getDay();
|
1446
|
+
var finishDate = date.advance({days: length - 1});
|
1447
|
+
|
1448
|
+
if (finishDate.getTime() > lastWday.getTime()) {
|
1449
|
+
finishDate = lastWday;
|
1450
|
+
length = finishDate.days() - date.days() + 1;
|
1451
|
+
}
|
1452
|
+
var finishDay = finishDate.getDay();
|
1453
|
+
var wdays = null;
|
1454
|
+
if (firstDay <= finishDay) {
|
1455
|
+
wdays = $R(firstDay, finishDay, false);
|
1456
|
+
} else {
|
1457
|
+
wdays = $R(0, finishDay, false).toArray().concat($R(firstDay, rowMax, false).toArray());
|
1458
|
+
}
|
1459
|
+
var itemLength = wdays.findAll(function(day) {
|
1460
|
+
return indexes.include(day);
|
1461
|
+
}).length;
|
1462
|
+
|
1463
|
+
var cellDate = new Date(date.getTime());
|
1464
|
+
while (cellDate.days() <= finishDate.days()) {
|
1465
|
+
if (cellDate.getMonth() == targetDate.getMonth()) {
|
1466
|
+
var cellPosition = this.getCellPosition(cellDate.getDate());
|
1467
|
+
if (cellPosition) {
|
1468
|
+
var rowIndex = cellPosition.rowIndex;
|
1469
|
+
var cellIndex = cellPosition.cellIndex;
|
1470
|
+
|
1471
|
+
// create a schedule node.
|
1472
|
+
var result = this.buildSchedule(schedule);
|
1473
|
+
var item = result.first();
|
1474
|
+
item.length = itemLength;
|
1475
|
+
item.cellIndex = cellIndex;
|
1476
|
+
this.container.appendChild(item);
|
1477
|
+
|
1478
|
+
// set style(position and size) of a schedule item.
|
1479
|
+
this.setScheduleBaseStyle(item, rowIndex, cellIndex, itemLength);
|
1480
|
+
var skipNode = this.adjustScheduleStyle(item, rowIndex, cellIndex, holders[rowIndex]);
|
1481
|
+
if (skipNode) this.container.appendChild(skipNode);
|
1482
|
+
|
1483
|
+
if (!noEvent && ((schedule.edit == undefined) || schedule.edit)) {
|
1484
|
+
this.setDraggable(item, result.last(), distance);
|
1485
|
+
this.setResize(item);
|
1486
|
+
}
|
1487
|
+
|
1488
|
+
holders[rowIndex].push(item);
|
1489
|
+
this.scheduleNodes.push(item);
|
1490
|
+
break;
|
1491
|
+
} else if (indexes.include(cellDate.getDay())) {
|
1492
|
+
itemLength--;
|
1493
|
+
}
|
1494
|
+
} else if (indexes.include(cellDate.getDay())) {
|
1495
|
+
itemLength--;
|
1496
|
+
}
|
1497
|
+
cellDate = cellDate.advance({days: 1});
|
1498
|
+
}
|
1499
|
+
|
1500
|
+
if (items.length == 0) {
|
1501
|
+
days -= length;
|
1502
|
+
} else {
|
1503
|
+
days -= 7;
|
1504
|
+
}
|
1505
|
+
|
1506
|
+
var date = finishDate.advance({days: 1});
|
1507
|
+
if (item) items.push(item);
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
var self = this;
|
1511
|
+
if (!noEvent) {
|
1512
|
+
items.each(function(item) {
|
1513
|
+
Event.observe(item, 'mouseover', self.mouseOverSubSchedule.bind(this, items));
|
1514
|
+
Event.observe(item, 'mouseout', self.mouseOutSubSchedule.bind(this, items));
|
1515
|
+
});
|
1516
|
+
}
|
1517
|
+
},
|
1518
|
+
|
1519
|
+
getLastWday: function(date) {
|
1520
|
+
if (!this.calendar.wdays) {
|
1521
|
+
this.calendar.setIndex();
|
1522
|
+
}
|
1523
|
+
var index = this.calendar.wdays.indexOf(date.getDay()) + 1;
|
1524
|
+
return date.advance({days: this.calendar.wdays.length - index});
|
1525
|
+
},
|
1526
|
+
|
1527
|
+
setSelector: function() {
|
1528
|
+
var selector = $(this.getSelectorId());
|
1529
|
+
Element.setStyle(selector, {
|
1530
|
+
width: this.column.width + 'px',
|
1531
|
+
height: this.column.height - 2 + 'px'
|
1532
|
+
});
|
1533
|
+
Element.setOpacity(selector, 0.6);
|
1534
|
+
},
|
1535
|
+
|
1536
|
+
// set draggalbe event
|
1537
|
+
setDraggable: function(item, handle, distance) {
|
1538
|
+
var self = this;
|
1539
|
+
var offset = Position.cumulativeOffset(this.container);
|
1540
|
+
var selector = $(this.getSelectorId());
|
1541
|
+
var cWidth = this.column.width + (UserAgent.isIE() ? 0.5 : 0);
|
1542
|
+
var cHeight = this.column.height + (UserAgent.isIE() ? 1 : 0);
|
1543
|
+
var rowMax = this.rowMax || $(this.getCalendarTableId()).rows.length;
|
1544
|
+
var cellMax = this.calendar.options.displayIndexes.length - 1;
|
1545
|
+
var adjustSize = this.getAdjustSize();
|
1546
|
+
|
1547
|
+
new Draggable(item,
|
1548
|
+
{
|
1549
|
+
handle: handle,
|
1550
|
+
scroll: window,
|
1551
|
+
starteffect: Prototype.emptyFunction,
|
1552
|
+
endeffect: Prototype.emptyFunction,
|
1553
|
+
onStart: function(draggalbe) {
|
1554
|
+
Element.show(selector);
|
1555
|
+
},
|
1556
|
+
onDrag: function(draggable, event) {
|
1557
|
+
var element = draggable.element;
|
1558
|
+
var top = parseInt(Element.getStyle(element, 'top'), 10);
|
1559
|
+
var rowIndex = Math.floor(top / cHeight);
|
1560
|
+
var left = parseInt(Element.getStyle(element, 'left'), 10);
|
1561
|
+
var cellIndex = Math.floor(left / cWidth);
|
1562
|
+
|
1563
|
+
if ((cellIndex >= 0 && rowIndex >= 0) &&
|
1564
|
+
(cellIndex <= cellMax && rowIndex <= rowMax)) {
|
1565
|
+
Element.setStyle(selector, {
|
1566
|
+
left: cWidth * cellIndex + adjustSize * cellIndex + 'px',
|
1567
|
+
top: cHeight * rowIndex + 'px'
|
1568
|
+
});
|
1569
|
+
}
|
1570
|
+
},
|
1571
|
+
onEnd: function(draggable) {
|
1572
|
+
Element.hide(selector);
|
1573
|
+
self.changeSchedule(draggable);
|
1574
|
+
}
|
1575
|
+
}
|
1576
|
+
);
|
1577
|
+
},
|
1578
|
+
|
1579
|
+
// set resize event
|
1580
|
+
setResize: function(item) {
|
1581
|
+
var self = this;
|
1582
|
+
new CalendarResizeableEx(item, {
|
1583
|
+
left: 0,
|
1584
|
+
top: 0,
|
1585
|
+
bottom: 0,
|
1586
|
+
distance: this.column.width,
|
1587
|
+
restriction: true,
|
1588
|
+
resize: function(element) {
|
1589
|
+
self.updateTirm(element);
|
1590
|
+
}
|
1591
|
+
});
|
1592
|
+
},
|
1593
|
+
|
1594
|
+
/********************************** public method **********************************/
|
1595
|
+
getDate: function(element) {
|
1596
|
+
var date = this.calendar.date;
|
1597
|
+
if (element.constructor == String)
|
1598
|
+
return new Date(date.getFullYear(), date.getMonth(), element);
|
1599
|
+
else
|
1600
|
+
return new Date(date.getFullYear(), date.getMonth(), element.id.getSuffix());
|
1601
|
+
},
|
1602
|
+
|
1603
|
+
abstractSelect: function(event, method) {
|
1604
|
+
var element = null;
|
1605
|
+
if (this.calendar.options.size == 'large') {
|
1606
|
+
element = this.findClickedElement(event);
|
1607
|
+
} else {
|
1608
|
+
element = Event.element(event);
|
1609
|
+
if (element.tagName != 'TD') {
|
1610
|
+
element = Element.getParentByTagName(['TD'], element);
|
1611
|
+
}
|
1612
|
+
}
|
1613
|
+
if (element && element.id) {
|
1614
|
+
var date = this.getDate(element);
|
1615
|
+
method(date, element);
|
1616
|
+
}
|
1617
|
+
},
|
1618
|
+
|
1619
|
+
getSelectedTerm: function() {
|
1620
|
+
var self = this;
|
1621
|
+
var elements = this.calendar.getSelected();
|
1622
|
+
return [elements.first(), elements.last()].map(function(e) {
|
1623
|
+
return self.getDate(e);
|
1624
|
+
});
|
1625
|
+
},
|
1626
|
+
|
1627
|
+
/********************************** private method **********************************/
|
1628
|
+
selectDay: function(event) {
|
1629
|
+
var calendar = this.calendar;
|
1630
|
+
var th = Event.element(event);
|
1631
|
+
if (th.tagName != 'TH')
|
1632
|
+
th = Element.getParentByTagName('TH', th);
|
1633
|
+
|
1634
|
+
this.iterateTable({doCell: function(cell) {
|
1635
|
+
if ((cell.cellIndex == th.cellIndex) && cell.id)
|
1636
|
+
calendar.addSelectedClass(cell);
|
1637
|
+
}});
|
1638
|
+
},
|
1639
|
+
|
1640
|
+
inspectArgument: function(object, time) {
|
1641
|
+
var self = this;
|
1642
|
+
var dates = this.calendar.getSelected();
|
1643
|
+
var result = [];
|
1644
|
+
|
1645
|
+
self.calendar.recurrence(object, function(o) {
|
1646
|
+
if (!o.date) {
|
1647
|
+
dates.each(function(d) {
|
1648
|
+
var param = {};
|
1649
|
+
if (!o.date) {
|
1650
|
+
param = {date: self.getDate(d)};
|
1651
|
+
if (time) {
|
1652
|
+
param.start = {hour: 0, min: 0};
|
1653
|
+
param.finish = {hour: 0, min: 0};
|
1654
|
+
}
|
1655
|
+
}
|
1656
|
+
Object.extend(param, o);
|
1657
|
+
result.push(param);
|
1658
|
+
});
|
1659
|
+
} else if (o.date.constructor == Object) {
|
1660
|
+
o.date = new Date(o.date.year, o.date.month, o.date.day);
|
1661
|
+
result.push(o);
|
1662
|
+
} else {
|
1663
|
+
result.push(o);
|
1664
|
+
}
|
1665
|
+
});
|
1666
|
+
return result;
|
1667
|
+
},
|
1668
|
+
|
1669
|
+
inspectDateArgument: function(date) {
|
1670
|
+
if (date) {
|
1671
|
+
map = [];
|
1672
|
+
this.calendar.recurrence(date, function(d) {
|
1673
|
+
if (d.constructor == Object)
|
1674
|
+
map.push(new Date(d.year, d.month, d.day));
|
1675
|
+
else
|
1676
|
+
map.push(d);
|
1677
|
+
});
|
1678
|
+
return map;
|
1679
|
+
} else {
|
1680
|
+
var calendar = this;
|
1681
|
+
var dates = this.calendar.getSelected();
|
1682
|
+
if (dates.length == 0) return null;
|
1683
|
+
|
1684
|
+
return dates.collect(function(d) {
|
1685
|
+
return calendar.getDate(d);
|
1686
|
+
});
|
1687
|
+
}
|
1688
|
+
},
|
1689
|
+
|
1690
|
+
findClickedElement: function(event) {
|
1691
|
+
var container = $(this.getScheduleContainerId());
|
1692
|
+
var position = Position.cumulativeOffset(container);
|
1693
|
+
var scrollTop = Position.realOffset(container).last();
|
1694
|
+
scrollTop -= document.documentElement.scrollTop || document.body.scrollTop;
|
1695
|
+
var x = Event.pointerX(event) - position[0];
|
1696
|
+
var y = Event.pointerY(event) - position[1] + scrollTop;
|
1697
|
+
var rowIndex = Math.floor(y / this.column.height);
|
1698
|
+
var cellIndex = Math.floor(x / this.column.width);
|
1699
|
+
return $(this.calendarTable.rows[rowIndex].cells[cellIndex]);
|
1700
|
+
},
|
1701
|
+
|
1702
|
+
multipleSelection: function(event) {
|
1703
|
+
if (!this.calendar.selectedBase || !this.calendar.mouseDown) return;
|
1704
|
+
var self = this;
|
1705
|
+
var calendar = this.calendar;
|
1706
|
+
var selected = this.calendar.selectedBase;
|
1707
|
+
|
1708
|
+
this.abstractSelect(event, function(date, element) {
|
1709
|
+
var selectedElement = $(selected.id);
|
1710
|
+
|
1711
|
+
var range = calendar.createRange(
|
1712
|
+
parseInt(selectedElement.id.getSuffix()),
|
1713
|
+
parseInt(element.id.getSuffix())
|
1714
|
+
);
|
1715
|
+
|
1716
|
+
self.iterateTable({doCell: function(cell) {
|
1717
|
+
if (cell.tagName != 'TD' || !cell.id) throw $continue;
|
1718
|
+
var id = parseInt(cell.id.getSuffix());
|
1719
|
+
|
1720
|
+
if (range.include(id)) {
|
1721
|
+
calendar.addSelectedClass(cell);
|
1722
|
+
} else {
|
1723
|
+
calendar.removeSelectedClass(cell);
|
1724
|
+
}
|
1725
|
+
}});
|
1726
|
+
});
|
1727
|
+
},
|
1728
|
+
|
1729
|
+
iterateTable: function() {
|
1730
|
+
var options = Object.extend({
|
1731
|
+
doTable: null,
|
1732
|
+
doRow: null,
|
1733
|
+
doCell: null
|
1734
|
+
}, arguments[0]);
|
1735
|
+
|
1736
|
+
var calendar = $(this.getCalendarTableId());
|
1737
|
+
if (options.doTable) {
|
1738
|
+
options.doTable(calendar)
|
1739
|
+
};
|
1740
|
+
|
1741
|
+
$A(calendar.rows).each(function(row) {
|
1742
|
+
if (options.doRow) {
|
1743
|
+
options.doRow(row);
|
1744
|
+
}
|
1745
|
+
$A(row.cells).each(function(cell) {
|
1746
|
+
if (options.doCell) {
|
1747
|
+
options.doCell(cell);
|
1748
|
+
}
|
1749
|
+
});
|
1750
|
+
});
|
1751
|
+
},
|
1752
|
+
|
1753
|
+
findRow: function(rowIndex) {
|
1754
|
+
var table = $(this.getCalendarTableId());
|
1755
|
+
return $A(table.rows).detect(function(row) {
|
1756
|
+
return row.rowIndex == rowIndex;
|
1757
|
+
});
|
1758
|
+
},
|
1759
|
+
|
1760
|
+
findCell: function(rowIndex, cellIndex) {
|
1761
|
+
return $A(this.findRow(rowIndex).cells).detect(function(cell) {
|
1762
|
+
return cell.cellIndex == cellIndex;
|
1763
|
+
});
|
1764
|
+
},
|
1765
|
+
|
1766
|
+
getDateId: function(date) {
|
1767
|
+
var day = null;
|
1768
|
+
if (date.constructor == Date) {
|
1769
|
+
day = date.getDate();
|
1770
|
+
} else {
|
1771
|
+
day = date;
|
1772
|
+
}
|
1773
|
+
return this.calendar.element.id.appendSuffix(day);
|
1774
|
+
},
|
1775
|
+
|
1776
|
+
getCell: function(day) {
|
1777
|
+
return $(this.getDateId(day));
|
1778
|
+
},
|
1779
|
+
|
1780
|
+
getCellPosition: function(day) {
|
1781
|
+
var cell = this.getCell(day);
|
1782
|
+
if (cell) {
|
1783
|
+
var row = Element.getParentByTagName(['tr'], cell);
|
1784
|
+
return {cellIndex: cell.cellIndex, rowIndex: row.rowIndex};
|
1785
|
+
}
|
1786
|
+
},
|
1787
|
+
|
1788
|
+
changeSchedule: function(draggable) {
|
1789
|
+
var element = draggable.element;
|
1790
|
+
var schedule = element.schedule;
|
1791
|
+
this.calendar.cacheSchedule(schedule);
|
1792
|
+
|
1793
|
+
var top = parseInt(Element.getStyle(element, 'top'), 10);
|
1794
|
+
var rowIndex = Math.floor(top / this.column.height);
|
1795
|
+
var left = parseInt(Element.getStyle(element, 'left'), 10);
|
1796
|
+
var cellIndex = Math.floor(left / this.column.width);
|
1797
|
+
var table = $(this.getCalendarTableId());
|
1798
|
+
var rowMax = table.rows.length - 1;
|
1799
|
+
var cellMax = this.calendar.options.displayIndexes.length - 1;
|
1800
|
+
|
1801
|
+
if ((cellIndex >= 0 && rowIndex >= 0) &&
|
1802
|
+
(cellIndex <= cellMax && rowIndex <= rowMax)) {
|
1803
|
+
var cell = this.findCell(rowIndex, cellIndex);
|
1804
|
+
var date = new Date(this.calendar.date.getTime());
|
1805
|
+
date.setDate(parseInt(cell.id.getSuffix(), 10));
|
1806
|
+
var diff = this.getDayDiff(schedule);
|
1807
|
+
|
1808
|
+
var finish = date.advance({days: diff});
|
1809
|
+
if (
|
1810
|
+
schedule.start.month == date.getMonth() &&
|
1811
|
+
schedule.start.day == date.getDate() &&
|
1812
|
+
schedule.finish.month == finish.getMonth() &&
|
1813
|
+
schedule.finish.day == finish.getDate()
|
1814
|
+
) {this.calendar.refreshSchedule(); return;}
|
1815
|
+
|
1816
|
+
schedule.start.month = date.getMonth();
|
1817
|
+
schedule.start.day = date.getDate();
|
1818
|
+
schedule.finish.month = finish.getMonth();
|
1819
|
+
schedule.finish.day = finish.getDate();
|
1820
|
+
|
1821
|
+
this.calendar.refreshSchedule();
|
1822
|
+
this.calendar.options.changeSchedule(schedule);
|
1823
|
+
} else {
|
1824
|
+
this.calendar.refreshSchedule();
|
1825
|
+
}
|
1826
|
+
},
|
1827
|
+
|
1828
|
+
updateTirm: function(element) {
|
1829
|
+
var schedule = element.schedule;
|
1830
|
+
var width = parseInt(Element.getStyle(element, 'width'));
|
1831
|
+
var top = parseInt(Element.getStyle(element, 'top'));
|
1832
|
+
var left = parseInt(Element.getStyle(element, 'left'));
|
1833
|
+
var cellIndex = Math.round((left + width) / this.column.width) - 1;
|
1834
|
+
var rowIndex = Math.round(top / this.column.height);
|
1835
|
+
var cell = this.findCell(rowIndex, cellIndex);
|
1836
|
+
|
1837
|
+
var oldFinish = schedule.finish;
|
1838
|
+
var newFinish = this.dateMap[cell.id].toHash();
|
1839
|
+
newFinish.hour = oldFinish.hour;
|
1840
|
+
newFinish.min = oldFinish.min;
|
1841
|
+
|
1842
|
+
if (DateUtil.toDate(schedule.start).getTime() >= DateUtil.toDate(newFinish).getTime()) {
|
1843
|
+
var maxHour = 23;
|
1844
|
+
var maxMin = 55;
|
1845
|
+
if (schedule.start.hour == maxHour && schedule.start.min == maxMin) {
|
1846
|
+
this.calendar.refreshSchedule();
|
1847
|
+
this.calendar.options.updateTirm();
|
1848
|
+
return;
|
1849
|
+
} else {
|
1850
|
+
newFinish.hour = maxHour;
|
1851
|
+
newFinish.min = maxMin;
|
1852
|
+
}
|
1853
|
+
}
|
1854
|
+
schedule.finish = newFinish;
|
1855
|
+
|
1856
|
+
this.calendar.refreshSchedule();
|
1857
|
+
this.calendar.options.updateTirm(schedule);
|
1858
|
+
},
|
1859
|
+
|
1860
|
+
getTimeText: function(start, finish) {
|
1861
|
+
var calendar = this.calendar;
|
1862
|
+
return calendar.formatTime(start);
|
1863
|
+
},
|
1864
|
+
|
1865
|
+
getDayDiff: function(schedule) {
|
1866
|
+
return DateUtil.numberOfDays(this.toDate(schedule.start), this.toDate(schedule.finish));
|
1867
|
+
}
|
1868
|
+
});
|
1869
|
+
|
1870
|
+
|
1871
|
+
/**
|
1872
|
+
* CalendarWeek Class
|
1873
|
+
*/
|
1874
|
+
var CalendarWeek= Class.create();
|
1875
|
+
CalendarWeek.id = [
|
1876
|
+
'calTable',
|
1877
|
+
'columnContainer',
|
1878
|
+
'columnHeader',
|
1879
|
+
'column',
|
1880
|
+
'next',
|
1881
|
+
'pre',
|
1882
|
+
'headerText'
|
1883
|
+
];
|
1884
|
+
|
1885
|
+
Object.extend(CalendarWeek.prototype, AbstractCalendar.prototype);
|
1886
|
+
Object.extend(CalendarWeek.prototype, {
|
1887
|
+
|
1888
|
+
initialize: function(calendar) {
|
1889
|
+
this.calendar = calendar;
|
1890
|
+
this.week = this.getWeek();
|
1891
|
+
this.ids = SpinelzUtil.concat(this.calendar.element.id, CalendarWeek.id);
|
1892
|
+
this.setDisplayTime();
|
1893
|
+
},
|
1894
|
+
|
1895
|
+
/*** Week ***/
|
1896
|
+
/********************************** build functions **********************************/
|
1897
|
+
buildHeaderLeft: function() {
|
1898
|
+
return "<td class='" + this.calendar.classNames.preYears + "'>" +
|
1899
|
+
"<div id='" + this.ids.pre + "' class='" + this.calendar.classNames.preWeekMark + "'></div>" +
|
1900
|
+
"</td>";
|
1901
|
+
},
|
1902
|
+
|
1903
|
+
buildHeaderCenter: function() {
|
1904
|
+
var texts = [];
|
1905
|
+
if (this.calendar.options.weekHeaderFormat) {
|
1906
|
+
texts = [this.formatHeaderDate(this.week.first()), '-', this.formatHeaderDate(this.week.last())];
|
1907
|
+
}
|
1908
|
+
|
1909
|
+
return "<td class='" + this.calendar.classNames.years + "'>" +
|
1910
|
+
"<span class='" + this.calendar.classNames.ym + "'>" +
|
1911
|
+
(texts[0] || this.week[0].toDateString()) +
|
1912
|
+
"</span>" +
|
1913
|
+
"<span class='" + this.calendar.classNames.ym + "'>" +
|
1914
|
+
(texts[1] || '-') +
|
1915
|
+
"</span>" +
|
1916
|
+
"<span class='" + this.calendar.classNames.ym + "'>" +
|
1917
|
+
(texts[2] || this.week.last().toDateString()) +
|
1918
|
+
"</span>" +
|
1919
|
+
"</td>";
|
1920
|
+
},
|
1921
|
+
|
1922
|
+
formatHeaderDate: function(date) {
|
1923
|
+
if (this.calendar.options.weekHeaderFormat) {
|
1924
|
+
return new Template(this.calendar.options.weekHeaderFormat).evaluate({
|
1925
|
+
year: date.getFullYear(),
|
1926
|
+
month: date.getMonth() + 1,
|
1927
|
+
day: date.getDate(),
|
1928
|
+
wday: this.calendar.options.dayOfWeek[date.getDay()]
|
1929
|
+
});
|
1930
|
+
}
|
1931
|
+
return [];
|
1932
|
+
},
|
1933
|
+
|
1934
|
+
buildHeaderRight: function() {
|
1935
|
+
return "<td class='" + this.calendar.classNames.nextYears + "' align='right'>" +
|
1936
|
+
"<div id='" + this.ids.next + "' class='" + this.calendar.classNames.nextWeekMark + "'></div>" +
|
1937
|
+
"</td>";
|
1938
|
+
},
|
1939
|
+
|
1940
|
+
buildCalendar: function() {
|
1941
|
+
var tableRows = (this.calendar.options.displayTimeLine) ? this.buildTimeLine() : '';
|
1942
|
+
tableRows += this.buildCalendarContainer();
|
1943
|
+
|
1944
|
+
return "<table id='" + this.ids.columnContainer + "' class='" + this.calendar.classNames.weekTable + "'>" +
|
1945
|
+
"<tr>" + tableRows + "</tr>" +
|
1946
|
+
"</table>";
|
1947
|
+
},
|
1948
|
+
|
1949
|
+
buildTimeLine: function() {
|
1950
|
+
var time = new Date();
|
1951
|
+
var hour = 0, hoursOfDay = 24;
|
1952
|
+
time.setHours(hour);
|
1953
|
+
time.setMinutes(0);
|
1954
|
+
var nodes = this.buildTimeLineTop();
|
1955
|
+
var now = new Date().getHours();
|
1956
|
+
|
1957
|
+
while (hour < hoursOfDay) {
|
1958
|
+
if (this.includeDisplayTime(hour)) {
|
1959
|
+
var style = 'pointer: default;';
|
1960
|
+
if (nodes.length == 0) style += "border-top: none;";
|
1961
|
+
var className = this.calendar.classNames.timeLineTime;
|
1962
|
+
if (hour == now) className += ' ' + this.calendar.classNames.highlightTime;
|
1963
|
+
nodes += "<div class='" + className + "' style='" + style + "'>" + this.formatTime(time) + "</div>";
|
1964
|
+
}
|
1965
|
+
hour++;
|
1966
|
+
time.setHours(hour);
|
1967
|
+
}
|
1968
|
+
return "<td class='" + this.calendar.classNames.timeLine + "'>" + nodes + "</td>";
|
1969
|
+
},
|
1970
|
+
|
1971
|
+
buildTimeLineTop: function() {
|
1972
|
+
return "<div class='" + this.calendar.classNames.timeLineTimeTop + "'></div>";
|
1973
|
+
},
|
1974
|
+
|
1975
|
+
buildCalendarContainer: function() {
|
1976
|
+
return "<td>" +
|
1977
|
+
"<table class='" + this.calendar.classNames.weekMainTable + "'>" +
|
1978
|
+
this.buildCalendarHeader() +
|
1979
|
+
this.buildCalendarMain() +
|
1980
|
+
"</table>" +
|
1981
|
+
"</td>";
|
1982
|
+
},
|
1983
|
+
|
1984
|
+
buildCalendarHeader: function() {
|
1985
|
+
var indexes = this.calendar.options.displayIndexes;
|
1986
|
+
var ths = '';
|
1987
|
+
var today = new Date().days();
|
1988
|
+
var width = 100 / indexes.length + '%';
|
1989
|
+
var thIdBase = this.calendar.element.id.appendSuffix(this.ids.column);
|
1990
|
+
var linkIdBase = this.calendar.element.id.appendSuffix(this.ids.headerText);
|
1991
|
+
this.headers = [];
|
1992
|
+
var noEvent = this.calendar.options.noEvent;
|
1993
|
+
var subHeaderTempl = (this.calendar.options.weekSubHeaderFormat) ?
|
1994
|
+
new Template(this.calendar.options.weekSubHeaderFormat) : null;
|
1995
|
+
|
1996
|
+
this.week.each(function(w, index) {
|
1997
|
+
var text = null;
|
1998
|
+
if (subHeaderTempl) {
|
1999
|
+
text = subHeaderTempl.evaluate({
|
2000
|
+
month: w.getMonth().succ(),
|
2001
|
+
day: w.getDate(),
|
2002
|
+
wday: this.calendar.options.dayOfWeek[w.getDay()]
|
2003
|
+
});
|
2004
|
+
} else {
|
2005
|
+
text = w.toDateString().split(' ');
|
2006
|
+
text.pop();
|
2007
|
+
text = text.join(' ');
|
2008
|
+
}
|
2009
|
+
|
2010
|
+
var linkClass = (w.days() == today) ? this.calendar.classNames.highlightDay : '';
|
2011
|
+
var linkId = linkIdBase.appendSuffix(index);
|
2012
|
+
var node = "<div class='" + this.calendar.classNames.headerColumn + "'>";
|
2013
|
+
if (noEvent) {
|
2014
|
+
node += "<span='#' id='" + linkId + "' class='" + linkClass + "' style='cursor: default;'>" + text + "</a>";
|
2015
|
+
} else {
|
2016
|
+
node += "<a href='#' id='" + linkId + "' class='" + linkClass + "'>" + text + "</a>";
|
2017
|
+
}
|
2018
|
+
node += "</div>";
|
2019
|
+
|
2020
|
+
this.headers.push({id: linkId, wday: w});
|
2021
|
+
ths += "<th id='" + thIdBase.appendSuffix(index) + "' width='" + width + "'>" + node + "</th>";
|
2022
|
+
}.bind(this));
|
2023
|
+
|
2024
|
+
return "<tr>" +
|
2025
|
+
"<td>" +
|
2026
|
+
"<table class='" + this.calendar.classNames.weekMainTable + "'>" +
|
2027
|
+
"<tr>" + ths + "</tr>" +
|
2028
|
+
"</table>" +
|
2029
|
+
"</td>" +
|
2030
|
+
"</tr>";
|
2031
|
+
},
|
2032
|
+
|
2033
|
+
buildCalendarMain: function() {
|
2034
|
+
var indexes = this.calendar.options.displayIndexes;
|
2035
|
+
var tds = '';
|
2036
|
+
var width = 100.0 / indexes.length + '%';
|
2037
|
+
this.dateMap = {};
|
2038
|
+
|
2039
|
+
this.week.each(function(w, index) {
|
2040
|
+
var schedules = this.calendar.options.schedules[w.toDateString()];
|
2041
|
+
var nodes = '';
|
2042
|
+
var i = 0, j = 0;
|
2043
|
+
|
2044
|
+
while (i < 24) {
|
2045
|
+
if (this.includeDisplayTime(i)) {
|
2046
|
+
var className = '';
|
2047
|
+
if (nodes.length == 0) {
|
2048
|
+
className = this.calendar.classNames.columnTopDate;
|
2049
|
+
} else if (i % 1 == 0) {
|
2050
|
+
className = this.calendar.classNames.columnDate;
|
2051
|
+
} else {
|
2052
|
+
className = this.calendar.classNames.columnDateOdd;
|
2053
|
+
}
|
2054
|
+
var id = this.getDateId(w, i, index);
|
2055
|
+
var hour = i / 1;
|
2056
|
+
var min = i % 1 * 60;
|
2057
|
+
this.dateMap[id] = new Date(w.getFullYear(), w.getMonth(), w.getDate(), hour, min, 0);
|
2058
|
+
nodes += "<div id='" + id + "' class='" + className + "'></div>";
|
2059
|
+
}
|
2060
|
+
i += 0.5;
|
2061
|
+
}
|
2062
|
+
tds += "<td width='" + width + "'>" + nodes + "</td>";
|
2063
|
+
}.bind(this));
|
2064
|
+
|
2065
|
+
return "<tr>" +
|
2066
|
+
"<td>" +
|
2067
|
+
"<div id='" + this.getScheduleContainerId() + "' class='" + this.calendar.classNames.scheduleContainer + "' style='position: relative;'>" +
|
2068
|
+
"<table id='" + this.getCalendarTableId() + "' class='" + this.calendar.classNames.weekMainTable + "' style='position: relative;'>" +
|
2069
|
+
"<tr>" + tds + "</tr>" +
|
2070
|
+
"</table>" +
|
2071
|
+
"</div>" +
|
2072
|
+
"</td>" +
|
2073
|
+
"</tr>";
|
2074
|
+
},
|
2075
|
+
|
2076
|
+
setColumnEvent: function(node) {
|
2077
|
+
// do nothing
|
2078
|
+
},
|
2079
|
+
|
2080
|
+
beforeBuild: function() {
|
2081
|
+
this.column = {};
|
2082
|
+
var rule = CssUtil.getCssRuleBySelectorText('.' + Calendar.className.columnDate);
|
2083
|
+
this.column.height = parseInt(rule.style['height'], 10) + 1;
|
2084
|
+
},
|
2085
|
+
|
2086
|
+
/**********************************
|
2087
|
+
***** for make schedule item *****
|
2088
|
+
**********************************/
|
2089
|
+
buildSchedule: function(schedule) {
|
2090
|
+
var id = 'scheduleItem_' + schedule.id;
|
2091
|
+
var canEdit = (schedule.edit == undefined || schedule.edit);
|
2092
|
+
var item = Builder.node('DIV', {id: id});
|
2093
|
+
this.calendar.css.addClassNames(item, 'scheduleItemLarge');
|
2094
|
+
var noEvent = this.calendar.options.noEvent;
|
2095
|
+
|
2096
|
+
var styles = {};
|
2097
|
+
if (schedule.background_color) styles.backgroundColor = schedule.background_color;
|
2098
|
+
if (schedule.frame_color) styles.border = '2px solid ' + schedule.frame_color;
|
2099
|
+
if (noEvent) styles.cursor = 'default';
|
2100
|
+
Element.setStyle(item, styles);
|
2101
|
+
|
2102
|
+
if (canEdit) {
|
2103
|
+
var deleteImg = Builder.node('DIV',
|
2104
|
+
{
|
2105
|
+
id: 'scheduleDeleteImg_' + schedule.id,
|
2106
|
+
className: this.calendar.css.joinClassNames('deleteImg')
|
2107
|
+
}
|
2108
|
+
);
|
2109
|
+
Element.hide(deleteImg);
|
2110
|
+
item.appendChild(deleteImg);
|
2111
|
+
|
2112
|
+
// set event on a image.
|
2113
|
+
if (!noEvent) {
|
2114
|
+
Event.observe(deleteImg, 'click', this.clickDeleteImage.bind(this, schedule));
|
2115
|
+
Event.observe(item, 'mouseover', this.showDeleteImage.bind(this, deleteImg));
|
2116
|
+
Event.observe(item, 'mouseout', this.hideDeleteImage.bind(this, deleteImg));
|
2117
|
+
}
|
2118
|
+
}
|
2119
|
+
|
2120
|
+
// set dblclick event on a schedule item.
|
2121
|
+
if (!noEvent && this.calendar.options.dblclickSchedule) {
|
2122
|
+
Event.observe(item, 'dblclick', this.calendar.options.dblclickSchedule.bind(this, schedule));
|
2123
|
+
}
|
2124
|
+
|
2125
|
+
// drag handler
|
2126
|
+
var handler = null;
|
2127
|
+
if (canEdit) {
|
2128
|
+
handler = Builder.node('DIV', {className: this.calendar.css.joinClassNames('scheduleHandler')});
|
2129
|
+
if (noEvent) Element.hide(handler);
|
2130
|
+
item.appendChild(handler);
|
2131
|
+
}
|
2132
|
+
|
2133
|
+
var icon = null;
|
2134
|
+
if (schedule.icon) {
|
2135
|
+
icon = Builder.node('IMG', {src: schedule.icon, alt: 'icon', style: 'float: left;', width: 16, height: 16});
|
2136
|
+
item.appendChild(icon);
|
2137
|
+
}
|
2138
|
+
|
2139
|
+
// private mark
|
2140
|
+
if (!schedule.publicity) {
|
2141
|
+
icon = Builder.node('DIV', {id: 'private_img_' + schedule.id});
|
2142
|
+
this.calendar.css.addClassNames(icon, 'privateImg');
|
2143
|
+
item.appendChild(icon);
|
2144
|
+
}
|
2145
|
+
|
2146
|
+
var text = this.getTimeText(schedule.start, schedule.finish);
|
2147
|
+
text = Builder.node('DIV', {id: id + '_text'}, [text]);
|
2148
|
+
this.calendar.css.addClassNames(text, 'scheduleTimeArea');
|
2149
|
+
|
2150
|
+
item.appendChild(text);
|
2151
|
+
var description = schedule.description.unescapeHTML();
|
2152
|
+
item.appendChild(Builder.node('DIV', {id: id + '_description'}, [description]));
|
2153
|
+
item.title = description;
|
2154
|
+
item.schedule = schedule;
|
2155
|
+
|
2156
|
+
return [item, handler];
|
2157
|
+
},
|
2158
|
+
|
2159
|
+
adjustScheduleStyle: function(item, index, holder) {
|
2160
|
+
var schedule = item.schedule;
|
2161
|
+
var time = this.convertHours(schedule);
|
2162
|
+
var start = time[0];
|
2163
|
+
var finish = time[1];
|
2164
|
+
var same = [];
|
2165
|
+
var self = this;
|
2166
|
+
|
2167
|
+
holder.each(function(h) {
|
2168
|
+
var hTime = self.convertHours(h.schedule);
|
2169
|
+
var hStart = hTime[0];
|
2170
|
+
var hFinish = hTime[1];
|
2171
|
+
|
2172
|
+
if (
|
2173
|
+
((hStart <= start) && (hFinish > start)) || ((hStart < finish) && (hFinish >= finish)) ||
|
2174
|
+
((start <= hStart) && (finish > hStart)) || ((start < hFinish) && (finish >= hFinish))
|
2175
|
+
) {
|
2176
|
+
same.push(h);
|
2177
|
+
}
|
2178
|
+
});
|
2179
|
+
|
2180
|
+
var adjustSize = index * this.getAdjustSize();
|
2181
|
+
var left = this.column.width * index + adjustSize;
|
2182
|
+
if (same.length == 0) {
|
2183
|
+
Element.setStyle(item, {left: left + 'px'});
|
2184
|
+
} else {
|
2185
|
+
same.push(item);
|
2186
|
+
var width = parseInt(Element.getStyle(item, 'width'), 10) / (same.length) - (UserAgent.isIE() ? 1: 2);
|
2187
|
+
same.each(function(s, i) {
|
2188
|
+
var adjustLeft = left + width * i + (2 * i);
|
2189
|
+
// if (i != 0) adjustLeft += 2;
|
2190
|
+
Element.setStyle(s, {
|
2191
|
+
width: width + 'px',
|
2192
|
+
left: adjustLeft + 'px'
|
2193
|
+
});
|
2194
|
+
});
|
2195
|
+
}
|
2196
|
+
return left;
|
2197
|
+
},
|
2198
|
+
|
2199
|
+
setScheduleBaseStyle: function(item) {
|
2200
|
+
var schedule = item.schedule;
|
2201
|
+
if (!this.calendar.isSameDate(schedule.start, schedule.finish)) {
|
2202
|
+
schedule.finish.hour = 24;
|
2203
|
+
schedule.finish.min = 0;
|
2204
|
+
}
|
2205
|
+
|
2206
|
+
var time = this.convertHours(schedule);
|
2207
|
+
var startTime = time.first();
|
2208
|
+
var finishTime = time.last();
|
2209
|
+
var oneHour = this.column.height * 2;
|
2210
|
+
var diff = this.calendar.getTimeDiff(schedule.start, schedule.finish);
|
2211
|
+
var rate = (diff.hour + (diff.min / 60)) || 1;
|
2212
|
+
|
2213
|
+
var over = 0;
|
2214
|
+
var top = 0;
|
2215
|
+
var height = 0;
|
2216
|
+
|
2217
|
+
var includeStart = this.includeDisplayTime(startTime);
|
2218
|
+
var includeFinish = this.includeDisplayTime(finishTime);
|
2219
|
+
if (!includeStart && !includeFinish) {
|
2220
|
+
if ((this.startTime <= startTime && this.startTime <= finishTime) ||
|
2221
|
+
(startTime < this.finishTime && finishTime < this.finishTime)) {
|
2222
|
+
top = height = 0;
|
2223
|
+
Element.hide(item);
|
2224
|
+
} else {
|
2225
|
+
top = 0;
|
2226
|
+
height = oneHour * (this.finishTime - this.startTime) - 3;
|
2227
|
+
}
|
2228
|
+
} else {
|
2229
|
+
if (includeStart) {
|
2230
|
+
top = oneHour * (startTime - this.startTime);
|
2231
|
+
height = oneHour * rate - 3;
|
2232
|
+
} else {
|
2233
|
+
top = 0;
|
2234
|
+
over = this.startTime - startTime;
|
2235
|
+
height = oneHour * (rate - over);
|
2236
|
+
}
|
2237
|
+
|
2238
|
+
if (includeFinish) {
|
2239
|
+
} else {
|
2240
|
+
over = finishTime - this.finishTime;
|
2241
|
+
height -= oneHour * over;
|
2242
|
+
}
|
2243
|
+
}
|
2244
|
+
|
2245
|
+
try {
|
2246
|
+
Element.setStyle(item, {
|
2247
|
+
top: top + 'px',
|
2248
|
+
width: this.column.width + 'px',
|
2249
|
+
height: height + 'px'
|
2250
|
+
});
|
2251
|
+
} catch (e) {}
|
2252
|
+
},
|
2253
|
+
|
2254
|
+
afterBuild: function() {
|
2255
|
+
this.calendarTable = $(this.getCalendarTableId());
|
2256
|
+
this.setContainerInfo();
|
2257
|
+
this.setColumnWidth();
|
2258
|
+
this.setCover();
|
2259
|
+
|
2260
|
+
var self = this;
|
2261
|
+
var container = $(this.getScheduleContainerId());
|
2262
|
+
var distance = this.getDragDistance();
|
2263
|
+
this.scheduleNodes = [];
|
2264
|
+
var holders = this.week.map(function() {return []});
|
2265
|
+
var weekSize = this.week.legth - 1;
|
2266
|
+
var noEvent = this.calendar.options.noEvent;
|
2267
|
+
|
2268
|
+
this.calendar.options.schedules.each(function(schedule) {
|
2269
|
+
var items = [];
|
2270
|
+
var sub, subItem = null;
|
2271
|
+
self.week.each(function(date, index) {
|
2272
|
+
if (self.calendar.betweenDate(schedule, date)) {
|
2273
|
+
if (self.isSameStartDate(schedule, date) && self.isSameFinishDate(schedule, date)) {
|
2274
|
+
items.push(self.setSchedule(schedule, index, holders, container, distance));
|
2275
|
+
} else {
|
2276
|
+
sub = self.copyOneDaySchedule(schedule, date);
|
2277
|
+
subItem = self.setSchedule(sub, index, holders, container, distance);
|
2278
|
+
subItem.originalSchedule = schedule;
|
2279
|
+
items.push(subItem);
|
2280
|
+
}
|
2281
|
+
} else if (sub) {
|
2282
|
+
throw $break;
|
2283
|
+
}
|
2284
|
+
});
|
2285
|
+
|
2286
|
+
if (!noEvent) {
|
2287
|
+
items.each(function(item) {
|
2288
|
+
Event.observe(item, 'mouseover', self.mouseOverSubSchedule.bind(this, items));
|
2289
|
+
Event.observe(item, 'mouseout', self.mouseOutSubSchedule.bind(this, items));
|
2290
|
+
});
|
2291
|
+
}
|
2292
|
+
});
|
2293
|
+
},
|
2294
|
+
|
2295
|
+
setEvent: function() {
|
2296
|
+
if (!this.calendar.options.noEvent) {
|
2297
|
+
Event.observe(this.ids.pre, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
|
2298
|
+
Event.observe(this.ids.next, "click", this.calendar.changeCalendar.bindAsEventListener(this.calendar));
|
2299
|
+
new Hover(this.ids.pre);
|
2300
|
+
new Hover(this.ids.next);
|
2301
|
+
|
2302
|
+
var clickDateText = this.calendar.options.clickDateText || this.clickDateText;
|
2303
|
+
if (this.headers) {
|
2304
|
+
this.headers.each(function(header) {
|
2305
|
+
Event.observe(header.id, 'mousedown', clickDateText.bindAsEventListener(this, header.wday));
|
2306
|
+
}.bind(this));
|
2307
|
+
}
|
2308
|
+
}
|
2309
|
+
},
|
2310
|
+
|
2311
|
+
copyOneDaySchedule: function(schedule, date) {
|
2312
|
+
var sub = null;
|
2313
|
+
if (this.isSameStartDate(schedule, date)) {
|
2314
|
+
sub = this.copySchedule(schedule, date);
|
2315
|
+
sub.finish.hour = 24;
|
2316
|
+
sub.finish.min = 0;
|
2317
|
+
} else if (this.isSameFinishDate(schedule, date)) {
|
2318
|
+
sub = this.copySchedule(schedule, date);
|
2319
|
+
sub.start.hour = 0;
|
2320
|
+
sub.start.min = 0;
|
2321
|
+
} else {
|
2322
|
+
sub = this.copySchedule(schedule, date);
|
2323
|
+
sub.start.hour = 0;
|
2324
|
+
sub.start.min = 0;
|
2325
|
+
sub.finish.hour = 24;
|
2326
|
+
sub.finish.min = 0;
|
2327
|
+
}
|
2328
|
+
return sub;
|
2329
|
+
},
|
2330
|
+
|
2331
|
+
copySchedule: function(schedule, date) {
|
2332
|
+
sub = Object.extend({}, schedule);
|
2333
|
+
sub.start = {
|
2334
|
+
year: date.getFullYear(),
|
2335
|
+
month: date.getMonth(),
|
2336
|
+
day: date.getDate(),
|
2337
|
+
hour: schedule.start.hour,
|
2338
|
+
min: schedule.start.min
|
2339
|
+
}
|
2340
|
+
sub.finish = {
|
2341
|
+
year: date.getFullYear(),
|
2342
|
+
month: date.getMonth(),
|
2343
|
+
day: date.getDate(),
|
2344
|
+
hour: schedule.finish.hour,
|
2345
|
+
min: schedule.finish.min
|
2346
|
+
}
|
2347
|
+
return sub;
|
2348
|
+
},
|
2349
|
+
|
2350
|
+
setSchedule: function(schedule, index, holders, container, distance) {
|
2351
|
+
// create a schedule node.
|
2352
|
+
var result = this.buildSchedule(schedule);
|
2353
|
+
var item = result.first();
|
2354
|
+
container.appendChild(item);
|
2355
|
+
|
2356
|
+
// set style(position and size) of a schedule item.
|
2357
|
+
this.setScheduleBaseStyle(item);
|
2358
|
+
var left = this.adjustScheduleStyle(item, index, holders[index]);
|
2359
|
+
var adjustSize = index * this.getAdjustSize();
|
2360
|
+
var snapLeft = this.column.width + adjustSize + 'px';
|
2361
|
+
|
2362
|
+
if (!this.calendar.options.noEvent && ((schedule.edit == undefined) || schedule.edit)) {
|
2363
|
+
this.setDraggable(item, result.last(), container, distance);
|
2364
|
+
this.setResize(item);
|
2365
|
+
}
|
2366
|
+
|
2367
|
+
holders[index].push(item);
|
2368
|
+
this.scheduleNodes.push(item);
|
2369
|
+
return item;
|
2370
|
+
},
|
2371
|
+
|
2372
|
+
getDragDistance: function() {
|
2373
|
+
var adjustSize = this.getAdjustSize();
|
2374
|
+
return [this.column.width + adjustSize, this.column.height / 2];
|
2375
|
+
},
|
2376
|
+
|
2377
|
+
// set draggalbe event
|
2378
|
+
setDraggable: function(item, handle, container, distance) {
|
2379
|
+
var self = this;
|
2380
|
+
new Draggable(item,
|
2381
|
+
{
|
2382
|
+
handle: handle,
|
2383
|
+
scroll: window,
|
2384
|
+
starteffect: Prototype.emptyFunction,
|
2385
|
+
endeffect: Prototype.emptyFunction,
|
2386
|
+
snap: function(x, y) {
|
2387
|
+
var eDimensions = Element.getDimensions(item);
|
2388
|
+
var pDimensions = Element.getDimensions(container);
|
2389
|
+
var xy = [x, y].map(function(v, i) { return Math.floor(v/distance[i]) * distance[i]; });
|
2390
|
+
xy = [
|
2391
|
+
self._constrain(xy[0], 0, pDimensions.width - eDimensions.width),
|
2392
|
+
self._constrain(xy[1], 0, pDimensions.height - eDimensions.height)
|
2393
|
+
];
|
2394
|
+
return xy;
|
2395
|
+
},
|
2396
|
+
onEnd: function(draggable, event) {
|
2397
|
+
self.changeSchedule(draggable, event);
|
2398
|
+
},
|
2399
|
+
change: function(draggable) {
|
2400
|
+
self.changeTimeDisplay(draggable.element);
|
2401
|
+
}
|
2402
|
+
}
|
2403
|
+
);
|
2404
|
+
},
|
2405
|
+
|
2406
|
+
// set resize event
|
2407
|
+
setResize: function(item) {
|
2408
|
+
new CalendarResizeableEx(item, {
|
2409
|
+
left: 0,
|
2410
|
+
right: 0,
|
2411
|
+
distance: this.column.height / 2,
|
2412
|
+
restriction: true,
|
2413
|
+
resize: function(element) {
|
2414
|
+
this.updateTirm(element);
|
2415
|
+
}.bind(this),
|
2416
|
+
change: function(element) {
|
2417
|
+
this.changeTimeDisplay(element);
|
2418
|
+
}.bind(this)
|
2419
|
+
});
|
2420
|
+
},
|
2421
|
+
|
2422
|
+
/********************************** public method **********************************/
|
2423
|
+
getDate: function(element) {
|
2424
|
+
return element.date;
|
2425
|
+
},
|
2426
|
+
|
2427
|
+
abstractSelect: function(event, method) {
|
2428
|
+
var element = this.findClickedElement(event);
|
2429
|
+
if (element) {
|
2430
|
+
if (Element.hasClassName(element, Calendar.className.columnDate) ||
|
2431
|
+
Element.hasClassName(element, Calendar.className.columnDateOdd) ||
|
2432
|
+
Element.hasClassName(element, Calendar.className.columnTopDate)) {
|
2433
|
+
|
2434
|
+
var date = this.getDate(element);
|
2435
|
+
method(date, element);
|
2436
|
+
}
|
2437
|
+
}
|
2438
|
+
},
|
2439
|
+
|
2440
|
+
getSelectedTerm: function() {
|
2441
|
+
var elements = this.calendar.getSelected();
|
2442
|
+
if (elements.length == 0) return;
|
2443
|
+
if (this.calendar.options.build) {
|
2444
|
+
var last = elements.last();
|
2445
|
+
if (last) {
|
2446
|
+
last = this.dateMap[last.id];
|
2447
|
+
} else {
|
2448
|
+
last = this.dateMap[elements.first().id];
|
2449
|
+
}
|
2450
|
+
last = new Date(last.getFullYear(), last.getMonth(),
|
2451
|
+
last.getDate(), last.getHours(), last.getMinutes(), 0);
|
2452
|
+
last.setMinutes(last.getMinutes() + 30);
|
2453
|
+
|
2454
|
+
return [this.dateMap[elements.first().id], last];
|
2455
|
+
} else {
|
2456
|
+
var last = this._getDateTimeFromElement(elements.last());
|
2457
|
+
last.setMinutes(last.getMinutes() + 30);
|
2458
|
+
return [this._getDateTimeFromElement(elements.first()), last];
|
2459
|
+
}
|
2460
|
+
},
|
2461
|
+
|
2462
|
+
/*** Week ***/
|
2463
|
+
/********************************** private method **********************************/
|
2464
|
+
setWidth: function(node) {
|
2465
|
+
Element.setStyle(node, {width: this.column.width + 'px'});
|
2466
|
+
},
|
2467
|
+
|
2468
|
+
inspectArgument: function(object, time) {
|
2469
|
+
if (object.date) return object;
|
2470
|
+
|
2471
|
+
var self = this;
|
2472
|
+
var dates = this.calendar.getSelected();
|
2473
|
+
var result = [];
|
2474
|
+
this.calendar.recurrence(object, function(o) {
|
2475
|
+
var param = {};
|
2476
|
+
if (!o.date) {
|
2477
|
+
param = {date: self.getDate(dates[0])};
|
2478
|
+
if (!o.start)
|
2479
|
+
param.start = dates[0].time;
|
2480
|
+
if (!o.finish)
|
2481
|
+
param.finish = dates[dates.length - 1].time;
|
2482
|
+
}
|
2483
|
+
Object.extend(param, o);
|
2484
|
+
result.push(param);
|
2485
|
+
});
|
2486
|
+
|
2487
|
+
return result;
|
2488
|
+
},
|
2489
|
+
|
2490
|
+
inspectDateArgument: function(date) {
|
2491
|
+
if (date) return date;
|
2492
|
+
|
2493
|
+
var calendar = this;
|
2494
|
+
var dates = this.getSelected();
|
2495
|
+
if (dates.length == 0) return null;
|
2496
|
+
|
2497
|
+
return dates.collect(function(d) {
|
2498
|
+
return calendar.getDate(d);
|
2499
|
+
});
|
2500
|
+
},
|
2501
|
+
|
2502
|
+
addColumnClass: function(element) {
|
2503
|
+
if (document.all)
|
2504
|
+
this.calendar.css.addClassNames(element, 'columnWin');
|
2505
|
+
else
|
2506
|
+
this.calendar.css.addClassNames(element, 'column');
|
2507
|
+
},
|
2508
|
+
|
2509
|
+
getHeaderId: function() {
|
2510
|
+
return this.calendar.element.id.appendSuffix(CalendarWeek.id.columnHeader);
|
2511
|
+
},
|
2512
|
+
|
2513
|
+
getColumnId: function(i) {
|
2514
|
+
return this.calendar.element.id.appendSuffix(CalendarWeek.id.column + '_' + i);
|
2515
|
+
},
|
2516
|
+
|
2517
|
+
changeSchedule: function(draggable, event) {
|
2518
|
+
var element = draggable.element;
|
2519
|
+
var schedule = element.schedule;
|
2520
|
+
var time = this.getTimeByElement(element);
|
2521
|
+
this.calendar.cacheSchedule(schedule);
|
2522
|
+
|
2523
|
+
var container = $(this.getScheduleContainerId());
|
2524
|
+
var dimensions = Element.getDimensions(container);
|
2525
|
+
var offset = Position.cumulativeOffset(container);
|
2526
|
+
var x = Event.pointerX(event);
|
2527
|
+
var y = Event.pointerY(event);
|
2528
|
+
|
2529
|
+
if (
|
2530
|
+
offset[0] > x ||
|
2531
|
+
(offset[0] + dimensions.width) < x ||
|
2532
|
+
offset[1] > y ||
|
2533
|
+
(offset[1] + dimensions.height) < y
|
2534
|
+
) {this.calendar.refreshSchedule(); return};
|
2535
|
+
|
2536
|
+
var left = parseInt(Element.getStyle(element, 'left'));
|
2537
|
+
var weekIndex = Math.round(left / this.column.width);
|
2538
|
+
var date = this.week[weekIndex];
|
2539
|
+
|
2540
|
+
if (
|
2541
|
+
schedule.start.year == date.getFullYear() &&
|
2542
|
+
schedule.start.month == date.getMonth() &&
|
2543
|
+
schedule.start.day == date.getDate() &&
|
2544
|
+
schedule.start.hour == time[0].hour &&
|
2545
|
+
schedule.start.min == time[0].min &&
|
2546
|
+
schedule.finish.year == date.getFullYear() &&
|
2547
|
+
schedule.finish.month == date.getMonth() &&
|
2548
|
+
schedule.finish.day == date.getDate() &&
|
2549
|
+
schedule.finish.hour == time[1].hour &&
|
2550
|
+
schedule.finish.min == time[1].min
|
2551
|
+
) {this.calendar.refreshSchedule(); return};
|
2552
|
+
|
2553
|
+
if (element.originalSchedule) schedule = element.originalSchedule;
|
2554
|
+
var newStart = {
|
2555
|
+
year: date.getFullYear(),
|
2556
|
+
month: date.getMonth(),
|
2557
|
+
day: date.getDate(),
|
2558
|
+
hour: time[0].hour,
|
2559
|
+
min: time[0].min
|
2560
|
+
}
|
2561
|
+
var diff = DateUtil.toDate(newStart).getTime() - DateUtil.toDate(schedule.start).getTime();
|
2562
|
+
schedule.start = newStart;
|
2563
|
+
schedule.finish = new Date(DateUtil.toDate(schedule.finish).getTime() + diff).toHash();
|
2564
|
+
|
2565
|
+
this.calendar.refreshSchedule();
|
2566
|
+
this.calendar.options.changeSchedule(schedule);
|
2567
|
+
},
|
2568
|
+
|
2569
|
+
updateTirm: function(element) {
|
2570
|
+
var schedule = element.schedule;
|
2571
|
+
var time = this.getTimeByElement(element);
|
2572
|
+
this.calendar.cacheSchedule(schedule);
|
2573
|
+
|
2574
|
+
var left = parseInt(Element.getStyle(element, 'left'));
|
2575
|
+
var weekIndex = Math.round(left / this.column.width);
|
2576
|
+
var date = this.week[weekIndex];
|
2577
|
+
|
2578
|
+
var isChange = this.isChengeSchedule(element, time);
|
2579
|
+
if (element.originalSchedule) schedule = element.originalSchedule;
|
2580
|
+
|
2581
|
+
if (isChange.start) {
|
2582
|
+
schedule.start.year = date.getFullYear();
|
2583
|
+
schedule.start.month = date.getMonth();
|
2584
|
+
schedule.start.day = date.getDate();
|
2585
|
+
schedule.start.hour = time[0].hour;
|
2586
|
+
schedule.start.min = time[0].min;
|
2587
|
+
} else if (isChange.finish) {
|
2588
|
+
schedule.finish.year = date.getFullYear();
|
2589
|
+
schedule.finish.month = date.getMonth();
|
2590
|
+
schedule.finish.day = date.getDate();
|
2591
|
+
schedule.finish.hour = time[1].hour;
|
2592
|
+
schedule.finish.min = time[1].min;
|
2593
|
+
} else {
|
2594
|
+
return;
|
2595
|
+
}
|
2596
|
+
|
2597
|
+
this.calendar.refreshSchedule();
|
2598
|
+
this.calendar.options.updateTirm(schedule);
|
2599
|
+
},
|
2600
|
+
|
2601
|
+
changeTimeDisplay: function(element) {
|
2602
|
+
var schedule = element.schedule;
|
2603
|
+
var time = this.getTimeByElement(element);
|
2604
|
+
|
2605
|
+
var textNode = Element.getElementsByClassName(element, Calendar.className.scheduleTimeArea)[0];
|
2606
|
+
var text = this.getTimeText(time[0], time[1]);
|
2607
|
+
textNode.innerHTML = text;
|
2608
|
+
},
|
2609
|
+
|
2610
|
+
findClickedElement: function(event) {
|
2611
|
+
var container = $(this.getScheduleContainerId());
|
2612
|
+
var position = Position.cumulativeOffset(container);
|
2613
|
+
var scrollTop = Position.realOffset(container).last();
|
2614
|
+
scrollTop -= document.documentElement.scrollTop || document.body.scrollTop;
|
2615
|
+
var x = Event.pointerX(event) - position[0];
|
2616
|
+
var y = Event.pointerY(event) - position[1] + scrollTop;
|
2617
|
+
|
2618
|
+
var cellIndex = Math.floor(y / this.column.height);
|
2619
|
+
var rowIndex = Math.floor(x / this.column.width);
|
2620
|
+
return $(this.calendarTable.rows[0].cells[rowIndex]).down(cellIndex);
|
2621
|
+
},
|
2622
|
+
|
2623
|
+
multipleSelection: function(event) {
|
2624
|
+
if (!this.calendar.selectedBase || !this.calendar.mouseDown) return;
|
2625
|
+
var self = this;
|
2626
|
+
var calendar = this.calendar;
|
2627
|
+
var selected = this.calendar.selectedBase;
|
2628
|
+
var selectedDate = this._getDateFromElement(selected).getDate();
|
2629
|
+
|
2630
|
+
this.abstractSelect(event, function(date, element) {
|
2631
|
+
var selectedElement = $(selected.id);
|
2632
|
+
if (selectedDate != self._getDateFromElement(element).getDate()) return;
|
2633
|
+
|
2634
|
+
var nodes = $A(selectedElement.parentNode.childNodes);
|
2635
|
+
var ids = [this._getTime(selected), this._getTime(element)];
|
2636
|
+
ids.sort(function(a, b) {return a - b;});
|
2637
|
+
|
2638
|
+
nodes.each(function(n) {
|
2639
|
+
if (!n.id) throw $continue;
|
2640
|
+
var id = this._getTime(n);
|
2641
|
+
if ((id < ids[0]) || (ids[1] < id)) {
|
2642
|
+
calendar.removeSelectedClass(n);
|
2643
|
+
} else if (!Element.hasClassName(n, Calendar.className.selected)) {
|
2644
|
+
calendar.addSelectedClass(n);
|
2645
|
+
}
|
2646
|
+
}.bind(this));
|
2647
|
+
}.bind(this));
|
2648
|
+
},
|
2649
|
+
|
2650
|
+
getTimeByElement: function(element) {
|
2651
|
+
var schedule = element.schedule;
|
2652
|
+
var top = parseInt(Element.getStyle(element, 'top'), 10);
|
2653
|
+
var height = parseInt(Element.getStyle(element, 'height'), 10);
|
2654
|
+
var oneHour = this.column.height * 2;
|
2655
|
+
var distance = 15 / 60; // 5 minutes
|
2656
|
+
|
2657
|
+
var startTime = top / oneHour + this.startTime;
|
2658
|
+
startTime = Math.round(startTime / distance) * distance;
|
2659
|
+
var start = {};
|
2660
|
+
start.hour = Math.floor(startTime);
|
2661
|
+
start.min = (startTime - start.hour) * 60;
|
2662
|
+
|
2663
|
+
var finishTime = Math.round(height / oneHour / distance) * distance + startTime;
|
2664
|
+
var finish = {};
|
2665
|
+
finish.hour = Math.floor(finishTime);
|
2666
|
+
finish.min = Math.round((finishTime - finish.hour) * 60);
|
2667
|
+
|
2668
|
+
if (finish.min == 60) {
|
2669
|
+
finish.hour += 1;
|
2670
|
+
finish.min = 0;
|
2671
|
+
}
|
2672
|
+
|
2673
|
+
return [start, finish];
|
2674
|
+
},
|
2675
|
+
|
2676
|
+
getDateId: function(date, time, index) {
|
2677
|
+
var id = this.calendar.element.id.appendSuffix(index + '_' + date.getDate());
|
2678
|
+
return id.appendSuffix(time * 10);
|
2679
|
+
},
|
2680
|
+
|
2681
|
+
dateIdToTime: function(id) {
|
2682
|
+
id = id.getSuffix() / 10;
|
2683
|
+
var hour = Math.floor(id);
|
2684
|
+
return {hour: hour, min: (id - hour) * 60};
|
2685
|
+
},
|
2686
|
+
|
2687
|
+
formatTime: function(date) {
|
2688
|
+
var time = date.toTimeString();
|
2689
|
+
time = time.split(' ');
|
2690
|
+
time = time[0].split(':');
|
2691
|
+
time.pop();
|
2692
|
+
return time.join(':');
|
2693
|
+
},
|
2694
|
+
|
2695
|
+
/**
|
2696
|
+
* hours are 0, 0.5, 1, ..., 23.5, 24
|
2697
|
+
*/
|
2698
|
+
includeDisplayTime: function(hours) {
|
2699
|
+
return (this.startTime <= hours) && (hours < this.finishTime);
|
2700
|
+
},
|
2701
|
+
|
2702
|
+
/**
|
2703
|
+
* exsample
|
2704
|
+
*
|
2705
|
+
* {hour: 1, min: 30} => 1.5
|
2706
|
+
*/
|
2707
|
+
convertHours: function(schedule) {
|
2708
|
+
return [
|
2709
|
+
schedule.start.hour + schedule.start.min / 60,
|
2710
|
+
schedule.finish.hour + schedule.finish.min / 60
|
2711
|
+
];
|
2712
|
+
},
|
2713
|
+
|
2714
|
+
setDisplayTime: function() {
|
2715
|
+
this.startTime = this.calendar.options.displayTime.first().hour;
|
2716
|
+
var finishTime = this.calendar.options.displayTime.last();
|
2717
|
+
this.finishTime = Math.ceil(finishTime.hour + finishTime.min / 60);
|
2718
|
+
},
|
2719
|
+
|
2720
|
+
getTimeText: function(start, finish) {
|
2721
|
+
var calendar = this.calendar;
|
2722
|
+
return calendar.formatTime(start) + ' - ' + calendar.formatTime(finish);
|
2723
|
+
},
|
2724
|
+
|
2725
|
+
isChengeSchedule: function(scheduleElement, newTime) {
|
2726
|
+
var schedule = scheduleElement.schedule;
|
2727
|
+
var changeStart = ((schedule.start.hour != newTime[0].hour) || (schedule.start.min != newTime[0].min));
|
2728
|
+
var changeFinish = ((schedule.finish.hour != newTime[1].hour) || (schedule.finish.min != newTime[1].min));
|
2729
|
+
|
2730
|
+
if (scheduleElement.originalSchedule) {
|
2731
|
+
if (changeStart && changeFinish) {
|
2732
|
+
var currentDateStart = DateUtil.toDate(schedule.start).getTime();
|
2733
|
+
var OriginalDateStart = DateUtil.toDate(scheduleElement.originalSchedule.start).getTime();
|
2734
|
+
if (currentDateStart == OriginalDateStart) {
|
2735
|
+
changeFinish = false;
|
2736
|
+
} else {
|
2737
|
+
changeStart = false;
|
2738
|
+
}
|
2739
|
+
}
|
2740
|
+
}
|
2741
|
+
return {start: changeStart, finish: changeFinish};
|
2742
|
+
},
|
2743
|
+
|
2744
|
+
_getDateFromElement: function(element) {
|
2745
|
+
var arr = element.id.split('_');
|
2746
|
+
var index = arr[arr.length - 3];
|
2747
|
+
return this.week[index];
|
2748
|
+
},
|
2749
|
+
|
2750
|
+
_getDateTimeFromElement: function(element) {
|
2751
|
+
var id = element.id.split('_');
|
2752
|
+
var index = id[id.length - 3];
|
2753
|
+
if (this.week[index]) {
|
2754
|
+
var date = new Date(this.week[index].getTime());
|
2755
|
+
date.setMinutes(parseInt(id.pop(), 10));
|
2756
|
+
date.setHours(parseInt(id.pop(), 10));
|
2757
|
+
return date;
|
2758
|
+
} else {
|
2759
|
+
return this._getDate(element);
|
2760
|
+
}
|
2761
|
+
},
|
2762
|
+
|
2763
|
+
_getDate: function(element) {
|
2764
|
+
var id = element.id.split('_');
|
2765
|
+
var date = new Date(this.calendar.date.getTime());
|
2766
|
+
date.setMinutes(parseInt(id.pop(), 10));
|
2767
|
+
date.setHours(parseInt(id.pop(), 10));
|
2768
|
+
return date;
|
2769
|
+
},
|
2770
|
+
|
2771
|
+
_getTimeString: function(element) {
|
2772
|
+
var arr = element.id.split('_');
|
2773
|
+
var min = arr[arr.length - 1];
|
2774
|
+
if (min == '0') min = '00';
|
2775
|
+
return arr[arr.length - 2] + min;
|
2776
|
+
},
|
2777
|
+
|
2778
|
+
_getTime: function(element) {
|
2779
|
+
return parseInt(this._getTimeString(element), 10);
|
2780
|
+
}
|
2781
|
+
});
|
2782
|
+
|
2783
|
+
|
2784
|
+
/**
|
2785
|
+
* CalendarDay Class
|
2786
|
+
*/
|
2787
|
+
var CalendarDay = Class.create();
|
2788
|
+
CalendarDay.id = ['dayHeader'];
|
2789
|
+
Object.extend(CalendarDay.prototype, CalendarWeek.prototype);
|
2790
|
+
Object.extend(CalendarDay.prototype, {
|
2791
|
+
|
2792
|
+
initialize: function(calendar) {
|
2793
|
+
var day = calendar.date.getDay();
|
2794
|
+
this.calendar = calendar;
|
2795
|
+
this.ids = SpinelzUtil.concat(this.calendar.element.id, CalendarWeek.id);
|
2796
|
+
this.dayIds = SpinelzUtil.concat(this.calendar.element.id, CalendarDay.id);
|
2797
|
+
this.setDisplayTime();
|
2798
|
+
|
2799
|
+
this.calendar.options.displayIndexesOld = this.calendar.options.displayIndexes;
|
2800
|
+
this.calendar.options.displayIndexes = [day];
|
2801
|
+
this.calendar.options.weekIndexOld = this.calendar.options.weekIndex;
|
2802
|
+
this.calendar.options.weekIndex = day;
|
2803
|
+
this.week = this.getWeek();
|
2804
|
+
},
|
2805
|
+
|
2806
|
+
destroy: function() {
|
2807
|
+
this.calendar.options.displayIndexes = this.calendar.options.displayIndexesOld;
|
2808
|
+
this.calendar.options.weekIndex = this.calendar.options.weekIndexOld;
|
2809
|
+
delete this.calendar.options.displayIndexesOld;
|
2810
|
+
delete this.calendar.options.weekIndexOld;
|
2811
|
+
},
|
2812
|
+
|
2813
|
+
/*** Day ***/
|
2814
|
+
/********************************** build functions **********************************/
|
2815
|
+
buildHeaderCenter: function() {
|
2816
|
+
var headerText = this.calendar.date.toDateString();
|
2817
|
+
if (this.calendar.options.dayHeaderFormat) {
|
2818
|
+
var date = this.calendar.date;
|
2819
|
+
headerText = new Template(this.calendar.options.dayHeaderFormat).evaluate({
|
2820
|
+
year: date.getFullYear(),
|
2821
|
+
month: date.getMonth() + 1,
|
2822
|
+
day: date.getDate(),
|
2823
|
+
wday: this.calendar.options.dayOfWeek[date.getDay()]
|
2824
|
+
});
|
2825
|
+
}
|
2826
|
+
|
2827
|
+
return "<td class='" + this.calendar.classNames.years + "'>" +
|
2828
|
+
"<span id='" + this.dayIds.header + "' class='" + this.calendar.classNames.ym + "'>" +
|
2829
|
+
headerText +
|
2830
|
+
"</span>" +
|
2831
|
+
"</td>";
|
2832
|
+
},
|
2833
|
+
|
2834
|
+
buildTimeLineTop: function() { return '' },
|
2835
|
+
|
2836
|
+
buildCalendarHeader: function() { return '' },
|
2837
|
+
|
2838
|
+
/*** Day ***/
|
2839
|
+
/********************************** private method **********************************/
|
2840
|
+
changeCalendar: function(event) {
|
2841
|
+
var element = Event.element(event);
|
2842
|
+
var oldDate = new Date(this.calendar.date.toDateString());
|
2843
|
+
|
2844
|
+
if (this.hasClassName(element, Calendar.className.preWeekMark)) {
|
2845
|
+
this.calendar.date.setDate(this.calendar.date.getDate() - 1);
|
2846
|
+
} else if (this.hasClassName(element, Calendar.className.nextWeekMark)) {
|
2847
|
+
this.calendar.date.setDate(this.calendar.date.getDate() + 1);
|
2848
|
+
}
|
2849
|
+
|
2850
|
+
this.calendar.options.changeCalendar(this.calendar.date, oldDate);
|
2851
|
+
this.calendar.refresh();
|
2852
|
+
}
|
2853
|
+
});
|
2854
|
+
|
2855
|
+
|
2856
|
+
//
|
2857
|
+
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
2858
|
+
//
|
2859
|
+
// Permission is hereby granted, free of charge, to any person obtaining
|
2860
|
+
// a copy of this software and associated documentation files (the
|
2861
|
+
// "Software"), to deal in the Software without restriction, including
|
2862
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
2863
|
+
// distribute, sublicense, and/or sell copies of the Software, and to
|
2864
|
+
// permit persons to whom the Software is furnished to do so, subject to
|
2865
|
+
// the following conditions:
|
2866
|
+
//
|
2867
|
+
// The above copyright notice and this permission notice shall be
|
2868
|
+
// included in all copies or substantial portions of the Software.
|
2869
|
+
//
|
2870
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
2871
|
+
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
2872
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
2873
|
+
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
2874
|
+
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
2875
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
2876
|
+
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2877
|
+
|
2878
|
+
var CalendarResizeableEx = Class.create();
|
2879
|
+
Object.extend(CalendarResizeableEx.prototype, Resizeable.prototype);
|
2880
|
+
Object.extend(CalendarResizeableEx.prototype, {
|
2881
|
+
initialize: function(element) {
|
2882
|
+
var options = Object.extend({
|
2883
|
+
top: 6,
|
2884
|
+
bottom: 6,
|
2885
|
+
left: 6,
|
2886
|
+
right: 6,
|
2887
|
+
minHeight: 0,
|
2888
|
+
minWidth: 0,
|
2889
|
+
zindex: 1000,
|
2890
|
+
resize: null,
|
2891
|
+
distance: 1, // add by spinelz
|
2892
|
+
change: Prototype.emptyFunction,
|
2893
|
+
restriction: true
|
2894
|
+
}, arguments[1] || {});
|
2895
|
+
|
2896
|
+
this.element = $(element);
|
2897
|
+
this.handle = this.element;
|
2898
|
+
|
2899
|
+
Element.makePositioned(this.element); // fix IE
|
2900
|
+
|
2901
|
+
this.options = options;
|
2902
|
+
|
2903
|
+
this.active = false;
|
2904
|
+
this.resizing = false;
|
2905
|
+
this.currentDirection = '';
|
2906
|
+
|
2907
|
+
this.eventMouseDown = this.startResize.bindAsEventListener(this);
|
2908
|
+
this.eventMouseUp = this.endResize.bindAsEventListener(this);
|
2909
|
+
this.eventMouseMove = this.update.bindAsEventListener(this);
|
2910
|
+
this.eventCursorCheck = this.cursor.bindAsEventListener(this);
|
2911
|
+
this.eventKeypress = this.keyPress.bindAsEventListener(this);
|
2912
|
+
|
2913
|
+
this.registerEvents();
|
2914
|
+
},
|
2915
|
+
|
2916
|
+
startResize: function(event) {
|
2917
|
+
Event.stop(event);
|
2918
|
+
if(Event.isLeftClick(event)) {
|
2919
|
+
|
2920
|
+
// abort on form elements, fixes a Firefox issue
|
2921
|
+
var src = Event.element(event);
|
2922
|
+
if(src.tagName && (
|
2923
|
+
src.tagName=='INPUT' ||
|
2924
|
+
src.tagName=='SELECT' ||
|
2925
|
+
src.tagName=='BUTTON' ||
|
2926
|
+
src.tagName=='TEXTAREA')) return;
|
2927
|
+
|
2928
|
+
var dir = this.directions(event);
|
2929
|
+
if (dir.length > 0) {
|
2930
|
+
this.active = true;
|
2931
|
+
// var offsets = Position.cumulativeOffset(this.element);
|
2932
|
+
this.startTop = parseInt(Element.getStyle(this.element, 'top'), 10);
|
2933
|
+
this.startLeft = parseInt(Element.getStyle(this.element, 'left'), 10);
|
2934
|
+
this.startWidth = parseInt(Element.getStyle(this.element, 'width'), 10);
|
2935
|
+
this.startHeight = parseInt(Element.getStyle(this.element, 'height'), 10);
|
2936
|
+
this.startX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
|
2937
|
+
this.startY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
|
2938
|
+
|
2939
|
+
this.currentDirection = dir;
|
2940
|
+
|
2941
|
+
if (this.options.restriction) {
|
2942
|
+
var container = this.element.parentNode;
|
2943
|
+
this.restDimensions = Element.getDimensions(container);
|
2944
|
+
this.restOffset = Position.cumulativeOffset(container);
|
2945
|
+
}
|
2946
|
+
}
|
2947
|
+
}
|
2948
|
+
},
|
2949
|
+
|
2950
|
+
draw: function(event) {
|
2951
|
+
Event.stop(event);
|
2952
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
2953
|
+
var style = this.element.style;
|
2954
|
+
|
2955
|
+
if (this.currentDirection.indexOf('n') != -1) {
|
2956
|
+
if (this.restOffset[1] >= pointer[1]) return;
|
2957
|
+
var pointerMoved = this.startY - pointer[1];
|
2958
|
+
// var margin = Element.getStyle(this.element, 'margin-top') || "0";
|
2959
|
+
var newHeight = this.map(this.startHeight + pointerMoved);
|
2960
|
+
if (newHeight > this.options.minHeight) {
|
2961
|
+
style.height = newHeight + "px";
|
2962
|
+
style.top = this.map(this.startTop - pointerMoved) + "px";
|
2963
|
+
}
|
2964
|
+
}
|
2965
|
+
if (this.currentDirection.indexOf('w') != -1) {
|
2966
|
+
var pointerMoved = this.map(this.startX - pointer[0]);
|
2967
|
+
var margin = Element.getStyle(this.element, 'margin-left') || "0";
|
2968
|
+
var newWidth = this.startWidth + pointerMoved;
|
2969
|
+
if (newWidth > this.options.minWidth) {
|
2970
|
+
style.left = (this.startLeft - pointerMoved - parseInt(margin)) + "px";
|
2971
|
+
style.width = newWidth + "px";
|
2972
|
+
}
|
2973
|
+
}
|
2974
|
+
if (this.currentDirection.indexOf('s') != -1) {
|
2975
|
+
var bottom = this.restDimensions.height + this.restOffset[1];
|
2976
|
+
var pointerMoved = pointer[1] - this.startY;
|
2977
|
+
if (bottom <= pointer[1]) return;
|
2978
|
+
var newHeight = this.map(this.startHeight + pointer[1] - this.startY);
|
2979
|
+
if (newHeight > this.options.minHeight) {
|
2980
|
+
style.height = newHeight + "px";
|
2981
|
+
// style.top = this.startTop + "px";
|
2982
|
+
}
|
2983
|
+
}
|
2984
|
+
if (this.currentDirection.indexOf('e') != -1) {
|
2985
|
+
var newWidth = this.map(this.startWidth + pointer[0] - this.startX);
|
2986
|
+
if (newWidth > this.options.minWidth) {
|
2987
|
+
style.width = newWidth + "px";
|
2988
|
+
}
|
2989
|
+
}
|
2990
|
+
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
|
2991
|
+
this.options.change(this.element);
|
2992
|
+
},
|
2993
|
+
|
2994
|
+
directions: function(event) {
|
2995
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
2996
|
+
var offsets = Position.cumulativeOffset(this.element);
|
2997
|
+
var bodyScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
2998
|
+
var scroll = Position.realOffset(this.element)[1] - bodyScrollTop;
|
2999
|
+
|
3000
|
+
var cursor = '';
|
3001
|
+
if (this.between(pointer[1] - offsets[1] + scroll, 0, this.options.top)) cursor += 'n';
|
3002
|
+
if (this.between((offsets[1] + this.element.offsetHeight) - pointer[1] - scroll, 0, this.options.bottom)) cursor += 's';
|
3003
|
+
if (this.between(pointer[0] - offsets[0], 0, this.options.left)) cursor += 'w';
|
3004
|
+
if (this.between((offsets[0] + this.element.offsetWidth) - pointer[0], 0, this.options.right)) cursor += 'e';
|
3005
|
+
|
3006
|
+
return cursor;
|
3007
|
+
},
|
3008
|
+
|
3009
|
+
map: function(length) {
|
3010
|
+
return Math.round(length / this.options.distance) * this.options.distance;
|
3011
|
+
}
|
3012
|
+
});
|