incline 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +186 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +208 -0
- data/Rakefile +37 -0
- data/app/assets/fonts/incline/.keep +0 -0
- data/app/assets/images/incline/.keep +0 -0
- data/app/assets/images/incline/barcode-B.svg +181 -0
- data/app/assets/javascripts/incline/activate_classed_items.js +11 -0
- data/app/assets/javascripts/incline/application.js +30 -0
- data/app/assets/javascripts/incline/bootstrap-datepicker.js +1800 -0
- data/app/assets/javascripts/incline/datatables.js +22193 -0
- data/app/assets/javascripts/incline/escapeHtml.js +10 -0
- data/app/assets/javascripts/incline/inline_actions.js +479 -0
- data/app/assets/javascripts/incline/jquery.doubleScroll.js +112 -0
- data/app/assets/javascripts/incline/jquery.number.js +764 -0
- data/app/assets/javascripts/incline/regexMask.js +27 -0
- data/app/assets/javascripts/incline/select2/i18n/en.js +3 -0
- data/app/assets/javascripts/incline/select2/select2.full.js +6436 -0
- data/app/assets/stylesheets/incline/application.css +18 -0
- data/app/assets/stylesheets/incline/bootstrap-theme.min.css +5 -0
- data/app/assets/stylesheets/incline/custom.scss +279 -0
- data/app/assets/stylesheets/incline/datatables.css +494 -0
- data/app/assets/stylesheets/incline/datepicker3.css +790 -0
- data/app/assets/stylesheets/incline/select2.css +484 -0
- data/app/controllers/incline/access_groups_controller.rb +127 -0
- data/app/controllers/incline/access_test_controller.rb +30 -0
- data/app/controllers/incline/account_activations_controller.rb +28 -0
- data/app/controllers/incline/application_controller.rb +11 -0
- data/app/controllers/incline/contact_controller.rb +34 -0
- data/app/controllers/incline/password_resets_controller.rb +113 -0
- data/app/controllers/incline/security_controller.rb +100 -0
- data/app/controllers/incline/sessions_controller.rb +50 -0
- data/app/controllers/incline/users_controller.rb +304 -0
- data/app/controllers/incline/welcome_controller.rb +19 -0
- data/app/helpers/incline/.keep +0 -0
- data/app/mailers/incline/application_mailer_base.rb +11 -0
- data/app/mailers/incline/contact_form.rb +19 -0
- data/app/mailers/incline/user_mailer.rb +45 -0
- data/app/models/incline/access_group.rb +121 -0
- data/app/models/incline/access_group_group_member.rb +12 -0
- data/app/models/incline/access_group_user_member.rb +10 -0
- data/app/models/incline/action_group.rb +12 -0
- data/app/models/incline/action_security.rb +222 -0
- data/app/models/incline/contact_message.rb +37 -0
- data/app/models/incline/disable_info.rb +20 -0
- data/app/models/incline/password_reset.rb +14 -0
- data/app/models/incline/password_reset_request.rb +14 -0
- data/app/models/incline/user.rb +437 -0
- data/app/models/incline/user_login_history.rb +30 -0
- data/app/views/incline/access_groups/_details.json.jbuilder +10 -0
- data/app/views/incline/access_groups/_form.html.erb +19 -0
- data/app/views/incline/access_groups/_list.html.erb +60 -0
- data/app/views/incline/access_groups/_messages.json.jbuilder +6 -0
- data/app/views/incline/access_groups/edit.html.erb +2 -0
- data/app/views/incline/access_groups/index.html.erb +6 -0
- data/app/views/incline/access_groups/index.json.jbuilder +16 -0
- data/app/views/incline/access_groups/new.html.erb +2 -0
- data/app/views/incline/access_groups/show.html.erb +9 -0
- data/app/views/incline/access_groups/show.json.jbuilder +11 -0
- data/app/views/incline/contact/new.html.erb +22 -0
- data/app/views/incline/contact_form/contact.html.erb +16 -0
- data/app/views/incline/contact_form/contact.text.erb +13 -0
- data/app/views/incline/password_resets/edit.html.erb +16 -0
- data/app/views/incline/password_resets/new.html.erb +12 -0
- data/app/views/incline/security/_details.json.jbuilder +7 -0
- data/app/views/incline/security/_form.html.erb +20 -0
- data/app/views/incline/security/_list.html.erb +89 -0
- data/app/views/incline/security/_messages.json.jbuilder +6 -0
- data/app/views/incline/security/edit.html.erb +2 -0
- data/app/views/incline/security/index.html.erb +6 -0
- data/app/views/incline/security/index.json.jbuilder +16 -0
- data/app/views/incline/security/show.html.erb +31 -0
- data/app/views/incline/security/show.json.jbuilder +11 -0
- data/app/views/incline/sessions/new.html.erb +26 -0
- data/app/views/incline/user_mailer/account_activation.html.erb +7 -0
- data/app/views/incline/user_mailer/account_activation.text.erb +6 -0
- data/app/views/incline/user_mailer/invalid_password_reset.html.erb +3 -0
- data/app/views/incline/user_mailer/invalid_password_reset.text.erb +5 -0
- data/app/views/incline/user_mailer/password_reset.html.erb +8 -0
- data/app/views/incline/user_mailer/password_reset.text.erb +7 -0
- data/app/views/incline/users/_details.json.jbuilder +32 -0
- data/app/views/incline/users/_form.html.erb +21 -0
- data/app/views/incline/users/_list.html.erb +102 -0
- data/app/views/incline/users/_messages.json.jbuilder +6 -0
- data/app/views/incline/users/disable_confirm.html.erb +19 -0
- data/app/views/incline/users/edit.html.erb +5 -0
- data/app/views/incline/users/index.html.erb +6 -0
- data/app/views/incline/users/index.json.jbuilder +16 -0
- data/app/views/incline/users/new.html.erb +5 -0
- data/app/views/incline/users/show.html.erb +12 -0
- data/app/views/incline/users/show.json.jbuilder +11 -0
- data/app/views/incline/welcome/home.html.erb +5 -0
- data/app/views/layouts/application.html.erb +1 -0
- data/app/views/layouts/incline/_account_menu.html.erb +18 -0
- data/app/views/layouts/incline/_app_menu_anon.html.erb +1 -0
- data/app/views/layouts/incline/_app_menu_authenticated.html.erb +1 -0
- data/app/views/layouts/incline/_footer.html.erb +13 -0
- data/app/views/layouts/incline/_header.html.erb +21 -0
- data/app/views/layouts/incline/_html_mailer.html.erb +5 -0
- data/app/views/layouts/incline/_incline_app.html.erb +25 -0
- data/app/views/layouts/incline/_messages.html.erb +3 -0
- data/app/views/layouts/incline/_shim.html.erb +3 -0
- data/app/views/layouts/incline/_text_mailer.text.erb +1 -0
- data/app/views/layouts/incline/application.html.erb +1 -0
- data/app/views/layouts/mailer.html.erb +2 -0
- data/app/views/layouts/mailer.text.erb +2 -0
- data/bin/rails +12 -0
- data/bin/test_scaffold.sh +10 -0
- data/config/routes.rb +61 -0
- data/db/migrate/20170511230126_create_incline_users.rb +26 -0
- data/db/migrate/20170515003052_create_incline_access_groups.rb +10 -0
- data/db/migrate/20170515003221_create_incline_user_login_histories.rb +12 -0
- data/db/migrate/20170515150908_create_incline_access_group_user_members.rb +11 -0
- data/db/migrate/20170515151058_create_incline_access_group_group_members.rb +11 -0
- data/db/migrate/20170517193432_add_comments_to_incline_user.rb +5 -0
- data/db/migrate/20170622132700_create_incline_action_securities.rb +16 -0
- data/db/migrate/20170622172712_create_incline_action_groups.rb +11 -0
- data/db/migrate/20170622195742_add_non_standard_to_action_security.rb +5 -0
- data/db/migrate/20170622230422_add_visible_to_action_security.rb +5 -0
- data/db/seeds.rb +81 -0
- data/exe/new_incline_app +42 -0
- data/lib/generators/incline/install_generator.rb +259 -0
- data/lib/generators/incline/templates/_app_menu_anon.html.erb +1 -0
- data/lib/generators/incline/templates/_app_menu_authenticated.html.erb +1 -0
- data/lib/generators/incline/templates/incline_application.css +17 -0
- data/lib/generators/incline/templates/incline_application.html.erb +1 -0
- data/lib/generators/incline/templates/incline_application.js +12 -0
- data/lib/generators/incline/templates/incline_database.yml +25 -0
- data/lib/generators/incline/templates/incline_email.yml +20 -0
- data/lib/generators/incline/templates/incline_mailer.html.erb +2 -0
- data/lib/generators/incline/templates/incline_mailer.text.erb +2 -0
- data/lib/generators/incline/templates/incline_users.yml +64 -0
- data/lib/generators/incline/templates/incline_version.rb +3 -0
- data/lib/incline/auth_engine_base.rb +52 -0
- data/lib/incline/data_tables_request.rb +336 -0
- data/lib/incline/date_time_formats.rb +6 -0
- data/lib/incline/engine.rb +212 -0
- data/lib/incline/errors.rb +15 -0
- data/lib/incline/extensions/action_controller_base.rb +526 -0
- data/lib/incline/extensions/action_mailer_base.rb +66 -0
- data/lib/incline/extensions/action_view_base.rb +489 -0
- data/lib/incline/extensions/active_record_base.rb +308 -0
- data/lib/incline/extensions/application.rb +137 -0
- data/lib/incline/extensions/application_configuration.rb +50 -0
- data/lib/incline/extensions/connection_adapter.rb +55 -0
- data/lib/incline/extensions/date_time_value.rb +123 -0
- data/lib/incline/extensions/date_value.rb +77 -0
- data/lib/incline/extensions/decimal_value.rb +55 -0
- data/lib/incline/extensions/erb_scaffold_generator.rb +31 -0
- data/lib/incline/extensions/float_value.rb +59 -0
- data/lib/incline/extensions/form_builder.rb +617 -0
- data/lib/incline/extensions/integer_value.rb +54 -0
- data/lib/incline/extensions/jbuilder_generator.rb +38 -0
- data/lib/incline/extensions/jbuilder_template.rb +39 -0
- data/lib/incline/extensions/main_app.rb +40 -0
- data/lib/incline/extensions/numeric.rb +63 -0
- data/lib/incline/extensions/object.rb +31 -0
- data/lib/incline/extensions/resource_route_generator.rb +53 -0
- data/lib/incline/extensions/session.rb +113 -0
- data/lib/incline/extensions/string.rb +50 -0
- data/lib/incline/extensions/test_case.rb +764 -0
- data/lib/incline/extensions/time_zone_converter.rb +40 -0
- data/lib/incline/global_status.rb +236 -0
- data/lib/incline/helpers/route_hash_formatter.rb +46 -0
- data/lib/incline/json_log_formatter.rb +96 -0
- data/lib/incline/json_logger.rb +17 -0
- data/lib/incline/log.rb +153 -0
- data/lib/incline/number_formats.rb +17 -0
- data/lib/incline/recaptcha.rb +346 -0
- data/lib/incline/user_manager.rb +212 -0
- data/lib/incline/validators/email_validator.rb +45 -0
- data/lib/incline/validators/ip_address_validator.rb +32 -0
- data/lib/incline/validators/recaptcha_validator.rb +37 -0
- data/lib/incline/validators/safe_name_validator.rb +31 -0
- data/lib/incline/version.rb +3 -0
- data/lib/incline/work_path.rb +75 -0
- data/lib/incline.rb +197 -0
- data/lib/tasks/incline_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +43 -0
- data/lib/templates/erb/scaffold/_list.html.erb +81 -0
- data/lib/templates/erb/scaffold/edit.html.erb +1 -0
- data/lib/templates/erb/scaffold/index.html.erb +6 -0
- data/lib/templates/erb/scaffold/new.html.erb +1 -0
- data/lib/templates/erb/scaffold/show.html.erb +34 -0
- data/lib/templates/jbuilder/scaffold/_details.json.jbuilder +20 -0
- data/lib/templates/jbuilder/scaffold/index.json.jbuilder +16 -0
- data/lib/templates/jbuilder/scaffold/show.json.jbuilder +16 -0
- data/lib/templates/rails/scaffold_controller/controller.rb +128 -0
- data/test/controllers/incline/access_groups_controller_test.rb +65 -0
- data/test/controllers/incline/access_test_controller_test.rb +53 -0
- data/test/controllers/incline/contact_controller_test.rb +32 -0
- data/test/controllers/incline/security_controller_test.rb +39 -0
- data/test/controllers/incline/welcome_controller_test.rb +16 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +12 -0
- data/test/dummy/app/assets/stylesheets/application.css +17 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +1 -0
- data/test/dummy/app/views/layouts/incline/_app_menu_anon.html.erb +1 -0
- data/test/dummy/app/views/layouts/incline/_app_menu_authenticated.html.erb +1 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +2 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +2 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +38 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +34 -0
- data/test/dummy/config/email.yml +24 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +45 -0
- data/test/dummy/config/environments/production.rb +85 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/schema.rb +108 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/extensions/action_controller_base_extensions_test.rb +21 -0
- data/test/extensions/action_mailer_base_extensions_test.rb +20 -0
- data/test/extensions/action_view_base_extensions_test.rb +267 -0
- data/test/extensions/active_record_extensions_test.rb +173 -0
- data/test/extensions/application_configuration_extensions_test.rb +46 -0
- data/test/extensions/application_extensions_test.rb +23 -0
- data/test/extensions/connection_adapter_extensions_test.rb +54 -0
- data/test/extensions/date_time_value_extensions_test.rb +104 -0
- data/test/extensions/date_value_extensions_test.rb +102 -0
- data/test/extensions/decimal_value_extensions_test.rb +85 -0
- data/test/extensions/erb_scaffold_generator_extensions_test.rb +17 -0
- data/test/extensions/float_value_extensions_test.rb +78 -0
- data/test/extensions/form_builder_extensions_test.rb +28 -0
- data/test/extensions/integer_value_extensions_test.rb +78 -0
- data/test/extensions/jbuilder_generator_extensions_test.rb +21 -0
- data/test/extensions/jbuilder_template_extensions_test.rb +47 -0
- data/test/extensions/main_app_extensions_test.rb +55 -0
- data/test/extensions/numeric_extensions_test.rb +76 -0
- data/test/extensions/object_extensions_test.rb +104 -0
- data/test/extensions/session_extensions_test.rb +69 -0
- data/test/extensions/string_extensions_test.rb +32 -0
- data/test/extensions/test_case_extensions_test.rb +538 -0
- data/test/extensions/time_zone_converter_extensions_test.rb +10 -0
- data/test/fixtures/incline/access_group_group_members.yml +1 -0
- data/test/fixtures/incline/access_group_user_members.yml +1 -0
- data/test/fixtures/incline/access_groups.yml +13 -0
- data/test/fixtures/incline/action_groups.yml +6 -0
- data/test/fixtures/incline/action_securities.yml +18 -0
- data/test/fixtures/incline/user_login_histories.yml +1 -0
- data/test/fixtures/incline/users.yml +64 -0
- data/test/incline_test.rb +63 -0
- data/test/integration/incline/users_edit_test.rb +180 -0
- data/test/integration/incline/users_login_test.rb +105 -0
- data/test/integration/incline/users_signup_test.rb +147 -0
- data/test/integration/navigation_test.rb +11 -0
- data/test/lib/data_tables_request_test.rb +245 -0
- data/test/lib/date_time_formats_test.rb +111 -0
- data/test/lib/global_status_test.rb +89 -0
- data/test/lib/json_log_formatter_test.rb +43 -0
- data/test/lib/log_test.rb +36 -0
- data/test/lib/recaptcha_test.rb +75 -0
- data/test/lib/user_manager_test.rb +47 -0
- data/test/lib/work_path_test.rb +18 -0
- data/test/models/incline/access_group_group_member_test.rb +30 -0
- data/test/models/incline/access_group_test.rb +60 -0
- data/test/models/incline/access_group_user_member_test.rb +29 -0
- data/test/models/incline/action_group_test.rb +27 -0
- data/test/models/incline/action_security_test.rb +176 -0
- data/test/models/incline/contact_message_test.rb +66 -0
- data/test/models/incline/disable_info_test.rb +29 -0
- data/test/models/incline/password_reset_request_test.rb +35 -0
- data/test/models/incline/password_reset_test.rb +51 -0
- data/test/models/incline/user_login_history_test.rb +31 -0
- data/test/models/incline/user_test.rb +91 -0
- data/test/test_helper.rb +42 -0
- data/test/validators/email_validator_test.rb +102 -0
- data/test/validators/ip_address_validator_test.rb +107 -0
- data/test/validators/recaptcha_validator_test.rb +57 -0
- data/test/validators/safe_name_validator_test.rb +101 -0
- metadata +584 -0
@@ -0,0 +1,1800 @@
|
|
1
|
+
/*!
|
2
|
+
* Datepicker for Bootstrap v1.5.0-dev (https://github.com/eternicode/bootstrap-datepicker)
|
3
|
+
*
|
4
|
+
* Copyright 2012 Stefan Petre
|
5
|
+
* Improvements by Andrew Rowls
|
6
|
+
* Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
7
|
+
*/(function($, undefined){
|
8
|
+
|
9
|
+
function UTCDate(){
|
10
|
+
return new Date(Date.UTC.apply(Date, arguments));
|
11
|
+
}
|
12
|
+
function UTCToday(){
|
13
|
+
var today = new Date();
|
14
|
+
return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
|
15
|
+
}
|
16
|
+
function isUTCEquals(date1, date2) {
|
17
|
+
return (
|
18
|
+
date1.getUTCFullYear() === date2.getUTCFullYear() &&
|
19
|
+
date1.getUTCMonth() === date2.getUTCMonth() &&
|
20
|
+
date1.getUTCDate() === date2.getUTCDate()
|
21
|
+
);
|
22
|
+
}
|
23
|
+
function alias(method){
|
24
|
+
return function(){
|
25
|
+
return this[method].apply(this, arguments);
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
var DateArray = (function(){
|
30
|
+
var extras = {
|
31
|
+
get: function(i){
|
32
|
+
return this.slice(i)[0];
|
33
|
+
},
|
34
|
+
contains: function(d){
|
35
|
+
// Array.indexOf is not cross-browser;
|
36
|
+
// $.inArray doesn't work with Dates
|
37
|
+
var val = d && d.valueOf();
|
38
|
+
for (var i=0, l=this.length; i < l; i++)
|
39
|
+
if (this[i].valueOf() === val)
|
40
|
+
return i;
|
41
|
+
return -1;
|
42
|
+
},
|
43
|
+
remove: function(i){
|
44
|
+
this.splice(i,1);
|
45
|
+
},
|
46
|
+
replace: function(new_array){
|
47
|
+
if (!new_array)
|
48
|
+
return;
|
49
|
+
if (!$.isArray(new_array))
|
50
|
+
new_array = [new_array];
|
51
|
+
this.clear();
|
52
|
+
this.push.apply(this, new_array);
|
53
|
+
},
|
54
|
+
clear: function(){
|
55
|
+
this.length = 0;
|
56
|
+
},
|
57
|
+
copy: function(){
|
58
|
+
var a = new DateArray();
|
59
|
+
a.replace(this);
|
60
|
+
return a;
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
return function(){
|
65
|
+
var a = [];
|
66
|
+
a.push.apply(a, arguments);
|
67
|
+
$.extend(a, extras);
|
68
|
+
return a;
|
69
|
+
};
|
70
|
+
})();
|
71
|
+
|
72
|
+
|
73
|
+
// Picker object
|
74
|
+
|
75
|
+
var Datepicker = function(element, options){
|
76
|
+
this._process_options(options);
|
77
|
+
|
78
|
+
this.dates = new DateArray();
|
79
|
+
this.viewDate = this.o.defaultViewDate;
|
80
|
+
this.focusDate = null;
|
81
|
+
|
82
|
+
this.element = $(element);
|
83
|
+
this.isInline = false;
|
84
|
+
this.isInput = this.element.is('input');
|
85
|
+
this.component = this.element.hasClass('date') ? this.element.find('.add-on, .input-group-addon, .btn') : false;
|
86
|
+
this.hasInput = this.component && this.element.find('input').length;
|
87
|
+
if (this.component && this.component.length === 0)
|
88
|
+
this.component = false;
|
89
|
+
|
90
|
+
this.picker = $(DPGlobal.template);
|
91
|
+
this._buildEvents();
|
92
|
+
this._attachEvents();
|
93
|
+
|
94
|
+
if (this.isInline){
|
95
|
+
this.picker.addClass('datepicker-inline').appendTo(this.element);
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
this.picker.addClass('datepicker-dropdown dropdown-menu');
|
99
|
+
}
|
100
|
+
|
101
|
+
if (this.o.rtl){
|
102
|
+
this.picker.addClass('datepicker-rtl');
|
103
|
+
}
|
104
|
+
|
105
|
+
this.viewMode = this.o.startView;
|
106
|
+
|
107
|
+
if (this.o.calendarWeeks)
|
108
|
+
this.picker.find('tfoot .today, tfoot .clear')
|
109
|
+
.attr('colspan', function(i, val){
|
110
|
+
return parseInt(val) + 1;
|
111
|
+
});
|
112
|
+
|
113
|
+
this._allow_update = false;
|
114
|
+
|
115
|
+
this.setStartDate(this._o.startDate);
|
116
|
+
this.setEndDate(this._o.endDate);
|
117
|
+
this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
|
118
|
+
this.setDatesDisabled(this.o.datesDisabled);
|
119
|
+
|
120
|
+
this.fillDow();
|
121
|
+
this.fillMonths();
|
122
|
+
|
123
|
+
this._allow_update = true;
|
124
|
+
|
125
|
+
this.update();
|
126
|
+
this.showMode();
|
127
|
+
|
128
|
+
if (this.isInline){
|
129
|
+
this.show();
|
130
|
+
}
|
131
|
+
};
|
132
|
+
|
133
|
+
Datepicker.prototype = {
|
134
|
+
constructor: Datepicker,
|
135
|
+
|
136
|
+
_process_options: function(opts){
|
137
|
+
// Store raw options for reference
|
138
|
+
this._o = $.extend({}, this._o, opts);
|
139
|
+
// Processed options
|
140
|
+
var o = this.o = $.extend({}, this._o);
|
141
|
+
|
142
|
+
// Check if "de-DE" style date is available, if not language should
|
143
|
+
// fallback to 2 letter code eg "de"
|
144
|
+
var lang = o.language;
|
145
|
+
if (!dates[lang]){
|
146
|
+
lang = lang.split('-')[0];
|
147
|
+
if (!dates[lang])
|
148
|
+
lang = defaults.language;
|
149
|
+
}
|
150
|
+
o.language = lang;
|
151
|
+
|
152
|
+
switch (o.startView){
|
153
|
+
case 2:
|
154
|
+
case 'decade':
|
155
|
+
o.startView = 2;
|
156
|
+
break;
|
157
|
+
case 1:
|
158
|
+
case 'year':
|
159
|
+
o.startView = 1;
|
160
|
+
break;
|
161
|
+
default:
|
162
|
+
o.startView = 0;
|
163
|
+
}
|
164
|
+
|
165
|
+
switch (o.minViewMode){
|
166
|
+
case 1:
|
167
|
+
case 'months':
|
168
|
+
o.minViewMode = 1;
|
169
|
+
break;
|
170
|
+
case 2:
|
171
|
+
case 'years':
|
172
|
+
o.minViewMode = 2;
|
173
|
+
break;
|
174
|
+
default:
|
175
|
+
o.minViewMode = 0;
|
176
|
+
}
|
177
|
+
|
178
|
+
o.startView = Math.max(o.startView, o.minViewMode);
|
179
|
+
|
180
|
+
// true, false, or Number > 0
|
181
|
+
if (o.multidate !== true){
|
182
|
+
o.multidate = Number(o.multidate) || false;
|
183
|
+
if (o.multidate !== false)
|
184
|
+
o.multidate = Math.max(0, o.multidate);
|
185
|
+
}
|
186
|
+
o.multidateSeparator = String(o.multidateSeparator);
|
187
|
+
|
188
|
+
o.weekStart %= 7;
|
189
|
+
o.weekEnd = ((o.weekStart + 6) % 7);
|
190
|
+
|
191
|
+
var format = DPGlobal.parseFormat(o.format);
|
192
|
+
if (o.startDate !== -Infinity){
|
193
|
+
if (!!o.startDate){
|
194
|
+
if (o.startDate instanceof Date)
|
195
|
+
o.startDate = this._local_to_utc(this._zero_time(o.startDate));
|
196
|
+
else
|
197
|
+
o.startDate = DPGlobal.parseDate(o.startDate, format, o.language);
|
198
|
+
}
|
199
|
+
else {
|
200
|
+
o.startDate = -Infinity;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
if (o.endDate !== Infinity){
|
204
|
+
if (!!o.endDate){
|
205
|
+
if (o.endDate instanceof Date)
|
206
|
+
o.endDate = this._local_to_utc(this._zero_time(o.endDate));
|
207
|
+
else
|
208
|
+
o.endDate = DPGlobal.parseDate(o.endDate, format, o.language);
|
209
|
+
}
|
210
|
+
else {
|
211
|
+
o.endDate = Infinity;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
o.daysOfWeekDisabled = o.daysOfWeekDisabled||[];
|
216
|
+
if (!$.isArray(o.daysOfWeekDisabled))
|
217
|
+
o.daysOfWeekDisabled = o.daysOfWeekDisabled.split(/[,\s]*/);
|
218
|
+
o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function(d){
|
219
|
+
return parseInt(d, 10);
|
220
|
+
});
|
221
|
+
|
222
|
+
o.datesDisabled = o.datesDisabled||[];
|
223
|
+
if (!$.isArray(o.datesDisabled)) {
|
224
|
+
var datesDisabled = [];
|
225
|
+
datesDisabled.push(DPGlobal.parseDate(o.datesDisabled, format, o.language));
|
226
|
+
o.datesDisabled = datesDisabled;
|
227
|
+
}
|
228
|
+
o.datesDisabled = $.map(o.datesDisabled,function(d){
|
229
|
+
return DPGlobal.parseDate(d, format, o.language);
|
230
|
+
});
|
231
|
+
|
232
|
+
var plc = String(o.orientation).toLowerCase().split(/\s+/g),
|
233
|
+
_plc = o.orientation.toLowerCase();
|
234
|
+
plc = $.grep(plc, function(word){
|
235
|
+
return /^auto|left|right|top|bottom$/.test(word);
|
236
|
+
});
|
237
|
+
o.orientation = {x: 'auto', y: 'auto'};
|
238
|
+
if (!_plc || _plc === 'auto')
|
239
|
+
; // no action
|
240
|
+
else if (plc.length === 1){
|
241
|
+
switch (plc[0]){
|
242
|
+
case 'top':
|
243
|
+
case 'bottom':
|
244
|
+
o.orientation.y = plc[0];
|
245
|
+
break;
|
246
|
+
case 'left':
|
247
|
+
case 'right':
|
248
|
+
o.orientation.x = plc[0];
|
249
|
+
break;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
else {
|
253
|
+
_plc = $.grep(plc, function(word){
|
254
|
+
return /^left|right$/.test(word);
|
255
|
+
});
|
256
|
+
o.orientation.x = _plc[0] || 'auto';
|
257
|
+
|
258
|
+
_plc = $.grep(plc, function(word){
|
259
|
+
return /^top|bottom$/.test(word);
|
260
|
+
});
|
261
|
+
o.orientation.y = _plc[0] || 'auto';
|
262
|
+
}
|
263
|
+
if (o.defaultViewDate) {
|
264
|
+
var year = o.defaultViewDate.year || new Date().getFullYear();
|
265
|
+
var month = o.defaultViewDate.month || 0;
|
266
|
+
var day = o.defaultViewDate.day || 1;
|
267
|
+
o.defaultViewDate = UTCDate(year, month, day);
|
268
|
+
} else {
|
269
|
+
o.defaultViewDate = UTCToday();
|
270
|
+
}
|
271
|
+
o.showOnFocus = o.showOnFocus !== undefined ? o.showOnFocus : true;
|
272
|
+
},
|
273
|
+
_events: [],
|
274
|
+
_secondaryEvents: [],
|
275
|
+
_applyEvents: function(evs){
|
276
|
+
for (var i=0, el, ch, ev; i < evs.length; i++){
|
277
|
+
el = evs[i][0];
|
278
|
+
if (evs[i].length === 2){
|
279
|
+
ch = undefined;
|
280
|
+
ev = evs[i][1];
|
281
|
+
}
|
282
|
+
else if (evs[i].length === 3){
|
283
|
+
ch = evs[i][1];
|
284
|
+
ev = evs[i][2];
|
285
|
+
}
|
286
|
+
el.on(ev, ch);
|
287
|
+
}
|
288
|
+
},
|
289
|
+
_unapplyEvents: function(evs){
|
290
|
+
for (var i=0, el, ev, ch; i < evs.length; i++){
|
291
|
+
el = evs[i][0];
|
292
|
+
if (evs[i].length === 2){
|
293
|
+
ch = undefined;
|
294
|
+
ev = evs[i][1];
|
295
|
+
}
|
296
|
+
else if (evs[i].length === 3){
|
297
|
+
ch = evs[i][1];
|
298
|
+
ev = evs[i][2];
|
299
|
+
}
|
300
|
+
el.off(ev, ch);
|
301
|
+
}
|
302
|
+
},
|
303
|
+
_buildEvents: function(){
|
304
|
+
var events = {
|
305
|
+
keyup: $.proxy(function(e){
|
306
|
+
if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
|
307
|
+
this.update();
|
308
|
+
}, this),
|
309
|
+
keydown: $.proxy(this.keydown, this),
|
310
|
+
paste: $.proxy(this.paste, this)
|
311
|
+
};
|
312
|
+
|
313
|
+
if (this.o.showOnFocus === true) {
|
314
|
+
events.focus = $.proxy(this.show, this);
|
315
|
+
}
|
316
|
+
|
317
|
+
if (this.isInput) { // single input
|
318
|
+
this._events = [
|
319
|
+
[this.element, events]
|
320
|
+
];
|
321
|
+
}
|
322
|
+
else if (this.component && this.hasInput) { // component: input + button
|
323
|
+
this._events = [
|
324
|
+
// For components that are not readonly, allow keyboard nav
|
325
|
+
[this.element.find('input'), events],
|
326
|
+
[this.component, {
|
327
|
+
click: $.proxy(this.show, this)
|
328
|
+
}]
|
329
|
+
];
|
330
|
+
}
|
331
|
+
else if (this.element.is('div')){ // inline datepicker
|
332
|
+
this.isInline = true;
|
333
|
+
}
|
334
|
+
else {
|
335
|
+
this._events = [
|
336
|
+
[this.element, {
|
337
|
+
click: $.proxy(this.show, this)
|
338
|
+
}]
|
339
|
+
];
|
340
|
+
}
|
341
|
+
this._events.push(
|
342
|
+
// Component: listen for blur on element descendants
|
343
|
+
[this.element, '*', {
|
344
|
+
blur: $.proxy(function(e){
|
345
|
+
this._focused_from = e.target;
|
346
|
+
}, this)
|
347
|
+
}],
|
348
|
+
// Input: listen for blur on element
|
349
|
+
[this.element, {
|
350
|
+
blur: $.proxy(function(e){
|
351
|
+
this._focused_from = e.target;
|
352
|
+
}, this)
|
353
|
+
}]
|
354
|
+
);
|
355
|
+
|
356
|
+
this._secondaryEvents = [
|
357
|
+
[this.picker, {
|
358
|
+
click: $.proxy(this.click, this)
|
359
|
+
}],
|
360
|
+
[$(window), {
|
361
|
+
resize: $.proxy(this.place, this)
|
362
|
+
}],
|
363
|
+
[$(document), {
|
364
|
+
mousedown: $.proxy(function(e){
|
365
|
+
// Clicked outside the datepicker, hide it
|
366
|
+
if (!(
|
367
|
+
this.element.is(e.target) ||
|
368
|
+
this.element.find(e.target).length ||
|
369
|
+
this.picker.is(e.target) ||
|
370
|
+
this.picker.find(e.target).length
|
371
|
+
)){
|
372
|
+
this.hide();
|
373
|
+
}
|
374
|
+
}, this)
|
375
|
+
}]
|
376
|
+
];
|
377
|
+
},
|
378
|
+
_attachEvents: function(){
|
379
|
+
this._detachEvents();
|
380
|
+
this._applyEvents(this._events);
|
381
|
+
},
|
382
|
+
_detachEvents: function(){
|
383
|
+
this._unapplyEvents(this._events);
|
384
|
+
},
|
385
|
+
_attachSecondaryEvents: function(){
|
386
|
+
this._detachSecondaryEvents();
|
387
|
+
this._applyEvents(this._secondaryEvents);
|
388
|
+
},
|
389
|
+
_detachSecondaryEvents: function(){
|
390
|
+
this._unapplyEvents(this._secondaryEvents);
|
391
|
+
},
|
392
|
+
_trigger: function(event, altdate){
|
393
|
+
var date = altdate || this.dates.get(-1),
|
394
|
+
local_date = this._utc_to_local(date);
|
395
|
+
|
396
|
+
this.element.trigger({
|
397
|
+
type: event,
|
398
|
+
date: local_date,
|
399
|
+
dates: $.map(this.dates, this._utc_to_local),
|
400
|
+
format: $.proxy(function(ix, format){
|
401
|
+
if (arguments.length === 0){
|
402
|
+
ix = this.dates.length - 1;
|
403
|
+
format = this.o.format;
|
404
|
+
}
|
405
|
+
else if (typeof ix === 'string'){
|
406
|
+
format = ix;
|
407
|
+
ix = this.dates.length - 1;
|
408
|
+
}
|
409
|
+
format = format || this.o.format;
|
410
|
+
var date = this.dates.get(ix);
|
411
|
+
return DPGlobal.formatDate(date, format, this.o.language);
|
412
|
+
}, this)
|
413
|
+
});
|
414
|
+
},
|
415
|
+
|
416
|
+
show: function(){
|
417
|
+
if (this.element.attr('readonly') && this.o.enableOnReadonly === false)
|
418
|
+
return;
|
419
|
+
if (!this.isInline)
|
420
|
+
this.picker.appendTo(this.o.container);
|
421
|
+
this.place();
|
422
|
+
this.picker.show();
|
423
|
+
this._attachSecondaryEvents();
|
424
|
+
this._trigger('show');
|
425
|
+
if ((window.navigator.msMaxTouchPoints || 'ontouchstart' in document) && this.o.disableTouchKeyboard) {
|
426
|
+
$(this.element).blur();
|
427
|
+
}
|
428
|
+
return this;
|
429
|
+
},
|
430
|
+
|
431
|
+
hide: function(){
|
432
|
+
if (this.isInline)
|
433
|
+
return this;
|
434
|
+
if (!this.picker.is(':visible'))
|
435
|
+
return this;
|
436
|
+
this.focusDate = null;
|
437
|
+
this.picker.hide().detach();
|
438
|
+
this._detachSecondaryEvents();
|
439
|
+
this.viewMode = this.o.startView;
|
440
|
+
this.showMode();
|
441
|
+
|
442
|
+
if (
|
443
|
+
this.o.forceParse &&
|
444
|
+
(
|
445
|
+
this.isInput && this.element.val() ||
|
446
|
+
this.hasInput && this.element.find('input').val()
|
447
|
+
)
|
448
|
+
)
|
449
|
+
this.setValue();
|
450
|
+
this._trigger('hide');
|
451
|
+
return this;
|
452
|
+
},
|
453
|
+
|
454
|
+
remove: function(){
|
455
|
+
this.hide();
|
456
|
+
this._detachEvents();
|
457
|
+
this._detachSecondaryEvents();
|
458
|
+
this.picker.remove();
|
459
|
+
delete this.element.data().datepicker;
|
460
|
+
if (!this.isInput){
|
461
|
+
delete this.element.data().date;
|
462
|
+
}
|
463
|
+
return this;
|
464
|
+
},
|
465
|
+
|
466
|
+
paste: function(evt){
|
467
|
+
var dateString;
|
468
|
+
if (evt.originalEvent.clipboardData && evt.originalEvent.clipboardData.types
|
469
|
+
&& $.inArray('text/plain', evt.originalEvent.clipboardData.types) !== -1) {
|
470
|
+
dateString = evt.originalEvent.clipboardData.getData('text/plain');
|
471
|
+
}
|
472
|
+
else if (window.clipboardData) {
|
473
|
+
dateString = window.clipboardData.getData('Text');
|
474
|
+
}
|
475
|
+
else {
|
476
|
+
return;
|
477
|
+
}
|
478
|
+
this.setDate(dateString);
|
479
|
+
this.update();
|
480
|
+
evt.preventDefault();
|
481
|
+
},
|
482
|
+
|
483
|
+
_utc_to_local: function(utc){
|
484
|
+
return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()*60000));
|
485
|
+
},
|
486
|
+
_local_to_utc: function(local){
|
487
|
+
return local && new Date(local.getTime() - (local.getTimezoneOffset()*60000));
|
488
|
+
},
|
489
|
+
_zero_time: function(local){
|
490
|
+
return local && new Date(local.getFullYear(), local.getMonth(), local.getDate());
|
491
|
+
},
|
492
|
+
_zero_utc_time: function(utc){
|
493
|
+
return utc && new Date(Date.UTC(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate()));
|
494
|
+
},
|
495
|
+
|
496
|
+
getDates: function(){
|
497
|
+
return $.map(this.dates, this._utc_to_local);
|
498
|
+
},
|
499
|
+
|
500
|
+
getUTCDates: function(){
|
501
|
+
return $.map(this.dates, function(d){
|
502
|
+
return new Date(d);
|
503
|
+
});
|
504
|
+
},
|
505
|
+
|
506
|
+
getDate: function(){
|
507
|
+
return this._utc_to_local(this.getUTCDate());
|
508
|
+
},
|
509
|
+
|
510
|
+
getUTCDate: function(){
|
511
|
+
var selected_date = this.dates.get(-1);
|
512
|
+
if (typeof selected_date !== 'undefined') {
|
513
|
+
return new Date(selected_date);
|
514
|
+
} else {
|
515
|
+
return null;
|
516
|
+
}
|
517
|
+
},
|
518
|
+
|
519
|
+
clearDates: function(){
|
520
|
+
var element;
|
521
|
+
if (this.isInput) {
|
522
|
+
element = this.element;
|
523
|
+
} else if (this.component) {
|
524
|
+
element = this.element.find('input');
|
525
|
+
}
|
526
|
+
|
527
|
+
if (element) {
|
528
|
+
element.val('').change();
|
529
|
+
}
|
530
|
+
|
531
|
+
this.update();
|
532
|
+
this._trigger('changeDate');
|
533
|
+
|
534
|
+
if (this.o.autoclose) {
|
535
|
+
this.hide();
|
536
|
+
}
|
537
|
+
},
|
538
|
+
setDates: function(){
|
539
|
+
var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
|
540
|
+
this.update.apply(this, args);
|
541
|
+
this._trigger('changeDate');
|
542
|
+
this.setValue();
|
543
|
+
return this;
|
544
|
+
},
|
545
|
+
|
546
|
+
setUTCDates: function(){
|
547
|
+
var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
|
548
|
+
this.update.apply(this, $.map(args, this._utc_to_local));
|
549
|
+
this._trigger('changeDate');
|
550
|
+
this.setValue();
|
551
|
+
return this;
|
552
|
+
},
|
553
|
+
|
554
|
+
setDate: alias('setDates'),
|
555
|
+
setUTCDate: alias('setUTCDates'),
|
556
|
+
|
557
|
+
setValue: function(){
|
558
|
+
var formatted = this.getFormattedDate();
|
559
|
+
if (!this.isInput){
|
560
|
+
if (this.component){
|
561
|
+
this.element.find('input').val(formatted).change();
|
562
|
+
}
|
563
|
+
}
|
564
|
+
else {
|
565
|
+
this.element.val(formatted).change();
|
566
|
+
}
|
567
|
+
return this;
|
568
|
+
},
|
569
|
+
|
570
|
+
getFormattedDate: function(format){
|
571
|
+
if (format === undefined)
|
572
|
+
format = this.o.format;
|
573
|
+
|
574
|
+
var lang = this.o.language;
|
575
|
+
return $.map(this.dates, function(d){
|
576
|
+
return DPGlobal.formatDate(d, format, lang);
|
577
|
+
}).join(this.o.multidateSeparator);
|
578
|
+
},
|
579
|
+
|
580
|
+
setStartDate: function(startDate){
|
581
|
+
this._process_options({startDate: startDate});
|
582
|
+
this.update();
|
583
|
+
this.updateNavArrows();
|
584
|
+
return this;
|
585
|
+
},
|
586
|
+
|
587
|
+
setEndDate: function(endDate){
|
588
|
+
this._process_options({endDate: endDate});
|
589
|
+
this.update();
|
590
|
+
this.updateNavArrows();
|
591
|
+
return this;
|
592
|
+
},
|
593
|
+
|
594
|
+
setDaysOfWeekDisabled: function(daysOfWeekDisabled){
|
595
|
+
this._process_options({daysOfWeekDisabled: daysOfWeekDisabled});
|
596
|
+
this.update();
|
597
|
+
this.updateNavArrows();
|
598
|
+
return this;
|
599
|
+
},
|
600
|
+
|
601
|
+
setDatesDisabled: function(datesDisabled){
|
602
|
+
this._process_options({datesDisabled: datesDisabled});
|
603
|
+
this.update();
|
604
|
+
this.updateNavArrows();
|
605
|
+
},
|
606
|
+
|
607
|
+
place: function(){
|
608
|
+
if (this.isInline)
|
609
|
+
return this;
|
610
|
+
var calendarWidth = this.picker.outerWidth(),
|
611
|
+
calendarHeight = this.picker.outerHeight(),
|
612
|
+
visualPadding = 10,
|
613
|
+
windowWidth = $(this.o.container).width(),
|
614
|
+
windowHeight = $(this.o.container).height(),
|
615
|
+
scrollTop = $(this.o.container).scrollTop(),
|
616
|
+
appendOffset = $(this.o.container).offset();
|
617
|
+
|
618
|
+
var parentsZindex = [];
|
619
|
+
this.element.parents().each(function(){
|
620
|
+
var itemZIndex = $(this).css('z-index');
|
621
|
+
if (itemZIndex !== 'auto' && itemZIndex !== 0) parentsZindex.push(parseInt(itemZIndex));
|
622
|
+
});
|
623
|
+
var zIndex = Math.max.apply(Math, parentsZindex) + 10;
|
624
|
+
var offset = this.component ? this.component.parent().offset() : this.element.offset();
|
625
|
+
var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
|
626
|
+
var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
|
627
|
+
var left = offset.left - appendOffset.left,
|
628
|
+
top = offset.top - appendOffset.top;
|
629
|
+
|
630
|
+
this.picker.removeClass(
|
631
|
+
'datepicker-orient-top datepicker-orient-bottom '+
|
632
|
+
'datepicker-orient-right datepicker-orient-left'
|
633
|
+
);
|
634
|
+
|
635
|
+
if (this.o.orientation.x !== 'auto'){
|
636
|
+
this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
|
637
|
+
if (this.o.orientation.x === 'right')
|
638
|
+
left -= calendarWidth - width;
|
639
|
+
}
|
640
|
+
// auto x orientation is best-placement: if it crosses a window
|
641
|
+
// edge, fudge it sideways
|
642
|
+
else {
|
643
|
+
if (offset.left < 0) {
|
644
|
+
// component is outside the window on the left side. Move it into visible range
|
645
|
+
this.picker.addClass('datepicker-orient-left');
|
646
|
+
left -= offset.left - visualPadding;
|
647
|
+
} else if (left + calendarWidth > windowWidth) {
|
648
|
+
// the calendar passes the widow right edge. Align it to component right side
|
649
|
+
this.picker.addClass('datepicker-orient-right');
|
650
|
+
left = offset.left + width - calendarWidth;
|
651
|
+
} else {
|
652
|
+
// Default to left
|
653
|
+
this.picker.addClass('datepicker-orient-left');
|
654
|
+
}
|
655
|
+
}
|
656
|
+
|
657
|
+
// auto y orientation is best-situation: top or bottom, no fudging,
|
658
|
+
// decision based on which shows more of the calendar
|
659
|
+
var yorient = this.o.orientation.y,
|
660
|
+
top_overflow, bottom_overflow;
|
661
|
+
if (yorient === 'auto'){
|
662
|
+
top_overflow = -scrollTop + top - calendarHeight - 100; // (-100) to prefer the downward orientation.
|
663
|
+
bottom_overflow = scrollTop + windowHeight - (top + height + calendarHeight);
|
664
|
+
if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
|
665
|
+
yorient = 'top';
|
666
|
+
else
|
667
|
+
yorient = 'bottom';
|
668
|
+
}
|
669
|
+
this.picker.addClass('datepicker-orient-' + yorient);
|
670
|
+
if (yorient === 'top')
|
671
|
+
top += height;
|
672
|
+
else
|
673
|
+
top -= calendarHeight + parseInt(this.picker.css('padding-top'));
|
674
|
+
|
675
|
+
if (this.o.rtl) {
|
676
|
+
var right = windowWidth - (left + width);
|
677
|
+
this.picker.css({
|
678
|
+
top: top,
|
679
|
+
right: right,
|
680
|
+
zIndex: zIndex
|
681
|
+
});
|
682
|
+
} else {
|
683
|
+
this.picker.css({
|
684
|
+
top: top,
|
685
|
+
left: left,
|
686
|
+
zIndex: zIndex
|
687
|
+
});
|
688
|
+
}
|
689
|
+
return this;
|
690
|
+
},
|
691
|
+
|
692
|
+
_allow_update: true,
|
693
|
+
update: function(){
|
694
|
+
if (!this._allow_update)
|
695
|
+
return this;
|
696
|
+
|
697
|
+
var oldDates = this.dates.copy(),
|
698
|
+
dates = [],
|
699
|
+
fromArgs = false;
|
700
|
+
if (arguments.length){
|
701
|
+
$.each(arguments, $.proxy(function(i, date){
|
702
|
+
if (date instanceof Date)
|
703
|
+
date = this._local_to_utc(date);
|
704
|
+
dates.push(date);
|
705
|
+
}, this));
|
706
|
+
fromArgs = true;
|
707
|
+
}
|
708
|
+
else {
|
709
|
+
dates = this.isInput
|
710
|
+
? this.element.val()
|
711
|
+
: this.element.data('date') || this.element.find('input').val();
|
712
|
+
if (dates && this.o.multidate)
|
713
|
+
dates = dates.split(this.o.multidateSeparator);
|
714
|
+
else
|
715
|
+
dates = [dates];
|
716
|
+
delete this.element.data().date;
|
717
|
+
}
|
718
|
+
|
719
|
+
dates = $.map(dates, $.proxy(function(date){
|
720
|
+
return DPGlobal.parseDate(date, this.o.format, this.o.language);
|
721
|
+
}, this));
|
722
|
+
dates = $.grep(dates, $.proxy(function(date){
|
723
|
+
return (
|
724
|
+
date < this.o.startDate ||
|
725
|
+
date > this.o.endDate ||
|
726
|
+
!date
|
727
|
+
);
|
728
|
+
}, this), true);
|
729
|
+
this.dates.replace(dates);
|
730
|
+
|
731
|
+
if (this.dates.length)
|
732
|
+
this.viewDate = new Date(this.dates.get(-1));
|
733
|
+
else if (this.viewDate < this.o.startDate)
|
734
|
+
this.viewDate = new Date(this.o.startDate);
|
735
|
+
else if (this.viewDate > this.o.endDate)
|
736
|
+
this.viewDate = new Date(this.o.endDate);
|
737
|
+
|
738
|
+
if (fromArgs){
|
739
|
+
// setting date by clicking
|
740
|
+
this.setValue();
|
741
|
+
}
|
742
|
+
else if (dates.length){
|
743
|
+
// setting date by typing
|
744
|
+
if (String(oldDates) !== String(this.dates))
|
745
|
+
this._trigger('changeDate');
|
746
|
+
}
|
747
|
+
if (!this.dates.length && oldDates.length)
|
748
|
+
this._trigger('clearDate');
|
749
|
+
|
750
|
+
this.fill();
|
751
|
+
return this;
|
752
|
+
},
|
753
|
+
|
754
|
+
fillDow: function(){
|
755
|
+
var dowCnt = this.o.weekStart,
|
756
|
+
html = '<tr>';
|
757
|
+
if (this.o.calendarWeeks){
|
758
|
+
this.picker.find('.datepicker-days thead tr:first-child .datepicker-switch')
|
759
|
+
.attr('colspan', function(i, val){
|
760
|
+
return parseInt(val) + 1;
|
761
|
+
});
|
762
|
+
var cell = '<th class="cw"> </th>';
|
763
|
+
html += cell;
|
764
|
+
}
|
765
|
+
while (dowCnt < this.o.weekStart + 7){
|
766
|
+
html += '<th class="dow">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
|
767
|
+
}
|
768
|
+
html += '</tr>';
|
769
|
+
this.picker.find('.datepicker-days thead').append(html);
|
770
|
+
},
|
771
|
+
|
772
|
+
fillMonths: function(){
|
773
|
+
var html = '',
|
774
|
+
i = 0;
|
775
|
+
while (i < 12){
|
776
|
+
html += '<span class="month">'+dates[this.o.language].monthsShort[i++]+'</span>';
|
777
|
+
}
|
778
|
+
this.picker.find('.datepicker-months td').html(html);
|
779
|
+
},
|
780
|
+
|
781
|
+
setRange: function(range){
|
782
|
+
if (!range || !range.length)
|
783
|
+
delete this.range;
|
784
|
+
else
|
785
|
+
this.range = $.map(range, function(d){
|
786
|
+
return d.valueOf();
|
787
|
+
});
|
788
|
+
this.fill();
|
789
|
+
},
|
790
|
+
|
791
|
+
getClassNames: function(date){
|
792
|
+
var cls = [],
|
793
|
+
year = this.viewDate.getUTCFullYear(),
|
794
|
+
month = this.viewDate.getUTCMonth(),
|
795
|
+
today = new Date();
|
796
|
+
if (date.getUTCFullYear() < year || (date.getUTCFullYear() === year && date.getUTCMonth() < month)){
|
797
|
+
cls.push('old');
|
798
|
+
}
|
799
|
+
else if (date.getUTCFullYear() > year || (date.getUTCFullYear() === year && date.getUTCMonth() > month)){
|
800
|
+
cls.push('new');
|
801
|
+
}
|
802
|
+
if (this.focusDate && date.valueOf() === this.focusDate.valueOf())
|
803
|
+
cls.push('focused');
|
804
|
+
// Compare internal UTC date with local today, not UTC today
|
805
|
+
if (this.o.todayHighlight &&
|
806
|
+
date.getUTCFullYear() === today.getFullYear() &&
|
807
|
+
date.getUTCMonth() === today.getMonth() &&
|
808
|
+
date.getUTCDate() === today.getDate()){
|
809
|
+
cls.push('today');
|
810
|
+
}
|
811
|
+
if (this.dates.contains(date) !== -1)
|
812
|
+
cls.push('active');
|
813
|
+
if (date.valueOf() < this.o.startDate || date.valueOf() > this.o.endDate ||
|
814
|
+
$.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1){
|
815
|
+
cls.push('disabled');
|
816
|
+
}
|
817
|
+
if (this.o.datesDisabled.length > 0 &&
|
818
|
+
$.grep(this.o.datesDisabled, function(d){
|
819
|
+
return isUTCEquals(date, d); }).length > 0) {
|
820
|
+
cls.push('disabled', 'disabled-date');
|
821
|
+
}
|
822
|
+
|
823
|
+
if (this.range){
|
824
|
+
if (date > this.range[0] && date < this.range[this.range.length-1]){
|
825
|
+
cls.push('range');
|
826
|
+
}
|
827
|
+
if ($.inArray(date.valueOf(), this.range) !== -1){
|
828
|
+
cls.push('selected');
|
829
|
+
}
|
830
|
+
}
|
831
|
+
return cls;
|
832
|
+
},
|
833
|
+
|
834
|
+
fill: function(){
|
835
|
+
var d = new Date(this.viewDate),
|
836
|
+
year = d.getUTCFullYear(),
|
837
|
+
month = d.getUTCMonth(),
|
838
|
+
startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
|
839
|
+
startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
|
840
|
+
endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
|
841
|
+
endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
|
842
|
+
todaytxt = dates[this.o.language].today || dates['en'].today || '',
|
843
|
+
cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
|
844
|
+
tooltip;
|
845
|
+
if (isNaN(year) || isNaN(month))
|
846
|
+
return;
|
847
|
+
this.picker.find('.datepicker-days thead .datepicker-switch')
|
848
|
+
.text(dates[this.o.language].months[month]+' '+year);
|
849
|
+
this.picker.find('tfoot .today')
|
850
|
+
.text(todaytxt)
|
851
|
+
.toggle(this.o.todayBtn !== false);
|
852
|
+
this.picker.find('tfoot .clear')
|
853
|
+
.text(cleartxt)
|
854
|
+
.toggle(this.o.clearBtn !== false);
|
855
|
+
this.updateNavArrows();
|
856
|
+
this.fillMonths();
|
857
|
+
var prevMonth = UTCDate(year, month-1, 28),
|
858
|
+
day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
|
859
|
+
prevMonth.setUTCDate(day);
|
860
|
+
prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
|
861
|
+
var nextMonth = new Date(prevMonth);
|
862
|
+
nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
|
863
|
+
nextMonth = nextMonth.valueOf();
|
864
|
+
var html = [];
|
865
|
+
var clsName;
|
866
|
+
while (prevMonth.valueOf() < nextMonth){
|
867
|
+
if (prevMonth.getUTCDay() === this.o.weekStart){
|
868
|
+
html.push('<tr>');
|
869
|
+
if (this.o.calendarWeeks){
|
870
|
+
// ISO 8601: First week contains first thursday.
|
871
|
+
// ISO also states week starts on Monday, but we can be more abstract here.
|
872
|
+
var
|
873
|
+
// Start of current week: based on weekstart/current date
|
874
|
+
ws = new Date(+prevMonth + (this.o.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
|
875
|
+
// Thursday of this week
|
876
|
+
th = new Date(Number(ws) + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
|
877
|
+
// First Thursday of year, year from thursday
|
878
|
+
yth = new Date(Number(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
|
879
|
+
// Calendar week: ms between thursdays, div ms per day, div 7 days
|
880
|
+
calWeek = (th - yth) / 864e5 / 7 + 1;
|
881
|
+
html.push('<td class="cw">'+ calWeek +'</td>');
|
882
|
+
|
883
|
+
}
|
884
|
+
}
|
885
|
+
clsName = this.getClassNames(prevMonth);
|
886
|
+
clsName.push('day');
|
887
|
+
|
888
|
+
if (this.o.beforeShowDay !== $.noop){
|
889
|
+
var before = this.o.beforeShowDay(this._utc_to_local(prevMonth));
|
890
|
+
if (before === undefined)
|
891
|
+
before = {};
|
892
|
+
else if (typeof(before) === 'boolean')
|
893
|
+
before = {enabled: before};
|
894
|
+
else if (typeof(before) === 'string')
|
895
|
+
before = {classes: before};
|
896
|
+
if (before.enabled === false)
|
897
|
+
clsName.push('disabled');
|
898
|
+
if (before.classes)
|
899
|
+
clsName = clsName.concat(before.classes.split(/\s+/));
|
900
|
+
if (before.tooltip)
|
901
|
+
tooltip = before.tooltip;
|
902
|
+
}
|
903
|
+
|
904
|
+
clsName = $.unique(clsName);
|
905
|
+
html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + '>'+prevMonth.getUTCDate() + '</td>');
|
906
|
+
tooltip = null;
|
907
|
+
if (prevMonth.getUTCDay() === this.o.weekEnd){
|
908
|
+
html.push('</tr>');
|
909
|
+
}
|
910
|
+
prevMonth.setUTCDate(prevMonth.getUTCDate()+1);
|
911
|
+
}
|
912
|
+
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
913
|
+
|
914
|
+
var months = this.picker.find('.datepicker-months')
|
915
|
+
.find('th:eq(1)')
|
916
|
+
.text(year)
|
917
|
+
.end()
|
918
|
+
.find('span').removeClass('active');
|
919
|
+
|
920
|
+
$.each(this.dates, function(i, d){
|
921
|
+
if (d.getUTCFullYear() === year)
|
922
|
+
months.eq(d.getUTCMonth()).addClass('active');
|
923
|
+
});
|
924
|
+
|
925
|
+
if (year < startYear || year > endYear){
|
926
|
+
months.addClass('disabled');
|
927
|
+
}
|
928
|
+
if (year === startYear){
|
929
|
+
months.slice(0, startMonth).addClass('disabled');
|
930
|
+
}
|
931
|
+
if (year === endYear){
|
932
|
+
months.slice(endMonth+1).addClass('disabled');
|
933
|
+
}
|
934
|
+
|
935
|
+
if (this.o.beforeShowMonth !== $.noop){
|
936
|
+
var that = this;
|
937
|
+
$.each(months, function(i, month){
|
938
|
+
if (!$(month).hasClass('disabled')) {
|
939
|
+
var moDate = new Date(year, i, 1);
|
940
|
+
var before = that.o.beforeShowMonth(moDate);
|
941
|
+
if (before === false)
|
942
|
+
$(month).addClass('disabled');
|
943
|
+
}
|
944
|
+
});
|
945
|
+
}
|
946
|
+
|
947
|
+
html = '';
|
948
|
+
year = parseInt(year/10, 10) * 10;
|
949
|
+
var yearCont = this.picker.find('.datepicker-years')
|
950
|
+
.find('th:eq(1)')
|
951
|
+
.text(year + '-' + (year + 9))
|
952
|
+
.end()
|
953
|
+
.find('td');
|
954
|
+
year -= 1;
|
955
|
+
var years = $.map(this.dates, function(d){
|
956
|
+
return d.getUTCFullYear();
|
957
|
+
}),
|
958
|
+
classes;
|
959
|
+
for (var i = -1; i < 11; i++){
|
960
|
+
classes = ['year'];
|
961
|
+
if (i === -1)
|
962
|
+
classes.push('old');
|
963
|
+
else if (i === 10)
|
964
|
+
classes.push('new');
|
965
|
+
if ($.inArray(year, years) !== -1)
|
966
|
+
classes.push('active');
|
967
|
+
if (year < startYear || year > endYear)
|
968
|
+
classes.push('disabled');
|
969
|
+
html += '<span class="' + classes.join(' ') + '">' + year + '</span>';
|
970
|
+
year += 1;
|
971
|
+
}
|
972
|
+
yearCont.html(html);
|
973
|
+
},
|
974
|
+
|
975
|
+
updateNavArrows: function(){
|
976
|
+
if (!this._allow_update)
|
977
|
+
return;
|
978
|
+
|
979
|
+
var d = new Date(this.viewDate),
|
980
|
+
year = d.getUTCFullYear(),
|
981
|
+
month = d.getUTCMonth();
|
982
|
+
switch (this.viewMode){
|
983
|
+
case 0:
|
984
|
+
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() && month <= this.o.startDate.getUTCMonth()){
|
985
|
+
this.picker.find('.prev').css({visibility: 'hidden'});
|
986
|
+
}
|
987
|
+
else {
|
988
|
+
this.picker.find('.prev').css({visibility: 'visible'});
|
989
|
+
}
|
990
|
+
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() && month >= this.o.endDate.getUTCMonth()){
|
991
|
+
this.picker.find('.next').css({visibility: 'hidden'});
|
992
|
+
}
|
993
|
+
else {
|
994
|
+
this.picker.find('.next').css({visibility: 'visible'});
|
995
|
+
}
|
996
|
+
break;
|
997
|
+
case 1:
|
998
|
+
case 2:
|
999
|
+
if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()){
|
1000
|
+
this.picker.find('.prev').css({visibility: 'hidden'});
|
1001
|
+
}
|
1002
|
+
else {
|
1003
|
+
this.picker.find('.prev').css({visibility: 'visible'});
|
1004
|
+
}
|
1005
|
+
if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear()){
|
1006
|
+
this.picker.find('.next').css({visibility: 'hidden'});
|
1007
|
+
}
|
1008
|
+
else {
|
1009
|
+
this.picker.find('.next').css({visibility: 'visible'});
|
1010
|
+
}
|
1011
|
+
break;
|
1012
|
+
}
|
1013
|
+
},
|
1014
|
+
|
1015
|
+
click: function(e){
|
1016
|
+
e.preventDefault();
|
1017
|
+
var target = $(e.target).closest('span, td, th'),
|
1018
|
+
year, month, day;
|
1019
|
+
if (target.length === 1){
|
1020
|
+
switch (target[0].nodeName.toLowerCase()){
|
1021
|
+
case 'th':
|
1022
|
+
switch (target[0].className){
|
1023
|
+
case 'datepicker-switch':
|
1024
|
+
this.showMode(1);
|
1025
|
+
break;
|
1026
|
+
case 'prev':
|
1027
|
+
case 'next':
|
1028
|
+
var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1);
|
1029
|
+
switch (this.viewMode){
|
1030
|
+
case 0:
|
1031
|
+
this.viewDate = this.moveMonth(this.viewDate, dir);
|
1032
|
+
this._trigger('changeMonth', this.viewDate);
|
1033
|
+
break;
|
1034
|
+
case 1:
|
1035
|
+
case 2:
|
1036
|
+
this.viewDate = this.moveYear(this.viewDate, dir);
|
1037
|
+
if (this.viewMode === 1)
|
1038
|
+
this._trigger('changeYear', this.viewDate);
|
1039
|
+
break;
|
1040
|
+
}
|
1041
|
+
this.fill();
|
1042
|
+
break;
|
1043
|
+
case 'today':
|
1044
|
+
var date = new Date();
|
1045
|
+
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
1046
|
+
|
1047
|
+
this.showMode(-2);
|
1048
|
+
var which = this.o.todayBtn === 'linked' ? null : 'view';
|
1049
|
+
this._setDate(date, which);
|
1050
|
+
break;
|
1051
|
+
case 'clear':
|
1052
|
+
this.clearDates();
|
1053
|
+
break;
|
1054
|
+
}
|
1055
|
+
break;
|
1056
|
+
case 'span':
|
1057
|
+
if (!target.hasClass('disabled')){
|
1058
|
+
this.viewDate.setUTCDate(1);
|
1059
|
+
if (target.hasClass('month')){
|
1060
|
+
day = 1;
|
1061
|
+
month = target.parent().find('span').index(target);
|
1062
|
+
year = this.viewDate.getUTCFullYear();
|
1063
|
+
this.viewDate.setUTCMonth(month);
|
1064
|
+
this._trigger('changeMonth', this.viewDate);
|
1065
|
+
if (this.o.minViewMode === 1){
|
1066
|
+
this._setDate(UTCDate(year, month, day));
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
else {
|
1070
|
+
day = 1;
|
1071
|
+
month = 0;
|
1072
|
+
year = parseInt(target.text(), 10)||0;
|
1073
|
+
this.viewDate.setUTCFullYear(year);
|
1074
|
+
this._trigger('changeYear', this.viewDate);
|
1075
|
+
if (this.o.minViewMode === 2){
|
1076
|
+
this._setDate(UTCDate(year, month, day));
|
1077
|
+
}
|
1078
|
+
}
|
1079
|
+
this.showMode(-1);
|
1080
|
+
this.fill();
|
1081
|
+
}
|
1082
|
+
break;
|
1083
|
+
case 'td':
|
1084
|
+
if (target.hasClass('day') && !target.hasClass('disabled')){
|
1085
|
+
day = parseInt(target.text(), 10)||1;
|
1086
|
+
year = this.viewDate.getUTCFullYear();
|
1087
|
+
month = this.viewDate.getUTCMonth();
|
1088
|
+
if (target.hasClass('old')){
|
1089
|
+
if (month === 0){
|
1090
|
+
month = 11;
|
1091
|
+
year -= 1;
|
1092
|
+
}
|
1093
|
+
else {
|
1094
|
+
month -= 1;
|
1095
|
+
}
|
1096
|
+
}
|
1097
|
+
else if (target.hasClass('new')){
|
1098
|
+
if (month === 11){
|
1099
|
+
month = 0;
|
1100
|
+
year += 1;
|
1101
|
+
}
|
1102
|
+
else {
|
1103
|
+
month += 1;
|
1104
|
+
}
|
1105
|
+
}
|
1106
|
+
this._setDate(UTCDate(year, month, day));
|
1107
|
+
}
|
1108
|
+
break;
|
1109
|
+
}
|
1110
|
+
}
|
1111
|
+
if (this.picker.is(':visible') && this._focused_from){
|
1112
|
+
$(this._focused_from).focus();
|
1113
|
+
}
|
1114
|
+
delete this._focused_from;
|
1115
|
+
},
|
1116
|
+
|
1117
|
+
_toggle_multidate: function(date){
|
1118
|
+
var ix = this.dates.contains(date);
|
1119
|
+
if (!date){
|
1120
|
+
this.dates.clear();
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
if (ix !== -1){
|
1124
|
+
if (this.o.multidate === true || this.o.multidate > 1 || this.o.toggleActive){
|
1125
|
+
this.dates.remove(ix);
|
1126
|
+
}
|
1127
|
+
} else if (this.o.multidate === false) {
|
1128
|
+
this.dates.clear();
|
1129
|
+
this.dates.push(date);
|
1130
|
+
}
|
1131
|
+
else {
|
1132
|
+
this.dates.push(date);
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
if (typeof this.o.multidate === 'number')
|
1136
|
+
while (this.dates.length > this.o.multidate)
|
1137
|
+
this.dates.remove(0);
|
1138
|
+
},
|
1139
|
+
|
1140
|
+
_setDate: function(date, which){
|
1141
|
+
if (!which || which === 'date')
|
1142
|
+
this._toggle_multidate(date && new Date(date));
|
1143
|
+
if (!which || which === 'view')
|
1144
|
+
this.viewDate = date && new Date(date);
|
1145
|
+
|
1146
|
+
this.fill();
|
1147
|
+
this.setValue();
|
1148
|
+
if (!which || which !== 'view') {
|
1149
|
+
this._trigger('changeDate');
|
1150
|
+
}
|
1151
|
+
var element;
|
1152
|
+
if (this.isInput){
|
1153
|
+
element = this.element;
|
1154
|
+
}
|
1155
|
+
else if (this.component){
|
1156
|
+
element = this.element.find('input');
|
1157
|
+
}
|
1158
|
+
if (element){
|
1159
|
+
element.change();
|
1160
|
+
}
|
1161
|
+
if (this.o.autoclose && (!which || which === 'date')){
|
1162
|
+
this.hide();
|
1163
|
+
}
|
1164
|
+
},
|
1165
|
+
|
1166
|
+
moveMonth: function(date, dir){
|
1167
|
+
if (!date)
|
1168
|
+
return undefined;
|
1169
|
+
if (!dir)
|
1170
|
+
return date;
|
1171
|
+
var new_date = new Date(date.valueOf()),
|
1172
|
+
day = new_date.getUTCDate(),
|
1173
|
+
month = new_date.getUTCMonth(),
|
1174
|
+
mag = Math.abs(dir),
|
1175
|
+
new_month, test;
|
1176
|
+
dir = dir > 0 ? 1 : -1;
|
1177
|
+
if (mag === 1){
|
1178
|
+
test = dir === -1
|
1179
|
+
// If going back one month, make sure month is not current month
|
1180
|
+
// (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
|
1181
|
+
? function(){
|
1182
|
+
return new_date.getUTCMonth() === month;
|
1183
|
+
}
|
1184
|
+
// If going forward one month, make sure month is as expected
|
1185
|
+
// (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
|
1186
|
+
: function(){
|
1187
|
+
return new_date.getUTCMonth() !== new_month;
|
1188
|
+
};
|
1189
|
+
new_month = month + dir;
|
1190
|
+
new_date.setUTCMonth(new_month);
|
1191
|
+
// Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
|
1192
|
+
if (new_month < 0 || new_month > 11)
|
1193
|
+
new_month = (new_month + 12) % 12;
|
1194
|
+
}
|
1195
|
+
else {
|
1196
|
+
// For magnitudes >1, move one month at a time...
|
1197
|
+
for (var i=0; i < mag; i++)
|
1198
|
+
// ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
|
1199
|
+
new_date = this.moveMonth(new_date, dir);
|
1200
|
+
// ...then reset the day, keeping it in the new month
|
1201
|
+
new_month = new_date.getUTCMonth();
|
1202
|
+
new_date.setUTCDate(day);
|
1203
|
+
test = function(){
|
1204
|
+
return new_month !== new_date.getUTCMonth();
|
1205
|
+
};
|
1206
|
+
}
|
1207
|
+
// Common date-resetting loop -- if date is beyond end of month, make it
|
1208
|
+
// end of month
|
1209
|
+
while (test()){
|
1210
|
+
new_date.setUTCDate(--day);
|
1211
|
+
new_date.setUTCMonth(new_month);
|
1212
|
+
}
|
1213
|
+
return new_date;
|
1214
|
+
},
|
1215
|
+
|
1216
|
+
moveYear: function(date, dir){
|
1217
|
+
return this.moveMonth(date, dir*12);
|
1218
|
+
},
|
1219
|
+
|
1220
|
+
dateWithinRange: function(date){
|
1221
|
+
return date >= this.o.startDate && date <= this.o.endDate;
|
1222
|
+
},
|
1223
|
+
|
1224
|
+
keydown: function(e){
|
1225
|
+
if (!this.picker.is(':visible')){
|
1226
|
+
if (e.keyCode === 40 || e.keyCode === 27) // allow down to re-show picker
|
1227
|
+
this.show();
|
1228
|
+
return;
|
1229
|
+
}
|
1230
|
+
var dateChanged = false,
|
1231
|
+
dir, newDate, newViewDate,
|
1232
|
+
focusDate = this.focusDate || this.viewDate;
|
1233
|
+
switch (e.keyCode){
|
1234
|
+
case 27: // escape
|
1235
|
+
if (this.focusDate){
|
1236
|
+
this.focusDate = null;
|
1237
|
+
this.viewDate = this.dates.get(-1) || this.viewDate;
|
1238
|
+
this.fill();
|
1239
|
+
}
|
1240
|
+
else
|
1241
|
+
this.hide();
|
1242
|
+
e.preventDefault();
|
1243
|
+
break;
|
1244
|
+
case 37: // left
|
1245
|
+
case 39: // right
|
1246
|
+
if (!this.o.keyboardNavigation)
|
1247
|
+
break;
|
1248
|
+
dir = e.keyCode === 37 ? -1 : 1;
|
1249
|
+
if (e.ctrlKey){
|
1250
|
+
newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
|
1251
|
+
newViewDate = this.moveYear(focusDate, dir);
|
1252
|
+
this._trigger('changeYear', this.viewDate);
|
1253
|
+
}
|
1254
|
+
else if (e.shiftKey){
|
1255
|
+
newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
|
1256
|
+
newViewDate = this.moveMonth(focusDate, dir);
|
1257
|
+
this._trigger('changeMonth', this.viewDate);
|
1258
|
+
}
|
1259
|
+
else {
|
1260
|
+
newDate = new Date(this.dates.get(-1) || UTCToday());
|
1261
|
+
newDate.setUTCDate(newDate.getUTCDate() + dir);
|
1262
|
+
newViewDate = new Date(focusDate);
|
1263
|
+
newViewDate.setUTCDate(focusDate.getUTCDate() + dir);
|
1264
|
+
}
|
1265
|
+
if (this.dateWithinRange(newViewDate)){
|
1266
|
+
this.focusDate = this.viewDate = newViewDate;
|
1267
|
+
this.setValue();
|
1268
|
+
this.fill();
|
1269
|
+
e.preventDefault();
|
1270
|
+
}
|
1271
|
+
break;
|
1272
|
+
case 38: // up
|
1273
|
+
case 40: // down
|
1274
|
+
if (!this.o.keyboardNavigation)
|
1275
|
+
break;
|
1276
|
+
dir = e.keyCode === 38 ? -1 : 1;
|
1277
|
+
if (e.ctrlKey){
|
1278
|
+
newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
|
1279
|
+
newViewDate = this.moveYear(focusDate, dir);
|
1280
|
+
this._trigger('changeYear', this.viewDate);
|
1281
|
+
}
|
1282
|
+
else if (e.shiftKey){
|
1283
|
+
newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
|
1284
|
+
newViewDate = this.moveMonth(focusDate, dir);
|
1285
|
+
this._trigger('changeMonth', this.viewDate);
|
1286
|
+
}
|
1287
|
+
else {
|
1288
|
+
newDate = new Date(this.dates.get(-1) || UTCToday());
|
1289
|
+
newDate.setUTCDate(newDate.getUTCDate() + dir * 7);
|
1290
|
+
newViewDate = new Date(focusDate);
|
1291
|
+
newViewDate.setUTCDate(focusDate.getUTCDate() + dir * 7);
|
1292
|
+
}
|
1293
|
+
if (this.dateWithinRange(newViewDate)){
|
1294
|
+
this.focusDate = this.viewDate = newViewDate;
|
1295
|
+
this.setValue();
|
1296
|
+
this.fill();
|
1297
|
+
e.preventDefault();
|
1298
|
+
}
|
1299
|
+
break;
|
1300
|
+
case 32: // spacebar
|
1301
|
+
// Spacebar is used in manually typing dates in some formats.
|
1302
|
+
// As such, its behavior should not be hijacked.
|
1303
|
+
break;
|
1304
|
+
case 13: // enter
|
1305
|
+
focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
|
1306
|
+
if (this.o.keyboardNavigation) {
|
1307
|
+
this._toggle_multidate(focusDate);
|
1308
|
+
dateChanged = true;
|
1309
|
+
}
|
1310
|
+
this.focusDate = null;
|
1311
|
+
this.viewDate = this.dates.get(-1) || this.viewDate;
|
1312
|
+
this.setValue();
|
1313
|
+
this.fill();
|
1314
|
+
if (this.picker.is(':visible')){
|
1315
|
+
e.preventDefault();
|
1316
|
+
if (typeof e.stopPropagation === 'function') {
|
1317
|
+
e.stopPropagation(); // All modern browsers, IE9+
|
1318
|
+
} else {
|
1319
|
+
e.cancelBubble = true; // IE6,7,8 ignore "stopPropagation"
|
1320
|
+
}
|
1321
|
+
if (this.o.autoclose)
|
1322
|
+
this.hide();
|
1323
|
+
}
|
1324
|
+
break;
|
1325
|
+
case 9: // tab
|
1326
|
+
this.focusDate = null;
|
1327
|
+
this.viewDate = this.dates.get(-1) || this.viewDate;
|
1328
|
+
this.fill();
|
1329
|
+
this.hide();
|
1330
|
+
break;
|
1331
|
+
}
|
1332
|
+
if (dateChanged){
|
1333
|
+
if (this.dates.length)
|
1334
|
+
this._trigger('changeDate');
|
1335
|
+
else
|
1336
|
+
this._trigger('clearDate');
|
1337
|
+
var element;
|
1338
|
+
if (this.isInput){
|
1339
|
+
element = this.element;
|
1340
|
+
}
|
1341
|
+
else if (this.component){
|
1342
|
+
element = this.element.find('input');
|
1343
|
+
}
|
1344
|
+
if (element){
|
1345
|
+
element.change();
|
1346
|
+
}
|
1347
|
+
}
|
1348
|
+
},
|
1349
|
+
|
1350
|
+
showMode: function(dir){
|
1351
|
+
if (dir){
|
1352
|
+
this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
|
1353
|
+
}
|
1354
|
+
this.picker
|
1355
|
+
.children('div')
|
1356
|
+
.hide()
|
1357
|
+
.filter('.datepicker-' + DPGlobal.modes[this.viewMode].clsName)
|
1358
|
+
.css('display', 'block');
|
1359
|
+
this.updateNavArrows();
|
1360
|
+
}
|
1361
|
+
};
|
1362
|
+
|
1363
|
+
var DateRangePicker = function(element, options){
|
1364
|
+
this.element = $(element);
|
1365
|
+
this.inputs = $.map(options.inputs, function(i){
|
1366
|
+
return i.jquery ? i[0] : i;
|
1367
|
+
});
|
1368
|
+
delete options.inputs;
|
1369
|
+
|
1370
|
+
datepickerPlugin.call($(this.inputs), options)
|
1371
|
+
.on('changeDate', $.proxy(this.dateUpdated, this));
|
1372
|
+
|
1373
|
+
this.pickers = $.map(this.inputs, function(i){
|
1374
|
+
return $(i).data('datepicker');
|
1375
|
+
});
|
1376
|
+
this.updateDates();
|
1377
|
+
};
|
1378
|
+
DateRangePicker.prototype = {
|
1379
|
+
updateDates: function(){
|
1380
|
+
this.dates = $.map(this.pickers, function(i){
|
1381
|
+
return i.getUTCDate();
|
1382
|
+
});
|
1383
|
+
this.updateRanges();
|
1384
|
+
},
|
1385
|
+
updateRanges: function(){
|
1386
|
+
var range = $.map(this.dates, function(d){
|
1387
|
+
return d.valueOf();
|
1388
|
+
});
|
1389
|
+
$.each(this.pickers, function(i, p){
|
1390
|
+
p.setRange(range);
|
1391
|
+
});
|
1392
|
+
},
|
1393
|
+
dateUpdated: function(e){
|
1394
|
+
// `this.updating` is a workaround for preventing infinite recursion
|
1395
|
+
// between `changeDate` triggering and `setUTCDate` calling. Until
|
1396
|
+
// there is a better mechanism.
|
1397
|
+
if (this.updating)
|
1398
|
+
return;
|
1399
|
+
this.updating = true;
|
1400
|
+
|
1401
|
+
var dp = $(e.target).data('datepicker'),
|
1402
|
+
new_date = dp.getUTCDate(),
|
1403
|
+
i = $.inArray(e.target, this.inputs),
|
1404
|
+
j = i - 1,
|
1405
|
+
k = i + 1,
|
1406
|
+
l = this.inputs.length;
|
1407
|
+
if (i === -1)
|
1408
|
+
return;
|
1409
|
+
|
1410
|
+
$.each(this.pickers, function(i, p){
|
1411
|
+
if (!p.getUTCDate())
|
1412
|
+
p.setUTCDate(new_date);
|
1413
|
+
});
|
1414
|
+
|
1415
|
+
if (new_date < this.dates[j]){
|
1416
|
+
// Date being moved earlier/left
|
1417
|
+
while (j >= 0 && new_date < this.dates[j]){
|
1418
|
+
this.pickers[j--].setUTCDate(new_date);
|
1419
|
+
}
|
1420
|
+
}
|
1421
|
+
else if (new_date > this.dates[k]){
|
1422
|
+
// Date being moved later/right
|
1423
|
+
while (k < l && new_date > this.dates[k]){
|
1424
|
+
this.pickers[k++].setUTCDate(new_date);
|
1425
|
+
}
|
1426
|
+
}
|
1427
|
+
this.updateDates();
|
1428
|
+
|
1429
|
+
delete this.updating;
|
1430
|
+
},
|
1431
|
+
remove: function(){
|
1432
|
+
$.map(this.pickers, function(p){ p.remove(); });
|
1433
|
+
delete this.element.data().datepicker;
|
1434
|
+
}
|
1435
|
+
};
|
1436
|
+
|
1437
|
+
function opts_from_el(el, prefix){
|
1438
|
+
// Derive options from element data-attrs
|
1439
|
+
var data = $(el).data(),
|
1440
|
+
out = {}, inkey,
|
1441
|
+
replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])');
|
1442
|
+
prefix = new RegExp('^' + prefix.toLowerCase());
|
1443
|
+
function re_lower(_,a){
|
1444
|
+
return a.toLowerCase();
|
1445
|
+
}
|
1446
|
+
for (var key in data)
|
1447
|
+
if (prefix.test(key)){
|
1448
|
+
inkey = key.replace(replace, re_lower);
|
1449
|
+
out[inkey] = data[key];
|
1450
|
+
}
|
1451
|
+
return out;
|
1452
|
+
}
|
1453
|
+
|
1454
|
+
function opts_from_locale(lang){
|
1455
|
+
// Derive options from locale plugins
|
1456
|
+
var out = {};
|
1457
|
+
// Check if "de-DE" style date is available, if not language should
|
1458
|
+
// fallback to 2 letter code eg "de"
|
1459
|
+
if (!dates[lang]){
|
1460
|
+
lang = lang.split('-')[0];
|
1461
|
+
if (!dates[lang])
|
1462
|
+
return;
|
1463
|
+
}
|
1464
|
+
var d = dates[lang];
|
1465
|
+
$.each(locale_opts, function(i,k){
|
1466
|
+
if (k in d)
|
1467
|
+
out[k] = d[k];
|
1468
|
+
});
|
1469
|
+
return out;
|
1470
|
+
}
|
1471
|
+
|
1472
|
+
var old = $.fn.datepicker;
|
1473
|
+
var datepickerPlugin = function(option){
|
1474
|
+
var args = Array.apply(null, arguments);
|
1475
|
+
args.shift();
|
1476
|
+
var internal_return;
|
1477
|
+
this.each(function(){
|
1478
|
+
var $this = $(this),
|
1479
|
+
data = $this.data('datepicker'),
|
1480
|
+
options = typeof option === 'object' && option;
|
1481
|
+
if (!data){
|
1482
|
+
var elopts = opts_from_el(this, 'date'),
|
1483
|
+
// Preliminary otions
|
1484
|
+
xopts = $.extend({}, defaults, elopts, options),
|
1485
|
+
locopts = opts_from_locale(xopts.language),
|
1486
|
+
// Options priority: js args, data-attrs, locales, defaults
|
1487
|
+
opts = $.extend({}, defaults, locopts, elopts, options);
|
1488
|
+
if ($this.hasClass('input-daterange') || opts.inputs){
|
1489
|
+
var ropts = {
|
1490
|
+
inputs: opts.inputs || $this.find('input').toArray()
|
1491
|
+
};
|
1492
|
+
$this.data('datepicker', (data = new DateRangePicker(this, $.extend(opts, ropts))));
|
1493
|
+
}
|
1494
|
+
else {
|
1495
|
+
$this.data('datepicker', (data = new Datepicker(this, opts)));
|
1496
|
+
}
|
1497
|
+
}
|
1498
|
+
if (typeof option === 'string' && typeof data[option] === 'function'){
|
1499
|
+
internal_return = data[option].apply(data, args);
|
1500
|
+
if (internal_return !== undefined)
|
1501
|
+
return false;
|
1502
|
+
}
|
1503
|
+
});
|
1504
|
+
if (internal_return !== undefined)
|
1505
|
+
return internal_return;
|
1506
|
+
else
|
1507
|
+
return this;
|
1508
|
+
};
|
1509
|
+
$.fn.datepicker = datepickerPlugin;
|
1510
|
+
|
1511
|
+
var defaults = $.fn.datepicker.defaults = {
|
1512
|
+
autoclose: false,
|
1513
|
+
beforeShowDay: $.noop,
|
1514
|
+
beforeShowMonth: $.noop,
|
1515
|
+
calendarWeeks: false,
|
1516
|
+
clearBtn: false,
|
1517
|
+
toggleActive: false,
|
1518
|
+
daysOfWeekDisabled: [],
|
1519
|
+
datesDisabled: [],
|
1520
|
+
endDate: Infinity,
|
1521
|
+
forceParse: true,
|
1522
|
+
format: 'mm/dd/yyyy',
|
1523
|
+
keyboardNavigation: true,
|
1524
|
+
language: 'en',
|
1525
|
+
minViewMode: 0,
|
1526
|
+
multidate: false,
|
1527
|
+
multidateSeparator: ',',
|
1528
|
+
orientation: "auto",
|
1529
|
+
rtl: false,
|
1530
|
+
startDate: -Infinity,
|
1531
|
+
startView: 0,
|
1532
|
+
todayBtn: false,
|
1533
|
+
todayHighlight: false,
|
1534
|
+
weekStart: 0,
|
1535
|
+
disableTouchKeyboard: false,
|
1536
|
+
enableOnReadonly: true,
|
1537
|
+
container: 'body'
|
1538
|
+
};
|
1539
|
+
var locale_opts = $.fn.datepicker.locale_opts = [
|
1540
|
+
'format',
|
1541
|
+
'rtl',
|
1542
|
+
'weekStart'
|
1543
|
+
];
|
1544
|
+
$.fn.datepicker.Constructor = Datepicker;
|
1545
|
+
var dates = $.fn.datepicker.dates = {
|
1546
|
+
en: {
|
1547
|
+
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
1548
|
+
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
1549
|
+
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
1550
|
+
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
1551
|
+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
1552
|
+
today: "Today",
|
1553
|
+
clear: "Clear"
|
1554
|
+
}
|
1555
|
+
};
|
1556
|
+
|
1557
|
+
var DPGlobal = {
|
1558
|
+
modes: [
|
1559
|
+
{
|
1560
|
+
clsName: 'days',
|
1561
|
+
navFnc: 'Month',
|
1562
|
+
navStep: 1
|
1563
|
+
},
|
1564
|
+
{
|
1565
|
+
clsName: 'months',
|
1566
|
+
navFnc: 'FullYear',
|
1567
|
+
navStep: 1
|
1568
|
+
},
|
1569
|
+
{
|
1570
|
+
clsName: 'years',
|
1571
|
+
navFnc: 'FullYear',
|
1572
|
+
navStep: 10
|
1573
|
+
}],
|
1574
|
+
isLeapYear: function(year){
|
1575
|
+
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
|
1576
|
+
},
|
1577
|
+
getDaysInMonth: function(year, month){
|
1578
|
+
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
|
1579
|
+
},
|
1580
|
+
validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
|
1581
|
+
nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
|
1582
|
+
parseFormat: function(format){
|
1583
|
+
// IE treats \0 as a string end in inputs (truncating the value),
|
1584
|
+
// so it's a bad format delimiter, anyway
|
1585
|
+
var separators = format.replace(this.validParts, '\0').split('\0'),
|
1586
|
+
parts = format.match(this.validParts);
|
1587
|
+
if (!separators || !separators.length || !parts || parts.length === 0){
|
1588
|
+
throw new Error("Invalid date format.");
|
1589
|
+
}
|
1590
|
+
return {separators: separators, parts: parts};
|
1591
|
+
},
|
1592
|
+
parseDate: function(date, format, language){
|
1593
|
+
if (!date)
|
1594
|
+
return undefined;
|
1595
|
+
if (date instanceof Date)
|
1596
|
+
return date;
|
1597
|
+
if (typeof format === 'string')
|
1598
|
+
format = DPGlobal.parseFormat(format);
|
1599
|
+
var part_re = /([\-+]\d+)([dmwy])/,
|
1600
|
+
parts = date.match(/([\-+]\d+)([dmwy])/g),
|
1601
|
+
part, dir, i;
|
1602
|
+
if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)){
|
1603
|
+
date = new Date();
|
1604
|
+
for (i=0; i < parts.length; i++){
|
1605
|
+
part = part_re.exec(parts[i]);
|
1606
|
+
dir = parseInt(part[1]);
|
1607
|
+
switch (part[2]){
|
1608
|
+
case 'd':
|
1609
|
+
date.setUTCDate(date.getUTCDate() + dir);
|
1610
|
+
break;
|
1611
|
+
case 'm':
|
1612
|
+
date = Datepicker.prototype.moveMonth.call(Datepicker.prototype, date, dir);
|
1613
|
+
break;
|
1614
|
+
case 'w':
|
1615
|
+
date.setUTCDate(date.getUTCDate() + dir * 7);
|
1616
|
+
break;
|
1617
|
+
case 'y':
|
1618
|
+
date = Datepicker.prototype.moveYear.call(Datepicker.prototype, date, dir);
|
1619
|
+
break;
|
1620
|
+
}
|
1621
|
+
}
|
1622
|
+
return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
|
1623
|
+
}
|
1624
|
+
parts = date && date.match(this.nonpunctuation) || [];
|
1625
|
+
date = new Date();
|
1626
|
+
var parsed = {},
|
1627
|
+
setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
|
1628
|
+
setters_map = {
|
1629
|
+
yyyy: function(d,v){
|
1630
|
+
return d.setUTCFullYear(v);
|
1631
|
+
},
|
1632
|
+
yy: function(d,v){
|
1633
|
+
return d.setUTCFullYear(2000+v);
|
1634
|
+
},
|
1635
|
+
m: function(d,v){
|
1636
|
+
if (isNaN(d))
|
1637
|
+
return d;
|
1638
|
+
v -= 1;
|
1639
|
+
while (v < 0) v += 12;
|
1640
|
+
v %= 12;
|
1641
|
+
d.setUTCMonth(v);
|
1642
|
+
while (d.getUTCMonth() !== v)
|
1643
|
+
d.setUTCDate(d.getUTCDate()-1);
|
1644
|
+
return d;
|
1645
|
+
},
|
1646
|
+
d: function(d,v){
|
1647
|
+
return d.setUTCDate(v);
|
1648
|
+
}
|
1649
|
+
},
|
1650
|
+
val, filtered;
|
1651
|
+
setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
|
1652
|
+
setters_map['dd'] = setters_map['d'];
|
1653
|
+
date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
1654
|
+
var fparts = format.parts.slice();
|
1655
|
+
// Remove noop parts
|
1656
|
+
if (parts.length !== fparts.length){
|
1657
|
+
fparts = $(fparts).filter(function(i,p){
|
1658
|
+
return $.inArray(p, setters_order) !== -1;
|
1659
|
+
}).toArray();
|
1660
|
+
}
|
1661
|
+
// Process remainder
|
1662
|
+
function match_part(){
|
1663
|
+
var m = this.slice(0, parts[i].length),
|
1664
|
+
p = parts[i].slice(0, m.length);
|
1665
|
+
return m.toLowerCase() === p.toLowerCase();
|
1666
|
+
}
|
1667
|
+
if (parts.length === fparts.length){
|
1668
|
+
var cnt;
|
1669
|
+
for (i=0, cnt = fparts.length; i < cnt; i++){
|
1670
|
+
val = parseInt(parts[i], 10);
|
1671
|
+
part = fparts[i];
|
1672
|
+
if (isNaN(val)){
|
1673
|
+
switch (part){
|
1674
|
+
case 'MM':
|
1675
|
+
filtered = $(dates[language].months).filter(match_part);
|
1676
|
+
val = $.inArray(filtered[0], dates[language].months) + 1;
|
1677
|
+
break;
|
1678
|
+
case 'M':
|
1679
|
+
filtered = $(dates[language].monthsShort).filter(match_part);
|
1680
|
+
val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
|
1681
|
+
break;
|
1682
|
+
}
|
1683
|
+
}
|
1684
|
+
parsed[part] = val;
|
1685
|
+
}
|
1686
|
+
var _date, s;
|
1687
|
+
for (i=0; i < setters_order.length; i++){
|
1688
|
+
s = setters_order[i];
|
1689
|
+
if (s in parsed && !isNaN(parsed[s])){
|
1690
|
+
_date = new Date(date);
|
1691
|
+
setters_map[s](_date, parsed[s]);
|
1692
|
+
if (!isNaN(_date))
|
1693
|
+
date = _date;
|
1694
|
+
}
|
1695
|
+
}
|
1696
|
+
}
|
1697
|
+
return date;
|
1698
|
+
},
|
1699
|
+
formatDate: function(date, format, language){
|
1700
|
+
if (!date)
|
1701
|
+
return '';
|
1702
|
+
if (typeof format === 'string')
|
1703
|
+
format = DPGlobal.parseFormat(format);
|
1704
|
+
var val = {
|
1705
|
+
d: date.getUTCDate(),
|
1706
|
+
D: dates[language].daysShort[date.getUTCDay()],
|
1707
|
+
DD: dates[language].days[date.getUTCDay()],
|
1708
|
+
m: date.getUTCMonth() + 1,
|
1709
|
+
M: dates[language].monthsShort[date.getUTCMonth()],
|
1710
|
+
MM: dates[language].months[date.getUTCMonth()],
|
1711
|
+
yy: date.getUTCFullYear().toString().substring(2),
|
1712
|
+
yyyy: date.getUTCFullYear()
|
1713
|
+
};
|
1714
|
+
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
1715
|
+
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
1716
|
+
date = [];
|
1717
|
+
var seps = $.extend([], format.separators);
|
1718
|
+
for (var i=0, cnt = format.parts.length; i <= cnt; i++){
|
1719
|
+
if (seps.length)
|
1720
|
+
date.push(seps.shift());
|
1721
|
+
date.push(val[format.parts[i]]);
|
1722
|
+
}
|
1723
|
+
return date.join('');
|
1724
|
+
},
|
1725
|
+
headTemplate: '<thead>'+
|
1726
|
+
'<tr>'+
|
1727
|
+
'<th class="prev">«</th>'+
|
1728
|
+
'<th colspan="5" class="datepicker-switch"></th>'+
|
1729
|
+
'<th class="next">»</th>'+
|
1730
|
+
'</tr>'+
|
1731
|
+
'</thead>',
|
1732
|
+
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
|
1733
|
+
footTemplate: '<tfoot>'+
|
1734
|
+
'<tr>'+
|
1735
|
+
'<th colspan="7" class="today"></th>'+
|
1736
|
+
'</tr>'+
|
1737
|
+
'<tr>'+
|
1738
|
+
'<th colspan="7" class="clear"></th>'+
|
1739
|
+
'</tr>'+
|
1740
|
+
'</tfoot>'
|
1741
|
+
};
|
1742
|
+
DPGlobal.template = '<div class="datepicker">'+
|
1743
|
+
'<div class="datepicker-days">'+
|
1744
|
+
'<table class=" table-condensed">'+
|
1745
|
+
DPGlobal.headTemplate+
|
1746
|
+
'<tbody></tbody>'+
|
1747
|
+
DPGlobal.footTemplate+
|
1748
|
+
'</table>'+
|
1749
|
+
'</div>'+
|
1750
|
+
'<div class="datepicker-months">'+
|
1751
|
+
'<table class="table-condensed">'+
|
1752
|
+
DPGlobal.headTemplate+
|
1753
|
+
DPGlobal.contTemplate+
|
1754
|
+
DPGlobal.footTemplate+
|
1755
|
+
'</table>'+
|
1756
|
+
'</div>'+
|
1757
|
+
'<div class="datepicker-years">'+
|
1758
|
+
'<table class="table-condensed">'+
|
1759
|
+
DPGlobal.headTemplate+
|
1760
|
+
DPGlobal.contTemplate+
|
1761
|
+
DPGlobal.footTemplate+
|
1762
|
+
'</table>'+
|
1763
|
+
'</div>'+
|
1764
|
+
'</div>';
|
1765
|
+
|
1766
|
+
$.fn.datepicker.DPGlobal = DPGlobal;
|
1767
|
+
|
1768
|
+
|
1769
|
+
/* DATEPICKER NO CONFLICT
|
1770
|
+
* =================== */
|
1771
|
+
|
1772
|
+
$.fn.datepicker.noConflict = function(){
|
1773
|
+
$.fn.datepicker = old;
|
1774
|
+
return this;
|
1775
|
+
};
|
1776
|
+
|
1777
|
+
/* DATEPICKER VERSION
|
1778
|
+
* =================== */
|
1779
|
+
$.fn.datepicker.version = "1.5.0";
|
1780
|
+
|
1781
|
+
/* DATEPICKER DATA-API
|
1782
|
+
* ================== */
|
1783
|
+
|
1784
|
+
$(document).on(
|
1785
|
+
'focus.datepicker.data-api click.datepicker.data-api',
|
1786
|
+
'[data-provide="datepicker"]',
|
1787
|
+
function(e){
|
1788
|
+
var $this = $(this);
|
1789
|
+
if ($this.data('datepicker'))
|
1790
|
+
return;
|
1791
|
+
e.preventDefault();
|
1792
|
+
// component click requires us to explicitly show it
|
1793
|
+
datepickerPlugin.call($this, 'show');
|
1794
|
+
}
|
1795
|
+
);
|
1796
|
+
$(function(){
|
1797
|
+
datepickerPlugin.call($('[data-provide="datepicker-inline"]'));
|
1798
|
+
});
|
1799
|
+
|
1800
|
+
}(window.jQuery));
|