guara 0.0.1.rc
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/.travis.yml +33 -0
- data/Gemfile +82 -0
- data/Gemfile.lock +323 -0
- data/Guardfile +32 -0
- data/MIT-LICENSE +20 -0
- data/README.md +8 -0
- data/Rakefile +7 -0
- data/app/admin/business_activities.rb +3 -0
- data/app/admin/business_departments.rb +3 -0
- data/app/admin/business_segments.rb +13 -0
- data/app/admin/cities.rb +3 -0
- data/app/admin/company_businesses.rb +3 -0
- data/app/admin/dashboard.rb +39 -0
- data/app/admin/districts.rb +3 -0
- data/app/admin/states.rb +3 -0
- data/app/admin/task_types.rb +3 -0
- data/app/admin/user_groups.rb +3 -0
- data/app/admin/users.rb +3 -0
- data/app/assets/images/close.gif +0 -0
- data/app/assets/images/custom/logo.png +0 -0
- data/app/assets/images/custom/nav_logo.png +0 -0
- data/app/assets/images/custom/nav_logo.psd +0 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/javascripts/active_admin.js +5 -0
- data/app/assets/javascripts/application.js +97 -0
- data/app/assets/javascripts/business_departments.js.coffee +3 -0
- data/app/assets/javascripts/company_businesses.js.coffee +3 -0
- data/app/assets/javascripts/crm.js.coffee +14 -0
- data/app/assets/javascripts/fcbk.js +556 -0
- data/app/assets/javascripts/jquery-ui-timepicker-addon.js +1326 -0
- data/app/assets/javascripts/jquery.mask.1.3.js +7 -0
- data/app/assets/javascripts/jquery.multiselect.filter.xjs +173 -0
- data/app/assets/javascripts/jquery.multiselect.xjs +668 -0
- data/app/assets/javascripts/system_task_status.js.coffee +3 -0
- data/app/assets/javascripts/tests/ajaxes.js.coffee +3 -0
- data/app/assets/stylesheets/abilities.css.scss +6 -0
- data/app/assets/stylesheets/active_admin.css.scss +65 -0
- data/app/assets/stylesheets/application.css +19 -0
- data/app/assets/stylesheets/business_departments.css.scss +3 -0
- data/app/assets/stylesheets/company_businesses.css.scss +3 -0
- data/app/assets/stylesheets/custom.css.scss +322 -0
- data/app/assets/stylesheets/customer.scss +7 -0
- data/app/assets/stylesheets/fcbk.css +165 -0
- data/app/assets/stylesheets/guara.css.scss +159 -0
- data/app/assets/stylesheets/jquery-ui.css +567 -0
- data/app/assets/stylesheets/jquery_bootstrap.css.scss +92 -0
- data/app/assets/stylesheets/jquery_multiselect_filter.xcss +3 -0
- data/app/assets/stylesheets/scaffolds.css.scss +42 -0
- data/app/assets/stylesheets/users.css.scss +10 -0
- data/app/controllers/abilities_controller.rb +37 -0
- data/app/controllers/application_controller.rb +12 -0
- data/app/controllers/business_activities_controller.rb +87 -0
- data/app/controllers/business_departments_controller.rb +90 -0
- data/app/controllers/business_segments_controller.rb +88 -0
- data/app/controllers/company_businesses_controller.rb +46 -0
- data/app/controllers/contacts_controller.rb +105 -0
- data/app/controllers/customers_controller.rb +117 -0
- data/app/controllers/microposts_controller.rb +31 -0
- data/app/controllers/sessions_controller.rb +32 -0
- data/app/controllers/static_pages_controller.rb +23 -0
- data/app/controllers/system_task_status_controller.rb +84 -0
- data/app/controllers/task_feedbacks_controller.rb +6 -0
- data/app/controllers/task_types_controller.rb +85 -0
- data/app/controllers/tasks_controller.rb +107 -0
- data/app/controllers/tests/ajaxes_controller.rb +115 -0
- data/app/controllers/tests/lab_ajax_controller.rb +27 -0
- data/app/controllers/users_controller.rb +62 -0
- data/app/helpers/ability_helper.rb +15 -0
- data/app/helpers/application_helper.rb +32 -0
- data/app/helpers/business_activities_helper.rb +2 -0
- data/app/helpers/business_departments_helper.rb +2 -0
- data/app/helpers/business_segments_helper.rb +2 -0
- data/app/helpers/company_businesses_helper.rb +2 -0
- data/app/helpers/contacts_helper.rb +2 -0
- data/app/helpers/customers_helper.rb +23 -0
- data/app/helpers/email_helper.rb +8 -0
- data/app/helpers/form_ajax_helper.rb +8 -0
- data/app/helpers/guara_views_helper.rb +38 -0
- data/app/helpers/locale_helper.rb +24 -0
- data/app/helpers/menu_helper.rb +55 -0
- data/app/helpers/sessions_helper.rb +56 -0
- data/app/helpers/tasks_helper.rb +20 -0
- data/app/helpers/tests/ajaxes_helper.rb +2 -0
- data/app/helpers/user_abilities_helper.rb +12 -0
- data/app/helpers/users_helper.rb +29 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/ability.rb +52 -0
- data/app/models/address.rb +7 -0
- data/app/models/business_activity.rb +5 -0
- data/app/models/business_department.rb +3 -0
- data/app/models/business_segment.rb +5 -0
- data/app/models/city.rb +7 -0
- data/app/models/company_business.rb +6 -0
- data/app/models/contact.rb +69 -0
- data/app/models/customer.rb +117 -0
- data/app/models/customer_activity.rb +9 -0
- data/app/models/customer_financial.rb +10 -0
- data/app/models/customer_has_customers.rb +7 -0
- data/app/models/customer_pf.rb +13 -0
- data/app/models/customer_pj.rb +71 -0
- data/app/models/customer_pj_has_customers_pj.rb +7 -0
- data/app/models/customer_product.rb +3 -0
- data/app/models/customer_segment.rb +9 -0
- data/app/models/district.rb +6 -0
- data/app/models/email.rb +7 -0
- data/app/models/micropost.rb +10 -0
- data/app/models/relationship.rb +9 -0
- data/app/models/search.rb +17 -0
- data/app/models/state.rb +3 -0
- data/app/models/system_ability.rb +16 -0
- data/app/models/system_module.rb +16 -0
- data/app/models/system_task_resolution.rb +26 -0
- data/app/models/system_task_status.rb +19 -0
- data/app/models/task.rb +76 -0
- data/app/models/task_feedback.rb +11 -0
- data/app/models/task_type.rb +12 -0
- data/app/models/tests.rb +5 -0
- data/app/models/tests/ajax.rb +3 -0
- data/app/models/user.rb +126 -0
- data/app/models/user_ability.rb +23 -0
- data/app/models/user_group.rb +9 -0
- data/app/models/user_type.rb +9 -0
- data/app/models/users_has_groups.rb +9 -0
- data/app/validators/customer_cnpj_validator.rb +14 -0
- data/app/validators/email_validator.rb +21 -0
- data/app/views/abilities/index.html.erb +25 -0
- data/app/views/active_extend/_one_to_many_inputs.html.erb +7 -0
- data/app/views/active_extend/_one_to_many_inputs_fields.html.erb +10 -0
- data/app/views/active_extend/_one_to_many_inputs_with_glyph.html.erb +21 -0
- data/app/views/business_activities/_business_activity.html.erb +0 -0
- data/app/views/business_activities/_form.html.erb +25 -0
- data/app/views/business_activities/edit.html.erb +6 -0
- data/app/views/business_activities/index.html.erb +33 -0
- data/app/views/business_activities/new.html.erb +5 -0
- data/app/views/business_activities/show.html.erb +15 -0
- data/app/views/business_departments/_form.html.erb +10 -0
- data/app/views/business_departments/edit.html.erb +6 -0
- data/app/views/business_departments/index.html.erb +33 -0
- data/app/views/business_departments/new.html.erb +5 -0
- data/app/views/business_departments/show.html.erb +15 -0
- data/app/views/business_segments/_business_segment.html.erb +8 -0
- data/app/views/business_segments/_form.html.erb +25 -0
- data/app/views/business_segments/edit.html.erb +6 -0
- data/app/views/business_segments/index.html.erb +33 -0
- data/app/views/business_segments/new.html.erb +5 -0
- data/app/views/business_segments/show.html.erb +15 -0
- data/app/views/company_businesses/_form.html.erb +10 -0
- data/app/views/company_businesses/edit.html.erb +6 -0
- data/app/views/company_businesses/index.html.erb +25 -0
- data/app/views/company_businesses/new.html.erb +5 -0
- data/app/views/company_businesses/show.html.erb +15 -0
- data/app/views/contacts/_form.html.erb +53 -0
- data/app/views/contacts/_header.html.erb +3 -0
- data/app/views/contacts/_list.html.erb +46 -0
- data/app/views/contacts/_side_panel.html.erb +61 -0
- data/app/views/contacts/edit.html.erb +6 -0
- data/app/views/contacts/index.html.erb +72 -0
- data/app/views/contacts/new.html.erb +5 -0
- data/app/views/contacts/show.html.erb +52 -0
- data/app/views/customers/_businesses_done.html.erb +18 -0
- data/app/views/customers/_customer_segment.html.erb +9 -0
- data/app/views/customers/_form.html.erb +177 -0
- data/app/views/customers/_form_search.html.erb +119 -0
- data/app/views/customers/_modules.html.erb +6 -0
- data/app/views/customers/_navbar.html.erb +23 -0
- data/app/views/customers/_segment.html.erb +10 -0
- data/app/views/customers/edit.html.erb +8 -0
- data/app/views/customers/index.html.erb +46 -0
- data/app/views/customers/new.pj.html.erb +4 -0
- data/app/views/customers/show.pj.html.erb +200 -0
- data/app/views/devise/confirmations/new.html.erb +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +16 -0
- data/app/views/devise/passwords/new.html.erb +12 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +24 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/app/views/emails/_email_fields.html.erb +1 -0
- data/app/views/layouts/_active_admin_footer.html.erb +4 -0
- data/app/views/layouts/_active_admin_header.html.erb +5 -0
- data/app/views/layouts/_footer.html.erb +12 -0
- data/app/views/layouts/_header.html.erb +51 -0
- data/app/views/layouts/_shim.html.erb +3 -0
- data/app/views/layouts/active_admin.html.arb +1 -0
- data/app/views/layouts/application.html.erb +24 -0
- data/app/views/microposts/_micropost.html.erb +11 -0
- data/app/views/sessions/new.html.erb +18 -0
- data/app/views/shared/_calendar.html.erb +17 -0
- data/app/views/shared/_error_messages.html.erb +13 -0
- data/app/views/shared/_feed.html.erb +10 -0
- data/app/views/shared/_feed_item.html.erb +15 -0
- data/app/views/shared/_micropost_form.html.erb +7 -0
- data/app/views/shared/_multi_selection.html.erb +16 -0
- data/app/views/shared/_multi_selection.html_checkbox.erb +11 -0
- data/app/views/shared/_multi_selection_autocomple.html.erb +5 -0
- data/app/views/shared/_notifies.html.erb +17 -0
- data/app/views/shared/_user_info.html.erb +14 -0
- data/app/views/static_pages/about.html.erb +5 -0
- data/app/views/static_pages/contact.html.erb +5 -0
- data/app/views/static_pages/help.html.erb +5 -0
- data/app/views/static_pages/home.html.erb +37 -0
- data/app/views/static_pages/news.html.erb +2 -0
- data/app/views/system_task_status/_form.html.erb +9 -0
- data/app/views/system_task_status/edit.html.erb +6 -0
- data/app/views/system_task_status/index.html.erb +23 -0
- data/app/views/system_task_status/new.html.erb +5 -0
- data/app/views/system_task_status/show.html.erb +10 -0
- data/app/views/task_feedbacks/_list.html.erb +51 -0
- data/app/views/task_feedbacks/_side_form.html.erb +56 -0
- data/app/views/task_feedbacks/_side_panel.html.erb +64 -0
- data/app/views/task_types/_form.html.erb +10 -0
- data/app/views/task_types/edit.html.erb +6 -0
- data/app/views/task_types/index.html.erb +23 -0
- data/app/views/task_types/new.html.erb +5 -0
- data/app/views/task_types/show.html.erb +10 -0
- data/app/views/tasks/_form.html.erb +52 -0
- data/app/views/tasks/_header.html.erb +3 -0
- data/app/views/tasks/_list.html.erb +50 -0
- data/app/views/tasks/_side_panel.html.erb +64 -0
- data/app/views/tasks/create.js.erb +1 -0
- data/app/views/tasks/edit.html.erb +6 -0
- data/app/views/tasks/index.html.erb +61 -0
- data/app/views/tasks/new.html.erb +5 -0
- data/app/views/tasks/show.html.erb +46 -0
- data/app/views/tests/ajaxes/_form.html.erb +10 -0
- data/app/views/tests/ajaxes/_list.html.erb +6 -0
- data/app/views/tests/ajaxes/add_and_update.html.erb +22 -0
- data/app/views/tests/ajaxes/all.js.erb +2 -0
- data/app/views/tests/ajaxes/edit.html.erb +6 -0
- data/app/views/tests/ajaxes/index.html.erb +25 -0
- data/app/views/tests/ajaxes/new.html.erb +5 -0
- data/app/views/tests/ajaxes/show.html.erb +15 -0
- data/app/views/tests/js.js +51 -0
- data/app/views/tests/lab_ajax/multiselection.html.erb +84 -0
- data/app/views/users/_user.html.erb +8 -0
- data/app/views/users/edit.html.erb +27 -0
- data/app/views/users/index.html.erb +9 -0
- data/app/views/users/new.html.erb +24 -0
- data/app/views/users/show.html.erb +26 -0
- data/bundle +0 -0
- data/config.ru +4 -0
- data/config/application.rb +73 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +38 -0
- data/config/environment.rb +31 -0
- data/config/environments/development.rb +42 -0
- data/config/environments/production.rb +68 -0
- data/config/environments/test.rb +39 -0
- data/config/guara/menus.rb +34 -0
- data/config/initializers/active_admin.rb +210 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cmgb_rules.rb +2 -0
- data/config/initializers/devise.rb +216 -0
- data/config/initializers/formtastic.rb +77 -0
- data/config/initializers/inflections.rb +19 -0
- data/config/initializers/json_paches_utf8.rb +13 -0
- data/config/initializers/kaminari.rb +21 -0
- data/config/initializers/locale.rb +7 -0
- data/config/initializers/meta_search.rb +10 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/secret_token.rb +7 -0
- data/config/initializers/session_store.rb +8 -0
- data/config/initializers/string.rb +9 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/locales/devise.pt-BR.yml +62 -0
- data/config/locales/pt-BR.yml +404 -0
- data/config/routes.rb +129 -0
- data/db/migrate/20120610142404_create_users.rb +10 -0
- data/db/migrate/20120610183820_add_index_to_users_email.rb +5 -0
- data/db/migrate/20120610185217_add_password_digest_to_users.rb +5 -0
- data/db/migrate/20120612000411_add_remember_token_to_users.rb +6 -0
- data/db/migrate/20120616162515_add_admin_to_users.rb +5 -0
- data/db/migrate/20120616215835_create_microposts.rb +11 -0
- data/db/migrate/20120617224530_create_relationships.rb +14 -0
- data/db/migrate/20120621095918_create_customers.rb +36 -0
- data/db/migrate/20120621100528_create_customer_pfs.rb +14 -0
- data/db/migrate/20120621100534_create_customer_pjs.rb +13 -0
- data/db/migrate/20120621100557_create_emails.rb +13 -0
- data/db/migrate/20120621100618_create_tasks.rb +26 -0
- data/db/migrate/20120621100639_create_customer_products.rb +14 -0
- data/db/migrate/20120621100705_create_districts.rb +11 -0
- data/db/migrate/20120621100720_create_cities.rb +11 -0
- data/db/migrate/20120624192444_create_business_segments.rb +10 -0
- data/db/migrate/20120624224245_create_business_activities.rb +13 -0
- data/db/migrate/20120628092744_create_customer_activities.rb +9 -0
- data/db/migrate/20120628092754_create_customer_segments.rb +9 -0
- data/db/migrate/20120703102859_create_states.rb +10 -0
- data/db/migrate/20120705121011_create_contacts.rb +18 -0
- data/db/migrate/20120711233943_add_devise_to_users.rb +56 -0
- data/db/migrate/20120723102847_create_user_abilities.rb +10 -0
- data/db/migrate/20120723104500_create_system_modules.rb +9 -0
- data/db/migrate/20120723104639_create_system_abilities.rb +9 -0
- data/db/migrate/20120728181903_create_user_groups.rb +10 -0
- data/db/migrate/20120729112600_create_users_has_groups.rb +14 -0
- data/db/migrate/20120729121922_add_groups_to_users.rb +6 -0
- data/db/migrate/20120910002835_create_system_task_status.rb +7 -0
- data/db/migrate/20120910010153_create_system_task_resolutions.rb +7 -0
- data/db/migrate/20120911021535_create_task_types.rb +10 -0
- data/db/migrate/20120911070836_create_task_feedbacks.rb +14 -0
- data/db/migrate/20120924022719_create_tests_ajaxes.rb +10 -0
- data/db/migrate/20121007131035_create_business_departments.rb +10 -0
- data/db/migrate/20121013120849_add_notes_and_other_contacts_to_customer.rb +5 -0
- data/db/migrate/20121014201255_create_company_businesses.rb +10 -0
- data/db/migrate/20121014202449_add_company_business_to_task_type.rb +6 -0
- data/db/migrate/20121014212430_add_primary_company_business_to_user.rb +5 -0
- data/db/migrate/20121015101844_add_parent_id_to_system_task_resolution.rb +5 -0
- data/db/migrate/20121026231241_create_customer_has_customers.rb +10 -0
- data/db/migrate/20121026232755_create_customer_pj_has_customers_pjs.rb +10 -0
- data/db/migrate/20121029094047_create_admin_notes.rb +17 -0
- data/db/migrate/20121029094048_move_admin_notes_to_comments.rb +25 -0
- data/db/migrate/20121103183646_add_enabled_to_cities.rb +5 -0
- data/db/migrate/20121104135014_create_customer_financials.rb +17 -0
- data/db/migrate/20121104141751_create_addresses.rb +19 -0
- data/db/migrate/20121205150619_add_type_id_to_users.rb +5 -0
- data/db/schema.rb~ +378 -0
- data/db/seeds.rb +99 -0
- data/gemfiles/Gemfile.rails.3.2.x +82 -0
- data/guara.gemspec +31 -0
- data/lib/active_extend/README.md +19 -0
- data/lib/active_extend/active_disablable.rb +59 -0
- data/lib/active_extend/string_helper.rb +9 -0
- data/lib/active_migration.rb +4 -0
- data/lib/active_migration/converters/rtf_to_html.rb +123 -0
- data/lib/active_migration/dictionary.rb +19 -0
- data/lib/active_migration/migration.rb +211 -0
- data/lib/active_migration/schemas.rb +143 -0
- data/lib/active_migration/spelling_fix.rb +20 -0
- data/lib/active_migration/transformer/grouped_field_fixed_spelling.rb +110 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/cmgb_rules/app/models/task.rb +19 -0
- data/lib/guara/version.rb +3 -0
- data/lib/spec/asserts/sheet1.xls +0 -0
- data/lib/spec/lib/active_migration_schemas_spec.rb +40 -0
- data/lib/spec/lib/active_migration_spec.rb +78 -0
- data/lib/spec/spec_helper.rb +121 -0
- data/lib/spec/support/active_migration_helper.rb +109 -0
- data/lib/spec/support/utilities.rb +7 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/add_privilegies.rake +6 -0
- data/lib/tasks/external_migration.rake +22 -0
- data/lib/tasks/sample_data.rake +77 -0
- data/lib/tasks/smaple_data_test.rake +13 -0
- data/lib/templates/erb/scaffold/_form.html.erb +11 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +25 -0
- data/public/data.txt +1 -0
- data/public/favicon.ico +0 -0
- data/public/javascripts/autocomplete-rails.js +16 -0
- data/public/robots.txt +5 -0
- data/script/create_db +5 -0
- data/script/rails +6 -0
- data/script/recreate_db +5 -0
- data/script/recreate_db.bat +9 -0
- data/script/recreate_db_test +5 -0
- data/script/recreate_development_db +10 -0
- data/spec/controllers/business_activities_controller_spec.disabled +167 -0
- data/spec/controllers/business_departments_controller_spec.disabled +164 -0
- data/spec/controllers/business_segments_controller_spec.disabled +165 -0
- data/spec/controllers/company_businesses_controller_spec.disabled +164 -0
- data/spec/controllers/system_task_status_controller_spec.disabled +164 -0
- data/spec/controllers/system_task_status_spec.disabled +11 -0
- data/spec/controllers/task_types_controller_spec.disabled +164 -0
- data/spec/controllers/tasks_controller_spec.disabled +23 -0
- data/spec/controllers/tests/ajaxes_controller_spec.disabled +164 -0
- data/spec/factories.rb +101 -0
- data/spec/factories/addresses.rb +13 -0
- data/spec/factories/business_departments.rb +8 -0
- data/spec/factories/company_businesses.rb +8 -0
- data/spec/factories/customer_financials.rb +11 -0
- data/spec/factories/customer_has_customers.rb +8 -0
- data/spec/factories/customer_pj_has_customers_pjs.rb +8 -0
- data/spec/factories/system_task_resolutions.rb +7 -0
- data/spec/factories/system_task_status.rb +7 -0
- data/spec/factories/task.rb +17 -0
- data/spec/factories/task_feedbacks.rb +19 -0
- data/spec/factories/task_types.rb +8 -0
- data/spec/factories/tests_ajaxes.rb +8 -0
- data/spec/helpers/business_activities_helper_spec.rb +15 -0
- data/spec/helpers/business_departments_helper_spec.rb +15 -0
- data/spec/helpers/business_segments_helper_spec.rb +15 -0
- data/spec/helpers/company_businesses_helper_spec.rb +15 -0
- data/spec/helpers/customers/contacts_helper_spec.rb +15 -0
- data/spec/helpers/menu_helper_spec.rb +25 -0
- data/spec/helpers/tests/ajaxes_helper_spec.rb +15 -0
- data/spec/helpers/users_helpers_spec.rb +32 -0
- data/spec/models/address_spec.rb +5 -0
- data/spec/models/business_activity_spec.rb +5 -0
- data/spec/models/business_department_spec.rb +5 -0
- data/spec/models/business_segment_spec.rb +5 -0
- data/spec/models/city_spec.rb +5 -0
- data/spec/models/company_business_spec.rb +19 -0
- data/spec/models/contact_spec.rb +60 -0
- data/spec/models/customer_activity_spec.rb +5 -0
- data/spec/models/customer_financial_spec.rb +48 -0
- data/spec/models/customer_has_customers_spec.rb +18 -0
- data/spec/models/customer_pf_spec.rb +24 -0
- data/spec/models/customer_pj_has_customers_pj_spec.rb +34 -0
- data/spec/models/customer_pj_spec.rb +72 -0
- data/spec/models/customer_product_spec.rb +5 -0
- data/spec/models/customer_segment_spec.rb +5 -0
- data/spec/models/customer_spec.rb +135 -0
- data/spec/models/district_spec.rb +5 -0
- data/spec/models/emails_spec.rb +24 -0
- data/spec/models/micropost_spec.rb +49 -0
- data/spec/models/relationship_spec.rb +38 -0
- data/spec/models/state_spec.rb +5 -0
- data/spec/models/system_ability_spec.rb +5 -0
- data/spec/models/system_module_spec.rb +5 -0
- data/spec/models/system_task_resolution_spec.rb +17 -0
- data/spec/models/system_task_status_spec.rb +17 -0
- data/spec/models/task_feedback_spec.rb +46 -0
- data/spec/models/task_spec.rb +176 -0
- data/spec/models/task_type_spec.rb +27 -0
- data/spec/models/tests/ajax_spec.rb +5 -0
- data/spec/models/user_ability_spec.rb +35 -0
- data/spec/models/user_group_spec.rb +26 -0
- data/spec/models/user_spec.rb +274 -0
- data/spec/models/users_has_groups_spec.rb +29 -0
- data/spec/requests/authentication_pages_spec.rb +157 -0
- data/spec/requests/business_activities_spec.rb +7 -0
- data/spec/requests/business_departments_spec.rb +7 -0
- data/spec/requests/business_segments_spec.rb +7 -0
- data/spec/requests/company_businesses_spec.rb +11 -0
- data/spec/requests/customer_contacts_pages_spec.rb +96 -0
- data/spec/requests/customer_pages_spec.rb +60 -0
- data/spec/requests/micropost_pages_spec.rb +58 -0
- data/spec/requests/static_pages_spec.rb +57 -0
- data/spec/requests/task_pages_spec.rb +124 -0
- data/spec/requests/tests/tests_ajaxes_spec.rb +11 -0
- data/spec/requests/user_abilities_pages_spec.rb +73 -0
- data/spec/requests/user_pages_spec.rb +116 -0
- data/spec/routing/business_activities_routing_spec.rb +35 -0
- data/spec/routing/business_departments_routing_spec.rb +35 -0
- data/spec/routing/business_segments_routing_spec.rb +35 -0
- data/spec/routing/company_businesses_routing_spec.rb +35 -0
- data/spec/routing/system_task_status_routing_spec.rb +35 -0
- data/spec/routing/task_types_routing_spec.rb +35 -0
- data/spec/routing/tests/ajaxes_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +123 -0
- data/spec/support/custom_matchers.rb +9 -0
- data/spec/support/utilities.rb +120 -0
- data/spec/views/business_departments/edit.html.erb_spec.rb +20 -0
- data/spec/views/business_departments/index.html.erb_spec.disabled +23 -0
- data/spec/views/business_departments/new.html.erb_spec.rb +20 -0
- data/spec/views/business_departments/show.html.erb_spec.rb +17 -0
- data/spec/views/company_businesses/edit.html.erb_spec.rb +20 -0
- data/spec/views/company_businesses/index.html.erb_spec.rb +23 -0
- data/spec/views/company_businesses/new.html.erb_spec.rb +20 -0
- data/spec/views/company_businesses/show.html.erb_spec.rb +17 -0
- data/spec/views/task_types/edit.html.erb_spec.rb +18 -0
- data/spec/views/task_types/index.html.erb_spec.rb +20 -0
- data/spec/views/task_types/new.html.erb_spec.rb +18 -0
- data/spec/views/task_types/show.html.erb_spec.rb +15 -0
- data/test/fixtures/.gitkeep +0 -0
- data/test/functional/.gitkeep +0 -0
- data/test/integration/.gitkeep +0 -0
- data/test/performance/browsing_test.rb +12 -0
- data/test/test_helper.rb +13 -0
- data/test/unit/.gitkeep +0 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/active_admin/_base.css.scss +45 -0
- data/vendor/assets/stylesheets/active_admin/_forms.css.scss +270 -0
- data/vendor/assets/stylesheets/active_admin/_header.css.scss +137 -0
- data/vendor/assets/stylesheets/active_admin/_mixins.css.scss +1 -0
- data/vendor/assets/stylesheets/active_admin/_typography.css.scss +100 -0
- data/vendor/assets/stylesheets/active_admin/components/_batch_actions.css.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/components/_blank_slates.scss +31 -0
- data/vendor/assets/stylesheets/active_admin/components/_breadcrumbs.scss +20 -0
- data/vendor/assets/stylesheets/active_admin/components/_buttons.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/components/_columns.scss +3 -0
- data/vendor/assets/stylesheets/active_admin/components/_comments.css.scss +40 -0
- data/vendor/assets/stylesheets/active_admin/components/_date_picker.css.scss +123 -0
- data/vendor/assets/stylesheets/active_admin/components/_dropdown_menu.scss +151 -0
- data/vendor/assets/stylesheets/active_admin/components/_flash_messages.css.scss +39 -0
- data/vendor/assets/stylesheets/active_admin/components/_grid.scss +9 -0
- data/vendor/assets/stylesheets/active_admin/components/_links.scss +5 -0
- data/vendor/assets/stylesheets/active_admin/components/_pagination.scss +34 -0
- data/vendor/assets/stylesheets/active_admin/components/_panels.scss +6 -0
- data/vendor/assets/stylesheets/active_admin/components/_popovers.css.scss +123 -0
- data/vendor/assets/stylesheets/active_admin/components/_scopes.scss +10 -0
- data/vendor/assets/stylesheets/active_admin/components/_status_tags.scss +12 -0
- data/vendor/assets/stylesheets/active_admin/components/_table_tools.css.scss +94 -0
- data/vendor/assets/stylesheets/active_admin/components/_tables.css.scss +108 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_all.css.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_buttons.css.scss +66 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_gradients.css.scss +37 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_icons.css.scss +24 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_reset.css.scss +165 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_rounded.css.scss +43 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_sections.css.scss +36 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_shadows.css.scss +22 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_typography.scss +3 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_utilities.scss +26 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_variables.css.scss +24 -0
- data/vendor/assets/stylesheets/active_admin/pages/_dashboard.scss +5 -0
- data/vendor/assets/stylesheets/active_admin/pages/_logged_out.scss +44 -0
- data/vendor/assets/stylesheets/active_admin/print.css.scss +290 -0
- data/vendor/assets/stylesheets/active_admin/structure/_footer.scss +14 -0
- data/vendor/assets/stylesheets/active_admin/structure/_main_structure.scss +26 -0
- data/vendor/assets/stylesheets/active_admin/structure/_title_bar.scss +44 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +731 -0
@@ -0,0 +1,1326 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery timepicker addon
|
3
|
+
* By: Trent Richardson [http://trentrichardson.com]
|
4
|
+
* Version 0.9.9
|
5
|
+
* Last Modified: 02/05/2012
|
6
|
+
*
|
7
|
+
* Copyright 2012 Trent Richardson
|
8
|
+
* Dual licensed under the MIT and GPL licenses.
|
9
|
+
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
|
10
|
+
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
|
11
|
+
*
|
12
|
+
* HERES THE CSS:
|
13
|
+
* .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
|
14
|
+
* .ui-timepicker-div dl { text-align: left; }
|
15
|
+
* .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
|
16
|
+
* .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
|
17
|
+
* .ui-timepicker-div td { font-size: 90%; }
|
18
|
+
* .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
|
19
|
+
*/
|
20
|
+
|
21
|
+
(function($) {
|
22
|
+
|
23
|
+
$.extend($.ui, { timepicker: { version: "0.9.9" } });
|
24
|
+
|
25
|
+
/* Time picker manager.
|
26
|
+
Use the singleton instance of this class, $.timepicker, to interact with the time picker.
|
27
|
+
Settings for (groups of) time pickers are maintained in an instance object,
|
28
|
+
allowing multiple different settings on the same page. */
|
29
|
+
|
30
|
+
function Timepicker() {
|
31
|
+
this.regional = []; // Available regional settings, indexed by language code
|
32
|
+
this.regional[''] = { // Default regional settings
|
33
|
+
currentText: 'Now',
|
34
|
+
closeText: 'Done',
|
35
|
+
ampm: false,
|
36
|
+
amNames: ['AM', 'A'],
|
37
|
+
pmNames: ['PM', 'P'],
|
38
|
+
timeFormat: 'hh:mm tt',
|
39
|
+
timeSuffix: '',
|
40
|
+
timeOnlyTitle: 'Choose Time',
|
41
|
+
timeText: 'Time',
|
42
|
+
hourText: 'Hour',
|
43
|
+
minuteText: 'Minute',
|
44
|
+
secondText: 'Second',
|
45
|
+
millisecText: 'Millisecond',
|
46
|
+
timezoneText: 'Time Zone'
|
47
|
+
};
|
48
|
+
this._defaults = { // Global defaults for all the datetime picker instances
|
49
|
+
showButtonPanel: true,
|
50
|
+
timeOnly: false,
|
51
|
+
showHour: true,
|
52
|
+
showMinute: true,
|
53
|
+
showSecond: false,
|
54
|
+
showMillisec: false,
|
55
|
+
showTimezone: false,
|
56
|
+
showTime: true,
|
57
|
+
stepHour: 1,
|
58
|
+
stepMinute: 1,
|
59
|
+
stepSecond: 1,
|
60
|
+
stepMillisec: 1,
|
61
|
+
hour: 0,
|
62
|
+
minute: 0,
|
63
|
+
second: 0,
|
64
|
+
millisec: 0,
|
65
|
+
timezone: '+0000',
|
66
|
+
hourMin: 0,
|
67
|
+
minuteMin: 0,
|
68
|
+
secondMin: 0,
|
69
|
+
millisecMin: 0,
|
70
|
+
hourMax: 23,
|
71
|
+
minuteMax: 59,
|
72
|
+
secondMax: 59,
|
73
|
+
millisecMax: 999,
|
74
|
+
minDateTime: null,
|
75
|
+
maxDateTime: null,
|
76
|
+
onSelect: null,
|
77
|
+
hourGrid: 0,
|
78
|
+
minuteGrid: 0,
|
79
|
+
secondGrid: 0,
|
80
|
+
millisecGrid: 0,
|
81
|
+
alwaysSetTime: true,
|
82
|
+
separator: ' ',
|
83
|
+
altFieldTimeOnly: true,
|
84
|
+
showTimepicker: true,
|
85
|
+
timezoneIso8609: false,
|
86
|
+
timezoneList: null,
|
87
|
+
addSliderAccess: false,
|
88
|
+
sliderAccessArgs: null
|
89
|
+
};
|
90
|
+
$.extend(this._defaults, this.regional['']);
|
91
|
+
};
|
92
|
+
|
93
|
+
$.extend(Timepicker.prototype, {
|
94
|
+
$input: null,
|
95
|
+
$altInput: null,
|
96
|
+
$timeObj: null,
|
97
|
+
inst: null,
|
98
|
+
hour_slider: null,
|
99
|
+
minute_slider: null,
|
100
|
+
second_slider: null,
|
101
|
+
millisec_slider: null,
|
102
|
+
timezone_select: null,
|
103
|
+
hour: 0,
|
104
|
+
minute: 0,
|
105
|
+
second: 0,
|
106
|
+
millisec: 0,
|
107
|
+
timezone: '+0000',
|
108
|
+
hourMinOriginal: null,
|
109
|
+
minuteMinOriginal: null,
|
110
|
+
secondMinOriginal: null,
|
111
|
+
millisecMinOriginal: null,
|
112
|
+
hourMaxOriginal: null,
|
113
|
+
minuteMaxOriginal: null,
|
114
|
+
secondMaxOriginal: null,
|
115
|
+
millisecMaxOriginal: null,
|
116
|
+
ampm: '',
|
117
|
+
formattedDate: '',
|
118
|
+
formattedTime: '',
|
119
|
+
formattedDateTime: '',
|
120
|
+
timezoneList: null,
|
121
|
+
|
122
|
+
/* Override the default settings for all instances of the time picker.
|
123
|
+
@param settings object - the new settings to use as defaults (anonymous object)
|
124
|
+
@return the manager object */
|
125
|
+
setDefaults: function(settings) {
|
126
|
+
extendRemove(this._defaults, settings || {});
|
127
|
+
return this;
|
128
|
+
},
|
129
|
+
|
130
|
+
//########################################################################
|
131
|
+
// Create a new Timepicker instance
|
132
|
+
//########################################################################
|
133
|
+
_newInst: function($input, o) {
|
134
|
+
var tp_inst = new Timepicker(),
|
135
|
+
inlineSettings = {};
|
136
|
+
|
137
|
+
for (var attrName in this._defaults) {
|
138
|
+
var attrValue = $input.attr('time:' + attrName);
|
139
|
+
if (attrValue) {
|
140
|
+
try {
|
141
|
+
inlineSettings[attrName] = eval(attrValue);
|
142
|
+
} catch (err) {
|
143
|
+
inlineSettings[attrName] = attrValue;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
|
148
|
+
beforeShow: function(input, dp_inst) {
|
149
|
+
if ($.isFunction(o.beforeShow))
|
150
|
+
return o.beforeShow(input, dp_inst, tp_inst);
|
151
|
+
},
|
152
|
+
onChangeMonthYear: function(year, month, dp_inst) {
|
153
|
+
// Update the time as well : this prevents the time from disappearing from the $input field.
|
154
|
+
tp_inst._updateDateTime(dp_inst);
|
155
|
+
if ($.isFunction(o.onChangeMonthYear))
|
156
|
+
o.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
|
157
|
+
},
|
158
|
+
onClose: function(dateText, dp_inst) {
|
159
|
+
if (tp_inst.timeDefined === true && $input.val() != '')
|
160
|
+
tp_inst._updateDateTime(dp_inst);
|
161
|
+
if ($.isFunction(o.onClose))
|
162
|
+
o.onClose.call($input[0], dateText, dp_inst, tp_inst);
|
163
|
+
},
|
164
|
+
timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
|
165
|
+
});
|
166
|
+
tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase() });
|
167
|
+
tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase() });
|
168
|
+
|
169
|
+
if (tp_inst._defaults.timezoneList === null) {
|
170
|
+
var timezoneList = [];
|
171
|
+
for (var i = -11; i <= 12; i++)
|
172
|
+
timezoneList.push((i >= 0 ? '+' : '-') + ('0' + Math.abs(i).toString()).slice(-2) + '00');
|
173
|
+
if (tp_inst._defaults.timezoneIso8609)
|
174
|
+
timezoneList = $.map(timezoneList, function(val) {
|
175
|
+
return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
|
176
|
+
});
|
177
|
+
tp_inst._defaults.timezoneList = timezoneList;
|
178
|
+
}
|
179
|
+
|
180
|
+
tp_inst.hour = tp_inst._defaults.hour;
|
181
|
+
tp_inst.minute = tp_inst._defaults.minute;
|
182
|
+
tp_inst.second = tp_inst._defaults.second;
|
183
|
+
tp_inst.millisec = tp_inst._defaults.millisec;
|
184
|
+
tp_inst.ampm = '';
|
185
|
+
tp_inst.$input = $input;
|
186
|
+
|
187
|
+
if (o.altField)
|
188
|
+
tp_inst.$altInput = $(o.altField)
|
189
|
+
.css({ cursor: 'pointer' })
|
190
|
+
.focus(function(){ $input.trigger("focus"); });
|
191
|
+
|
192
|
+
if(tp_inst._defaults.minDate==0 || tp_inst._defaults.minDateTime==0)
|
193
|
+
{
|
194
|
+
tp_inst._defaults.minDate=new Date();
|
195
|
+
}
|
196
|
+
if(tp_inst._defaults.maxDate==0 || tp_inst._defaults.maxDateTime==0)
|
197
|
+
{
|
198
|
+
tp_inst._defaults.maxDate=new Date();
|
199
|
+
}
|
200
|
+
|
201
|
+
// datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
|
202
|
+
if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
|
203
|
+
tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
|
204
|
+
if(tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date)
|
205
|
+
tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
|
206
|
+
if(tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date)
|
207
|
+
tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
|
208
|
+
if(tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date)
|
209
|
+
tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
|
210
|
+
return tp_inst;
|
211
|
+
},
|
212
|
+
|
213
|
+
//########################################################################
|
214
|
+
// add our sliders to the calendar
|
215
|
+
//########################################################################
|
216
|
+
_addTimePicker: function(dp_inst) {
|
217
|
+
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
|
218
|
+
this.$input.val() + ' ' + this.$altInput.val() :
|
219
|
+
this.$input.val();
|
220
|
+
|
221
|
+
this.timeDefined = this._parseTime(currDT);
|
222
|
+
this._limitMinMaxDateTime(dp_inst, false);
|
223
|
+
this._injectTimePicker();
|
224
|
+
},
|
225
|
+
|
226
|
+
//########################################################################
|
227
|
+
// parse the time string from input value or _setTime
|
228
|
+
//########################################################################
|
229
|
+
_parseTime: function(timeString, withDate) {
|
230
|
+
var regstr = this._defaults.timeFormat.toString()
|
231
|
+
.replace(/h{1,2}/ig, '(\\d?\\d)')
|
232
|
+
.replace(/m{1,2}/ig, '(\\d?\\d)')
|
233
|
+
.replace(/s{1,2}/ig, '(\\d?\\d)')
|
234
|
+
.replace(/l{1}/ig, '(\\d?\\d?\\d)')
|
235
|
+
.replace(/t{1,2}/ig, this._getPatternAmpm())
|
236
|
+
.replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d)?')
|
237
|
+
.replace(/\s/g, '\\s?') + this._defaults.timeSuffix + '$',
|
238
|
+
order = this._getFormatPositions(),
|
239
|
+
ampm = '',
|
240
|
+
treg;
|
241
|
+
|
242
|
+
if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
|
243
|
+
|
244
|
+
if (withDate || !this._defaults.timeOnly) {
|
245
|
+
// the time should come after x number of characters and a space.
|
246
|
+
// x = at least the length of text specified by the date format
|
247
|
+
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
|
248
|
+
// escape special regex characters in the seperator
|
249
|
+
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
|
250
|
+
regstr = '^.{' + dp_dateFormat.length + ',}?' + this._defaults.separator.replace(specials, "\\$&") + regstr;
|
251
|
+
}
|
252
|
+
|
253
|
+
treg = timeString.match(new RegExp(regstr, 'i'));
|
254
|
+
|
255
|
+
if (treg) {
|
256
|
+
if (order.t !== -1) {
|
257
|
+
if (treg[order.t] === undefined || treg[order.t].length === 0) {
|
258
|
+
ampm = '';
|
259
|
+
this.ampm = '';
|
260
|
+
} else {
|
261
|
+
ampm = $.inArray(treg[order.t].toUpperCase(), this.amNames) !== -1 ? 'AM' : 'PM';
|
262
|
+
this.ampm = this._defaults[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
|
263
|
+
}
|
264
|
+
}
|
265
|
+
|
266
|
+
if (order.h !== -1) {
|
267
|
+
if (ampm == 'AM' && treg[order.h] == '12')
|
268
|
+
this.hour = 0; // 12am = 0 hour
|
269
|
+
else if (ampm == 'PM' && treg[order.h] != '12')
|
270
|
+
this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
|
271
|
+
else this.hour = Number(treg[order.h]);
|
272
|
+
}
|
273
|
+
|
274
|
+
if (order.m !== -1) this.minute = Number(treg[order.m]);
|
275
|
+
if (order.s !== -1) this.second = Number(treg[order.s]);
|
276
|
+
if (order.l !== -1) this.millisec = Number(treg[order.l]);
|
277
|
+
if (order.z !== -1 && treg[order.z] !== undefined) {
|
278
|
+
var tz = treg[order.z].toUpperCase();
|
279
|
+
switch (tz.length) {
|
280
|
+
case 1: // Z
|
281
|
+
tz = this._defaults.timezoneIso8609 ? 'Z' : '+0000';
|
282
|
+
break;
|
283
|
+
case 5: // +hhmm
|
284
|
+
if (this._defaults.timezoneIso8609)
|
285
|
+
tz = tz.substring(1) == '0000'
|
286
|
+
? 'Z'
|
287
|
+
: tz.substring(0, 3) + ':' + tz.substring(3);
|
288
|
+
break;
|
289
|
+
case 6: // +hh:mm
|
290
|
+
if (!this._defaults.timezoneIso8609)
|
291
|
+
tz = tz == 'Z' || tz.substring(1) == '00:00'
|
292
|
+
? '+0000'
|
293
|
+
: tz.replace(/:/, '');
|
294
|
+
else if (tz.substring(1) == '00:00')
|
295
|
+
tz = 'Z';
|
296
|
+
break;
|
297
|
+
}
|
298
|
+
this.timezone = tz;
|
299
|
+
}
|
300
|
+
|
301
|
+
return true;
|
302
|
+
|
303
|
+
}
|
304
|
+
return false;
|
305
|
+
},
|
306
|
+
|
307
|
+
//########################################################################
|
308
|
+
// pattern for standard and localized AM/PM markers
|
309
|
+
//########################################################################
|
310
|
+
_getPatternAmpm: function() {
|
311
|
+
var markers = [];
|
312
|
+
o = this._defaults;
|
313
|
+
if (o.amNames)
|
314
|
+
$.merge(markers, o.amNames);
|
315
|
+
if (o.pmNames)
|
316
|
+
$.merge(markers, o.pmNames);
|
317
|
+
markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&') });
|
318
|
+
return '(' + markers.join('|') + ')?';
|
319
|
+
},
|
320
|
+
|
321
|
+
//########################################################################
|
322
|
+
// figure out position of time elements.. cause js cant do named captures
|
323
|
+
//########################################################################
|
324
|
+
_getFormatPositions: function() {
|
325
|
+
var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z)/g),
|
326
|
+
orders = { h: -1, m: -1, s: -1, l: -1, t: -1, z: -1 };
|
327
|
+
|
328
|
+
if (finds)
|
329
|
+
for (var i = 0; i < finds.length; i++)
|
330
|
+
if (orders[finds[i].toString().charAt(0)] == -1)
|
331
|
+
orders[finds[i].toString().charAt(0)] = i + 1;
|
332
|
+
|
333
|
+
return orders;
|
334
|
+
},
|
335
|
+
|
336
|
+
//########################################################################
|
337
|
+
// generate and inject html for timepicker into ui datepicker
|
338
|
+
//########################################################################
|
339
|
+
_injectTimePicker: function() {
|
340
|
+
var $dp = this.inst.dpDiv,
|
341
|
+
o = this._defaults,
|
342
|
+
tp_inst = this,
|
343
|
+
// Added by Peter Medeiros:
|
344
|
+
// - Figure out what the hour/minute/second max should be based on the step values.
|
345
|
+
// - Example: if stepMinute is 15, then minMax is 45.
|
346
|
+
hourMax = parseInt((o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)) ,10),
|
347
|
+
minMax = parseInt((o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)) ,10),
|
348
|
+
secMax = parseInt((o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)) ,10),
|
349
|
+
millisecMax = parseInt((o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)) ,10),
|
350
|
+
dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
|
351
|
+
|
352
|
+
// Prevent displaying twice
|
353
|
+
//if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
|
354
|
+
if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
|
355
|
+
var noDisplay = ' style="display:none;"',
|
356
|
+
html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
|
357
|
+
'<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
|
358
|
+
((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
|
359
|
+
'<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
|
360
|
+
((o.showTime) ? '' : noDisplay) + '></dd>' +
|
361
|
+
'<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
|
362
|
+
((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
|
363
|
+
hourGridSize = 0,
|
364
|
+
minuteGridSize = 0,
|
365
|
+
secondGridSize = 0,
|
366
|
+
millisecGridSize = 0,
|
367
|
+
size;
|
368
|
+
|
369
|
+
// Hours
|
370
|
+
html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' +
|
371
|
+
((o.showHour) ? '' : noDisplay) + '></div>';
|
372
|
+
if (o.showHour && o.hourGrid > 0) {
|
373
|
+
html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
|
374
|
+
|
375
|
+
for (var h = o.hourMin; h <= hourMax; h += parseInt(o.hourGrid,10)) {
|
376
|
+
hourGridSize++;
|
377
|
+
var tmph = (o.ampm && h > 12) ? h-12 : h;
|
378
|
+
if (tmph < 10) tmph = '0' + tmph;
|
379
|
+
if (o.ampm) {
|
380
|
+
if (h == 0) tmph = 12 +'a';
|
381
|
+
else if (h < 12) tmph += 'a';
|
382
|
+
else tmph += 'p';
|
383
|
+
}
|
384
|
+
html += '<td>' + tmph + '</td>';
|
385
|
+
}
|
386
|
+
|
387
|
+
html += '</tr></table></div>';
|
388
|
+
}
|
389
|
+
html += '</dd>';
|
390
|
+
|
391
|
+
// Minutes
|
392
|
+
html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
|
393
|
+
((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>'+
|
394
|
+
'<dd class="ui_tpicker_minute"><div id="ui_tpicker_minute_' + dp_id + '"' +
|
395
|
+
((o.showMinute) ? '' : noDisplay) + '></div>';
|
396
|
+
|
397
|
+
if (o.showMinute && o.minuteGrid > 0) {
|
398
|
+
html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
|
399
|
+
|
400
|
+
for (var m = o.minuteMin; m <= minMax; m += parseInt(o.minuteGrid,10)) {
|
401
|
+
minuteGridSize++;
|
402
|
+
html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
|
403
|
+
}
|
404
|
+
|
405
|
+
html += '</tr></table></div>';
|
406
|
+
}
|
407
|
+
html += '</dd>';
|
408
|
+
|
409
|
+
// Seconds
|
410
|
+
html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
|
411
|
+
((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>'+
|
412
|
+
'<dd class="ui_tpicker_second"><div id="ui_tpicker_second_' + dp_id + '"'+
|
413
|
+
((o.showSecond) ? '' : noDisplay) + '></div>';
|
414
|
+
|
415
|
+
if (o.showSecond && o.secondGrid > 0) {
|
416
|
+
html += '<div style="padding-left: 1px"><table><tr>';
|
417
|
+
|
418
|
+
for (var s = o.secondMin; s <= secMax; s += parseInt(o.secondGrid,10)) {
|
419
|
+
secondGridSize++;
|
420
|
+
html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
|
421
|
+
}
|
422
|
+
|
423
|
+
html += '</tr></table></div>';
|
424
|
+
}
|
425
|
+
html += '</dd>';
|
426
|
+
|
427
|
+
// Milliseconds
|
428
|
+
html += '<dt class="ui_tpicker_millisec_label" id="ui_tpicker_millisec_label_' + dp_id + '"' +
|
429
|
+
((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>'+
|
430
|
+
'<dd class="ui_tpicker_millisec"><div id="ui_tpicker_millisec_' + dp_id + '"'+
|
431
|
+
((o.showMillisec) ? '' : noDisplay) + '></div>';
|
432
|
+
|
433
|
+
if (o.showMillisec && o.millisecGrid > 0) {
|
434
|
+
html += '<div style="padding-left: 1px"><table><tr>';
|
435
|
+
|
436
|
+
for (var l = o.millisecMin; l <= millisecMax; l += parseInt(o.millisecGrid,10)) {
|
437
|
+
millisecGridSize++;
|
438
|
+
html += '<td>' + ((l < 10) ? '0' : '') + l + '</td>';
|
439
|
+
}
|
440
|
+
|
441
|
+
html += '</tr></table></div>';
|
442
|
+
}
|
443
|
+
html += '</dd>';
|
444
|
+
|
445
|
+
// Timezone
|
446
|
+
html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
|
447
|
+
((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
|
448
|
+
html += '<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_' + dp_id + '"' +
|
449
|
+
((o.showTimezone) ? '' : noDisplay) + '></dd>';
|
450
|
+
|
451
|
+
html += '</dl></div>';
|
452
|
+
$tp = $(html);
|
453
|
+
|
454
|
+
// if we only want time picker...
|
455
|
+
if (o.timeOnly === true) {
|
456
|
+
$tp.prepend(
|
457
|
+
'<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' +
|
458
|
+
'<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' +
|
459
|
+
'</div>');
|
460
|
+
$dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
|
461
|
+
}
|
462
|
+
|
463
|
+
this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({
|
464
|
+
orientation: "horizontal",
|
465
|
+
value: this.hour,
|
466
|
+
min: o.hourMin,
|
467
|
+
max: hourMax,
|
468
|
+
step: o.stepHour,
|
469
|
+
slide: function(event, ui) {
|
470
|
+
tp_inst.hour_slider.slider( "option", "value", ui.value);
|
471
|
+
tp_inst._onTimeChange();
|
472
|
+
}
|
473
|
+
});
|
474
|
+
|
475
|
+
|
476
|
+
// Updated by Peter Medeiros:
|
477
|
+
// - Pass in Event and UI instance into slide function
|
478
|
+
this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
|
479
|
+
orientation: "horizontal",
|
480
|
+
value: this.minute,
|
481
|
+
min: o.minuteMin,
|
482
|
+
max: minMax,
|
483
|
+
step: o.stepMinute,
|
484
|
+
slide: function(event, ui) {
|
485
|
+
tp_inst.minute_slider.slider( "option", "value", ui.value);
|
486
|
+
tp_inst._onTimeChange();
|
487
|
+
}
|
488
|
+
});
|
489
|
+
|
490
|
+
this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({
|
491
|
+
orientation: "horizontal",
|
492
|
+
value: this.second,
|
493
|
+
min: o.secondMin,
|
494
|
+
max: secMax,
|
495
|
+
step: o.stepSecond,
|
496
|
+
slide: function(event, ui) {
|
497
|
+
tp_inst.second_slider.slider( "option", "value", ui.value);
|
498
|
+
tp_inst._onTimeChange();
|
499
|
+
}
|
500
|
+
});
|
501
|
+
|
502
|
+
this.millisec_slider = $tp.find('#ui_tpicker_millisec_'+ dp_id).slider({
|
503
|
+
orientation: "horizontal",
|
504
|
+
value: this.millisec,
|
505
|
+
min: o.millisecMin,
|
506
|
+
max: millisecMax,
|
507
|
+
step: o.stepMillisec,
|
508
|
+
slide: function(event, ui) {
|
509
|
+
tp_inst.millisec_slider.slider( "option", "value", ui.value);
|
510
|
+
tp_inst._onTimeChange();
|
511
|
+
}
|
512
|
+
});
|
513
|
+
|
514
|
+
this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('<select></select>').find("select");
|
515
|
+
$.fn.append.apply(this.timezone_select,
|
516
|
+
$.map(o.timezoneList, function(val, idx) {
|
517
|
+
return $("<option />")
|
518
|
+
.val(typeof val == "object" ? val.value : val)
|
519
|
+
.text(typeof val == "object" ? val.label : val);
|
520
|
+
})
|
521
|
+
);
|
522
|
+
this.timezone_select.val((typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") ? this.timezone : o.timezone);
|
523
|
+
this.timezone_select.change(function() {
|
524
|
+
tp_inst._onTimeChange();
|
525
|
+
});
|
526
|
+
|
527
|
+
// Add grid functionality
|
528
|
+
if (o.showHour && o.hourGrid > 0) {
|
529
|
+
size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
|
530
|
+
|
531
|
+
$tp.find(".ui_tpicker_hour table").css({
|
532
|
+
width: size + "%",
|
533
|
+
marginLeft: (size / (-2 * hourGridSize)) + "%",
|
534
|
+
borderCollapse: 'collapse'
|
535
|
+
}).find("td").each( function(index) {
|
536
|
+
$(this).click(function() {
|
537
|
+
var h = $(this).html();
|
538
|
+
if(o.ampm) {
|
539
|
+
var ap = h.substring(2).toLowerCase(),
|
540
|
+
aph = parseInt(h.substring(0,2), 10);
|
541
|
+
if (ap == 'a') {
|
542
|
+
if (aph == 12) h = 0;
|
543
|
+
else h = aph;
|
544
|
+
} else if (aph == 12) h = 12;
|
545
|
+
else h = aph + 12;
|
546
|
+
}
|
547
|
+
tp_inst.hour_slider.slider("option", "value", h);
|
548
|
+
tp_inst._onTimeChange();
|
549
|
+
tp_inst._onSelectHandler();
|
550
|
+
}).css({
|
551
|
+
cursor: 'pointer',
|
552
|
+
width: (100 / hourGridSize) + '%',
|
553
|
+
textAlign: 'center',
|
554
|
+
overflow: 'hidden'
|
555
|
+
});
|
556
|
+
});
|
557
|
+
}
|
558
|
+
|
559
|
+
if (o.showMinute && o.minuteGrid > 0) {
|
560
|
+
size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
|
561
|
+
$tp.find(".ui_tpicker_minute table").css({
|
562
|
+
width: size + "%",
|
563
|
+
marginLeft: (size / (-2 * minuteGridSize)) + "%",
|
564
|
+
borderCollapse: 'collapse'
|
565
|
+
}).find("td").each(function(index) {
|
566
|
+
$(this).click(function() {
|
567
|
+
tp_inst.minute_slider.slider("option", "value", $(this).html());
|
568
|
+
tp_inst._onTimeChange();
|
569
|
+
tp_inst._onSelectHandler();
|
570
|
+
}).css({
|
571
|
+
cursor: 'pointer',
|
572
|
+
width: (100 / minuteGridSize) + '%',
|
573
|
+
textAlign: 'center',
|
574
|
+
overflow: 'hidden'
|
575
|
+
});
|
576
|
+
});
|
577
|
+
}
|
578
|
+
|
579
|
+
if (o.showSecond && o.secondGrid > 0) {
|
580
|
+
$tp.find(".ui_tpicker_second table").css({
|
581
|
+
width: size + "%",
|
582
|
+
marginLeft: (size / (-2 * secondGridSize)) + "%",
|
583
|
+
borderCollapse: 'collapse'
|
584
|
+
}).find("td").each(function(index) {
|
585
|
+
$(this).click(function() {
|
586
|
+
tp_inst.second_slider.slider("option", "value", $(this).html());
|
587
|
+
tp_inst._onTimeChange();
|
588
|
+
tp_inst._onSelectHandler();
|
589
|
+
}).css({
|
590
|
+
cursor: 'pointer',
|
591
|
+
width: (100 / secondGridSize) + '%',
|
592
|
+
textAlign: 'center',
|
593
|
+
overflow: 'hidden'
|
594
|
+
});
|
595
|
+
});
|
596
|
+
}
|
597
|
+
|
598
|
+
if (o.showMillisec && o.millisecGrid > 0) {
|
599
|
+
$tp.find(".ui_tpicker_millisec table").css({
|
600
|
+
width: size + "%",
|
601
|
+
marginLeft: (size / (-2 * millisecGridSize)) + "%",
|
602
|
+
borderCollapse: 'collapse'
|
603
|
+
}).find("td").each(function(index) {
|
604
|
+
$(this).click(function() {
|
605
|
+
tp_inst.millisec_slider.slider("option", "value", $(this).html());
|
606
|
+
tp_inst._onTimeChange();
|
607
|
+
tp_inst._onSelectHandler();
|
608
|
+
}).css({
|
609
|
+
cursor: 'pointer',
|
610
|
+
width: (100 / millisecGridSize) + '%',
|
611
|
+
textAlign: 'center',
|
612
|
+
overflow: 'hidden'
|
613
|
+
});
|
614
|
+
});
|
615
|
+
}
|
616
|
+
|
617
|
+
var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
|
618
|
+
if ($buttonPanel.length) $buttonPanel.before($tp);
|
619
|
+
else $dp.append($tp);
|
620
|
+
|
621
|
+
this.$timeObj = $tp.find('#ui_tpicker_time_'+ dp_id);
|
622
|
+
|
623
|
+
if (this.inst !== null) {
|
624
|
+
var timeDefined = this.timeDefined;
|
625
|
+
this._onTimeChange();
|
626
|
+
this.timeDefined = timeDefined;
|
627
|
+
}
|
628
|
+
|
629
|
+
//Emulate datepicker onSelect behavior. Call on slidestop.
|
630
|
+
var onSelectDelegate = function() {
|
631
|
+
tp_inst._onSelectHandler();
|
632
|
+
};
|
633
|
+
this.hour_slider.bind('slidestop',onSelectDelegate);
|
634
|
+
this.minute_slider.bind('slidestop',onSelectDelegate);
|
635
|
+
this.second_slider.bind('slidestop',onSelectDelegate);
|
636
|
+
this.millisec_slider.bind('slidestop',onSelectDelegate);
|
637
|
+
|
638
|
+
// slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
|
639
|
+
if (this._defaults.addSliderAccess){
|
640
|
+
var sliderAccessArgs = this._defaults.sliderAccessArgs;
|
641
|
+
setTimeout(function(){ // fix for inline mode
|
642
|
+
if($tp.find('.ui-slider-access').length == 0){
|
643
|
+
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
|
644
|
+
|
645
|
+
// fix any grids since sliders are shorter
|
646
|
+
var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
|
647
|
+
if(sliderAccessWidth){
|
648
|
+
$tp.find('table:visible').each(function(){
|
649
|
+
var $g = $(this),
|
650
|
+
oldWidth = $g.outerWidth(),
|
651
|
+
oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
|
652
|
+
newWidth = oldWidth - sliderAccessWidth,
|
653
|
+
newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
|
654
|
+
|
655
|
+
$g.css({ width: newWidth, marginLeft: newMarginLeft });
|
656
|
+
});
|
657
|
+
}
|
658
|
+
}
|
659
|
+
},0);
|
660
|
+
}
|
661
|
+
// end slideAccess integration
|
662
|
+
|
663
|
+
}
|
664
|
+
},
|
665
|
+
|
666
|
+
//########################################################################
|
667
|
+
// This function tries to limit the ability to go outside the
|
668
|
+
// min/max date range
|
669
|
+
//########################################################################
|
670
|
+
_limitMinMaxDateTime: function(dp_inst, adjustSliders){
|
671
|
+
var o = this._defaults,
|
672
|
+
dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
|
673
|
+
|
674
|
+
if(!this._defaults.showTimepicker) return; // No time so nothing to check here
|
675
|
+
|
676
|
+
if($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date){
|
677
|
+
var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
|
678
|
+
minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
|
679
|
+
|
680
|
+
if(this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null){
|
681
|
+
this.hourMinOriginal = o.hourMin;
|
682
|
+
this.minuteMinOriginal = o.minuteMin;
|
683
|
+
this.secondMinOriginal = o.secondMin;
|
684
|
+
this.millisecMinOriginal = o.millisecMin;
|
685
|
+
}
|
686
|
+
|
687
|
+
if(dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
|
688
|
+
this._defaults.hourMin = minDateTime.getHours();
|
689
|
+
if (this.hour <= this._defaults.hourMin) {
|
690
|
+
this.hour = this._defaults.hourMin;
|
691
|
+
this._defaults.minuteMin = minDateTime.getMinutes();
|
692
|
+
if (this.minute <= this._defaults.minuteMin) {
|
693
|
+
this.minute = this._defaults.minuteMin;
|
694
|
+
this._defaults.secondMin = minDateTime.getSeconds();
|
695
|
+
} else if (this.second <= this._defaults.secondMin){
|
696
|
+
this.second = this._defaults.secondMin;
|
697
|
+
this._defaults.millisecMin = minDateTime.getMilliseconds();
|
698
|
+
} else {
|
699
|
+
if(this.millisec < this._defaults.millisecMin)
|
700
|
+
this.millisec = this._defaults.millisecMin;
|
701
|
+
this._defaults.millisecMin = this.millisecMinOriginal;
|
702
|
+
}
|
703
|
+
} else {
|
704
|
+
this._defaults.minuteMin = this.minuteMinOriginal;
|
705
|
+
this._defaults.secondMin = this.secondMinOriginal;
|
706
|
+
this._defaults.millisecMin = this.millisecMinOriginal;
|
707
|
+
}
|
708
|
+
}else{
|
709
|
+
this._defaults.hourMin = this.hourMinOriginal;
|
710
|
+
this._defaults.minuteMin = this.minuteMinOriginal;
|
711
|
+
this._defaults.secondMin = this.secondMinOriginal;
|
712
|
+
this._defaults.millisecMin = this.millisecMinOriginal;
|
713
|
+
}
|
714
|
+
}
|
715
|
+
|
716
|
+
if($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date){
|
717
|
+
var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
|
718
|
+
maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
|
719
|
+
|
720
|
+
if(this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null){
|
721
|
+
this.hourMaxOriginal = o.hourMax;
|
722
|
+
this.minuteMaxOriginal = o.minuteMax;
|
723
|
+
this.secondMaxOriginal = o.secondMax;
|
724
|
+
this.millisecMaxOriginal = o.millisecMax;
|
725
|
+
}
|
726
|
+
|
727
|
+
if(dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()){
|
728
|
+
this._defaults.hourMax = maxDateTime.getHours();
|
729
|
+
if (this.hour >= this._defaults.hourMax) {
|
730
|
+
this.hour = this._defaults.hourMax;
|
731
|
+
this._defaults.minuteMax = maxDateTime.getMinutes();
|
732
|
+
if (this.minute >= this._defaults.minuteMax) {
|
733
|
+
this.minute = this._defaults.minuteMax;
|
734
|
+
this._defaults.secondMax = maxDateTime.getSeconds();
|
735
|
+
} else if (this.second >= this._defaults.secondMax) {
|
736
|
+
this.second = this._defaults.secondMax;
|
737
|
+
this._defaults.millisecMax = maxDateTime.getMilliseconds();
|
738
|
+
} else {
|
739
|
+
if(this.millisec > this._defaults.millisecMax) this.millisec = this._defaults.millisecMax;
|
740
|
+
this._defaults.millisecMax = this.millisecMaxOriginal;
|
741
|
+
}
|
742
|
+
} else {
|
743
|
+
this._defaults.minuteMax = this.minuteMaxOriginal;
|
744
|
+
this._defaults.secondMax = this.secondMaxOriginal;
|
745
|
+
this._defaults.millisecMax = this.millisecMaxOriginal;
|
746
|
+
}
|
747
|
+
}else{
|
748
|
+
this._defaults.hourMax = this.hourMaxOriginal;
|
749
|
+
this._defaults.minuteMax = this.minuteMaxOriginal;
|
750
|
+
this._defaults.secondMax = this.secondMaxOriginal;
|
751
|
+
this._defaults.millisecMax = this.millisecMaxOriginal;
|
752
|
+
}
|
753
|
+
}
|
754
|
+
|
755
|
+
if(adjustSliders !== undefined && adjustSliders === true){
|
756
|
+
var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)) ,10),
|
757
|
+
minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)) ,10),
|
758
|
+
secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)) ,10),
|
759
|
+
millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)) ,10);
|
760
|
+
|
761
|
+
if(this.hour_slider)
|
762
|
+
this.hour_slider.slider("option", { min: this._defaults.hourMin, max: hourMax }).slider('value', this.hour);
|
763
|
+
if(this.minute_slider)
|
764
|
+
this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: minMax }).slider('value', this.minute);
|
765
|
+
if(this.second_slider)
|
766
|
+
this.second_slider.slider("option", { min: this._defaults.secondMin, max: secMax }).slider('value', this.second);
|
767
|
+
if(this.millisec_slider)
|
768
|
+
this.millisec_slider.slider("option", { min: this._defaults.millisecMin, max: millisecMax }).slider('value', this.millisec);
|
769
|
+
}
|
770
|
+
|
771
|
+
},
|
772
|
+
|
773
|
+
|
774
|
+
//########################################################################
|
775
|
+
// when a slider moves, set the internal time...
|
776
|
+
// on time change is also called when the time is updated in the text field
|
777
|
+
//########################################################################
|
778
|
+
_onTimeChange: function() {
|
779
|
+
var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
|
780
|
+
minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
|
781
|
+
second = (this.second_slider) ? this.second_slider.slider('value') : false,
|
782
|
+
millisec = (this.millisec_slider) ? this.millisec_slider.slider('value') : false,
|
783
|
+
timezone = (this.timezone_select) ? this.timezone_select.val() : false,
|
784
|
+
o = this._defaults;
|
785
|
+
|
786
|
+
if (typeof(hour) == 'object') hour = false;
|
787
|
+
if (typeof(minute) == 'object') minute = false;
|
788
|
+
if (typeof(second) == 'object') second = false;
|
789
|
+
if (typeof(millisec) == 'object') millisec = false;
|
790
|
+
if (typeof(timezone) == 'object') timezone = false;
|
791
|
+
|
792
|
+
if (hour !== false) hour = parseInt(hour,10);
|
793
|
+
if (minute !== false) minute = parseInt(minute,10);
|
794
|
+
if (second !== false) second = parseInt(second,10);
|
795
|
+
if (millisec !== false) millisec = parseInt(millisec,10);
|
796
|
+
|
797
|
+
var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
|
798
|
+
|
799
|
+
// If the update was done in the input field, the input field should not be updated.
|
800
|
+
// If the update was done using the sliders, update the input field.
|
801
|
+
var hasChanged = (hour != this.hour || minute != this.minute
|
802
|
+
|| second != this.second || millisec != this.millisec
|
803
|
+
|| (this.ampm.length > 0
|
804
|
+
&& (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
|
805
|
+
|| timezone != this.timezone);
|
806
|
+
|
807
|
+
if (hasChanged) {
|
808
|
+
|
809
|
+
if (hour !== false)this.hour = hour;
|
810
|
+
if (minute !== false) this.minute = minute;
|
811
|
+
if (second !== false) this.second = second;
|
812
|
+
if (millisec !== false) this.millisec = millisec;
|
813
|
+
if (timezone !== false) this.timezone = timezone;
|
814
|
+
|
815
|
+
if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
|
816
|
+
|
817
|
+
this._limitMinMaxDateTime(this.inst, true);
|
818
|
+
}
|
819
|
+
if (o.ampm) this.ampm = ampm;
|
820
|
+
|
821
|
+
//this._formatTime();
|
822
|
+
this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
|
823
|
+
if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix);
|
824
|
+
this.timeDefined = true;
|
825
|
+
if (hasChanged) this._updateDateTime();
|
826
|
+
},
|
827
|
+
|
828
|
+
//########################################################################
|
829
|
+
// call custom onSelect.
|
830
|
+
// bind to sliders slidestop, and grid click.
|
831
|
+
//########################################################################
|
832
|
+
_onSelectHandler: function() {
|
833
|
+
var onSelect = this._defaults.onSelect;
|
834
|
+
var inputEl = this.$input ? this.$input[0] : null;
|
835
|
+
if (onSelect && inputEl) {
|
836
|
+
onSelect.apply(inputEl, [this.formattedDateTime, this]);
|
837
|
+
}
|
838
|
+
},
|
839
|
+
|
840
|
+
//########################################################################
|
841
|
+
// left for any backwards compatibility
|
842
|
+
//########################################################################
|
843
|
+
_formatTime: function(time, format) {
|
844
|
+
time = time || { hour: this.hour, minute: this.minute, second: this.second, millisec: this.millisec, ampm: this.ampm, timezone: this.timezone };
|
845
|
+
var tmptime = (format || this._defaults.timeFormat).toString();
|
846
|
+
|
847
|
+
tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);
|
848
|
+
|
849
|
+
if (arguments.length) return tmptime;
|
850
|
+
else this.formattedTime = tmptime;
|
851
|
+
},
|
852
|
+
|
853
|
+
//########################################################################
|
854
|
+
// update our input with the new date time..
|
855
|
+
//########################################################################
|
856
|
+
_updateDateTime: function(dp_inst) {
|
857
|
+
dp_inst = this.inst || dp_inst;
|
858
|
+
var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
859
|
+
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
|
860
|
+
formatCfg = $.datepicker._getFormatConfig(dp_inst),
|
861
|
+
timeAvailable = dt !== null && this.timeDefined;
|
862
|
+
this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
|
863
|
+
var formattedDateTime = this.formattedDate;
|
864
|
+
if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
|
865
|
+
return;
|
866
|
+
|
867
|
+
if (this._defaults.timeOnly === true) {
|
868
|
+
formattedDateTime = this.formattedTime;
|
869
|
+
} else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
|
870
|
+
formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
|
871
|
+
}
|
872
|
+
|
873
|
+
this.formattedDateTime = formattedDateTime;
|
874
|
+
|
875
|
+
if(!this._defaults.showTimepicker) {
|
876
|
+
this.$input.val(this.formattedDate);
|
877
|
+
} else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
|
878
|
+
this.$altInput.val(this.formattedTime);
|
879
|
+
this.$input.val(this.formattedDate);
|
880
|
+
} else if(this.$altInput) {
|
881
|
+
this.$altInput.val(formattedDateTime);
|
882
|
+
this.$input.val(formattedDateTime);
|
883
|
+
} else {
|
884
|
+
this.$input.val(formattedDateTime);
|
885
|
+
}
|
886
|
+
|
887
|
+
this.$input.trigger("change");
|
888
|
+
}
|
889
|
+
|
890
|
+
});
|
891
|
+
|
892
|
+
$.fn.extend({
|
893
|
+
//########################################################################
|
894
|
+
// shorthand just to use timepicker..
|
895
|
+
//########################################################################
|
896
|
+
timepicker: function(o) {
|
897
|
+
o = o || {};
|
898
|
+
var tmp_args = arguments;
|
899
|
+
|
900
|
+
if (typeof o == 'object') tmp_args[0] = $.extend(o, { timeOnly: true });
|
901
|
+
|
902
|
+
return $(this).each(function() {
|
903
|
+
$.fn.datetimepicker.apply($(this), tmp_args);
|
904
|
+
});
|
905
|
+
},
|
906
|
+
|
907
|
+
//########################################################################
|
908
|
+
// extend timepicker to datepicker
|
909
|
+
//########################################################################
|
910
|
+
datetimepicker: function(o) {
|
911
|
+
o = o || {};
|
912
|
+
var $input = this,
|
913
|
+
tmp_args = arguments;
|
914
|
+
|
915
|
+
if (typeof(o) == 'string'){
|
916
|
+
if(o == 'getDate')
|
917
|
+
return $.fn.datepicker.apply($(this[0]), tmp_args);
|
918
|
+
else
|
919
|
+
return this.each(function() {
|
920
|
+
var $t = $(this);
|
921
|
+
$t.datepicker.apply($t, tmp_args);
|
922
|
+
});
|
923
|
+
}
|
924
|
+
else
|
925
|
+
return this.each(function() {
|
926
|
+
var $t = $(this);
|
927
|
+
$t.datepicker($.timepicker._newInst($t, o)._defaults);
|
928
|
+
});
|
929
|
+
}
|
930
|
+
});
|
931
|
+
|
932
|
+
//########################################################################
|
933
|
+
// format the time all pretty...
|
934
|
+
// format = string format of the time
|
935
|
+
// time = a {}, not a Date() for timezones
|
936
|
+
// options = essentially the regional[].. amNames, pmNames, ampm
|
937
|
+
//########################################################################
|
938
|
+
$.datepicker.formatTime = function(format, time, options) {
|
939
|
+
options = options || {};
|
940
|
+
options = $.extend($.timepicker._defaults, options);
|
941
|
+
time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time);
|
942
|
+
|
943
|
+
var tmptime = format;
|
944
|
+
var ampmName = options['amNames'][0];
|
945
|
+
|
946
|
+
var hour = parseInt(time.hour, 10);
|
947
|
+
if (options.ampm) {
|
948
|
+
if (hour > 11){
|
949
|
+
ampmName = options['pmNames'][0];
|
950
|
+
if(hour > 12)
|
951
|
+
hour = hour % 12;
|
952
|
+
}
|
953
|
+
if (hour === 0)
|
954
|
+
hour = 12;
|
955
|
+
}
|
956
|
+
tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
|
957
|
+
switch (match.toLowerCase()) {
|
958
|
+
case 'hh': return ('0' + hour).slice(-2);
|
959
|
+
case 'h': return hour;
|
960
|
+
case 'mm': return ('0' + time.minute).slice(-2);
|
961
|
+
case 'm': return time.minute;
|
962
|
+
case 'ss': return ('0' + time.second).slice(-2);
|
963
|
+
case 's': return time.second;
|
964
|
+
case 'l': return ('00' + time.millisec).slice(-3);
|
965
|
+
case 'z': return time.timezone;
|
966
|
+
case 't': case 'tt':
|
967
|
+
if (options.ampm) {
|
968
|
+
if (match.length == 1)
|
969
|
+
ampmName = ampmName.charAt(0);
|
970
|
+
return match.charAt(0) == 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
|
971
|
+
}
|
972
|
+
return '';
|
973
|
+
}
|
974
|
+
});
|
975
|
+
|
976
|
+
tmptime = $.trim(tmptime);
|
977
|
+
return tmptime;
|
978
|
+
}
|
979
|
+
|
980
|
+
//########################################################################
|
981
|
+
// the bad hack :/ override datepicker so it doesnt close on select
|
982
|
+
// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
|
983
|
+
//########################################################################
|
984
|
+
$.datepicker._base_selectDate = $.datepicker._selectDate;
|
985
|
+
$.datepicker._selectDate = function (id, dateStr) {
|
986
|
+
var inst = this._getInst($(id)[0]),
|
987
|
+
tp_inst = this._get(inst, 'timepicker');
|
988
|
+
|
989
|
+
if (tp_inst) {
|
990
|
+
tp_inst._limitMinMaxDateTime(inst, true);
|
991
|
+
inst.inline = inst.stay_open = true;
|
992
|
+
//This way the onSelect handler called from calendarpicker get the full dateTime
|
993
|
+
this._base_selectDate(id, dateStr);
|
994
|
+
inst.inline = inst.stay_open = false;
|
995
|
+
this._notifyChange(inst);
|
996
|
+
this._updateDatepicker(inst);
|
997
|
+
}
|
998
|
+
else this._base_selectDate(id, dateStr);
|
999
|
+
};
|
1000
|
+
|
1001
|
+
//#############################################################################################
|
1002
|
+
// second bad hack :/ override datepicker so it triggers an event when changing the input field
|
1003
|
+
// and does not redraw the datepicker on every selectDate event
|
1004
|
+
//#############################################################################################
|
1005
|
+
$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
|
1006
|
+
$.datepicker._updateDatepicker = function(inst) {
|
1007
|
+
|
1008
|
+
// don't popup the datepicker if there is another instance already opened
|
1009
|
+
var input = inst.input[0];
|
1010
|
+
if($.datepicker._curInst &&
|
1011
|
+
$.datepicker._curInst != inst &&
|
1012
|
+
$.datepicker._datepickerShowing &&
|
1013
|
+
$.datepicker._lastInput != input) {
|
1014
|
+
return;
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
|
1018
|
+
|
1019
|
+
this._base_updateDatepicker(inst);
|
1020
|
+
|
1021
|
+
// Reload the time control when changing something in the input text field.
|
1022
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1023
|
+
if(tp_inst) tp_inst._addTimePicker(inst);
|
1024
|
+
}
|
1025
|
+
};
|
1026
|
+
|
1027
|
+
//#######################################################################################
|
1028
|
+
// third bad hack :/ override datepicker so it allows spaces and colon in the input field
|
1029
|
+
//#######################################################################################
|
1030
|
+
$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
|
1031
|
+
$.datepicker._doKeyPress = function(event) {
|
1032
|
+
var inst = $.datepicker._getInst(event.target),
|
1033
|
+
tp_inst = $.datepicker._get(inst, 'timepicker');
|
1034
|
+
|
1035
|
+
if (tp_inst) {
|
1036
|
+
if ($.datepicker._get(inst, 'constrainInput')) {
|
1037
|
+
var ampm = tp_inst._defaults.ampm,
|
1038
|
+
dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
|
1039
|
+
datetimeChars = tp_inst._defaults.timeFormat.toString()
|
1040
|
+
.replace(/[hms]/g, '')
|
1041
|
+
.replace(/TT/g, ampm ? 'APM' : '')
|
1042
|
+
.replace(/Tt/g, ampm ? 'AaPpMm' : '')
|
1043
|
+
.replace(/tT/g, ampm ? 'AaPpMm' : '')
|
1044
|
+
.replace(/T/g, ampm ? 'AP' : '')
|
1045
|
+
.replace(/tt/g, ampm ? 'apm' : '')
|
1046
|
+
.replace(/t/g, ampm ? 'ap' : '') +
|
1047
|
+
" " +
|
1048
|
+
tp_inst._defaults.separator +
|
1049
|
+
tp_inst._defaults.timeSuffix +
|
1050
|
+
(tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
|
1051
|
+
(tp_inst._defaults.amNames.join('')) +
|
1052
|
+
(tp_inst._defaults.pmNames.join('')) +
|
1053
|
+
dateChars,
|
1054
|
+
chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
1055
|
+
return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
|
1056
|
+
}
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
return $.datepicker._base_doKeyPress(event);
|
1060
|
+
};
|
1061
|
+
|
1062
|
+
//#######################################################################################
|
1063
|
+
// Override key up event to sync manual input changes.
|
1064
|
+
//#######################################################################################
|
1065
|
+
$.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
|
1066
|
+
$.datepicker._doKeyUp = function (event) {
|
1067
|
+
var inst = $.datepicker._getInst(event.target),
|
1068
|
+
tp_inst = $.datepicker._get(inst, 'timepicker');
|
1069
|
+
|
1070
|
+
if (tp_inst) {
|
1071
|
+
if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
|
1072
|
+
try {
|
1073
|
+
$.datepicker._updateDatepicker(inst);
|
1074
|
+
}
|
1075
|
+
catch (err) {
|
1076
|
+
$.datepicker.log(err);
|
1077
|
+
}
|
1078
|
+
}
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
return $.datepicker._base_doKeyUp(event);
|
1082
|
+
};
|
1083
|
+
|
1084
|
+
//#######################################################################################
|
1085
|
+
// override "Today" button to also grab the time.
|
1086
|
+
//#######################################################################################
|
1087
|
+
$.datepicker._base_gotoToday = $.datepicker._gotoToday;
|
1088
|
+
$.datepicker._gotoToday = function(id) {
|
1089
|
+
var inst = this._getInst($(id)[0]),
|
1090
|
+
$dp = inst.dpDiv;
|
1091
|
+
this._base_gotoToday(id);
|
1092
|
+
var now = new Date();
|
1093
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1094
|
+
if (tp_inst && tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
|
1095
|
+
var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
|
1096
|
+
var tzsign = tzoffset > 0 ? '-' : '+';
|
1097
|
+
tzoffset = Math.abs(tzoffset);
|
1098
|
+
var tzmin = tzoffset % 60;
|
1099
|
+
tzoffset = tzsign + ('0' + (tzoffset - tzmin) / 60).slice(-2) + ('0' + tzmin).slice(-2);
|
1100
|
+
if (tp_inst._defaults.timezoneIso8609)
|
1101
|
+
tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
|
1102
|
+
tp_inst.timezone_select.val(tzoffset);
|
1103
|
+
}
|
1104
|
+
this._setTime(inst, now);
|
1105
|
+
$( '.ui-datepicker-today', $dp).click();
|
1106
|
+
};
|
1107
|
+
|
1108
|
+
//#######################################################################################
|
1109
|
+
// Disable & enable the Time in the datetimepicker
|
1110
|
+
//#######################################################################################
|
1111
|
+
$.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
|
1112
|
+
var inst = this._getInst(target),
|
1113
|
+
tp_inst = this._get(inst, 'timepicker');
|
1114
|
+
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
|
1115
|
+
if (tp_inst) {
|
1116
|
+
tp_inst._defaults.showTimepicker = false;
|
1117
|
+
tp_inst._updateDateTime(inst);
|
1118
|
+
}
|
1119
|
+
};
|
1120
|
+
|
1121
|
+
$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
|
1122
|
+
var inst = this._getInst(target),
|
1123
|
+
tp_inst = this._get(inst, 'timepicker');
|
1124
|
+
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
|
1125
|
+
if (tp_inst) {
|
1126
|
+
tp_inst._defaults.showTimepicker = true;
|
1127
|
+
tp_inst._addTimePicker(inst); // Could be disabled on page load
|
1128
|
+
tp_inst._updateDateTime(inst);
|
1129
|
+
}
|
1130
|
+
};
|
1131
|
+
|
1132
|
+
//#######################################################################################
|
1133
|
+
// Create our own set time function
|
1134
|
+
//#######################################################################################
|
1135
|
+
$.datepicker._setTime = function(inst, date) {
|
1136
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1137
|
+
if (tp_inst) {
|
1138
|
+
var defaults = tp_inst._defaults,
|
1139
|
+
// calling _setTime with no date sets time to defaults
|
1140
|
+
hour = date ? date.getHours() : defaults.hour,
|
1141
|
+
minute = date ? date.getMinutes() : defaults.minute,
|
1142
|
+
second = date ? date.getSeconds() : defaults.second,
|
1143
|
+
millisec = date ? date.getMilliseconds() : defaults.millisec;
|
1144
|
+
|
1145
|
+
//check if within min/max times..
|
1146
|
+
if ((hour < defaults.hourMin || hour > defaults.hourMax) || (minute < defaults.minuteMin || minute > defaults.minuteMax) || (second < defaults.secondMin || second > defaults.secondMax) || (millisec < defaults.millisecMin || millisec > defaults.millisecMax)) {
|
1147
|
+
hour = defaults.hourMin;
|
1148
|
+
minute = defaults.minuteMin;
|
1149
|
+
second = defaults.secondMin;
|
1150
|
+
millisec = defaults.millisecMin;
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
tp_inst.hour = hour;
|
1154
|
+
tp_inst.minute = minute;
|
1155
|
+
tp_inst.second = second;
|
1156
|
+
tp_inst.millisec = millisec;
|
1157
|
+
|
1158
|
+
if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
|
1159
|
+
if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
|
1160
|
+
if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
|
1161
|
+
if (tp_inst.millisec_slider) tp_inst.millisec_slider.slider('value', millisec);
|
1162
|
+
|
1163
|
+
tp_inst._onTimeChange();
|
1164
|
+
tp_inst._updateDateTime(inst);
|
1165
|
+
}
|
1166
|
+
};
|
1167
|
+
|
1168
|
+
//#######################################################################################
|
1169
|
+
// Create new public method to set only time, callable as $().datepicker('setTime', date)
|
1170
|
+
//#######################################################################################
|
1171
|
+
$.datepicker._setTimeDatepicker = function(target, date, withDate) {
|
1172
|
+
var inst = this._getInst(target),
|
1173
|
+
tp_inst = this._get(inst, 'timepicker');
|
1174
|
+
|
1175
|
+
if (tp_inst) {
|
1176
|
+
this._setDateFromField(inst);
|
1177
|
+
var tp_date;
|
1178
|
+
if (date) {
|
1179
|
+
if (typeof date == "string") {
|
1180
|
+
tp_inst._parseTime(date, withDate);
|
1181
|
+
tp_date = new Date();
|
1182
|
+
tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
1183
|
+
}
|
1184
|
+
else tp_date = new Date(date.getTime());
|
1185
|
+
if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
|
1186
|
+
this._setTime(inst, tp_date);
|
1187
|
+
}
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
};
|
1191
|
+
|
1192
|
+
//#######################################################################################
|
1193
|
+
// override setDate() to allow setting time too within Date object
|
1194
|
+
//#######################################################################################
|
1195
|
+
$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
|
1196
|
+
$.datepicker._setDateDatepicker = function(target, date) {
|
1197
|
+
var inst = this._getInst(target),
|
1198
|
+
tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
|
1199
|
+
|
1200
|
+
this._updateDatepicker(inst);
|
1201
|
+
this._base_setDateDatepicker.apply(this, arguments);
|
1202
|
+
this._setTimeDatepicker(target, tp_date, true);
|
1203
|
+
};
|
1204
|
+
|
1205
|
+
//#######################################################################################
|
1206
|
+
// override getDate() to allow getting time too within Date object
|
1207
|
+
//#######################################################################################
|
1208
|
+
$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
|
1209
|
+
$.datepicker._getDateDatepicker = function(target, noDefault) {
|
1210
|
+
var inst = this._getInst(target),
|
1211
|
+
tp_inst = this._get(inst, 'timepicker');
|
1212
|
+
|
1213
|
+
if (tp_inst) {
|
1214
|
+
this._setDateFromField(inst, noDefault);
|
1215
|
+
var date = this._getDate(inst);
|
1216
|
+
if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
1217
|
+
return date;
|
1218
|
+
}
|
1219
|
+
return this._base_getDateDatepicker(target, noDefault);
|
1220
|
+
};
|
1221
|
+
|
1222
|
+
//#######################################################################################
|
1223
|
+
// override parseDate() because UI 1.8.14 throws an error about "Extra characters"
|
1224
|
+
// An option in datapicker to ignore extra format characters would be nicer.
|
1225
|
+
//#######################################################################################
|
1226
|
+
$.datepicker._base_parseDate = $.datepicker.parseDate;
|
1227
|
+
$.datepicker.parseDate = function(format, value, settings) {
|
1228
|
+
var date;
|
1229
|
+
try {
|
1230
|
+
date = this._base_parseDate(format, value, settings);
|
1231
|
+
} catch (err) {
|
1232
|
+
if (err.indexOf(":") >= 0) {
|
1233
|
+
// Hack! The error message ends with a colon, a space, and
|
1234
|
+
// the "extra" characters. We rely on that instead of
|
1235
|
+
// attempting to perfectly reproduce the parsing algorithm.
|
1236
|
+
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
|
1237
|
+
} else {
|
1238
|
+
// The underlying error was not related to the time
|
1239
|
+
throw err;
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
return date;
|
1243
|
+
};
|
1244
|
+
|
1245
|
+
//#######################################################################################
|
1246
|
+
// override formatDate to set date with time to the input
|
1247
|
+
//#######################################################################################
|
1248
|
+
$.datepicker._base_formatDate=$.datepicker._formatDate;
|
1249
|
+
$.datepicker._formatDate = function(inst, day, month, year){
|
1250
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1251
|
+
if(tp_inst)
|
1252
|
+
{
|
1253
|
+
if(day)
|
1254
|
+
var b = this._base_formatDate(inst, day, month, year);
|
1255
|
+
tp_inst._updateDateTime(inst);
|
1256
|
+
return tp_inst.$input.val();
|
1257
|
+
}
|
1258
|
+
return this._base_formatDate(inst);
|
1259
|
+
};
|
1260
|
+
|
1261
|
+
//#######################################################################################
|
1262
|
+
// override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
|
1263
|
+
//#######################################################################################
|
1264
|
+
$.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
|
1265
|
+
$.datepicker._optionDatepicker = function(target, name, value) {
|
1266
|
+
var inst = this._getInst(target),
|
1267
|
+
tp_inst = this._get(inst, 'timepicker');
|
1268
|
+
if (tp_inst) {
|
1269
|
+
var min,max,onselect;
|
1270
|
+
if (typeof name == 'string') { // if min/max was set with the string
|
1271
|
+
if (name==='minDate' || name==='minDateTime' )
|
1272
|
+
min = value;
|
1273
|
+
else if (name==='maxDate' || name==='maxDateTime')
|
1274
|
+
max = value;
|
1275
|
+
else if (name==='onSelect')
|
1276
|
+
onselect=value;
|
1277
|
+
} else if (typeof name == 'object') { //if min/max was set with the JSON
|
1278
|
+
if(name.minDate)
|
1279
|
+
min = name.minDate;
|
1280
|
+
else if (name.minDateTime)
|
1281
|
+
min = name.minDateTime;
|
1282
|
+
else if (name.maxDate)
|
1283
|
+
max = name.maxDate;
|
1284
|
+
else if (name.maxDateTime)
|
1285
|
+
max = name.maxDateTime;
|
1286
|
+
}
|
1287
|
+
if(min){ //if min was set
|
1288
|
+
if(min==0)
|
1289
|
+
min=new Date();
|
1290
|
+
else
|
1291
|
+
min= new Date(min);
|
1292
|
+
|
1293
|
+
tp_inst._defaults.minDate = min;
|
1294
|
+
tp_inst._defaults.minDateTime = min;
|
1295
|
+
} else if (max){ //if max was set
|
1296
|
+
if(max==0)
|
1297
|
+
max=new Date();
|
1298
|
+
else
|
1299
|
+
max= new Date(max);
|
1300
|
+
tp_inst._defaults.maxDate = max;
|
1301
|
+
tp_inst._defaults.maxDateTime = max;
|
1302
|
+
}
|
1303
|
+
else if (onselect)
|
1304
|
+
tp_inst._defaults.onSelect=onselect;
|
1305
|
+
}
|
1306
|
+
if (value === undefined)
|
1307
|
+
return this._base_optionDatepicker(target, name);
|
1308
|
+
return this._base_optionDatepicker(target, name, value);
|
1309
|
+
};
|
1310
|
+
|
1311
|
+
//#######################################################################################
|
1312
|
+
// jQuery extend now ignores nulls!
|
1313
|
+
//#######################################################################################
|
1314
|
+
function extendRemove(target, props) {
|
1315
|
+
$.extend(target, props);
|
1316
|
+
for (var name in props)
|
1317
|
+
if (props[name] === null || props[name] === undefined)
|
1318
|
+
target[name] = props[name];
|
1319
|
+
return target;
|
1320
|
+
};
|
1321
|
+
|
1322
|
+
$.timepicker = new Timepicker(); // singleton instance
|
1323
|
+
$.timepicker.version = "0.9.9";
|
1324
|
+
|
1325
|
+
})(jQuery);
|
1326
|
+
|