sunrise-cms 1.0.3 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +25 -0
- data/.rubocop.yml +87 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.rdoc +11 -3
- data/Gemfile +49 -0
- data/README.md +6 -0
- data/Rakefile +4 -2
- data/app/assets/images/sunrise/icons/export.svg +4 -0
- data/app/assets/images/sunrise/icons/import.svg +5 -0
- data/app/assets/javascripts/sunrise/application.js +2 -3
- data/app/assets/javascripts/sunrise/jquery-ui-timepicker-addon.js +2143 -831
- data/app/assets/javascripts/sunrise/jquery.dialog.js.coffee +113 -40
- data/app/assets/javascripts/sunrise/jquery.editable.js.coffee +21 -21
- data/app/assets/javascripts/sunrise/manage.js.coffee +29 -28
- data/app/assets/stylesheets/sunrise/application.css +4 -4
- data/app/assets/stylesheets/sunrise/customize.css +7 -16
- data/app/assets/stylesheets/sunrise/jquery-ui-timepicker-addon.css +11 -0
- data/app/assets/stylesheets/sunrise/main.css +883 -606
- data/app/controllers/sunrise/activities_controller.rb +7 -5
- data/app/controllers/sunrise/application_controller.rb +17 -17
- data/app/controllers/sunrise/dashboard_controller.rb +6 -5
- data/app/controllers/sunrise/manager_controller.rb +145 -104
- data/app/controllers/sunrise/settings_controller.rb +5 -3
- data/app/helpers/sunrise/activities_helper.rb +8 -7
- data/app/helpers/sunrise/application_helper.rb +11 -9
- data/app/helpers/sunrise/dashboard_helper.rb +3 -1
- data/app/helpers/sunrise/manager_helper.rb +28 -27
- data/app/helpers/sunrise/structure_helper.rb +11 -8
- data/app/views/layouts/sunrise/application.html.erb +7 -6
- data/app/views/sunrise/manager/buttons/_export.html.erb +9 -2
- data/app/views/sunrise/manager/buttons/_import.html.erb +25 -0
- data/app/views/sunrise/manager/buttons/_sort.html.erb +3 -3
- data/app/views/sunrise/manager/tree/index.html.erb +1 -1
- data/config/locales/defaults/datetime.rb +7 -7
- data/config/locales/defaults/pluralize.rb +5 -3
- data/config/routes.rb +23 -20
- data/db/migrate/20111216144515_create_assets.rb +9 -7
- data/db/migrate/20111216144915_create_structures.rb +14 -12
- data/db/migrate/20111216145015_create_users.rb +20 -18
- data/db/migrate/20120611095315_create_settings.rb +7 -5
- data/lib/generators/sunrise/install_generator.rb +51 -49
- data/lib/generators/sunrise/templates/config/active_record/sunrise.rb +12 -10
- data/lib/generators/sunrise/templates/config/mongoid/sunrise.rb +14 -12
- data/lib/generators/sunrise/templates/config/seeds.rb +7 -7
- data/lib/generators/sunrise/templates/models/active_record/ability.rb +4 -3
- data/lib/generators/sunrise/templates/models/active_record/asset.rb +5 -3
- data/lib/generators/sunrise/templates/models/active_record/attachment_file.rb +4 -2
- data/lib/generators/sunrise/templates/models/active_record/avatar.rb +7 -5
- data/lib/generators/sunrise/templates/models/active_record/picture.rb +6 -4
- data/lib/generators/sunrise/templates/models/active_record/position_type.rb +5 -3
- data/lib/generators/sunrise/templates/models/active_record/role_type.rb +6 -4
- data/lib/generators/sunrise/templates/models/active_record/settings.rb +5 -3
- data/lib/generators/sunrise/templates/models/active_record/structure.rb +3 -1
- data/lib/generators/sunrise/templates/models/active_record/structure_type.rb +7 -5
- data/lib/generators/sunrise/templates/models/active_record/user.rb +5 -3
- data/lib/generators/sunrise/templates/models/mongoid/ability.rb +4 -3
- data/lib/generators/sunrise/templates/models/mongoid/asset.rb +18 -16
- data/lib/generators/sunrise/templates/models/mongoid/attachment_file.rb +4 -2
- data/lib/generators/sunrise/templates/models/mongoid/avatar.rb +7 -5
- data/lib/generators/sunrise/templates/models/mongoid/picture.rb +4 -2
- data/lib/generators/sunrise/templates/models/mongoid/position_type.rb +5 -3
- data/lib/generators/sunrise/templates/models/mongoid/role_type.rb +6 -4
- data/lib/generators/sunrise/templates/models/mongoid/settings.rb +9 -7
- data/lib/generators/sunrise/templates/models/mongoid/structure.rb +12 -10
- data/lib/generators/sunrise/templates/models/mongoid/structure_type.rb +7 -5
- data/lib/generators/sunrise/templates/models/mongoid/user.rb +37 -35
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_navigation.rb +9 -7
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_page.rb +5 -3
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_structure.rb +10 -9
- data/lib/generators/sunrise/templates/models/sunrise/sunrise_user.rb +15 -13
- data/lib/generators/sunrise/templates/spec/controllers/pages_controller_spec.rb +12 -10
- data/lib/generators/sunrise/templates/spec/controllers/welcome_controller_spec.rb +8 -6
- data/lib/generators/sunrise/templates/spec/factories/structure_factory.rb +6 -5
- data/lib/generators/sunrise/templates/spec/factories/user_factory.rb +19 -18
- data/lib/generators/sunrise/templates/spec/spec_helper.rb +9 -7
- data/lib/generators/sunrise/templates/spec/support/helpers/controller_macros.rb +10 -9
- data/lib/generators/sunrise/templates/uploaders/attachment_file_uploader.rb +4 -2
- data/lib/generators/sunrise/templates/uploaders/avatar_uploader.rb +10 -7
- data/lib/generators/sunrise/templates/uploaders/picture_uploader.rb +9 -6
- data/lib/sunrise-cms.rb +2 -0
- data/lib/sunrise.rb +20 -13
- data/lib/sunrise/abstract_model.rb +103 -106
- data/lib/sunrise/carrierwave/base_uploader.rb +43 -46
- data/lib/sunrise/carrierwave/file_size_validator.rb +16 -11
- data/lib/sunrise/carrierwave/glue.rb +9 -9
- data/lib/sunrise/config.rb +14 -12
- data/lib/sunrise/config/association.rb +4 -3
- data/lib/sunrise/config/base.rb +15 -13
- data/lib/sunrise/config/export.rb +5 -3
- data/lib/sunrise/config/field.rb +26 -24
- data/lib/sunrise/config/form.rb +2 -0
- data/lib/sunrise/config/group.rb +9 -6
- data/lib/sunrise/config/has_fields.rb +6 -5
- data/lib/sunrise/config/has_groups.rb +4 -2
- data/lib/sunrise/config/index.rb +9 -7
- data/lib/sunrise/config/model.rb +20 -14
- data/lib/sunrise/config/navigation.rb +21 -19
- data/lib/sunrise/config/navigation_item.rb +7 -5
- data/lib/sunrise/config/nested_field.rb +13 -12
- data/lib/sunrise/config/page_presenter.rb +5 -2
- data/lib/sunrise/config/show.rb +2 -0
- data/lib/sunrise/core_ext.rb +2 -0
- data/lib/sunrise/core_ext/i18n.rb +9 -9
- data/lib/sunrise/core_ext/string.rb +4 -2
- data/lib/sunrise/engine.rb +22 -16
- data/lib/sunrise/hooks/adapters/active_record.rb +3 -1
- data/lib/sunrise/hooks/adapters/mongoid.rb +4 -2
- data/lib/sunrise/models/ability.rb +12 -10
- data/lib/sunrise/models/asset.rb +43 -43
- data/lib/sunrise/models/position_type.rb +7 -6
- data/lib/sunrise/models/role_type.rb +8 -7
- data/lib/sunrise/models/structure.rb +27 -28
- data/lib/sunrise/models/structure_type.rb +7 -6
- data/lib/sunrise/models/user.rb +39 -37
- data/lib/sunrise/utils.rb +16 -17
- data/lib/sunrise/utils/csv_document.rb +23 -23
- data/lib/sunrise/utils/eval_helpers.rb +41 -39
- data/lib/sunrise/utils/search_wrapper.rb +8 -7
- data/lib/sunrise/utils/transliteration.rb +42 -41
- data/lib/sunrise/version.rb +3 -1
- data/lib/sunrise/views/date_time_input.rb +19 -17
- data/lib/sunrise/views/form_builder.rb +15 -13
- data/lib/sunrise/views/helper.rb +32 -32
- data/lib/sunrise/views/search_wrapper.rb +5 -3
- data/lib/tasks/assets.rake +11 -9
- data/sunrise-cms.gemspec +50 -0
- metadata +85 -596
- data/spec/controllers/sunrise/activities_controller_spec.rb +0 -33
- data/spec/controllers/sunrise/manager_controller_spec.rb +0 -64
- data/spec/controllers/sunrise/settings_controller_spec.rb +0 -45
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -9
- data/spec/dummy/app/assets/javascripts/sunrise/plugins.js +0 -0
- data/spec/dummy/app/assets/javascripts/welcome.js +0 -2
- data/spec/dummy/app/assets/stylesheets/application.css +0 -7
- data/spec/dummy/app/assets/stylesheets/sunrise/plugins.css +0 -0
- data/spec/dummy/app/assets/stylesheets/welcome.css +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/welcome_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -12
- data/spec/dummy/app/helpers/welcome_helper.rb +0 -2
- data/spec/dummy/app/models/active_record/post.rb +0 -18
- data/spec/dummy/app/models/mongoid/post.rb +0 -27
- data/spec/dummy/app/sunrise/sunrise_post.rb +0 -34
- data/spec/dummy/app/views/layouts/application.html.erb +0 -20
- data/spec/dummy/app/views/public_activity/post/_create.html.erb +0 -5
- data/spec/dummy/app/views/public_activity/post/_destroy.html.erb +0 -5
- data/spec/dummy/app/views/public_activity/post/_update.html.erb +0 -5
- data/spec/dummy/app/views/sunrise/manager/users/thumbs/_record.html.erb +0 -34
- data/spec/dummy/app/views/welcome/index.html.erb +0 -2
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -55
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -42
- data/spec/dummy/config/database.yml.sample +0 -34
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -33
- data/spec/dummy/config/environments/production.rb +0 -66
- data/spec/dummy/config/environments/test.rb +0 -41
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/devise.rb +0 -216
- data/spec/dummy/config/initializers/inflections.rb +0 -10
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/sunrise.rb +0 -51
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/mongoid.yml +0 -80
- data/spec/dummy/config/routes.rb +0 -10
- data/spec/dummy/db/migrate/20111227111941_install_acts_as_audited.rb +0 -28
- data/spec/dummy/db/migrate/20111227143901_create_page_parts.rb +0 -20
- data/spec/dummy/db/migrate/20111228152051_create_posts.rb +0 -14
- data/spec/dummy/db/migrate/20120105114018_create_meta_tags.rb +0 -21
- data/spec/dummy/db/migrate/20130214090723_create_activities.rb +0 -23
- data/spec/dummy/db/schema.rb +0 -90
- data/spec/dummy/log/test.log +0 -235
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy/tmp/cache/696/1F0/settings%3Ato_key +0 -1
- data/spec/dummy/tmp/cache/87C/5D0/settings%3Apersisted%3F +0 -1
- data/spec/dummy/tmp/cache/91C/830/settings%3Asome_setting +0 -1
- data/spec/dummy/tmp/cache/94E/D10/settings%3Asome_setting2 +0 -1
- data/spec/dummy/tmp/cache/assets/test/sass/f4a02ee710d6db0936c29533f2166c1526a55a9e/select2.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/03bae0b322a9c8706915fdb4f8d50961 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0a4412d6feb107cf35e452cc82a01134 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0c538631f0f094ca39bdb1448da8a4bc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0c94e795dfbbbf3599fdf312aeb577b9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0e7270936d642e566d747ab335c44ec2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0f894abd40c0b6114a9dff3a0599af7e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0fdc292bf2b2ddb2d0bf079950c8e770 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/10bb80e2753b3d1716765b02ad9a2db3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1349c61c2b491567c1632fcae44110a0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13e20c0d57b7b851a7f025f5606f833f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/146ce2f3522fd98d4a8a1501f16c7092 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/172c139e25cc08516d5a8c72c777dd4d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/18b64b11b8b00cc21a396da25a5ff156 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/197d8d604ec08a638b656e053944b734 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1b73ae25962d8ff98f9f008b73c64bf4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1bdb903463fe67323dbadb0f78337c70 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1ea532f332f1ff667097010cda704c99 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/20215d59350863282208d478ea94cf08 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/212fc15df4fd708ebdef5bd3be2191c1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/256dcb01e7f35659d770584fd71a85d2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/27ec6453d976c5e273e6f2c25830492c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3006732de695a5dfe249dcbf6852b543 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3008328e1cba59ad00ac79ac20275f17 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/31ffcb9d2aba762160a2f4341e5cfd50 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/32ae3cda2e7c692fc9711ab76fcf1c62 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/35948a84ebda6147e5e5b67191ae37d8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/37766ae8287a873cb196a187f3253e66 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/37b44bd55598f75d532d9edbe8c98336 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/383908afbabb6096b774ab7c1856a102 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/38611f05ed0bf72a4755c136796ff5d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3b99bacd5915b4ff7fb2664bc2aa30d0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/443ca9dc693ccf91d6e1cecaffe0fa9a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/45c759123f4f6b42cdcff44b446655a5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4ca01587005a9b895bca383881bec87d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4cffdba2a7aac80c1765e060b152b382 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4d38783b41d7c000fed2419b5173f87a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/51fe2df168cee49df9d4136f59c87872 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/564db16c8d964c3505bfca526e3fccf2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/56e5bd2f3c94d7a9d0da7c4e05c7ad78 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5807e61754ed8b16702f6ad7ba34d439 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/593d990734170367188181754939b317 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5a44970074ecbfeae2cc9798ed7da7aa +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5e7901fbee32b66040fd6376a8c981d8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5ecbfe03cab317594d2bc1c6866d26db +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/609ce9936a503352d73f954f68be7f81 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/65224b6e799d399f4e6cf4bf98155de2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6a1e72555b75237fffccb5de8937b4d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6a8187f5c6f2e115d1a1c21ca2ec81a0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6c9a2f7ab6f8d1f8e3e4cf1d7d6cc68a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6f4f668f70fb14b2132289fed6718f0e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/727e0f830601f307d4c8b9a76e464c1a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/749bd767d6654c80265f5ca0959dc8e1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7a92952d5fff10f09ce91b852d6a744f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7ad564910e515e335bb008989a97efb7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7b55037b89f2debe558b43fe7542e409 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7bb04b7318793726b5414daaa4f049d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7c5f37d1af8a5557b67d6ffb8afcc2b5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7f5092f53db371ea56be62557677a506 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/7f9ced6d264f71631c80df15194abf4d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/80870efa2a2ddb1de325c224daff5712 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/831e225c0e792be993a1d1dc58f20e54 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/83f98047f864c578534b34068cb015e0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/84361af51e20dcfad7fae0f32f284ab7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/894aeaae9cc8483fa9f7a5146ff6ff6f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/89567cbb5e7770a065e88360dcd02833 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/89a5be65dc0d00fa22be4375c029d69c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8bf0319a2b612416dfde2d3b939dbf99 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8cfeb6443a5f7398e67010a202ee2de2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8e3769f6378278754105f0924e6dd1ff +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/96c321f84bd796096692021bc4a87eed +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/97e875e2282fba5939cf71198faab1f0 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9911ee0fc41f519a1c4faa7912547cce +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9ac84ed11232b2f7fc9f80c18844abc8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9ba0cab624f25b68f79447e62fbc6112 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9e9edfa954375fd0cc6498f70b883e8e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a3863764f2fbc185e0d2ea584c7e2174 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a4c4a00b0d2b8334de3ee3169064adad +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a744e8f2a7ce02e7af9784f40c711ed5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a78a33e8cea959257da93b3e67786300 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a9956bd25bbe4c811a1a758f71aec748 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/aa4822def20c419f0e50e2a38e73a1df +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/aaa24da6bd0fcf694077519e189b7392 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b0493d9dbe3afb3268b7ffce2b87bf78 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b2c398b7a51a65be12ba944bdea13415 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b81381e4a978aa69cc2ab1f892a40e97 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b82707486d5133da748e4382c62de995 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bb83cb3c179681d65c77a41e98f1c70f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bbc50f2009705d8fd7b91330bc24dcb8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bcb7548b203cc2c5a484ef7649911c2d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/becade26fead85d486f136be49b45e23 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/bfc0fef30976427a03ddccb1ce78d6e7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c0dd93a468e038b3653ed4d28874e0cb +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c1d2340cbfe5e80d388f95e7a08698d9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c25afdb537c84a18bd62fc782164d298 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c3dc3ada4560805584739bfe7c2b24d9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c4dc50a79ec929d33d9e2835d1926fd9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c5f990ee58d3727faeb4cfd3f5667e8a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c622effcf1aa225bf2920d2b63ca525c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d09dc20f2dc66183aa23ce1fd8fc9f2c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d60bdefb444e91b75e4cc2f3fc49228b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d7c40ebee2fb9471bab352337570ba40 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d9bc94e1e0cc114986f8760bc4eb42ce +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/da4488b32bd6fb75c655a077956c9034 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/daeb51b1ca3de2a1f2146dea431249d3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/dd0e13880601ea049b7c6d8c76ea535f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/dd15d7b9860a8a187c4a6c167dc56547 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/dd8ed9b0203321fd815ba48a5867620e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e1e036b04a3a20b2fb589420ad03b926 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e4f46080338c0c52e3933999a7f8106d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e59a3c2ff941e0fdc7987168580bf4cc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e6cfe2e09e34ec2b24494a74eed5243a +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e8e088454cc6f38324bd168e299cf08f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e949207f9e9578cfd48ab90bb82ea384 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ee5a41236d43159aac87f9224a0bcfb8 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/ef5f76363cd723089ce62b8c207415a4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f2de4855fd4840abb2f6e80afee5f4ed +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f5165c4d7cee0e7cb99bc069fd4c09b9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f660938bc4a80358883ba6c576e1dd13 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7379cc2d3a2fc4b87d64c68d2d8684f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f81b83e98592ff24dd8518985baa48cd +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f94b13174ed1cc7f087a66c0094ef4cf +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f975cba8c490022ddfc45bab0b512879 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/face6eb5e3ee8802296bdc38e5704d72 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fc9155176668e1a56a5ca3843febe3c3 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/fd7e46e0b42a510b40f17d1f1bacf80e +0 -0
- data/spec/factories/asset_factory.rb +0 -21
- data/spec/factories/files/rails.png +0 -0
- data/spec/factories/files/silicon_valley.jpg +0 -0
- data/spec/factories/page_factory.rb +0 -10
- data/spec/factories/post_factory.rb +0 -9
- data/spec/factories/structure_factory.rb +0 -22
- data/spec/factories/user_factory.rb +0 -49
- data/spec/generators/install_generator_spec.rb +0 -55
- data/spec/models/avatar_spec.rb +0 -138
- data/spec/models/i18n_backend.rb +0 -30
- data/spec/models/structure_spec.rb +0 -120
- data/spec/models/sunrise/abstract_model_spec.rb +0 -88
- data/spec/models/sunrise/carrierwave/picture_uploader_spec.rb +0 -49
- data/spec/models/sunrise/search_wrapper_spec.rb +0 -21
- data/spec/models/user_spec.rb +0 -63
- data/spec/orm/active_record.rb +0 -5
- data/spec/orm/kaminari/active_record.rb +0 -18
- data/spec/orm/kaminari/mongoid.rb +0 -20
- data/spec/orm/mongoid.rb +0 -15
- data/spec/requests/activities_spec.rb +0 -41
- data/spec/requests/dashboard_spec.rb +0 -35
- data/spec/requests/manager/default/create_spec.rb +0 -43
- data/spec/requests/manager/default/destroy_spec.rb +0 -36
- data/spec/requests/manager/default/edit_spec.rb +0 -72
- data/spec/requests/manager/default/export_spec.rb +0 -121
- data/spec/requests/manager/default/index_spec.rb +0 -67
- data/spec/requests/manager/default/new_spec.rb +0 -59
- data/spec/requests/manager/default/show_spec.rb +0 -41
- data/spec/requests/manager/default/update_spec.rb +0 -73
- data/spec/requests/manager/many/create_spec.rb +0 -52
- data/spec/requests/manager/many/destroy_spec.rb +0 -41
- data/spec/requests/manager/many/edit_spec.rb +0 -43
- data/spec/requests/manager/many/index_spec.rb +0 -54
- data/spec/requests/manager/many/new_spec.rb +0 -40
- data/spec/requests/manager/many/update_spec.rb +0 -55
- data/spec/spec_helper.rb +0 -90
- data/spec/sunrise_spec.rb +0 -29
- data/spec/support/helpers/controller_helper.rb +0 -27
- data/spec/support/helpers/controller_macros.rb +0 -40
- data/spec/support/hooks/structure.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '098ce642eeaa4b3b99e038cac5afe914c4fec9c8e5a89a74454f2fa3bc0e8505'
|
4
|
+
data.tar.gz: accfeff359f7db91dee2ad3b186f7b1b93130d6c8e0f716c4e689d32963d9760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2560918f0f7f7103a48b27b4afc7f753effa7757054f2d1cb8a3f6e3964c987a7183a0f78a43c4950358f9131c0c895160e1b11f0278417ac2cbce622f8711d
|
7
|
+
data.tar.gz: '082d6d8027a20ace581d6a1008fe13981ff25198997dd5689383ba09b4ae319ec08db84ee7ccab75d9400a072812da9328dc94c428617af5e38e053a2d98e8ca'
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
pkg/
|
2
|
+
Gemfile.lock
|
3
|
+
.rspec
|
4
|
+
spec/tmp
|
5
|
+
spec/dummy/log/*.log
|
6
|
+
spec/dummy/tmp/
|
7
|
+
spec/dummy/config/*.yml
|
8
|
+
spec/dummy/config/*.conf
|
9
|
+
spec/dummy/config/logrotate-config
|
10
|
+
spec/dummy/config/nginx-config
|
11
|
+
spec/dummy/db/schema.rb
|
12
|
+
spec/dummy/db/sphinx/
|
13
|
+
spec/dummy/public/cache/
|
14
|
+
spec/dummy/public/assets/
|
15
|
+
spec/dummy/public/ckeditor_assets/
|
16
|
+
spec/dummy/public/uploads/
|
17
|
+
spec/dummy/vendor/bundle/
|
18
|
+
spec/dummy/app/helpers/manage
|
19
|
+
spec/dummy/config/database.yml
|
20
|
+
spec/dummy/log/development.log
|
21
|
+
.bundle/
|
22
|
+
vendor/bundle/
|
23
|
+
.DS_Store
|
24
|
+
uploads/
|
25
|
+
.byebug_history
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require: rubocop-rails
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.5.5
|
4
|
+
Exclude:
|
5
|
+
- '**/vendor/**/*'
|
6
|
+
- '**/db/schema.rb'
|
7
|
+
- '**/db/migrate'
|
8
|
+
- '**/app/views/**/*'
|
9
|
+
|
10
|
+
##################### Styles ##################################
|
11
|
+
|
12
|
+
Style/Documentation:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/SymbolArray:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/ClassAndModuleChildren:
|
19
|
+
Exclude:
|
20
|
+
- "app/models/**/*.rb"
|
21
|
+
- "app/controllers/**/*.rb"
|
22
|
+
- "app/serializers/**/*.rb"
|
23
|
+
|
24
|
+
Style/BlockDelimiters:
|
25
|
+
Exclude:
|
26
|
+
- "spec/controllers/**/*.rb"
|
27
|
+
|
28
|
+
Style/SymbolProc:
|
29
|
+
Exclude:
|
30
|
+
- "app/policies/*.rb"
|
31
|
+
|
32
|
+
#################### Lint ##################################
|
33
|
+
|
34
|
+
Lint/AmbiguousBlockAssociation:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
##################### Metrics ##################################
|
38
|
+
|
39
|
+
Metrics/LineLength:
|
40
|
+
Max: 110
|
41
|
+
|
42
|
+
Metrics/MethodLength:
|
43
|
+
Max: 15
|
44
|
+
Exclude:
|
45
|
+
- "app/policies/*.rb"
|
46
|
+
|
47
|
+
Metrics/ClassLength:
|
48
|
+
Max: 200
|
49
|
+
Exclude:
|
50
|
+
- "app/policies/*.rb"
|
51
|
+
|
52
|
+
Metrics/ModuleLength:
|
53
|
+
Max: 200
|
54
|
+
Exclude:
|
55
|
+
- "**/*_spec.rb"
|
56
|
+
|
57
|
+
Metrics/BlockLength:
|
58
|
+
Max: 50
|
59
|
+
Exclude:
|
60
|
+
- "**/*_spec.rb"
|
61
|
+
- "config/routes.rb"
|
62
|
+
- "app/policies/*.rb"
|
63
|
+
|
64
|
+
##################### Rails ##################################
|
65
|
+
|
66
|
+
Rails:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
Rails/SkipsModelValidations:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
Rails/InverseOf:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Rails/HasManyOrHasOneDependent:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
Rails/UnknownEnv:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Rails/OutputSafety:
|
82
|
+
Exclude:
|
83
|
+
- 'app/inputs/*.rb'
|
84
|
+
|
85
|
+
Rails/HttpPositionalArguments:
|
86
|
+
Exclude:
|
87
|
+
- 'spec/requests/**/*_spec.rb'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.5
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
== 1.1.1
|
2
|
+
* Update code to be compatible with rails 5.x
|
3
|
+
* Import for records functional
|
4
|
+
* Remove select2 dependecy
|
5
|
+
|
6
|
+
== 1.0.5
|
7
|
+
* Update jQuery UI
|
8
|
+
|
1
9
|
== 1.0.3
|
2
10
|
* Fix parents relations
|
3
|
-
|
11
|
+
|
4
12
|
== 1.0.2
|
5
13
|
* Use select2
|
6
14
|
* Remove chosen
|
@@ -60,10 +68,10 @@
|
|
60
68
|
* Replace paperclip with carrierwave
|
61
69
|
* New model filter logic
|
62
70
|
|
63
|
-
* Scaffold
|
71
|
+
* Scaffold
|
64
72
|
* Generate spec tests for controllers
|
65
73
|
* Apply new model filter logic
|
66
|
-
|
74
|
+
|
67
75
|
== 0.1.5
|
68
76
|
* Core
|
69
77
|
* Export users to csv
|
data/Gemfile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Declare your gem's dependencies in sunrise-cms.gemspec.
|
6
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
7
|
+
# development dependencies will be added by default to the :development group.
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
gem 'rails', '~> 4.2', '>= 4.2.11.1'
|
11
|
+
|
12
|
+
# jquery-rails is used by the dummy application
|
13
|
+
gem 'jquery-rails'
|
14
|
+
|
15
|
+
gem 'devise'
|
16
|
+
gem 'devise-encryptable'
|
17
|
+
gem 'ruby2xlsx'
|
18
|
+
|
19
|
+
gem 'galetahub-enum_field', '~> 0.4.0'
|
20
|
+
gem 'rails-settings-cached', '~> 0.4.0'
|
21
|
+
gem 'rails-uploader', '~> 0.3.4'
|
22
|
+
|
23
|
+
gem 'sprockets', '>= 3.0.0', '< 4.0.0'
|
24
|
+
|
25
|
+
# Gems used only for assets and not required
|
26
|
+
# in production environments by default.
|
27
|
+
group :assets do
|
28
|
+
gem 'coffee-rails'
|
29
|
+
gem 'sass-rails'
|
30
|
+
gem 'sass'
|
31
|
+
|
32
|
+
gem 'libv8', '~> 3.11.8.4', platforms: :ruby
|
33
|
+
gem 'uglifier', '>= 1.0.3'
|
34
|
+
# gem 'therubyracer', platforms: :ruby
|
35
|
+
end
|
36
|
+
|
37
|
+
group :development, :test do
|
38
|
+
gem 'byebug'
|
39
|
+
gem 'fuubar'
|
40
|
+
gem 'generator_spec', '~> 0.9.4'
|
41
|
+
gem 'launchy'
|
42
|
+
gem 'ruby-progressbar'
|
43
|
+
end
|
44
|
+
|
45
|
+
group :active_record do
|
46
|
+
gem 'activerecord'
|
47
|
+
gem 'awesome_nested_set'
|
48
|
+
gem 'pg', '~> 0.15'
|
49
|
+
end
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'rake'
|
3
4
|
require 'rake/testtask'
|
4
5
|
require 'rdoc/task'
|
6
|
+
require 'bundler/gem_tasks'
|
5
7
|
|
6
8
|
desc 'Default: run unit tests.'
|
7
|
-
task :
|
9
|
+
task default: :test
|
8
10
|
|
9
11
|
desc 'Test the sunrise plugin.'
|
10
12
|
Rake::TestTask.new(:test) do |t|
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg id="i-export" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
|
3
|
+
<path d="M28 22 L28 30 4 30 4 22 M16 4 L16 24 M8 12 L16 4 24 12" />
|
4
|
+
</svg>
|
@@ -1,11 +1,10 @@
|
|
1
1
|
//= require jquery
|
2
2
|
//= require jquery_ujs
|
3
3
|
|
4
|
-
//= require jquery
|
5
|
-
//= require jquery
|
4
|
+
//= require jquery-ui/sortable
|
5
|
+
//= require jquery-ui/datepicker
|
6
6
|
//= require datepicker/jquery.ui.datepicker-uk
|
7
7
|
//= require datepicker/jquery.ui.datepicker-ru
|
8
|
-
//= require select2
|
9
8
|
|
10
9
|
//= require sunrise/jquery.tmpl.min
|
11
10
|
//= require sunrise/jquery.cookie
|
@@ -1,911 +1,2223 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
*
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
*
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
*
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
function
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
1
|
+
/*! jQuery Timepicker Addon - v1.5.0 - 2014-09-01
|
2
|
+
* http://trentrichardson.com/examples/timepicker
|
3
|
+
* Copyright (c) 2014 Trent Richardson; Licensed MIT */
|
4
|
+
(function ($) {
|
5
|
+
|
6
|
+
/*
|
7
|
+
* Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
|
8
|
+
*/
|
9
|
+
$.ui.timepicker = $.ui.timepicker || {};
|
10
|
+
if ($.ui.timepicker.version) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Extend jQueryUI, get it started with our version number
|
16
|
+
*/
|
17
|
+
$.extend($.ui, {
|
18
|
+
timepicker: {
|
19
|
+
version: "1.5.0"
|
20
|
+
}
|
21
|
+
});
|
22
|
+
|
23
|
+
/*
|
24
|
+
* Timepicker manager.
|
25
|
+
* Use the singleton instance of this class, $.timepicker, to interact with the time picker.
|
26
|
+
* Settings for (groups of) time pickers are maintained in an instance object,
|
27
|
+
* allowing multiple different settings on the same page.
|
28
|
+
*/
|
29
|
+
var Timepicker = function () {
|
30
|
+
this.regional = []; // Available regional settings, indexed by language code
|
31
|
+
this.regional[''] = { // Default regional settings
|
32
|
+
currentText: 'Now',
|
33
|
+
closeText: 'Done',
|
34
|
+
amNames: ['AM', 'A'],
|
35
|
+
pmNames: ['PM', 'P'],
|
36
|
+
timeFormat: 'HH:mm',
|
37
|
+
timeSuffix: '',
|
38
|
+
timeOnlyTitle: 'Choose Time',
|
39
|
+
timeText: 'Time',
|
40
|
+
hourText: 'Hour',
|
41
|
+
minuteText: 'Minute',
|
42
|
+
secondText: 'Second',
|
43
|
+
millisecText: 'Millisecond',
|
44
|
+
microsecText: 'Microsecond',
|
45
|
+
timezoneText: 'Time Zone',
|
46
|
+
isRTL: false
|
47
|
+
};
|
48
|
+
this._defaults = { // Global defaults for all the datetime picker instances
|
49
|
+
showButtonPanel: true,
|
50
|
+
timeOnly: false,
|
51
|
+
timeOnlyShowDate: false,
|
52
|
+
showHour: null,
|
53
|
+
showMinute: null,
|
54
|
+
showSecond: null,
|
55
|
+
showMillisec: null,
|
56
|
+
showMicrosec: null,
|
57
|
+
showTimezone: null,
|
58
|
+
showTime: true,
|
59
|
+
stepHour: 1,
|
60
|
+
stepMinute: 1,
|
61
|
+
stepSecond: 1,
|
62
|
+
stepMillisec: 1,
|
63
|
+
stepMicrosec: 1,
|
64
|
+
hour: 0,
|
65
|
+
minute: 0,
|
66
|
+
second: 0,
|
67
|
+
millisec: 0,
|
68
|
+
microsec: 0,
|
69
|
+
timezone: null,
|
70
|
+
hourMin: 0,
|
71
|
+
minuteMin: 0,
|
72
|
+
secondMin: 0,
|
73
|
+
millisecMin: 0,
|
74
|
+
microsecMin: 0,
|
75
|
+
hourMax: 23,
|
76
|
+
minuteMax: 59,
|
77
|
+
secondMax: 59,
|
78
|
+
millisecMax: 999,
|
79
|
+
microsecMax: 999,
|
80
|
+
minDateTime: null,
|
81
|
+
maxDateTime: null,
|
82
|
+
maxTime: null,
|
83
|
+
minTime: null,
|
84
|
+
onSelect: null,
|
85
|
+
hourGrid: 0,
|
86
|
+
minuteGrid: 0,
|
87
|
+
secondGrid: 0,
|
88
|
+
millisecGrid: 0,
|
89
|
+
microsecGrid: 0,
|
90
|
+
alwaysSetTime: true,
|
91
|
+
separator: ' ',
|
92
|
+
altFieldTimeOnly: true,
|
93
|
+
altTimeFormat: null,
|
94
|
+
altSeparator: null,
|
95
|
+
altTimeSuffix: null,
|
96
|
+
altRedirectFocus: true,
|
97
|
+
pickerTimeFormat: null,
|
98
|
+
pickerTimeSuffix: null,
|
99
|
+
showTimepicker: true,
|
100
|
+
timezoneList: null,
|
101
|
+
addSliderAccess: false,
|
102
|
+
sliderAccessArgs: null,
|
103
|
+
controlType: 'slider',
|
104
|
+
defaultValue: null,
|
105
|
+
parse: 'strict'
|
106
|
+
};
|
107
|
+
$.extend(this._defaults, this.regional['']);
|
108
|
+
};
|
109
|
+
|
110
|
+
$.extend(Timepicker.prototype, {
|
111
|
+
$input: null,
|
112
|
+
$altInput: null,
|
113
|
+
$timeObj: null,
|
114
|
+
inst: null,
|
115
|
+
hour_slider: null,
|
116
|
+
minute_slider: null,
|
117
|
+
second_slider: null,
|
118
|
+
millisec_slider: null,
|
119
|
+
microsec_slider: null,
|
120
|
+
timezone_select: null,
|
121
|
+
maxTime: null,
|
122
|
+
minTime: null,
|
52
123
|
hour: 0,
|
53
124
|
minute: 0,
|
54
125
|
second: 0,
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
126
|
+
millisec: 0,
|
127
|
+
microsec: 0,
|
128
|
+
timezone: null,
|
129
|
+
hourMinOriginal: null,
|
130
|
+
minuteMinOriginal: null,
|
131
|
+
secondMinOriginal: null,
|
132
|
+
millisecMinOriginal: null,
|
133
|
+
microsecMinOriginal: null,
|
134
|
+
hourMaxOriginal: null,
|
135
|
+
minuteMaxOriginal: null,
|
136
|
+
secondMaxOriginal: null,
|
137
|
+
millisecMaxOriginal: null,
|
138
|
+
microsecMaxOriginal: null,
|
139
|
+
ampm: '',
|
140
|
+
formattedDate: '',
|
141
|
+
formattedTime: '',
|
142
|
+
formattedDateTime: '',
|
143
|
+
timezoneList: null,
|
144
|
+
units: ['hour', 'minute', 'second', 'millisec', 'microsec'],
|
145
|
+
support: {},
|
146
|
+
control: null,
|
147
|
+
|
148
|
+
/*
|
149
|
+
* Override the default settings for all instances of the time picker.
|
150
|
+
* @param {Object} settings object - the new settings to use as defaults (anonymous object)
|
151
|
+
* @return {Object} the manager object
|
152
|
+
*/
|
153
|
+
setDefaults: function (settings) {
|
154
|
+
extendRemove(this._defaults, settings || {});
|
155
|
+
return this;
|
156
|
+
},
|
157
|
+
|
158
|
+
/*
|
159
|
+
* Create a new Timepicker instance
|
160
|
+
*/
|
161
|
+
_newInst: function ($input, opts) {
|
162
|
+
var tp_inst = new Timepicker(),
|
163
|
+
inlineSettings = {},
|
164
|
+
fns = {},
|
165
|
+
overrides, i;
|
166
|
+
|
167
|
+
for (var attrName in this._defaults) {
|
168
|
+
if (this._defaults.hasOwnProperty(attrName)) {
|
169
|
+
var attrValue = $input.attr('time:' + attrName);
|
170
|
+
if (attrValue) {
|
171
|
+
try {
|
172
|
+
inlineSettings[attrName] = eval(attrValue);
|
173
|
+
} catch (err) {
|
174
|
+
inlineSettings[attrName] = attrValue;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
overrides = {
|
181
|
+
beforeShow: function (input, dp_inst) {
|
182
|
+
if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
|
183
|
+
return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
|
184
|
+
}
|
185
|
+
},
|
186
|
+
onChangeMonthYear: function (year, month, dp_inst) {
|
187
|
+
// Update the time as well : this prevents the time from disappearing from the $input field.
|
188
|
+
tp_inst._updateDateTime(dp_inst);
|
189
|
+
if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
|
190
|
+
tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
|
191
|
+
}
|
192
|
+
},
|
193
|
+
onClose: function (dateText, dp_inst) {
|
194
|
+
if (tp_inst.timeDefined === true && $input.val() !== '') {
|
195
|
+
tp_inst._updateDateTime(dp_inst);
|
196
|
+
}
|
197
|
+
if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
|
198
|
+
tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
};
|
202
|
+
for (i in overrides) {
|
203
|
+
if (overrides.hasOwnProperty(i)) {
|
204
|
+
fns[i] = opts[i] || null;
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, {
|
209
|
+
evnts: fns,
|
210
|
+
timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
|
211
|
+
});
|
212
|
+
tp_inst.amNames = $.map(tp_inst._defaults.amNames, function (val) {
|
213
|
+
return val.toUpperCase();
|
214
|
+
});
|
215
|
+
tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function (val) {
|
216
|
+
return val.toUpperCase();
|
217
|
+
});
|
218
|
+
|
219
|
+
// detect which units are supported
|
220
|
+
tp_inst.support = detectSupport(
|
221
|
+
tp_inst._defaults.timeFormat +
|
222
|
+
(tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') +
|
223
|
+
(tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : ''));
|
224
|
+
|
225
|
+
// controlType is string - key to our this._controls
|
226
|
+
if (typeof(tp_inst._defaults.controlType) === 'string') {
|
227
|
+
if (tp_inst._defaults.controlType === 'slider' && typeof($.ui.slider) === 'undefined') {
|
228
|
+
tp_inst._defaults.controlType = 'select';
|
229
|
+
}
|
230
|
+
tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
|
231
|
+
}
|
232
|
+
// controlType is an object and must implement create, options, value methods
|
233
|
+
else {
|
234
|
+
tp_inst.control = tp_inst._defaults.controlType;
|
235
|
+
}
|
117
236
|
|
118
|
-
|
119
|
-
var
|
120
|
-
|
237
|
+
// prep the timezone options
|
238
|
+
var timezoneList = [-720, -660, -600, -570, -540, -480, -420, -360, -300, -270, -240, -210, -180, -120, -60,
|
239
|
+
0, 60, 120, 180, 210, 240, 270, 300, 330, 345, 360, 390, 420, 480, 525, 540, 570, 600, 630, 660, 690, 720, 765, 780, 840];
|
240
|
+
if (tp_inst._defaults.timezoneList !== null) {
|
241
|
+
timezoneList = tp_inst._defaults.timezoneList;
|
242
|
+
}
|
243
|
+
var tzl = timezoneList.length, tzi = 0, tzv = null;
|
244
|
+
if (tzl > 0 && typeof timezoneList[0] !== 'object') {
|
245
|
+
for (; tzi < tzl; tzi++) {
|
246
|
+
tzv = timezoneList[tzi];
|
247
|
+
timezoneList[tzi] = { value: tzv, label: $.timepicker.timezoneOffsetString(tzv, tp_inst.support.iso8601) };
|
248
|
+
}
|
249
|
+
}
|
250
|
+
tp_inst._defaults.timezoneList = timezoneList;
|
251
|
+
|
252
|
+
// set the default units
|
253
|
+
tp_inst.timezone = tp_inst._defaults.timezone !== null ? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) :
|
254
|
+
((new Date()).getTimezoneOffset() * -1);
|
255
|
+
tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin ? tp_inst._defaults.hourMin :
|
256
|
+
tp_inst._defaults.hour > tp_inst._defaults.hourMax ? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
|
257
|
+
tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin ? tp_inst._defaults.minuteMin :
|
258
|
+
tp_inst._defaults.minute > tp_inst._defaults.minuteMax ? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
|
259
|
+
tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin ? tp_inst._defaults.secondMin :
|
260
|
+
tp_inst._defaults.second > tp_inst._defaults.secondMax ? tp_inst._defaults.secondMax : tp_inst._defaults.second;
|
261
|
+
tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin ? tp_inst._defaults.millisecMin :
|
262
|
+
tp_inst._defaults.millisec > tp_inst._defaults.millisecMax ? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
|
263
|
+
tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin ? tp_inst._defaults.microsecMin :
|
264
|
+
tp_inst._defaults.microsec > tp_inst._defaults.microsecMax ? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec;
|
265
|
+
tp_inst.ampm = '';
|
266
|
+
tp_inst.$input = $input;
|
267
|
+
|
268
|
+
if (tp_inst._defaults.altField) {
|
269
|
+
tp_inst.$altInput = $(tp_inst._defaults.altField);
|
270
|
+
if (tp_inst._defaults.altRedirectFocus === true) {
|
271
|
+
tp_inst.$altInput.css({
|
272
|
+
cursor: 'pointer'
|
273
|
+
}).focus(function () {
|
274
|
+
$input.trigger("focus");
|
275
|
+
});
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {
|
280
|
+
tp_inst._defaults.minDate = new Date();
|
281
|
+
}
|
282
|
+
if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) {
|
283
|
+
tp_inst._defaults.maxDate = new Date();
|
284
|
+
}
|
285
|
+
|
286
|
+
// datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
|
287
|
+
if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) {
|
288
|
+
tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
|
289
|
+
}
|
290
|
+
if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
|
291
|
+
tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
|
292
|
+
}
|
293
|
+
if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
|
294
|
+
tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
|
295
|
+
}
|
296
|
+
if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
|
297
|
+
tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
|
298
|
+
}
|
299
|
+
tp_inst.$input.bind('focus', function () {
|
300
|
+
tp_inst._onFocus();
|
301
|
+
});
|
302
|
+
|
303
|
+
return tp_inst;
|
304
|
+
},
|
305
|
+
|
306
|
+
/*
|
307
|
+
* add our sliders to the calendar
|
308
|
+
*/
|
309
|
+
_addTimePicker: function (dp_inst) {
|
310
|
+
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
|
311
|
+
|
312
|
+
this.timeDefined = this._parseTime(currDT);
|
313
|
+
this._limitMinMaxDateTime(dp_inst, false);
|
314
|
+
this._injectTimePicker();
|
315
|
+
},
|
316
|
+
|
317
|
+
/*
|
318
|
+
* parse the time string from input value or _setTime
|
319
|
+
*/
|
320
|
+
_parseTime: function (timeString, withDate) {
|
321
|
+
if (!this.inst) {
|
322
|
+
this.inst = $.datepicker._getInst(this.$input[0]);
|
323
|
+
}
|
324
|
+
|
325
|
+
if (withDate || !this._defaults.timeOnly) {
|
326
|
+
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
|
121
327
|
try {
|
122
|
-
|
328
|
+
var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
|
329
|
+
if (!parseRes.timeObj) {
|
330
|
+
return false;
|
331
|
+
}
|
332
|
+
$.extend(this, parseRes.timeObj);
|
123
333
|
} catch (err) {
|
124
|
-
|
334
|
+
$.timepicker.log("Error parsing the date/time string: " + err +
|
335
|
+
"\ndate/time string = " + timeString +
|
336
|
+
"\ntimeFormat = " + this._defaults.timeFormat +
|
337
|
+
"\ndateFormat = " + dp_dateFormat);
|
338
|
+
return false;
|
339
|
+
}
|
340
|
+
return true;
|
341
|
+
} else {
|
342
|
+
var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
|
343
|
+
if (!timeObj) {
|
344
|
+
return false;
|
125
345
|
}
|
346
|
+
$.extend(this, timeObj);
|
347
|
+
return true;
|
126
348
|
}
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
tp_inst
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
349
|
+
},
|
350
|
+
|
351
|
+
/*
|
352
|
+
* generate and inject html for timepicker into ui datepicker
|
353
|
+
*/
|
354
|
+
_injectTimePicker: function () {
|
355
|
+
var $dp = this.inst.dpDiv,
|
356
|
+
o = this.inst.settings,
|
357
|
+
tp_inst = this,
|
358
|
+
litem = '',
|
359
|
+
uitem = '',
|
360
|
+
show = null,
|
361
|
+
max = {},
|
362
|
+
gridSize = {},
|
363
|
+
size = null,
|
364
|
+
i = 0,
|
365
|
+
l = 0;
|
366
|
+
|
367
|
+
// Prevent displaying twice
|
368
|
+
if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
|
369
|
+
var noDisplay = ' style="display:none;"',
|
370
|
+
html = '<div class="ui-timepicker-div' + (o.isRTL ? ' ui-timepicker-rtl' : '') + '"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
|
371
|
+
'<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
|
372
|
+
|
373
|
+
// Create the markup
|
374
|
+
for (i = 0, l = this.units.length; i < l; i++) {
|
375
|
+
litem = this.units[i];
|
376
|
+
uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
|
377
|
+
show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
|
378
|
+
|
379
|
+
// Added by Peter Medeiros:
|
380
|
+
// - Figure out what the hour/minute/second max should be based on the step values.
|
381
|
+
// - Example: if stepMinute is 15, then minMax is 45.
|
382
|
+
max[litem] = parseInt((o[litem + 'Max'] - ((o[litem + 'Max'] - o[litem + 'Min']) % o['step' + uitem])), 10);
|
383
|
+
gridSize[litem] = 0;
|
384
|
+
|
385
|
+
html += '<dt class="ui_tpicker_' + litem + '_label"' + (show ? '' : noDisplay) + '>' + o[litem + 'Text'] + '</dt>' +
|
386
|
+
'<dd class="ui_tpicker_' + litem + '"><div class="ui_tpicker_' + litem + '_slider"' + (show ? '' : noDisplay) + '></div>';
|
387
|
+
|
388
|
+
if (show && o[litem + 'Grid'] > 0) {
|
389
|
+
html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
|
390
|
+
|
391
|
+
if (litem === 'hour') {
|
392
|
+
for (var h = o[litem + 'Min']; h <= max[litem]; h += parseInt(o[litem + 'Grid'], 10)) {
|
393
|
+
gridSize[litem]++;
|
394
|
+
var tmph = $.datepicker.formatTime(this.support.ampm ? 'hht' : 'HH', {hour: h}, o);
|
395
|
+
html += '<td data-for="' + litem + '">' + tmph + '</td>';
|
396
|
+
}
|
397
|
+
}
|
398
|
+
else {
|
399
|
+
for (var m = o[litem + 'Min']; m <= max[litem]; m += parseInt(o[litem + 'Grid'], 10)) {
|
400
|
+
gridSize[litem]++;
|
401
|
+
html += '<td data-for="' + litem + '">' + ((m < 10) ? '0' : '') + m + '</td>';
|
402
|
+
}
|
403
|
+
}
|
147
404
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
405
|
+
html += '</tr></table></div>';
|
406
|
+
}
|
407
|
+
html += '</dd>';
|
408
|
+
}
|
409
|
+
|
410
|
+
// Timezone
|
411
|
+
var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
|
412
|
+
html += '<dt class="ui_tpicker_timezone_label"' + (showTz ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
|
413
|
+
html += '<dd class="ui_tpicker_timezone" ' + (showTz ? '' : noDisplay) + '></dd>';
|
414
|
+
|
415
|
+
// Create the elements from string
|
416
|
+
html += '</dl></div>';
|
417
|
+
var $tp = $(html);
|
418
|
+
|
419
|
+
// if we only want time picker...
|
420
|
+
if (o.timeOnly === true) {
|
421
|
+
$tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
|
422
|
+
$dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
|
423
|
+
}
|
424
|
+
|
425
|
+
// add sliders, adjust grids, add events
|
426
|
+
for (i = 0, l = tp_inst.units.length; i < l; i++) {
|
427
|
+
litem = tp_inst.units[i];
|
428
|
+
uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
|
429
|
+
show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
|
430
|
+
|
431
|
+
// add the slider
|
432
|
+
tp_inst[litem + '_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_' + litem + '_slider'), litem, tp_inst[litem], o[litem + 'Min'], max[litem], o['step' + uitem]);
|
433
|
+
|
434
|
+
// adjust the grid and add click event
|
435
|
+
if (show && o[litem + 'Grid'] > 0) {
|
436
|
+
size = 100 * gridSize[litem] * o[litem + 'Grid'] / (max[litem] - o[litem + 'Min']);
|
437
|
+
$tp.find('.ui_tpicker_' + litem + ' table').css({
|
438
|
+
width: size + "%",
|
439
|
+
marginLeft: o.isRTL ? '0' : ((size / (-2 * gridSize[litem])) + "%"),
|
440
|
+
marginRight: o.isRTL ? ((size / (-2 * gridSize[litem])) + "%") : '0',
|
441
|
+
borderCollapse: 'collapse'
|
442
|
+
}).find("td").click(function (e) {
|
443
|
+
var $t = $(this),
|
444
|
+
h = $t.html(),
|
445
|
+
n = parseInt(h.replace(/[^0-9]/g), 10),
|
446
|
+
ap = h.replace(/[^apm]/ig),
|
447
|
+
f = $t.data('for'); // loses scope, so we use data-for
|
448
|
+
|
449
|
+
if (f === 'hour') {
|
450
|
+
if (ap.indexOf('p') !== -1 && n < 12) {
|
451
|
+
n += 12;
|
452
|
+
}
|
453
|
+
else {
|
454
|
+
if (ap.indexOf('a') !== -1 && n === 12) {
|
455
|
+
n = 0;
|
456
|
+
}
|
457
|
+
}
|
458
|
+
}
|
459
|
+
|
460
|
+
tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n);
|
461
|
+
|
462
|
+
tp_inst._onTimeChange();
|
463
|
+
tp_inst._onSelectHandler();
|
464
|
+
}).css({
|
465
|
+
cursor: 'pointer',
|
466
|
+
width: (100 / gridSize[litem]) + '%',
|
467
|
+
textAlign: 'center',
|
468
|
+
overflow: 'hidden'
|
469
|
+
});
|
470
|
+
} // end if grid > 0
|
471
|
+
} // end for loop
|
472
|
+
|
473
|
+
// Add timezone options
|
474
|
+
this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
|
475
|
+
$.fn.append.apply(this.timezone_select,
|
476
|
+
$.map(o.timezoneList, function (val, idx) {
|
477
|
+
return $("<option />").val(typeof val === "object" ? val.value : val).text(typeof val === "object" ? val.label : val);
|
478
|
+
}));
|
479
|
+
if (typeof(this.timezone) !== "undefined" && this.timezone !== null && this.timezone !== "") {
|
480
|
+
var local_timezone = (new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12)).getTimezoneOffset() * -1;
|
481
|
+
if (local_timezone === this.timezone) {
|
482
|
+
selectLocalTimezone(tp_inst);
|
483
|
+
} else {
|
484
|
+
this.timezone_select.val(this.timezone);
|
485
|
+
}
|
486
|
+
} else {
|
487
|
+
if (typeof(this.hour) !== "undefined" && this.hour !== null && this.hour !== "") {
|
488
|
+
this.timezone_select.val(o.timezone);
|
489
|
+
} else {
|
490
|
+
selectLocalTimezone(tp_inst);
|
491
|
+
}
|
492
|
+
}
|
493
|
+
this.timezone_select.change(function () {
|
494
|
+
tp_inst._onTimeChange();
|
495
|
+
tp_inst._onSelectHandler();
|
496
|
+
});
|
497
|
+
// End timezone options
|
498
|
+
|
499
|
+
// inject timepicker into datepicker
|
500
|
+
var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
|
501
|
+
if ($buttonPanel.length) {
|
502
|
+
$buttonPanel.before($tp);
|
503
|
+
} else {
|
504
|
+
$dp.append($tp);
|
505
|
+
}
|
506
|
+
|
507
|
+
this.$timeObj = $tp.find('.ui_tpicker_time');
|
508
|
+
|
509
|
+
if (this.inst !== null) {
|
510
|
+
var timeDefined = this.timeDefined;
|
511
|
+
this._onTimeChange();
|
512
|
+
this.timeDefined = timeDefined;
|
513
|
+
}
|
514
|
+
|
515
|
+
// slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
|
516
|
+
if (this._defaults.addSliderAccess) {
|
517
|
+
var sliderAccessArgs = this._defaults.sliderAccessArgs,
|
518
|
+
rtl = this._defaults.isRTL;
|
519
|
+
sliderAccessArgs.isRTL = rtl;
|
152
520
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
521
|
+
setTimeout(function () { // fix for inline mode
|
522
|
+
if ($tp.find('.ui-slider-access').length === 0) {
|
523
|
+
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
|
524
|
+
|
525
|
+
// fix any grids since sliders are shorter
|
526
|
+
var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
|
527
|
+
if (sliderAccessWidth) {
|
528
|
+
$tp.find('table:visible').each(function () {
|
529
|
+
var $g = $(this),
|
530
|
+
oldWidth = $g.outerWidth(),
|
531
|
+
oldMarginLeft = $g.css(rtl ? 'marginRight' : 'marginLeft').toString().replace('%', ''),
|
532
|
+
newWidth = oldWidth - sliderAccessWidth,
|
533
|
+
newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
|
534
|
+
css = { width: newWidth, marginRight: 0, marginLeft: 0 };
|
535
|
+
css[rtl ? 'marginRight' : 'marginLeft'] = newMarginLeft;
|
536
|
+
$g.css(css);
|
537
|
+
});
|
538
|
+
}
|
539
|
+
}
|
540
|
+
}, 10);
|
541
|
+
}
|
542
|
+
// end slideAccess integration
|
543
|
+
|
544
|
+
tp_inst._limitMinMaxDateTime(this.inst, true);
|
545
|
+
}
|
546
|
+
},
|
547
|
+
|
548
|
+
/*
|
549
|
+
* This function tries to limit the ability to go outside the
|
550
|
+
* min/max date range
|
551
|
+
*/
|
552
|
+
_limitMinMaxDateTime: function (dp_inst, adjustSliders) {
|
553
|
+
var o = this._defaults,
|
554
|
+
dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
|
555
|
+
|
556
|
+
if (!this._defaults.showTimepicker) {
|
557
|
+
return;
|
558
|
+
} // No time so nothing to check here
|
559
|
+
|
560
|
+
if ($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date) {
|
561
|
+
var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
|
562
|
+
minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
|
563
|
+
|
564
|
+
if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null || this.microsecMinOriginal === null) {
|
565
|
+
this.hourMinOriginal = o.hourMin;
|
566
|
+
this.minuteMinOriginal = o.minuteMin;
|
567
|
+
this.secondMinOriginal = o.secondMin;
|
568
|
+
this.millisecMinOriginal = o.millisecMin;
|
569
|
+
this.microsecMinOriginal = o.microsecMin;
|
570
|
+
}
|
571
|
+
|
572
|
+
if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() === dp_date.getTime()) {
|
573
|
+
this._defaults.hourMin = minDateTime.getHours();
|
574
|
+
if (this.hour <= this._defaults.hourMin) {
|
575
|
+
this.hour = this._defaults.hourMin;
|
576
|
+
this._defaults.minuteMin = minDateTime.getMinutes();
|
577
|
+
if (this.minute <= this._defaults.minuteMin) {
|
578
|
+
this.minute = this._defaults.minuteMin;
|
579
|
+
this._defaults.secondMin = minDateTime.getSeconds();
|
580
|
+
if (this.second <= this._defaults.secondMin) {
|
581
|
+
this.second = this._defaults.secondMin;
|
582
|
+
this._defaults.millisecMin = minDateTime.getMilliseconds();
|
583
|
+
if (this.millisec <= this._defaults.millisecMin) {
|
584
|
+
this.millisec = this._defaults.millisecMin;
|
585
|
+
this._defaults.microsecMin = minDateTime.getMicroseconds();
|
586
|
+
} else {
|
587
|
+
if (this.microsec < this._defaults.microsecMin) {
|
588
|
+
this.microsec = this._defaults.microsecMin;
|
589
|
+
}
|
590
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
591
|
+
}
|
592
|
+
} else {
|
593
|
+
this._defaults.millisecMin = this.millisecMinOriginal;
|
594
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
595
|
+
}
|
596
|
+
} else {
|
597
|
+
this._defaults.secondMin = this.secondMinOriginal;
|
598
|
+
this._defaults.millisecMin = this.millisecMinOriginal;
|
599
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
600
|
+
}
|
601
|
+
} else {
|
602
|
+
this._defaults.minuteMin = this.minuteMinOriginal;
|
603
|
+
this._defaults.secondMin = this.secondMinOriginal;
|
604
|
+
this._defaults.millisecMin = this.millisecMinOriginal;
|
605
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
606
|
+
}
|
607
|
+
} else {
|
608
|
+
this._defaults.hourMin = this.hourMinOriginal;
|
609
|
+
this._defaults.minuteMin = this.minuteMinOriginal;
|
610
|
+
this._defaults.secondMin = this.secondMinOriginal;
|
611
|
+
this._defaults.millisecMin = this.millisecMinOriginal;
|
612
|
+
this._defaults.microsecMin = this.microsecMinOriginal;
|
613
|
+
}
|
614
|
+
}
|
615
|
+
|
616
|
+
if ($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date) {
|
617
|
+
var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
|
618
|
+
maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
|
619
|
+
|
620
|
+
if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null || this.millisecMaxOriginal === null) {
|
621
|
+
this.hourMaxOriginal = o.hourMax;
|
622
|
+
this.minuteMaxOriginal = o.minuteMax;
|
623
|
+
this.secondMaxOriginal = o.secondMax;
|
624
|
+
this.millisecMaxOriginal = o.millisecMax;
|
625
|
+
this.microsecMaxOriginal = o.microsecMax;
|
626
|
+
}
|
627
|
+
|
628
|
+
if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() === dp_date.getTime()) {
|
629
|
+
this._defaults.hourMax = maxDateTime.getHours();
|
630
|
+
if (this.hour >= this._defaults.hourMax) {
|
631
|
+
this.hour = this._defaults.hourMax;
|
632
|
+
this._defaults.minuteMax = maxDateTime.getMinutes();
|
633
|
+
if (this.minute >= this._defaults.minuteMax) {
|
634
|
+
this.minute = this._defaults.minuteMax;
|
635
|
+
this._defaults.secondMax = maxDateTime.getSeconds();
|
636
|
+
if (this.second >= this._defaults.secondMax) {
|
637
|
+
this.second = this._defaults.secondMax;
|
638
|
+
this._defaults.millisecMax = maxDateTime.getMilliseconds();
|
639
|
+
if (this.millisec >= this._defaults.millisecMax) {
|
640
|
+
this.millisec = this._defaults.millisecMax;
|
641
|
+
this._defaults.microsecMax = maxDateTime.getMicroseconds();
|
642
|
+
} else {
|
643
|
+
if (this.microsec > this._defaults.microsecMax) {
|
644
|
+
this.microsec = this._defaults.microsecMax;
|
645
|
+
}
|
646
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
647
|
+
}
|
648
|
+
} else {
|
649
|
+
this._defaults.millisecMax = this.millisecMaxOriginal;
|
650
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
651
|
+
}
|
652
|
+
} else {
|
653
|
+
this._defaults.secondMax = this.secondMaxOriginal;
|
654
|
+
this._defaults.millisecMax = this.millisecMaxOriginal;
|
655
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
656
|
+
}
|
657
|
+
} else {
|
658
|
+
this._defaults.minuteMax = this.minuteMaxOriginal;
|
659
|
+
this._defaults.secondMax = this.secondMaxOriginal;
|
660
|
+
this._defaults.millisecMax = this.millisecMaxOriginal;
|
661
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
662
|
+
}
|
663
|
+
} else {
|
664
|
+
this._defaults.hourMax = this.hourMaxOriginal;
|
665
|
+
this._defaults.minuteMax = this.minuteMaxOriginal;
|
666
|
+
this._defaults.secondMax = this.secondMaxOriginal;
|
667
|
+
this._defaults.millisecMax = this.millisecMaxOriginal;
|
668
|
+
this._defaults.microsecMax = this.microsecMaxOriginal;
|
669
|
+
}
|
670
|
+
}
|
671
|
+
|
672
|
+
if (dp_inst.settings.minTime!==null) {
|
673
|
+
var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime);
|
674
|
+
if (this.hour<tempMinTime.getHours()) {
|
675
|
+
this.hour=this._defaults.hourMin=tempMinTime.getHours();
|
676
|
+
this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
|
677
|
+
} else if (this.hour===tempMinTime.getHours() && this.minute<tempMinTime.getMinutes()) {
|
678
|
+
this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
|
679
|
+
} else {
|
680
|
+
if (this._defaults.hourMin<tempMinTime.getHours()) {
|
681
|
+
this._defaults.hourMin=tempMinTime.getHours();
|
682
|
+
this._defaults.minuteMin=tempMinTime.getMinutes();
|
683
|
+
} else if (this._defaults.hourMin===tempMinTime.getHours()===this.hour && this._defaults.minuteMin<tempMinTime.getMinutes()) {
|
684
|
+
this._defaults.minuteMin=tempMinTime.getMinutes();
|
685
|
+
} else {
|
686
|
+
this._defaults.minuteMin=0;
|
687
|
+
}
|
688
|
+
}
|
689
|
+
}
|
162
690
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
//########################################################################
|
182
|
-
_parseTime: function(timeString, withDate) {
|
183
|
-
var regstr = this._defaults.timeFormat.toString()
|
184
|
-
.replace(/h{1,2}/ig, '(\\d?\\d)')
|
185
|
-
.replace(/m{1,2}/ig, '(\\d?\\d)')
|
186
|
-
.replace(/s{1,2}/ig, '(\\d?\\d)')
|
187
|
-
.replace(/t{1,2}/ig, '(am|pm|a|p)?')
|
188
|
-
.replace(/\s/g, '\\s?') + '$',
|
189
|
-
order = this._getFormatPositions(),
|
190
|
-
treg;
|
191
|
-
|
192
|
-
if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
|
193
|
-
|
194
|
-
if (withDate || !this._defaults.timeOnly) {
|
195
|
-
// the time should come after x number of characters and a space.
|
196
|
-
// x = at least the length of text specified by the date format
|
197
|
-
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
|
198
|
-
regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator + regstr;
|
199
|
-
}
|
200
|
-
|
201
|
-
treg = timeString.match(new RegExp(regstr, 'i'));
|
202
|
-
|
203
|
-
if (treg) {
|
204
|
-
if (order.t !== -1)
|
205
|
-
this.ampm = ((treg[order.t] === undefined || treg[order.t].length === 0) ?
|
206
|
-
'' :
|
207
|
-
(treg[order.t].charAt(0).toUpperCase() == 'A') ? 'AM' : 'PM').toUpperCase();
|
208
|
-
|
209
|
-
if (order.h !== -1) {
|
210
|
-
if (this.ampm == 'AM' && treg[order.h] == '12')
|
211
|
-
this.hour = 0; // 12am = 0 hour
|
212
|
-
else if (this.ampm == 'PM' && treg[order.h] != '12')
|
213
|
-
this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
|
214
|
-
else this.hour = Number(treg[order.h]);
|
215
|
-
}
|
216
|
-
|
217
|
-
if (order.m !== -1) this.minute = Number(treg[order.m]);
|
218
|
-
if (order.s !== -1) this.second = Number(treg[order.s]);
|
691
|
+
if (dp_inst.settings.maxTime!==null) {
|
692
|
+
var tempMaxTime=new Date("01/01/1970 " + dp_inst.settings.maxTime);
|
693
|
+
if (this.hour>tempMaxTime.getHours()) {
|
694
|
+
this.hour=this._defaults.hourMax=tempMaxTime.getHours();
|
695
|
+
this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
|
696
|
+
} else if (this.hour===tempMaxTime.getHours() && this.minute>tempMaxTime.getMinutes()) {
|
697
|
+
this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
|
698
|
+
} else {
|
699
|
+
if (this._defaults.hourMax>tempMaxTime.getHours()) {
|
700
|
+
this._defaults.hourMax=tempMaxTime.getHours();
|
701
|
+
this._defaults.minuteMax=tempMaxTime.getMinutes();
|
702
|
+
} else if (this._defaults.hourMax===tempMaxTime.getHours()===this.hour && this._defaults.minuteMax>tempMaxTime.getMinutes()) {
|
703
|
+
this._defaults.minuteMax=tempMaxTime.getMinutes();
|
704
|
+
} else {
|
705
|
+
this._defaults.minuteMax=59;
|
706
|
+
}
|
707
|
+
}
|
708
|
+
}
|
219
709
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
if (
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
// Added by Peter Medeiros:
|
249
|
-
// - Figure out what the hour/minute/second max should be based on the step values.
|
250
|
-
// - Example: if stepMinute is 15, then minMax is 45.
|
251
|
-
hourMax = (o.hourMax - (o.hourMax % o.stepHour)).toFixed(0),
|
252
|
-
minMax = (o.minuteMax - (o.minuteMax % o.stepMinute)).toFixed(0),
|
253
|
-
secMax = (o.secondMax - (o.secondMax % o.stepSecond)).toFixed(0),
|
254
|
-
dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
|
255
|
-
|
256
|
-
// Prevent displaying twice
|
257
|
-
//if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
|
258
|
-
if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
|
259
|
-
var noDisplay = ' style="display:none;"',
|
260
|
-
html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
|
261
|
-
'<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
|
262
|
-
((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
|
263
|
-
'<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
|
264
|
-
((o.showTime) ? '' : noDisplay) + '></dd>' +
|
265
|
-
'<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
|
266
|
-
((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
|
267
|
-
hourGridSize = 0,
|
268
|
-
minuteGridSize = 0,
|
269
|
-
secondGridSize = 0,
|
270
|
-
size;
|
271
|
-
|
272
|
-
if (o.showHour && o.hourGrid > 0) {
|
273
|
-
html += '<dd class="ui_tpicker_hour">' +
|
274
|
-
'<div id="ui_tpicker_hour_' + dp_id + '"' + ((o.showHour) ? '' : noDisplay) + '></div>' +
|
275
|
-
'<div style="padding-left: 1px"><table><tr>';
|
276
|
-
|
277
|
-
for (var h = o.hourMin; h < hourMax; h += o.hourGrid) {
|
278
|
-
hourGridSize++;
|
279
|
-
var tmph = (o.ampm && h > 12) ? h-12 : h;
|
280
|
-
if (tmph < 10) tmph = '0' + tmph;
|
281
|
-
if (o.ampm) {
|
282
|
-
if (h == 0) tmph = 12 +'a';
|
283
|
-
else if (h < 12) tmph += 'a';
|
284
|
-
else tmph += 'p';
|
285
|
-
}
|
286
|
-
html += '<td>' + tmph + '</td>';
|
287
|
-
}
|
288
|
-
|
289
|
-
html += '</tr></table></div>' +
|
290
|
-
'</dd>';
|
291
|
-
} else html += '<dd class="ui_tpicker_hour" id="ui_tpicker_hour_' + dp_id + '"' +
|
292
|
-
((o.showHour) ? '' : noDisplay) + '></dd>';
|
293
|
-
|
294
|
-
html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
|
295
|
-
((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>';
|
296
|
-
|
297
|
-
if (o.showMinute && o.minuteGrid > 0) {
|
298
|
-
html += '<dd class="ui_tpicker_minute ui_tpicker_minute_' + o.minuteGrid + '">' +
|
299
|
-
'<div id="ui_tpicker_minute_' + dp_id + '"' +
|
300
|
-
((o.showMinute) ? '' : noDisplay) + '></div>' +
|
301
|
-
'<div style="padding-left: 1px"><table><tr>';
|
302
|
-
|
303
|
-
for (var m = o.minuteMin; m < minMax; m += o.minuteGrid) {
|
304
|
-
minuteGridSize++;
|
305
|
-
html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
|
306
|
-
}
|
307
|
-
|
308
|
-
html += '</tr></table></div>' +
|
309
|
-
'</dd>';
|
310
|
-
} else html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_id + '"' +
|
311
|
-
((o.showMinute) ? '' : noDisplay) + '></dd>';
|
312
|
-
|
313
|
-
html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
|
314
|
-
((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>';
|
315
|
-
|
316
|
-
if (o.showSecond && o.secondGrid > 0) {
|
317
|
-
html += '<dd class="ui_tpicker_second ui_tpicker_second_' + o.secondGrid + '">' +
|
318
|
-
'<div id="ui_tpicker_second_' + dp_id + '"' +
|
319
|
-
((o.showSecond) ? '' : noDisplay) + '></div>' +
|
320
|
-
'<div style="padding-left: 1px"><table><tr>';
|
321
|
-
|
322
|
-
for (var s = o.secondMin; s < secMax; s += o.secondGrid) {
|
323
|
-
secondGridSize++;
|
324
|
-
html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
|
325
|
-
}
|
326
|
-
|
327
|
-
html += '</tr></table></div>' +
|
328
|
-
'</dd>';
|
329
|
-
} else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
|
330
|
-
((o.showSecond) ? '' : noDisplay) + '></dd>';
|
331
|
-
|
332
|
-
html += '</dl></div>';
|
333
|
-
$tp = $(html);
|
710
|
+
if (adjustSliders !== undefined && adjustSliders === true) {
|
711
|
+
var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
|
712
|
+
minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
|
713
|
+
secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
|
714
|
+
millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10),
|
715
|
+
microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
|
716
|
+
|
717
|
+
if (this.hour_slider) {
|
718
|
+
this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax, step: this._defaults.stepHour });
|
719
|
+
this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
|
720
|
+
}
|
721
|
+
if (this.minute_slider) {
|
722
|
+
this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax, step: this._defaults.stepMinute });
|
723
|
+
this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
|
724
|
+
}
|
725
|
+
if (this.second_slider) {
|
726
|
+
this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax, step: this._defaults.stepSecond });
|
727
|
+
this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
|
728
|
+
}
|
729
|
+
if (this.millisec_slider) {
|
730
|
+
this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax, step: this._defaults.stepMillisec });
|
731
|
+
this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
|
732
|
+
}
|
733
|
+
if (this.microsec_slider) {
|
734
|
+
this.control.options(this, this.microsec_slider, 'microsec', { min: this._defaults.microsecMin, max: microsecMax, step: this._defaults.stepMicrosec });
|
735
|
+
this.control.value(this, this.microsec_slider, 'microsec', this.microsec - (this.microsec % this._defaults.stepMicrosec));
|
736
|
+
}
|
737
|
+
}
|
334
738
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
value
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
739
|
+
},
|
740
|
+
|
741
|
+
/*
|
742
|
+
* when a slider moves, set the internal time...
|
743
|
+
* on time change is also called when the time is updated in the text field
|
744
|
+
*/
|
745
|
+
_onTimeChange: function () {
|
746
|
+
if (!this._defaults.showTimepicker) {
|
747
|
+
return;
|
748
|
+
}
|
749
|
+
var hour = (this.hour_slider) ? this.control.value(this, this.hour_slider, 'hour') : false,
|
750
|
+
minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
|
751
|
+
second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
|
752
|
+
millisec = (this.millisec_slider) ? this.control.value(this, this.millisec_slider, 'millisec') : false,
|
753
|
+
microsec = (this.microsec_slider) ? this.control.value(this, this.microsec_slider, 'microsec') : false,
|
754
|
+
timezone = (this.timezone_select) ? this.timezone_select.val() : false,
|
755
|
+
o = this._defaults,
|
756
|
+
pickerTimeFormat = o.pickerTimeFormat || o.timeFormat,
|
757
|
+
pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix;
|
758
|
+
|
759
|
+
if (typeof(hour) === 'object') {
|
760
|
+
hour = false;
|
761
|
+
}
|
762
|
+
if (typeof(minute) === 'object') {
|
763
|
+
minute = false;
|
764
|
+
}
|
765
|
+
if (typeof(second) === 'object') {
|
766
|
+
second = false;
|
767
|
+
}
|
768
|
+
if (typeof(millisec) === 'object') {
|
769
|
+
millisec = false;
|
770
|
+
}
|
771
|
+
if (typeof(microsec) === 'object') {
|
772
|
+
microsec = false;
|
773
|
+
}
|
774
|
+
if (typeof(timezone) === 'object') {
|
775
|
+
timezone = false;
|
776
|
+
}
|
777
|
+
|
778
|
+
if (hour !== false) {
|
779
|
+
hour = parseInt(hour, 10);
|
780
|
+
}
|
781
|
+
if (minute !== false) {
|
782
|
+
minute = parseInt(minute, 10);
|
783
|
+
}
|
784
|
+
if (second !== false) {
|
785
|
+
second = parseInt(second, 10);
|
786
|
+
}
|
787
|
+
if (millisec !== false) {
|
788
|
+
millisec = parseInt(millisec, 10);
|
789
|
+
}
|
790
|
+
if (microsec !== false) {
|
791
|
+
microsec = parseInt(microsec, 10);
|
792
|
+
}
|
793
|
+
if (timezone !== false) {
|
794
|
+
timezone = timezone.toString();
|
795
|
+
}
|
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 = (
|
802
|
+
hour !== parseInt(this.hour,10) || // sliders should all be numeric
|
803
|
+
minute !== parseInt(this.minute,10) ||
|
804
|
+
second !== parseInt(this.second,10) ||
|
805
|
+
millisec !== parseInt(this.millisec,10) ||
|
806
|
+
microsec !== parseInt(this.microsec,10) ||
|
807
|
+
(this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) ||
|
808
|
+
(this.timezone !== null && timezone !== this.timezone.toString()) // could be numeric or "EST" format, so use toString()
|
809
|
+
);
|
810
|
+
|
811
|
+
if (hasChanged) {
|
812
|
+
|
813
|
+
if (hour !== false) {
|
814
|
+
this.hour = hour;
|
815
|
+
}
|
816
|
+
if (minute !== false) {
|
817
|
+
this.minute = minute;
|
818
|
+
}
|
819
|
+
if (second !== false) {
|
820
|
+
this.second = second;
|
821
|
+
}
|
822
|
+
if (millisec !== false) {
|
823
|
+
this.millisec = millisec;
|
824
|
+
}
|
825
|
+
if (microsec !== false) {
|
826
|
+
this.microsec = microsec;
|
827
|
+
}
|
828
|
+
if (timezone !== false) {
|
829
|
+
this.timezone = timezone;
|
353
830
|
}
|
354
|
-
});
|
355
831
|
|
356
|
-
|
357
|
-
|
358
|
-
this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
|
359
|
-
orientation: "horizontal",
|
360
|
-
value: this.minute,
|
361
|
-
min: o.minuteMin,
|
362
|
-
max: minMax,
|
363
|
-
step: o.stepMinute,
|
364
|
-
slide: function(event, ui) {
|
365
|
-
// update the global minute slider instance value with the current slider value
|
366
|
-
tp_inst.minute_slider.slider( "option", "value", ui.value);
|
367
|
-
tp_inst._onTimeChange();
|
832
|
+
if (!this.inst) {
|
833
|
+
this.inst = $.datepicker._getInst(this.$input[0]);
|
368
834
|
}
|
369
|
-
});
|
370
835
|
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
836
|
+
this._limitMinMaxDateTime(this.inst, true);
|
837
|
+
}
|
838
|
+
if (this.support.ampm) {
|
839
|
+
this.ampm = ampm;
|
840
|
+
}
|
841
|
+
|
842
|
+
// Updates the time within the timepicker
|
843
|
+
this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
|
844
|
+
if (this.$timeObj) {
|
845
|
+
if (pickerTimeFormat === o.timeFormat) {
|
846
|
+
this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
|
380
847
|
}
|
381
|
-
|
848
|
+
else {
|
849
|
+
this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
|
850
|
+
}
|
851
|
+
}
|
382
852
|
|
383
|
-
|
384
|
-
if (
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
853
|
+
this.timeDefined = true;
|
854
|
+
if (hasChanged) {
|
855
|
+
this._updateDateTime();
|
856
|
+
//this.$input.focus(); // may automatically open the picker on setDate
|
857
|
+
}
|
858
|
+
},
|
859
|
+
|
860
|
+
/*
|
861
|
+
* call custom onSelect.
|
862
|
+
* bind to sliders slidestop, and grid click.
|
863
|
+
*/
|
864
|
+
_onSelectHandler: function () {
|
865
|
+
var onSelect = this._defaults.onSelect || this.inst.settings.onSelect;
|
866
|
+
var inputEl = this.$input ? this.$input[0] : null;
|
867
|
+
if (onSelect && inputEl) {
|
868
|
+
onSelect.apply(inputEl, [this.formattedDateTime, this]);
|
869
|
+
}
|
870
|
+
},
|
871
|
+
|
872
|
+
/*
|
873
|
+
* update our input with the new date time..
|
874
|
+
*/
|
875
|
+
_updateDateTime: function (dp_inst) {
|
876
|
+
dp_inst = this.inst || dp_inst;
|
877
|
+
var dtTmp = (dp_inst.currentYear > 0?
|
878
|
+
new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) :
|
879
|
+
new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
880
|
+
dt = $.datepicker._daylightSavingAdjust(dtTmp),
|
881
|
+
//dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
882
|
+
//dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
|
883
|
+
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
|
884
|
+
formatCfg = $.datepicker._getFormatConfig(dp_inst),
|
885
|
+
timeAvailable = dt !== null && this.timeDefined;
|
886
|
+
this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
|
887
|
+
var formattedDateTime = this.formattedDate;
|
888
|
+
|
889
|
+
// if a slider was changed but datepicker doesn't have a value yet, set it
|
890
|
+
if (dp_inst.lastVal === "") {
|
891
|
+
dp_inst.currentYear = dp_inst.selectedYear;
|
892
|
+
dp_inst.currentMonth = dp_inst.selectedMonth;
|
893
|
+
dp_inst.currentDay = dp_inst.selectedDay;
|
894
|
+
}
|
895
|
+
|
896
|
+
/*
|
897
|
+
* remove following lines to force every changes in date picker to change the input value
|
898
|
+
* Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
|
899
|
+
* If the user manually empty the value in the input field, the date picker will never change selected value.
|
900
|
+
*/
|
901
|
+
//if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
|
902
|
+
// return;
|
903
|
+
//}
|
904
|
+
|
905
|
+
if (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === false) {
|
906
|
+
formattedDateTime = this.formattedTime;
|
907
|
+
} else if ((this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) || (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === true)) {
|
908
|
+
formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
|
909
|
+
}
|
910
|
+
|
911
|
+
this.formattedDateTime = formattedDateTime;
|
912
|
+
|
913
|
+
if (!this._defaults.showTimepicker) {
|
914
|
+
this.$input.val(this.formattedDate);
|
915
|
+
} else if (this.$altInput && this._defaults.timeOnly === false && this._defaults.altFieldTimeOnly === true) {
|
916
|
+
this.$altInput.val(this.formattedTime);
|
917
|
+
this.$input.val(this.formattedDate);
|
918
|
+
} else if (this.$altInput) {
|
919
|
+
this.$input.val(formattedDateTime);
|
920
|
+
var altFormattedDateTime = '',
|
921
|
+
altSeparator = this._defaults.altSeparator !== null ? this._defaults.altSeparator : this._defaults.separator,
|
922
|
+
altTimeSuffix = this._defaults.altTimeSuffix !== null ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
|
923
|
+
|
924
|
+
if (!this._defaults.timeOnly) {
|
925
|
+
if (this._defaults.altFormat) {
|
926
|
+
altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
|
927
|
+
}
|
928
|
+
else {
|
929
|
+
altFormattedDateTime = this.formattedDate;
|
930
|
+
}
|
931
|
+
|
932
|
+
if (altFormattedDateTime) {
|
933
|
+
altFormattedDateTime += altSeparator;
|
934
|
+
}
|
935
|
+
}
|
936
|
+
|
937
|
+
if (this._defaults.altTimeFormat !== null) {
|
938
|
+
altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
|
939
|
+
}
|
940
|
+
else {
|
941
|
+
altFormattedDateTime += this.formattedTime + altTimeSuffix;
|
942
|
+
}
|
943
|
+
this.$altInput.val(altFormattedDateTime);
|
944
|
+
} else {
|
945
|
+
this.$input.val(formattedDateTime);
|
946
|
+
}
|
947
|
+
|
948
|
+
this.$input.trigger("change");
|
949
|
+
},
|
950
|
+
|
951
|
+
_onFocus: function () {
|
952
|
+
if (!this.$input.val() && this._defaults.defaultValue) {
|
953
|
+
this.$input.val(this._defaults.defaultValue);
|
954
|
+
var inst = $.datepicker._getInst(this.$input.get(0)),
|
955
|
+
tp_inst = $.datepicker._get(inst, 'timepicker');
|
956
|
+
if (tp_inst) {
|
957
|
+
if (tp_inst._defaults.timeOnly && (inst.input.val() !== inst.lastVal)) {
|
958
|
+
try {
|
959
|
+
$.datepicker._updateDatepicker(inst);
|
960
|
+
} catch (err) {
|
961
|
+
$.timepicker.log(err);
|
402
962
|
}
|
403
|
-
|
404
|
-
|
405
|
-
}).css({
|
406
|
-
cursor: 'pointer',
|
407
|
-
width: (100 / hourGridSize) + '%',
|
408
|
-
textAlign: 'center',
|
409
|
-
overflow: 'hidden'
|
410
|
-
});
|
411
|
-
});
|
963
|
+
}
|
964
|
+
}
|
412
965
|
}
|
966
|
+
},
|
967
|
+
|
968
|
+
/*
|
969
|
+
* Small abstraction to control types
|
970
|
+
* We can add more, just be sure to follow the pattern: create, options, value
|
971
|
+
*/
|
972
|
+
_controls: {
|
973
|
+
// slider methods
|
974
|
+
slider: {
|
975
|
+
create: function (tp_inst, obj, unit, val, min, max, step) {
|
976
|
+
var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
|
977
|
+
return obj.prop('slide', null).slider({
|
978
|
+
orientation: "horizontal",
|
979
|
+
value: rtl ? val * -1 : val,
|
980
|
+
min: rtl ? max * -1 : min,
|
981
|
+
max: rtl ? min * -1 : max,
|
982
|
+
step: step,
|
983
|
+
slide: function (event, ui) {
|
984
|
+
tp_inst.control.value(tp_inst, $(this), unit, rtl ? ui.value * -1 : ui.value);
|
985
|
+
tp_inst._onTimeChange();
|
986
|
+
},
|
987
|
+
stop: function (event, ui) {
|
988
|
+
tp_inst._onSelectHandler();
|
989
|
+
}
|
990
|
+
});
|
991
|
+
},
|
992
|
+
options: function (tp_inst, obj, unit, opts, val) {
|
993
|
+
if (tp_inst._defaults.isRTL) {
|
994
|
+
if (typeof(opts) === 'string') {
|
995
|
+
if (opts === 'min' || opts === 'max') {
|
996
|
+
if (val !== undefined) {
|
997
|
+
return obj.slider(opts, val * -1);
|
998
|
+
}
|
999
|
+
return Math.abs(obj.slider(opts));
|
1000
|
+
}
|
1001
|
+
return obj.slider(opts);
|
1002
|
+
}
|
1003
|
+
var min = opts.min,
|
1004
|
+
max = opts.max;
|
1005
|
+
opts.min = opts.max = null;
|
1006
|
+
if (min !== undefined) {
|
1007
|
+
opts.max = min * -1;
|
1008
|
+
}
|
1009
|
+
if (max !== undefined) {
|
1010
|
+
opts.min = max * -1;
|
1011
|
+
}
|
1012
|
+
return obj.slider(opts);
|
1013
|
+
}
|
1014
|
+
if (typeof(opts) === 'string' && val !== undefined) {
|
1015
|
+
return obj.slider(opts, val);
|
1016
|
+
}
|
1017
|
+
return obj.slider(opts);
|
1018
|
+
},
|
1019
|
+
value: function (tp_inst, obj, unit, val) {
|
1020
|
+
if (tp_inst._defaults.isRTL) {
|
1021
|
+
if (val !== undefined) {
|
1022
|
+
return obj.slider('value', val * -1);
|
1023
|
+
}
|
1024
|
+
return Math.abs(obj.slider('value'));
|
1025
|
+
}
|
1026
|
+
if (val !== undefined) {
|
1027
|
+
return obj.slider('value', val);
|
1028
|
+
}
|
1029
|
+
return obj.slider('value');
|
1030
|
+
}
|
1031
|
+
},
|
1032
|
+
// select methods
|
1033
|
+
select: {
|
1034
|
+
create: function (tp_inst, obj, unit, val, min, max, step) {
|
1035
|
+
var sel = '<select class="ui-timepicker-select ui-state-default ui-corner-all" data-unit="' + unit + '" data-min="' + min + '" data-max="' + max + '" data-step="' + step + '">',
|
1036
|
+
format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
|
1037
|
+
|
1038
|
+
for (var i = min; i <= max; i += step) {
|
1039
|
+
sel += '<option value="' + i + '"' + (i === val ? ' selected' : '') + '>';
|
1040
|
+
if (unit === 'hour') {
|
1041
|
+
sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig, '')), {hour: i}, tp_inst._defaults);
|
1042
|
+
}
|
1043
|
+
else if (unit === 'millisec' || unit === 'microsec' || i >= 10) { sel += i; }
|
1044
|
+
else {sel += '0' + i.toString(); }
|
1045
|
+
sel += '</option>';
|
1046
|
+
}
|
1047
|
+
sel += '</select>';
|
1048
|
+
|
1049
|
+
obj.children('select').remove();
|
413
1050
|
|
414
|
-
|
415
|
-
size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
|
416
|
-
$tp.find(".ui_tpicker_minute table").css({
|
417
|
-
width: size + "%",
|
418
|
-
marginLeft: (size / (-2 * minuteGridSize)) + "%",
|
419
|
-
borderCollapse: 'collapse'
|
420
|
-
}).find("td").each(function(index) {
|
421
|
-
$(this).click(function() {
|
422
|
-
tp_inst.minute_slider.slider("option", "value", $(this).html());
|
1051
|
+
$(sel).appendTo(obj).change(function (e) {
|
423
1052
|
tp_inst._onTimeChange();
|
424
|
-
|
425
|
-
cursor: 'pointer',
|
426
|
-
width: (100 / minuteGridSize) + '%',
|
427
|
-
textAlign: 'center',
|
428
|
-
overflow: 'hidden'
|
1053
|
+
tp_inst._onSelectHandler();
|
429
1054
|
});
|
1055
|
+
|
1056
|
+
return obj;
|
1057
|
+
},
|
1058
|
+
options: function (tp_inst, obj, unit, opts, val) {
|
1059
|
+
var o = {},
|
1060
|
+
$t = obj.children('select');
|
1061
|
+
if (typeof(opts) === 'string') {
|
1062
|
+
if (val === undefined) {
|
1063
|
+
return $t.data(opts);
|
1064
|
+
}
|
1065
|
+
o[opts] = val;
|
1066
|
+
}
|
1067
|
+
else { o = opts; }
|
1068
|
+
return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
|
1069
|
+
},
|
1070
|
+
value: function (tp_inst, obj, unit, val) {
|
1071
|
+
var $t = obj.children('select');
|
1072
|
+
if (val !== undefined) {
|
1073
|
+
return $t.val(val);
|
1074
|
+
}
|
1075
|
+
return $t.val();
|
1076
|
+
}
|
1077
|
+
}
|
1078
|
+
} // end _controls
|
1079
|
+
|
1080
|
+
});
|
1081
|
+
|
1082
|
+
$.fn.extend({
|
1083
|
+
/*
|
1084
|
+
* shorthand just to use timepicker.
|
1085
|
+
*/
|
1086
|
+
timepicker: function (o) {
|
1087
|
+
o = o || {};
|
1088
|
+
var tmp_args = Array.prototype.slice.call(arguments);
|
1089
|
+
|
1090
|
+
if (typeof o === 'object') {
|
1091
|
+
tmp_args[0] = $.extend(o, {
|
1092
|
+
timeOnly: true
|
430
1093
|
});
|
431
1094
|
}
|
432
1095
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
1096
|
+
return $(this).each(function () {
|
1097
|
+
$.fn.datetimepicker.apply($(this), tmp_args);
|
1098
|
+
});
|
1099
|
+
},
|
1100
|
+
|
1101
|
+
/*
|
1102
|
+
* extend timepicker to datepicker
|
1103
|
+
*/
|
1104
|
+
datetimepicker: function (o) {
|
1105
|
+
o = o || {};
|
1106
|
+
var tmp_args = arguments;
|
1107
|
+
|
1108
|
+
if (typeof(o) === 'string') {
|
1109
|
+
if (o === 'getDate' || (o === 'option' && tmp_args.length === 2 && typeof (tmp_args[1]) === 'string')) {
|
1110
|
+
return $.fn.datepicker.apply($(this[0]), tmp_args);
|
1111
|
+
} else {
|
1112
|
+
return this.each(function () {
|
1113
|
+
var $t = $(this);
|
1114
|
+
$t.datepicker.apply($t, tmp_args);
|
447
1115
|
});
|
1116
|
+
}
|
1117
|
+
} else {
|
1118
|
+
return this.each(function () {
|
1119
|
+
var $t = $(this);
|
1120
|
+
$t.datepicker($.timepicker._newInst($t, o)._defaults);
|
448
1121
|
});
|
449
1122
|
}
|
1123
|
+
}
|
1124
|
+
});
|
1125
|
+
|
1126
|
+
/*
|
1127
|
+
* Public Utility to parse date and time
|
1128
|
+
*/
|
1129
|
+
$.datepicker.parseDateTime = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
|
1130
|
+
var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
|
1131
|
+
if (parseRes.timeObj) {
|
1132
|
+
var t = parseRes.timeObj;
|
1133
|
+
parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
|
1134
|
+
parseRes.date.setMicroseconds(t.microsec);
|
1135
|
+
}
|
450
1136
|
|
451
|
-
|
452
|
-
|
453
|
-
|
1137
|
+
return parseRes.date;
|
1138
|
+
};
|
1139
|
+
|
1140
|
+
/*
|
1141
|
+
* Public utility to parse time
|
1142
|
+
*/
|
1143
|
+
$.datepicker.parseTime = function (timeFormat, timeString, options) {
|
1144
|
+
var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {}),
|
1145
|
+
iso8601 = (timeFormat.replace(/\'.*?\'/g, '').indexOf('Z') !== -1);
|
1146
|
+
|
1147
|
+
// Strict parse requires the timeString to match the timeFormat exactly
|
1148
|
+
var strictParse = function (f, s, o) {
|
1149
|
+
|
1150
|
+
// pattern for standard and localized AM/PM markers
|
1151
|
+
var getPatternAmpm = function (amNames, pmNames) {
|
1152
|
+
var markers = [];
|
1153
|
+
if (amNames) {
|
1154
|
+
$.merge(markers, amNames);
|
1155
|
+
}
|
1156
|
+
if (pmNames) {
|
1157
|
+
$.merge(markers, pmNames);
|
1158
|
+
}
|
1159
|
+
markers = $.map(markers, function (val) {
|
1160
|
+
return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
|
1161
|
+
});
|
1162
|
+
return '(' + markers.join('|') + ')?';
|
1163
|
+
};
|
1164
|
+
|
1165
|
+
// figure out position of time elements.. cause js cant do named captures
|
1166
|
+
var getFormatPositions = function (timeFormat) {
|
1167
|
+
var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|c{1}|t{1,2}|z|'.*?')/g),
|
1168
|
+
orders = {
|
1169
|
+
h: -1,
|
1170
|
+
m: -1,
|
1171
|
+
s: -1,
|
1172
|
+
l: -1,
|
1173
|
+
c: -1,
|
1174
|
+
t: -1,
|
1175
|
+
z: -1
|
1176
|
+
};
|
1177
|
+
|
1178
|
+
if (finds) {
|
1179
|
+
for (var i = 0; i < finds.length; i++) {
|
1180
|
+
if (orders[finds[i].toString().charAt(0)] === -1) {
|
1181
|
+
orders[finds[i].toString().charAt(0)] = i + 1;
|
1182
|
+
}
|
1183
|
+
}
|
1184
|
+
}
|
1185
|
+
return orders;
|
1186
|
+
};
|
1187
|
+
|
1188
|
+
var regstr = '^' + f.toString()
|
1189
|
+
.replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
|
1190
|
+
var ml = match.length;
|
1191
|
+
switch (match.charAt(0).toLowerCase()) {
|
1192
|
+
case 'h':
|
1193
|
+
return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
|
1194
|
+
case 'm':
|
1195
|
+
return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
|
1196
|
+
case 's':
|
1197
|
+
return ml === 1 ? '(\\d?\\d)' : '(\\d{' + ml + '})';
|
1198
|
+
case 'l':
|
1199
|
+
return '(\\d?\\d?\\d)';
|
1200
|
+
case 'c':
|
1201
|
+
return '(\\d?\\d?\\d)';
|
1202
|
+
case 'z':
|
1203
|
+
return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
|
1204
|
+
case 't':
|
1205
|
+
return getPatternAmpm(o.amNames, o.pmNames);
|
1206
|
+
default: // literal escaped in quotes
|
1207
|
+
return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
|
1208
|
+
}
|
1209
|
+
})
|
1210
|
+
.replace(/\s/g, '\\s?') +
|
1211
|
+
o.timeSuffix + '$',
|
1212
|
+
order = getFormatPositions(f),
|
1213
|
+
ampm = '',
|
1214
|
+
treg;
|
1215
|
+
|
1216
|
+
treg = s.match(new RegExp(regstr, 'i'));
|
1217
|
+
|
1218
|
+
var resTime = {
|
1219
|
+
hour: 0,
|
1220
|
+
minute: 0,
|
1221
|
+
second: 0,
|
1222
|
+
millisec: 0,
|
1223
|
+
microsec: 0
|
1224
|
+
};
|
1225
|
+
|
1226
|
+
if (treg) {
|
1227
|
+
if (order.t !== -1) {
|
1228
|
+
if (treg[order.t] === undefined || treg[order.t].length === 0) {
|
1229
|
+
ampm = '';
|
1230
|
+
resTime.ampm = '';
|
1231
|
+
} else {
|
1232
|
+
ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
|
1233
|
+
resTime.ampm = o[ampm === 'AM' ? 'amNames' : 'pmNames'][0];
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
if (order.h !== -1) {
|
1238
|
+
if (ampm === 'AM' && treg[order.h] === '12') {
|
1239
|
+
resTime.hour = 0; // 12am = 0 hour
|
1240
|
+
} else {
|
1241
|
+
if (ampm === 'PM' && treg[order.h] !== '12') {
|
1242
|
+
resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
|
1243
|
+
} else {
|
1244
|
+
resTime.hour = Number(treg[order.h]);
|
1245
|
+
}
|
1246
|
+
}
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
if (order.m !== -1) {
|
1250
|
+
resTime.minute = Number(treg[order.m]);
|
1251
|
+
}
|
1252
|
+
if (order.s !== -1) {
|
1253
|
+
resTime.second = Number(treg[order.s]);
|
1254
|
+
}
|
1255
|
+
if (order.l !== -1) {
|
1256
|
+
resTime.millisec = Number(treg[order.l]);
|
1257
|
+
}
|
1258
|
+
if (order.c !== -1) {
|
1259
|
+
resTime.microsec = Number(treg[order.c]);
|
1260
|
+
}
|
1261
|
+
if (order.z !== -1 && treg[order.z] !== undefined) {
|
1262
|
+
resTime.timezone = $.timepicker.timezoneOffsetNumber(treg[order.z]);
|
1263
|
+
}
|
454
1264
|
|
455
|
-
this.$timeObj = $('#ui_tpicker_time_'+ dp_id);
|
456
1265
|
|
457
|
-
|
458
|
-
var timeDefined = this.timeDefined;
|
459
|
-
this._onTimeChange();
|
460
|
-
this.timeDefined = timeDefined;
|
1266
|
+
return resTime;
|
461
1267
|
}
|
1268
|
+
return false;
|
1269
|
+
};// end strictParse
|
462
1270
|
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
var
|
467
|
-
|
468
|
-
|
1271
|
+
// First try JS Date, if that fails, use strictParse
|
1272
|
+
var looseParse = function (f, s, o) {
|
1273
|
+
try {
|
1274
|
+
var d = new Date('2012-01-01 ' + s);
|
1275
|
+
if (isNaN(d.getTime())) {
|
1276
|
+
d = new Date('2012-01-01T' + s);
|
1277
|
+
if (isNaN(d.getTime())) {
|
1278
|
+
d = new Date('01/01/2012 ' + s);
|
1279
|
+
if (isNaN(d.getTime())) {
|
1280
|
+
throw "Unable to parse time with native Date: " + s;
|
1281
|
+
}
|
1282
|
+
}
|
469
1283
|
}
|
470
|
-
|
471
|
-
|
472
|
-
|
1284
|
+
|
1285
|
+
return {
|
1286
|
+
hour: d.getHours(),
|
1287
|
+
minute: d.getMinutes(),
|
1288
|
+
second: d.getSeconds(),
|
1289
|
+
millisec: d.getMilliseconds(),
|
1290
|
+
microsec: d.getMicroseconds(),
|
1291
|
+
timezone: d.getTimezoneOffset() * -1
|
1292
|
+
};
|
473
1293
|
}
|
1294
|
+
catch (err) {
|
1295
|
+
try {
|
1296
|
+
return strictParse(f, s, o);
|
1297
|
+
}
|
1298
|
+
catch (err2) {
|
1299
|
+
$.timepicker.log("Unable to parse \ntimeString: " + s + "\ntimeFormat: " + f);
|
1300
|
+
}
|
1301
|
+
}
|
1302
|
+
return false;
|
1303
|
+
}; // end looseParse
|
1304
|
+
|
1305
|
+
if (typeof o.parse === "function") {
|
1306
|
+
return o.parse(timeFormat, timeString, o);
|
1307
|
+
}
|
1308
|
+
if (o.parse === 'loose') {
|
1309
|
+
return looseParse(timeFormat, timeString, o);
|
474
1310
|
}
|
475
|
-
|
1311
|
+
return strictParse(timeFormat, timeString, o);
|
1312
|
+
};
|
476
1313
|
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
1314
|
+
/**
|
1315
|
+
* Public utility to format the time
|
1316
|
+
* @param {string} format format of the time
|
1317
|
+
* @param {Object} time Object not a Date for timezones
|
1318
|
+
* @param {Object} [options] essentially the regional[].. amNames, pmNames, ampm
|
1319
|
+
* @returns {string} the formatted time
|
1320
|
+
*/
|
1321
|
+
$.datepicker.formatTime = function (format, time, options) {
|
1322
|
+
options = options || {};
|
1323
|
+
options = $.extend({}, $.timepicker._defaults, options);
|
1324
|
+
time = $.extend({
|
1325
|
+
hour: 0,
|
1326
|
+
minute: 0,
|
1327
|
+
second: 0,
|
1328
|
+
millisec: 0,
|
1329
|
+
microsec: 0,
|
1330
|
+
timezone: null
|
1331
|
+
}, time);
|
1332
|
+
|
1333
|
+
var tmptime = format,
|
1334
|
+
ampmName = options.amNames[0],
|
1335
|
+
hour = parseInt(time.hour, 10);
|
1336
|
+
|
1337
|
+
if (hour > 11) {
|
1338
|
+
ampmName = options.pmNames[0];
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[zZ]|[lc]|'.*?')/g, function (match) {
|
1342
|
+
switch (match) {
|
1343
|
+
case 'HH':
|
1344
|
+
return ('0' + hour).slice(-2);
|
1345
|
+
case 'H':
|
1346
|
+
return hour;
|
1347
|
+
case 'hh':
|
1348
|
+
return ('0' + convert24to12(hour)).slice(-2);
|
1349
|
+
case 'h':
|
1350
|
+
return convert24to12(hour);
|
1351
|
+
case 'mm':
|
1352
|
+
return ('0' + time.minute).slice(-2);
|
1353
|
+
case 'm':
|
1354
|
+
return time.minute;
|
1355
|
+
case 'ss':
|
1356
|
+
return ('0' + time.second).slice(-2);
|
1357
|
+
case 's':
|
1358
|
+
return time.second;
|
1359
|
+
case 'l':
|
1360
|
+
return ('00' + time.millisec).slice(-3);
|
1361
|
+
case 'c':
|
1362
|
+
return ('00' + time.microsec).slice(-3);
|
1363
|
+
case 'z':
|
1364
|
+
return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, false);
|
1365
|
+
case 'Z':
|
1366
|
+
return $.timepicker.timezoneOffsetString(time.timezone === null ? options.timezone : time.timezone, true);
|
1367
|
+
case 'T':
|
1368
|
+
return ampmName.charAt(0).toUpperCase();
|
1369
|
+
case 'TT':
|
1370
|
+
return ampmName.toUpperCase();
|
1371
|
+
case 't':
|
1372
|
+
return ampmName.charAt(0).toLowerCase();
|
1373
|
+
case 'tt':
|
1374
|
+
return ampmName.toLowerCase();
|
1375
|
+
default:
|
1376
|
+
return match.replace(/'/g, "");
|
494
1377
|
}
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
1378
|
+
});
|
1379
|
+
|
1380
|
+
return tmptime;
|
1381
|
+
};
|
1382
|
+
|
1383
|
+
/*
|
1384
|
+
* the bad hack :/ override datepicker so it doesn't close on select
|
1385
|
+
// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
|
1386
|
+
*/
|
1387
|
+
$.datepicker._base_selectDate = $.datepicker._selectDate;
|
1388
|
+
$.datepicker._selectDate = function (id, dateStr) {
|
1389
|
+
var inst = this._getInst($(id)[0]),
|
1390
|
+
tp_inst = this._get(inst, 'timepicker'),
|
1391
|
+
was_inline;
|
1392
|
+
|
1393
|
+
if (tp_inst && inst.settings.showTimepicker) {
|
1394
|
+
tp_inst._limitMinMaxDateTime(inst, true);
|
1395
|
+
was_inline = inst.inline;
|
1396
|
+
inst.inline = inst.stay_open = true;
|
1397
|
+
//This way the onSelect handler called from calendarpicker get the full dateTime
|
1398
|
+
this._base_selectDate(id, dateStr);
|
1399
|
+
inst.inline = was_inline;
|
1400
|
+
inst.stay_open = false;
|
1401
|
+
this._notifyChange(inst);
|
1402
|
+
this._updateDatepicker(inst);
|
1403
|
+
} else {
|
1404
|
+
this._base_selectDate(id, dateStr);
|
1405
|
+
}
|
1406
|
+
};
|
1407
|
+
|
1408
|
+
/*
|
1409
|
+
* second bad hack :/ override datepicker so it triggers an event when changing the input field
|
1410
|
+
* and does not redraw the datepicker on every selectDate event
|
1411
|
+
*/
|
1412
|
+
$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
|
1413
|
+
$.datepicker._updateDatepicker = function (inst) {
|
1414
|
+
|
1415
|
+
// don't popup the datepicker if there is another instance already opened
|
1416
|
+
var input = inst.input[0];
|
1417
|
+
if ($.datepicker._curInst && $.datepicker._curInst !== inst && $.datepicker._datepickerShowing && $.datepicker._lastInput !== input) {
|
1418
|
+
return;
|
1419
|
+
}
|
500
1420
|
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
1421
|
+
if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
|
1422
|
+
|
1423
|
+
this._base_updateDatepicker(inst);
|
1424
|
+
|
1425
|
+
// Reload the time control when changing something in the input text field.
|
1426
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1427
|
+
if (tp_inst) {
|
1428
|
+
tp_inst._addTimePicker(inst);
|
508
1429
|
}
|
509
1430
|
}
|
1431
|
+
};
|
510
1432
|
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
1433
|
+
/*
|
1434
|
+
* third bad hack :/ override datepicker so it allows spaces and colon in the input field
|
1435
|
+
*/
|
1436
|
+
$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
|
1437
|
+
$.datepicker._doKeyPress = function (event) {
|
1438
|
+
var inst = $.datepicker._getInst(event.target),
|
1439
|
+
tp_inst = $.datepicker._get(inst, 'timepicker');
|
1440
|
+
|
1441
|
+
if (tp_inst) {
|
1442
|
+
if ($.datepicker._get(inst, 'constrainInput')) {
|
1443
|
+
var ampm = tp_inst.support.ampm,
|
1444
|
+
tz = tp_inst._defaults.showTimezone !== null ? tp_inst._defaults.showTimezone : tp_inst.support.timezone,
|
1445
|
+
dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
|
1446
|
+
datetimeChars = tp_inst._defaults.timeFormat.toString()
|
1447
|
+
.replace(/[hms]/g, '')
|
1448
|
+
.replace(/TT/g, ampm ? 'APM' : '')
|
1449
|
+
.replace(/Tt/g, ampm ? 'AaPpMm' : '')
|
1450
|
+
.replace(/tT/g, ampm ? 'AaPpMm' : '')
|
1451
|
+
.replace(/T/g, ampm ? 'AP' : '')
|
1452
|
+
.replace(/tt/g, ampm ? 'apm' : '')
|
1453
|
+
.replace(/t/g, ampm ? 'ap' : '') +
|
1454
|
+
" " + tp_inst._defaults.separator +
|
1455
|
+
tp_inst._defaults.timeSuffix +
|
1456
|
+
(tz ? tp_inst._defaults.timezoneList.join('') : '') +
|
1457
|
+
(tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
|
1458
|
+
dateChars,
|
1459
|
+
chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
1460
|
+
return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
|
519
1461
|
}
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
1462
|
+
}
|
1463
|
+
|
1464
|
+
return $.datepicker._base_doKeyPress(event);
|
1465
|
+
};
|
1466
|
+
|
1467
|
+
/*
|
1468
|
+
* Fourth bad hack :/ override _updateAlternate function used in inline mode to init altField
|
1469
|
+
* Update any alternate field to synchronise with the main field.
|
1470
|
+
*/
|
1471
|
+
$.datepicker._base_updateAlternate = $.datepicker._updateAlternate;
|
1472
|
+
$.datepicker._updateAlternate = function (inst) {
|
1473
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1474
|
+
if (tp_inst) {
|
1475
|
+
var altField = tp_inst._defaults.altField;
|
1476
|
+
if (altField) { // update alternate field too
|
1477
|
+
var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
|
1478
|
+
date = this._getDate(inst),
|
1479
|
+
formatCfg = $.datepicker._getFormatConfig(inst),
|
1480
|
+
altFormattedDateTime = '',
|
1481
|
+
altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
|
1482
|
+
altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
|
1483
|
+
altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
|
525
1484
|
|
526
|
-
|
527
|
-
if(
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
1485
|
+
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
|
1486
|
+
if (!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null) {
|
1487
|
+
if (tp_inst._defaults.altFormat) {
|
1488
|
+
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
|
1489
|
+
}
|
1490
|
+
else {
|
1491
|
+
altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
|
1492
|
+
}
|
1493
|
+
}
|
1494
|
+
$(altField).val( inst.input.val() ? altFormattedDateTime : "");
|
533
1495
|
}
|
534
1496
|
}
|
535
|
-
|
536
|
-
|
537
|
-
this.hour_slider.slider("option", { min: this._defaults.hourMin, max: this._defaults.hourMax }).slider('value', this.hour);
|
538
|
-
this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: this._defaults.minuteMax }).slider('value', this.minute);
|
539
|
-
this.second_slider.slider("option", { min: this._defaults.secondMin, max: this._defaults.secondMax }).slider('value', this.second);
|
1497
|
+
else {
|
1498
|
+
$.datepicker._base_updateAlternate(inst);
|
540
1499
|
}
|
1500
|
+
};
|
541
1501
|
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
|
550
|
-
minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
|
551
|
-
second = (this.second_slider) ? this.second_slider.slider('value') : false;
|
552
|
-
|
553
|
-
if (hour !== false) hour = parseInt(hour,10);
|
554
|
-
if (minute !== false) minute = parseInt(minute,10);
|
555
|
-
if (second !== false) second = parseInt(second,10);
|
556
|
-
|
557
|
-
var ampm = (hour < 12) ? 'AM' : 'PM';
|
558
|
-
|
559
|
-
// If the update was done in the input field, the input field should not be updated.
|
560
|
-
// If the update was done using the sliders, update the input field.
|
561
|
-
var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || (this.ampm.length > 0 && this.ampm != ampm));
|
562
|
-
|
563
|
-
if (hasChanged) {
|
1502
|
+
/*
|
1503
|
+
* Override key up event to sync manual input changes.
|
1504
|
+
*/
|
1505
|
+
$.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
|
1506
|
+
$.datepicker._doKeyUp = function (event) {
|
1507
|
+
var inst = $.datepicker._getInst(event.target),
|
1508
|
+
tp_inst = $.datepicker._get(inst, 'timepicker');
|
564
1509
|
|
565
|
-
|
566
|
-
if (
|
567
|
-
|
1510
|
+
if (tp_inst) {
|
1511
|
+
if (tp_inst._defaults.timeOnly && (inst.input.val() !== inst.lastVal)) {
|
1512
|
+
try {
|
1513
|
+
$.datepicker._updateDatepicker(inst);
|
1514
|
+
} catch (err) {
|
1515
|
+
$.timepicker.log(err);
|
1516
|
+
}
|
1517
|
+
}
|
568
1518
|
}
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
var
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
if (arguments.length) return tmptime;
|
611
|
-
else this.formattedTime = tmptime;
|
612
|
-
},
|
613
|
-
|
614
|
-
//########################################################################
|
615
|
-
// update our input with the new date time..
|
616
|
-
//########################################################################
|
617
|
-
_updateDateTime: function(dp_inst) {
|
618
|
-
dp_inst = this.inst || dp_inst,
|
619
|
-
dt = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
|
620
|
-
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
|
621
|
-
formatCfg = $.datepicker._getFormatConfig(dp_inst),
|
622
|
-
timeAvailable = dt !== null && this.timeDefined;
|
623
|
-
this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
|
624
|
-
var formattedDateTime = this.formattedDate;
|
625
|
-
if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
|
1519
|
+
|
1520
|
+
return $.datepicker._base_doKeyUp(event);
|
1521
|
+
};
|
1522
|
+
|
1523
|
+
/*
|
1524
|
+
* override "Today" button to also grab the time.
|
1525
|
+
*/
|
1526
|
+
$.datepicker._base_gotoToday = $.datepicker._gotoToday;
|
1527
|
+
$.datepicker._gotoToday = function (id) {
|
1528
|
+
var inst = this._getInst($(id)[0]),
|
1529
|
+
$dp = inst.dpDiv;
|
1530
|
+
this._base_gotoToday(id);
|
1531
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1532
|
+
selectLocalTimezone(tp_inst);
|
1533
|
+
var now = new Date();
|
1534
|
+
this._setTime(inst, now);
|
1535
|
+
this._setDate(inst, now);
|
1536
|
+
};
|
1537
|
+
|
1538
|
+
/*
|
1539
|
+
* Disable & enable the Time in the datetimepicker
|
1540
|
+
*/
|
1541
|
+
$.datepicker._disableTimepickerDatepicker = function (target) {
|
1542
|
+
var inst = this._getInst(target);
|
1543
|
+
if (!inst) {
|
1544
|
+
return;
|
1545
|
+
}
|
1546
|
+
|
1547
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1548
|
+
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
|
1549
|
+
if (tp_inst) {
|
1550
|
+
inst.settings.showTimepicker = false;
|
1551
|
+
tp_inst._defaults.showTimepicker = false;
|
1552
|
+
tp_inst._updateDateTime(inst);
|
1553
|
+
}
|
1554
|
+
};
|
1555
|
+
|
1556
|
+
$.datepicker._enableTimepickerDatepicker = function (target) {
|
1557
|
+
var inst = this._getInst(target);
|
1558
|
+
if (!inst) {
|
626
1559
|
return;
|
1560
|
+
}
|
627
1561
|
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
1562
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1563
|
+
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
|
1564
|
+
if (tp_inst) {
|
1565
|
+
inst.settings.showTimepicker = true;
|
1566
|
+
tp_inst._defaults.showTimepicker = true;
|
1567
|
+
tp_inst._addTimePicker(inst); // Could be disabled on page load
|
1568
|
+
tp_inst._updateDateTime(inst);
|
632
1569
|
}
|
1570
|
+
};
|
633
1571
|
|
634
|
-
|
1572
|
+
/*
|
1573
|
+
* Create our own set time function
|
1574
|
+
*/
|
1575
|
+
$.datepicker._setTime = function (inst, date) {
|
1576
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1577
|
+
if (tp_inst) {
|
1578
|
+
var defaults = tp_inst._defaults;
|
635
1579
|
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
1580
|
+
// calling _setTime with no date sets time to defaults
|
1581
|
+
tp_inst.hour = date ? date.getHours() : defaults.hour;
|
1582
|
+
tp_inst.minute = date ? date.getMinutes() : defaults.minute;
|
1583
|
+
tp_inst.second = date ? date.getSeconds() : defaults.second;
|
1584
|
+
tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
|
1585
|
+
tp_inst.microsec = date ? date.getMicroseconds() : defaults.microsec;
|
1586
|
+
|
1587
|
+
//check if within min/max times..
|
1588
|
+
tp_inst._limitMinMaxDateTime(inst, true);
|
1589
|
+
|
1590
|
+
tp_inst._onTimeChange();
|
1591
|
+
tp_inst._updateDateTime(inst);
|
1592
|
+
}
|
1593
|
+
};
|
1594
|
+
|
1595
|
+
/*
|
1596
|
+
* Create new public method to set only time, callable as $().datepicker('setTime', date)
|
1597
|
+
*/
|
1598
|
+
$.datepicker._setTimeDatepicker = function (target, date, withDate) {
|
1599
|
+
var inst = this._getInst(target);
|
1600
|
+
if (!inst) {
|
1601
|
+
return;
|
1602
|
+
}
|
1603
|
+
|
1604
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1605
|
+
|
1606
|
+
if (tp_inst) {
|
1607
|
+
this._setDateFromField(inst);
|
1608
|
+
var tp_date;
|
1609
|
+
if (date) {
|
1610
|
+
if (typeof date === "string") {
|
1611
|
+
tp_inst._parseTime(date, withDate);
|
1612
|
+
tp_date = new Date();
|
1613
|
+
tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
1614
|
+
tp_date.setMicroseconds(tp_inst.microsec);
|
1615
|
+
} else {
|
1616
|
+
tp_date = new Date(date.getTime());
|
1617
|
+
tp_date.setMicroseconds(date.getMicroseconds());
|
1618
|
+
}
|
1619
|
+
if (tp_date.toString() === 'Invalid Date') {
|
1620
|
+
tp_date = undefined;
|
1621
|
+
}
|
1622
|
+
this._setTime(inst, tp_date);
|
1623
|
+
}
|
1624
|
+
}
|
1625
|
+
|
1626
|
+
};
|
1627
|
+
|
1628
|
+
/*
|
1629
|
+
* override setDate() to allow setting time too within Date object
|
1630
|
+
*/
|
1631
|
+
$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
|
1632
|
+
$.datepicker._setDateDatepicker = function (target, _date) {
|
1633
|
+
var inst = this._getInst(target);
|
1634
|
+
var date = _date;
|
1635
|
+
if (!inst) {
|
1636
|
+
return;
|
1637
|
+
}
|
1638
|
+
|
1639
|
+
if (typeof(_date) === 'string') {
|
1640
|
+
date = new Date(_date);
|
1641
|
+
if (!date.getTime()) {
|
1642
|
+
this._base_setDateDatepicker.apply(this, arguments);
|
1643
|
+
date = $(target).datepicker('getDate');
|
1644
|
+
}
|
1645
|
+
}
|
1646
|
+
|
1647
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1648
|
+
var tp_date;
|
1649
|
+
if (date instanceof Date) {
|
1650
|
+
tp_date = new Date(date.getTime());
|
1651
|
+
tp_date.setMicroseconds(date.getMicroseconds());
|
644
1652
|
} else {
|
645
|
-
|
1653
|
+
tp_date = date;
|
646
1654
|
}
|
647
1655
|
|
648
|
-
|
649
|
-
|
1656
|
+
// This is important if you are using the timezone option, javascript's Date
|
1657
|
+
// object will only return the timezone offset for the current locale, so we
|
1658
|
+
// adjust it accordingly. If not using timezone option this won't matter..
|
1659
|
+
// If a timezone is different in tp, keep the timezone as is
|
1660
|
+
if (tp_inst && tp_date) {
|
1661
|
+
// look out for DST if tz wasn't specified
|
1662
|
+
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
|
1663
|
+
tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
|
1664
|
+
}
|
1665
|
+
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
|
1666
|
+
tp_date = $.timepicker.timezoneAdjust(tp_date, tp_inst.timezone);
|
1667
|
+
}
|
650
1668
|
|
651
|
-
|
1669
|
+
this._updateDatepicker(inst);
|
1670
|
+
this._base_setDateDatepicker.apply(this, arguments);
|
1671
|
+
this._setTimeDatepicker(target, tp_date, true);
|
1672
|
+
};
|
652
1673
|
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
1674
|
+
/*
|
1675
|
+
* override getDate() to allow getting time too within Date object
|
1676
|
+
*/
|
1677
|
+
$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
|
1678
|
+
$.datepicker._getDateDatepicker = function (target, noDefault) {
|
1679
|
+
var inst = this._getInst(target);
|
1680
|
+
if (!inst) {
|
1681
|
+
return;
|
1682
|
+
}
|
660
1683
|
|
661
|
-
|
1684
|
+
var tp_inst = this._get(inst, 'timepicker');
|
662
1685
|
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
}
|
1686
|
+
if (tp_inst) {
|
1687
|
+
// if it hasn't yet been defined, grab from field
|
1688
|
+
if (inst.lastVal === undefined) {
|
1689
|
+
this._setDateFromField(inst, noDefault);
|
1690
|
+
}
|
1691
|
+
|
1692
|
+
var date = this._getDate(inst);
|
1693
|
+
if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
|
1694
|
+
date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
1695
|
+
date.setMicroseconds(tp_inst.microsec);
|
1696
|
+
|
1697
|
+
// This is important if you are using the timezone option, javascript's Date
|
1698
|
+
// object will only return the timezone offset for the current locale, so we
|
1699
|
+
// adjust it accordingly. If not using timezone option this won't matter..
|
1700
|
+
if (tp_inst.timezone != null) {
|
1701
|
+
// look out for DST if tz wasn't specified
|
1702
|
+
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
|
1703
|
+
tp_inst.timezone = date.getTimezoneOffset() * -1;
|
1704
|
+
}
|
1705
|
+
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
|
1706
|
+
}
|
1707
|
+
}
|
1708
|
+
return date;
|
684
1709
|
}
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
// and does not redraw the datepicker on every selectDate event
|
717
|
-
//#############################################################################################
|
718
|
-
$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
|
719
|
-
$.datepicker._updateDatepicker = function(inst) {
|
720
|
-
if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
|
721
|
-
|
722
|
-
this._base_updateDatepicker(inst);
|
723
|
-
|
724
|
-
// Reload the time control when changing something in the input text field.
|
1710
|
+
return this._base_getDateDatepicker(target, noDefault);
|
1711
|
+
};
|
1712
|
+
|
1713
|
+
/*
|
1714
|
+
* override parseDate() because UI 1.8.14 throws an error about "Extra characters"
|
1715
|
+
* An option in datapicker to ignore extra format characters would be nicer.
|
1716
|
+
*/
|
1717
|
+
$.datepicker._base_parseDate = $.datepicker.parseDate;
|
1718
|
+
$.datepicker.parseDate = function (format, value, settings) {
|
1719
|
+
var date;
|
1720
|
+
try {
|
1721
|
+
date = this._base_parseDate(format, value, settings);
|
1722
|
+
} catch (err) {
|
1723
|
+
// Hack! The error message ends with a colon, a space, and
|
1724
|
+
// the "extra" characters. We rely on that instead of
|
1725
|
+
// attempting to perfectly reproduce the parsing algorithm.
|
1726
|
+
if (err.indexOf(":") >= 0) {
|
1727
|
+
date = this._base_parseDate(format, value.substring(0, value.length - (err.length - err.indexOf(':') - 2)), settings);
|
1728
|
+
$.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
|
1729
|
+
} else {
|
1730
|
+
throw err;
|
1731
|
+
}
|
1732
|
+
}
|
1733
|
+
return date;
|
1734
|
+
};
|
1735
|
+
|
1736
|
+
/*
|
1737
|
+
* override formatDate to set date with time to the input
|
1738
|
+
*/
|
1739
|
+
$.datepicker._base_formatDate = $.datepicker._formatDate;
|
1740
|
+
$.datepicker._formatDate = function (inst, day, month, year) {
|
725
1741
|
var tp_inst = this._get(inst, 'timepicker');
|
726
|
-
if(tp_inst)
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
//#######################################################################################
|
731
|
-
// third bad hack :/ override datepicker so it allows spaces and colan in the input field
|
732
|
-
//#######################################################################################
|
733
|
-
$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
|
734
|
-
$.datepicker._doKeyPress = function(event) {
|
735
|
-
var inst = $.datepicker._getInst(event.target),
|
736
|
-
tp_inst = $.datepicker._get(inst, 'timepicker');
|
737
|
-
|
738
|
-
if (tp_inst) {
|
739
|
-
if ($.datepicker._get(inst, 'constrainInput')) {
|
740
|
-
var ampm = tp_inst._defaults.ampm,
|
741
|
-
datetimeChars = tp_inst._defaults.timeFormat.toString()
|
742
|
-
.replace(/[hms]/g, '')
|
743
|
-
.replace(/TT/g, ampm ? 'APM' : '')
|
744
|
-
.replace(/T/g, ampm ? 'AP' : '')
|
745
|
-
.replace(/tt/g, ampm ? 'apm' : '')
|
746
|
-
.replace(/t/g, ampm ? 'ap' : '') +
|
747
|
-
" " +
|
748
|
-
tp_inst._defaults.separator +
|
749
|
-
$.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
|
750
|
-
chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
751
|
-
return event.ctrlKey || (chr < ' ' || !datetimeChars || datetimeChars.indexOf(chr) > -1);
|
1742
|
+
if (tp_inst) {
|
1743
|
+
tp_inst._updateDateTime(inst);
|
1744
|
+
return tp_inst.$input.val();
|
752
1745
|
}
|
753
|
-
|
1746
|
+
return this._base_formatDate(inst);
|
1747
|
+
};
|
1748
|
+
|
1749
|
+
/*
|
1750
|
+
* override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
|
1751
|
+
*/
|
1752
|
+
$.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
|
1753
|
+
$.datepicker._optionDatepicker = function (target, name, value) {
|
1754
|
+
var inst = this._getInst(target),
|
1755
|
+
name_clone;
|
1756
|
+
if (!inst) {
|
1757
|
+
return null;
|
1758
|
+
}
|
1759
|
+
|
1760
|
+
var tp_inst = this._get(inst, 'timepicker');
|
1761
|
+
if (tp_inst) {
|
1762
|
+
var min = null,
|
1763
|
+
max = null,
|
1764
|
+
onselect = null,
|
1765
|
+
overrides = tp_inst._defaults.evnts,
|
1766
|
+
fns = {},
|
1767
|
+
prop,
|
1768
|
+
ret,
|
1769
|
+
oldVal,
|
1770
|
+
$target;
|
1771
|
+
if (typeof name === 'string') { // if min/max was set with the string
|
1772
|
+
if (name === 'minDate' || name === 'minDateTime') {
|
1773
|
+
min = value;
|
1774
|
+
} else if (name === 'maxDate' || name === 'maxDateTime') {
|
1775
|
+
max = value;
|
1776
|
+
} else if (name === 'onSelect') {
|
1777
|
+
onselect = value;
|
1778
|
+
} else if (overrides.hasOwnProperty(name)) {
|
1779
|
+
if (typeof (value) === 'undefined') {
|
1780
|
+
return overrides[name];
|
1781
|
+
}
|
1782
|
+
fns[name] = value;
|
1783
|
+
name_clone = {}; //empty results in exiting function after overrides updated
|
1784
|
+
}
|
1785
|
+
} else if (typeof name === 'object') { //if min/max was set with the JSON
|
1786
|
+
if (name.minDate) {
|
1787
|
+
min = name.minDate;
|
1788
|
+
} else if (name.minDateTime) {
|
1789
|
+
min = name.minDateTime;
|
1790
|
+
} else if (name.maxDate) {
|
1791
|
+
max = name.maxDate;
|
1792
|
+
} else if (name.maxDateTime) {
|
1793
|
+
max = name.maxDateTime;
|
1794
|
+
}
|
1795
|
+
for (prop in overrides) {
|
1796
|
+
if (overrides.hasOwnProperty(prop) && name[prop]) {
|
1797
|
+
fns[prop] = name[prop];
|
1798
|
+
}
|
1799
|
+
}
|
1800
|
+
}
|
1801
|
+
for (prop in fns) {
|
1802
|
+
if (fns.hasOwnProperty(prop)) {
|
1803
|
+
overrides[prop] = fns[prop];
|
1804
|
+
if (!name_clone) { name_clone = $.extend({}, name); }
|
1805
|
+
delete name_clone[prop];
|
1806
|
+
}
|
1807
|
+
}
|
1808
|
+
if (name_clone && isEmptyObject(name_clone)) { return; }
|
1809
|
+
if (min) { //if min was set
|
1810
|
+
if (min === 0) {
|
1811
|
+
min = new Date();
|
1812
|
+
} else {
|
1813
|
+
min = new Date(min);
|
1814
|
+
}
|
1815
|
+
tp_inst._defaults.minDate = min;
|
1816
|
+
tp_inst._defaults.minDateTime = min;
|
1817
|
+
} else if (max) { //if max was set
|
1818
|
+
if (max === 0) {
|
1819
|
+
max = new Date();
|
1820
|
+
} else {
|
1821
|
+
max = new Date(max);
|
1822
|
+
}
|
1823
|
+
tp_inst._defaults.maxDate = max;
|
1824
|
+
tp_inst._defaults.maxDateTime = max;
|
1825
|
+
} else if (onselect) {
|
1826
|
+
tp_inst._defaults.onSelect = onselect;
|
1827
|
+
}
|
1828
|
+
|
1829
|
+
// Datepicker will override our date when we call _base_optionDatepicker when
|
1830
|
+
// calling minDate/maxDate, so we will first grab the value, call
|
1831
|
+
// _base_optionDatepicker, then set our value back.
|
1832
|
+
if(min || max){
|
1833
|
+
$target = $(target);
|
1834
|
+
oldVal = $target.datetimepicker('getDate');
|
1835
|
+
ret = this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
|
1836
|
+
$target.datetimepicker('setDate', oldVal);
|
1837
|
+
return ret;
|
1838
|
+
}
|
1839
|
+
}
|
1840
|
+
if (value === undefined) {
|
1841
|
+
return this._base_optionDatepicker.call($.datepicker, target, name);
|
1842
|
+
}
|
1843
|
+
return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
|
1844
|
+
};
|
754
1845
|
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
tp_inst = $.datepicker._get(inst, 'timepicker');
|
765
|
-
|
766
|
-
if (tp_inst) {
|
767
|
-
if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
|
768
|
-
try {
|
769
|
-
$.datepicker._updateDatepicker(inst);
|
1846
|
+
/*
|
1847
|
+
* jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
|
1848
|
+
* it will return false for all objects
|
1849
|
+
*/
|
1850
|
+
var isEmptyObject = function (obj) {
|
1851
|
+
var prop;
|
1852
|
+
for (prop in obj) {
|
1853
|
+
if (obj.hasOwnProperty(prop)) {
|
1854
|
+
return false;
|
770
1855
|
}
|
771
|
-
|
772
|
-
|
1856
|
+
}
|
1857
|
+
return true;
|
1858
|
+
};
|
1859
|
+
|
1860
|
+
/*
|
1861
|
+
* jQuery extend now ignores nulls!
|
1862
|
+
*/
|
1863
|
+
var extendRemove = function (target, props) {
|
1864
|
+
$.extend(target, props);
|
1865
|
+
for (var name in props) {
|
1866
|
+
if (props[name] === null || props[name] === undefined) {
|
1867
|
+
target[name] = props[name];
|
773
1868
|
}
|
774
1869
|
}
|
775
|
-
|
1870
|
+
return target;
|
1871
|
+
};
|
776
1872
|
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
tp_inst._onTimeChange();
|
798
|
-
tp_inst._updateDateTime(inst);
|
799
|
-
}
|
800
|
-
};
|
801
|
-
|
802
|
-
$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
|
803
|
-
var inst = this._getInst(target),
|
804
|
-
tp_inst = this._get(inst, 'timepicker');
|
805
|
-
if (tp_inst) {
|
806
|
-
tp_inst._defaults.showTimepicker = true;
|
807
|
-
tp_inst._onTimeChange();
|
808
|
-
tp_inst._updateDateTime(inst);
|
809
|
-
}
|
810
|
-
};
|
811
|
-
|
812
|
-
//#######################################################################################
|
813
|
-
// Create our own set time function
|
814
|
-
//#######################################################################################
|
815
|
-
$.datepicker._setTime = function(inst, date) {
|
816
|
-
var tp_inst = this._get(inst, 'timepicker');
|
817
|
-
if (tp_inst) {
|
818
|
-
var defaults = tp_inst._defaults,
|
819
|
-
// calling _setTime with no date sets time to defaults
|
820
|
-
hour = date ? date.getHours() : defaults.hour,
|
821
|
-
minute = date ? date.getMinutes() : defaults.minute,
|
822
|
-
second = date ? date.getSeconds() : defaults.second;
|
823
|
-
|
824
|
-
//check if within min/max times..
|
825
|
-
if ((hour < defaults.hourMin || hour > defaults.hourMax) || (minute < defaults.minuteMin || minute > defaults.minuteMax) || (second < defaults.secondMin || second > defaults.secondMax)) {
|
826
|
-
hour = defaults.hourMin;
|
827
|
-
minute = defaults.minuteMin;
|
828
|
-
second = defaults.secondMin;
|
829
|
-
}
|
830
|
-
|
831
|
-
if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
|
832
|
-
else tp_inst.hour = hour;
|
833
|
-
if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
|
834
|
-
else tp_inst.minute = minute;
|
835
|
-
if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
|
836
|
-
else tp_inst.second = second;
|
837
|
-
|
838
|
-
tp_inst._onTimeChange();
|
839
|
-
tp_inst._updateDateTime(inst);
|
840
|
-
}
|
841
|
-
};
|
1873
|
+
/*
|
1874
|
+
* Determine by the time format which units are supported
|
1875
|
+
* Returns an object of booleans for each unit
|
1876
|
+
*/
|
1877
|
+
var detectSupport = function (timeFormat) {
|
1878
|
+
var tf = timeFormat.replace(/'.*?'/g, '').toLowerCase(), // removes literals
|
1879
|
+
isIn = function (f, t) { // does the format contain the token?
|
1880
|
+
return f.indexOf(t) !== -1 ? true : false;
|
1881
|
+
};
|
1882
|
+
return {
|
1883
|
+
hour: isIn(tf, 'h'),
|
1884
|
+
minute: isIn(tf, 'm'),
|
1885
|
+
second: isIn(tf, 's'),
|
1886
|
+
millisec: isIn(tf, 'l'),
|
1887
|
+
microsec: isIn(tf, 'c'),
|
1888
|
+
timezone: isIn(tf, 'z'),
|
1889
|
+
ampm: isIn(tf, 't') && isIn(timeFormat, 'h'),
|
1890
|
+
iso8601: isIn(timeFormat, 'Z')
|
1891
|
+
};
|
1892
|
+
};
|
842
1893
|
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
var
|
848
|
-
|
1894
|
+
/*
|
1895
|
+
* Converts 24 hour format into 12 hour
|
1896
|
+
* Returns 12 hour without leading 0
|
1897
|
+
*/
|
1898
|
+
var convert24to12 = function (hour) {
|
1899
|
+
hour %= 12;
|
849
1900
|
|
850
|
-
|
851
|
-
|
852
|
-
var tp_date;
|
853
|
-
if (date) {
|
854
|
-
if (typeof date == "string") {
|
855
|
-
tp_inst._parseTime(date, withDate);
|
856
|
-
tp_date = new Date();
|
857
|
-
tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
|
858
|
-
}
|
859
|
-
else tp_date = new Date(date.getTime());
|
860
|
-
if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
|
1901
|
+
if (hour === 0) {
|
1902
|
+
hour = 12;
|
861
1903
|
}
|
862
|
-
this._setTime(inst, tp_date);
|
863
|
-
}
|
864
1904
|
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
1905
|
+
return String(hour);
|
1906
|
+
};
|
1907
|
+
|
1908
|
+
var computeEffectiveSetting = function (settings, property) {
|
1909
|
+
return settings && settings[property] ? settings[property] : $.timepicker._defaults[property];
|
1910
|
+
};
|
1911
|
+
|
1912
|
+
/*
|
1913
|
+
* Splits datetime string into date and time substrings.
|
1914
|
+
* Throws exception when date can't be parsed
|
1915
|
+
* Returns {dateString: dateString, timeString: timeString}
|
1916
|
+
*/
|
1917
|
+
var splitDateTime = function (dateTimeString, timeSettings) {
|
1918
|
+
// The idea is to get the number separator occurrences in datetime and the time format requested (since time has
|
1919
|
+
// fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
|
1920
|
+
var separator = computeEffectiveSetting(timeSettings, 'separator'),
|
1921
|
+
format = computeEffectiveSetting(timeSettings, 'timeFormat'),
|
1922
|
+
timeParts = format.split(separator), // how many occurrences of separator may be in our format?
|
1923
|
+
timePartsLen = timeParts.length,
|
1924
|
+
allParts = dateTimeString.split(separator),
|
1925
|
+
allPartsLen = allParts.length;
|
1926
|
+
|
1927
|
+
if (allPartsLen > 1) {
|
1928
|
+
return {
|
1929
|
+
dateString: allParts.splice(0, allPartsLen - timePartsLen).join(separator),
|
1930
|
+
timeString: allParts.splice(0, timePartsLen).join(separator)
|
1931
|
+
};
|
1932
|
+
}
|
1933
|
+
|
1934
|
+
return {
|
1935
|
+
dateString: dateTimeString,
|
1936
|
+
timeString: ''
|
1937
|
+
};
|
1938
|
+
};
|
1939
|
+
|
1940
|
+
/*
|
1941
|
+
* Internal function to parse datetime interval
|
1942
|
+
* Returns: {date: Date, timeObj: Object}, where
|
1943
|
+
* date - parsed date without time (type Date)
|
1944
|
+
* timeObj = {hour: , minute: , second: , millisec: , microsec: } - parsed time. Optional
|
1945
|
+
*/
|
1946
|
+
var parseDateTimeInternal = function (dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
|
1947
|
+
var date,
|
1948
|
+
parts,
|
1949
|
+
parsedTime;
|
1950
|
+
|
1951
|
+
parts = splitDateTime(dateTimeString, timeSettings);
|
1952
|
+
date = $.datepicker._base_parseDate(dateFormat, parts.dateString, dateSettings);
|
1953
|
+
|
1954
|
+
if (parts.timeString === '') {
|
1955
|
+
return {
|
1956
|
+
date: date
|
1957
|
+
};
|
1958
|
+
}
|
1959
|
+
|
1960
|
+
parsedTime = $.datepicker.parseTime(timeFormat, parts.timeString, timeSettings);
|
1961
|
+
|
1962
|
+
if (!parsedTime) {
|
1963
|
+
throw 'Wrong time format';
|
1964
|
+
}
|
1965
|
+
|
1966
|
+
return {
|
1967
|
+
date: date,
|
1968
|
+
timeObj: parsedTime
|
1969
|
+
};
|
1970
|
+
};
|
1971
|
+
|
1972
|
+
/*
|
1973
|
+
* Internal function to set timezone_select to the local timezone
|
1974
|
+
*/
|
1975
|
+
var selectLocalTimezone = function (tp_inst, date) {
|
1976
|
+
if (tp_inst && tp_inst.timezone_select) {
|
1977
|
+
var now = date || new Date();
|
1978
|
+
tp_inst.timezone_select.val(-now.getTimezoneOffset());
|
1979
|
+
}
|
1980
|
+
};
|
1981
|
+
|
1982
|
+
/*
|
1983
|
+
* Create a Singleton Instance
|
1984
|
+
*/
|
1985
|
+
$.timepicker = new Timepicker();
|
1986
|
+
|
1987
|
+
/**
|
1988
|
+
* Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
|
1989
|
+
* @param {number} tzMinutes if not a number, less than -720 (-1200), or greater than 840 (+1400) this value is returned
|
1990
|
+
* @param {boolean} iso8601 if true formats in accordance to iso8601 "+12:45"
|
1991
|
+
* @return {string}
|
1992
|
+
*/
|
1993
|
+
$.timepicker.timezoneOffsetString = function (tzMinutes, iso8601) {
|
1994
|
+
if (isNaN(tzMinutes) || tzMinutes > 840 || tzMinutes < -720) {
|
1995
|
+
return tzMinutes;
|
1996
|
+
}
|
1997
|
+
|
1998
|
+
var off = tzMinutes,
|
1999
|
+
minutes = off % 60,
|
2000
|
+
hours = (off - minutes) / 60,
|
2001
|
+
iso = iso8601 ? ':' : '',
|
2002
|
+
tz = (off >= 0 ? '+' : '-') + ('0' + Math.abs(hours)).slice(-2) + iso + ('0' + Math.abs(minutes)).slice(-2);
|
2003
|
+
|
2004
|
+
if (tz === '+00:00') {
|
2005
|
+
return 'Z';
|
2006
|
+
}
|
2007
|
+
return tz;
|
2008
|
+
};
|
2009
|
+
|
2010
|
+
/**
|
2011
|
+
* Get the number in minutes that represents a timezone string
|
2012
|
+
* @param {string} tzString formatted like "+0500", "-1245", "Z"
|
2013
|
+
* @return {number} the offset minutes or the original string if it doesn't match expectations
|
2014
|
+
*/
|
2015
|
+
$.timepicker.timezoneOffsetNumber = function (tzString) {
|
2016
|
+
var normalized = tzString.toString().replace(':', ''); // excuse any iso8601, end up with "+1245"
|
2017
|
+
|
2018
|
+
if (normalized.toUpperCase() === 'Z') { // if iso8601 with Z, its 0 minute offset
|
2019
|
+
return 0;
|
2020
|
+
}
|
2021
|
+
|
2022
|
+
if (!/^(\-|\+)\d{4}$/.test(normalized)) { // possibly a user defined tz, so just give it back
|
2023
|
+
return tzString;
|
2024
|
+
}
|
2025
|
+
|
2026
|
+
return ((normalized.substr(0, 1) === '-' ? -1 : 1) * // plus or minus
|
2027
|
+
((parseInt(normalized.substr(1, 2), 10) * 60) + // hours (converted to minutes)
|
2028
|
+
parseInt(normalized.substr(3, 2), 10))); // minutes
|
2029
|
+
};
|
2030
|
+
|
2031
|
+
/**
|
2032
|
+
* No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
|
2033
|
+
* @param {Date} date
|
2034
|
+
* @param {string} toTimezone formatted like "+0500", "-1245"
|
2035
|
+
* @return {Date}
|
2036
|
+
*/
|
2037
|
+
$.timepicker.timezoneAdjust = function (date, toTimezone) {
|
2038
|
+
var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
|
2039
|
+
if (!isNaN(toTz)) {
|
2040
|
+
date.setMinutes(date.getMinutes() + -date.getTimezoneOffset() - toTz);
|
2041
|
+
}
|
892
2042
|
return date;
|
2043
|
+
};
|
2044
|
+
|
2045
|
+
/**
|
2046
|
+
* Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
|
2047
|
+
* enforce date range limits.
|
2048
|
+
* n.b. The input value must be correctly formatted (reformatting is not supported)
|
2049
|
+
* @param {Element} startTime
|
2050
|
+
* @param {Element} endTime
|
2051
|
+
* @param {Object} options Options for the timepicker() call
|
2052
|
+
* @return {jQuery}
|
2053
|
+
*/
|
2054
|
+
$.timepicker.timeRange = function (startTime, endTime, options) {
|
2055
|
+
return $.timepicker.handleRange('timepicker', startTime, endTime, options);
|
2056
|
+
};
|
2057
|
+
|
2058
|
+
/**
|
2059
|
+
* Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
|
2060
|
+
* enforce date range limits.
|
2061
|
+
* @param {Element} startTime
|
2062
|
+
* @param {Element} endTime
|
2063
|
+
* @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
|
2064
|
+
* a boolean value that can be used to reformat the input values to the `dateFormat`.
|
2065
|
+
* @param {string} method Can be used to specify the type of picker to be added
|
2066
|
+
* @return {jQuery}
|
2067
|
+
*/
|
2068
|
+
$.timepicker.datetimeRange = function (startTime, endTime, options) {
|
2069
|
+
$.timepicker.handleRange('datetimepicker', startTime, endTime, options);
|
2070
|
+
};
|
2071
|
+
|
2072
|
+
/**
|
2073
|
+
* Calls `datepicker` on the `startTime` and `endTime` elements, and configures them to
|
2074
|
+
* enforce date range limits.
|
2075
|
+
* @param {Element} startTime
|
2076
|
+
* @param {Element} endTime
|
2077
|
+
* @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
|
2078
|
+
* a boolean value that can be used to reformat the input values to the `dateFormat`.
|
2079
|
+
* @return {jQuery}
|
2080
|
+
*/
|
2081
|
+
$.timepicker.dateRange = function (startTime, endTime, options) {
|
2082
|
+
$.timepicker.handleRange('datepicker', startTime, endTime, options);
|
2083
|
+
};
|
2084
|
+
|
2085
|
+
/**
|
2086
|
+
* Calls `method` on the `startTime` and `endTime` elements, and configures them to
|
2087
|
+
* enforce date range limits.
|
2088
|
+
* @param {string} method Can be used to specify the type of picker to be added
|
2089
|
+
* @param {Element} startTime
|
2090
|
+
* @param {Element} endTime
|
2091
|
+
* @param {Object} options Options for the `timepicker()` call. Also supports `reformat`,
|
2092
|
+
* a boolean value that can be used to reformat the input values to the `dateFormat`.
|
2093
|
+
* @return {jQuery}
|
2094
|
+
*/
|
2095
|
+
$.timepicker.handleRange = function (method, startTime, endTime, options) {
|
2096
|
+
options = $.extend({}, {
|
2097
|
+
minInterval: 0, // min allowed interval in milliseconds
|
2098
|
+
maxInterval: 0, // max allowed interval in milliseconds
|
2099
|
+
start: {}, // options for start picker
|
2100
|
+
end: {} // options for end picker
|
2101
|
+
}, options);
|
2102
|
+
|
2103
|
+
// for the mean time this fixes an issue with calling getDate with timepicker()
|
2104
|
+
var timeOnly = false;
|
2105
|
+
if(method === 'timepicker'){
|
2106
|
+
timeOnly = true;
|
2107
|
+
method = 'datetimepicker';
|
2108
|
+
}
|
2109
|
+
|
2110
|
+
function checkDates(changed, other) {
|
2111
|
+
var startdt = startTime[method]('getDate'),
|
2112
|
+
enddt = endTime[method]('getDate'),
|
2113
|
+
changeddt = changed[method]('getDate');
|
2114
|
+
|
2115
|
+
if (startdt !== null) {
|
2116
|
+
var minDate = new Date(startdt.getTime()),
|
2117
|
+
maxDate = new Date(startdt.getTime());
|
2118
|
+
|
2119
|
+
minDate.setMilliseconds(minDate.getMilliseconds() + options.minInterval);
|
2120
|
+
maxDate.setMilliseconds(maxDate.getMilliseconds() + options.maxInterval);
|
2121
|
+
|
2122
|
+
if (options.minInterval > 0 && minDate > enddt) { // minInterval check
|
2123
|
+
endTime[method]('setDate', minDate);
|
2124
|
+
}
|
2125
|
+
else if (options.maxInterval > 0 && maxDate < enddt) { // max interval check
|
2126
|
+
endTime[method]('setDate', maxDate);
|
2127
|
+
}
|
2128
|
+
else if (startdt > enddt) {
|
2129
|
+
other[method]('setDate', changeddt);
|
2130
|
+
}
|
2131
|
+
}
|
2132
|
+
}
|
2133
|
+
|
2134
|
+
function selected(changed, other, option) {
|
2135
|
+
if (!changed.val()) {
|
2136
|
+
return;
|
2137
|
+
}
|
2138
|
+
var date = changed[method].call(changed, 'getDate');
|
2139
|
+
if (date !== null && options.minInterval > 0) {
|
2140
|
+
if (option === 'minDate') {
|
2141
|
+
date.setMilliseconds(date.getMilliseconds() + options.minInterval);
|
2142
|
+
}
|
2143
|
+
if (option === 'maxDate') {
|
2144
|
+
date.setMilliseconds(date.getMilliseconds() - options.minInterval);
|
2145
|
+
}
|
2146
|
+
}
|
2147
|
+
|
2148
|
+
if (date.getTime) {
|
2149
|
+
other[method].call(other, 'option', option, date);
|
2150
|
+
}
|
2151
|
+
}
|
2152
|
+
|
2153
|
+
$.fn[method].call(startTime, $.extend({
|
2154
|
+
timeOnly: timeOnly,
|
2155
|
+
onClose: function (dateText, inst) {
|
2156
|
+
checkDates($(this), endTime);
|
2157
|
+
},
|
2158
|
+
onSelect: function (selectedDateTime) {
|
2159
|
+
selected($(this), endTime, 'minDate');
|
2160
|
+
}
|
2161
|
+
}, options, options.start));
|
2162
|
+
$.fn[method].call(endTime, $.extend({
|
2163
|
+
timeOnly: timeOnly,
|
2164
|
+
onClose: function (dateText, inst) {
|
2165
|
+
checkDates($(this), startTime);
|
2166
|
+
},
|
2167
|
+
onSelect: function (selectedDateTime) {
|
2168
|
+
selected($(this), startTime, 'maxDate');
|
2169
|
+
}
|
2170
|
+
}, options, options.end));
|
2171
|
+
|
2172
|
+
checkDates(startTime, endTime);
|
2173
|
+
|
2174
|
+
selected(startTime, endTime, 'minDate');
|
2175
|
+
selected(endTime, startTime, 'maxDate');
|
2176
|
+
|
2177
|
+
return $([startTime.get(0), endTime.get(0)]);
|
2178
|
+
};
|
2179
|
+
|
2180
|
+
/**
|
2181
|
+
* Log error or data to the console during error or debugging
|
2182
|
+
* @param {Object} err pass any type object to log to the console during error or debugging
|
2183
|
+
* @return {void}
|
2184
|
+
*/
|
2185
|
+
$.timepicker.log = function () {
|
2186
|
+
if (window.console) {
|
2187
|
+
window.console.log.apply(window.console, Array.prototype.slice.call(arguments));
|
2188
|
+
}
|
2189
|
+
};
|
2190
|
+
|
2191
|
+
/*
|
2192
|
+
* Add util object to allow access to private methods for testability.
|
2193
|
+
*/
|
2194
|
+
$.timepicker._util = {
|
2195
|
+
_extendRemove: extendRemove,
|
2196
|
+
_isEmptyObject: isEmptyObject,
|
2197
|
+
_convert24to12: convert24to12,
|
2198
|
+
_detectSupport: detectSupport,
|
2199
|
+
_selectLocalTimezone: selectLocalTimezone,
|
2200
|
+
_computeEffectiveSetting: computeEffectiveSetting,
|
2201
|
+
_splitDateTime: splitDateTime,
|
2202
|
+
_parseDateTimeInternal: parseDateTimeInternal
|
2203
|
+
};
|
2204
|
+
|
2205
|
+
/*
|
2206
|
+
* Microsecond support
|
2207
|
+
*/
|
2208
|
+
if (!Date.prototype.getMicroseconds) {
|
2209
|
+
Date.prototype.microseconds = 0;
|
2210
|
+
Date.prototype.getMicroseconds = function () { return this.microseconds; };
|
2211
|
+
Date.prototype.setMicroseconds = function (m) {
|
2212
|
+
this.setMilliseconds(this.getMilliseconds() + Math.floor(m / 1000));
|
2213
|
+
this.microseconds = m % 1000;
|
2214
|
+
return this;
|
2215
|
+
};
|
893
2216
|
}
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
//#######################################################################################
|
900
|
-
function extendRemove(target, props) {
|
901
|
-
$.extend(target, props);
|
902
|
-
for (var name in props)
|
903
|
-
if (props[name] === null || props[name] === undefined)
|
904
|
-
target[name] = props[name];
|
905
|
-
return target;
|
906
|
-
}
|
907
|
-
|
908
|
-
$.timepicker = new Timepicker(); // singleton instance
|
909
|
-
$.timepicker.version = "0.9.3";
|
2217
|
+
|
2218
|
+
/*
|
2219
|
+
* Keep up with the version
|
2220
|
+
*/
|
2221
|
+
$.timepicker.version = "1.5.0";
|
910
2222
|
|
911
2223
|
})(jQuery);
|