cybele 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +16 -2
- data/dump.rdb +1 -0
- data/lib/cybele/app_builder.rb +213 -220
- data/lib/cybele/generators/app_generator.rb +31 -20
- data/lib/cybele/version.rb +2 -2
- data/templates/.env.local.erb +11 -0
- data/templates/.env.production.erb +11 -0
- data/templates/.env.staging.erb +11 -0
- data/templates/README.md.erb +22 -0
- data/templates/app/assets/javascripts/application.js.coffee +63 -1
- data/templates/app/assets/javascripts/hq/application.js.coffee +93 -0
- data/templates/app/assets/stylesheets/application.css.sass +15 -4
- data/templates/app/assets/stylesheets/hq/application.css.sass +92 -0
- data/templates/app/controllers/application_controller.rb.erb +48 -0
- data/templates/app/controllers/concerns/basic_authentication.rb +18 -0
- data/templates/app/controllers/hq/admins_controller.rb +64 -0
- data/templates/app/controllers/hq/application_controller.rb +11 -0
- data/templates/app/controllers/hq/audits_controller.rb +16 -0
- data/templates/app/controllers/hq/cities_controller.rb +54 -0
- data/templates/app/controllers/hq/countries_controller.rb +54 -0
- data/templates/app/controllers/hq/dashboard_controller.rb +4 -1
- data/templates/app/controllers/hq/passwords_controller.rb +10 -0
- data/templates/app/controllers/hq/registrations_controller.rb +21 -0
- data/templates/app/controllers/hq/sessions_controller.rb +1 -1
- data/templates/app/controllers/hq/users_controller.rb +64 -0
- data/templates/app/controllers/user/dashboard_controller.rb +8 -0
- data/templates/app/controllers/user/passwords_controller.rb +10 -0
- data/templates/app/controllers/user/profiles_controller.rb +34 -0
- data/templates/app/controllers/user/registrations_controller.rb +20 -0
- data/templates/app/controllers/user/sessions_controller.rb +16 -0
- data/templates/app/controllers/user/user_application_controller.rb +20 -0
- data/templates/app/helpers/application_helper.rb.erb +27 -0
- data/templates/app/mailers/admin_mailer.rb +10 -0
- data/templates/app/mailers/base_mailer.rb +4 -0
- data/templates/app/mailers/user_mailer.rb +10 -0
- data/templates/app/models/admin.rb +51 -0
- data/templates/app/models/audit.rb +3 -0
- data/templates/app/models/city.rb +12 -0
- data/templates/app/models/country.rb +12 -0
- data/templates/app/models/user.rb +54 -0
- data/templates/app/views/admin_mailer/login_info.html.haml +13 -0
- data/templates/app/views/devise/confirmations/new.html.haml +6 -5
- data/templates/app/views/devise/mailer/confirmation_instructions.html.haml +5 -3
- data/templates/app/views/devise/mailer/reset_password_instructions.html.haml +2 -2
- data/templates/app/views/devise/passwords/edit.html.haml +3 -3
- data/templates/app/views/devise/passwords/new.html.haml +3 -3
- data/templates/app/views/devise/registrations/edit.html.haml +5 -11
- data/templates/app/views/devise/registrations/new.html.haml +18 -6
- data/templates/app/views/devise/sessions/new.html.haml +1 -1
- data/templates/app/views/devise/shared/_links.haml +3 -1
- data/templates/app/views/devise/unlocks/new.html.haml +4 -4
- data/templates/app/views/hq/admins/_admin.html.haml +21 -0
- data/templates/app/views/hq/admins/_blank.html.haml +9 -0
- data/templates/app/views/hq/admins/_filters.html.haml +20 -0
- data/templates/app/views/hq/admins/_form.html.haml +17 -0
- data/templates/app/views/hq/admins/_list.html.haml +15 -0
- data/templates/app/views/hq/admins/edit.html.haml +3 -0
- data/templates/app/views/hq/admins/index.html.haml +18 -0
- data/templates/app/views/hq/admins/new.html.haml +5 -0
- data/templates/app/views/hq/admins/show.html.haml +19 -0
- data/templates/app/views/hq/audits/_filters.html.haml +32 -0
- data/templates/app/views/hq/audits/_list.html.haml +37 -0
- data/templates/app/views/hq/audits/index.html.haml +5 -0
- data/templates/app/views/hq/audits/show.html.haml +5 -0
- data/templates/app/views/hq/cities/_blank.html.haml +9 -0
- data/templates/app/views/hq/cities/_city.html.haml +12 -0
- data/templates/app/views/hq/cities/_filters.html.haml +15 -0
- data/templates/app/views/hq/cities/_form.html.haml +15 -0
- data/templates/app/views/hq/cities/_list.html.haml +13 -0
- data/templates/app/views/hq/cities/edit.html.haml +3 -0
- data/templates/app/views/hq/cities/index.html.haml +18 -0
- data/templates/app/views/hq/cities/new.html.haml +3 -0
- data/templates/app/views/hq/cities/show.html.haml +13 -0
- data/templates/app/views/hq/countries/_blank.html.haml +9 -0
- data/templates/app/views/hq/countries/_country.html.haml +11 -0
- data/templates/app/views/hq/countries/_filters.html.haml +14 -0
- data/templates/app/views/hq/countries/_form.html.haml +14 -0
- data/templates/app/views/hq/countries/_list.html.haml +12 -0
- data/templates/app/views/hq/countries/edit.html.haml +3 -0
- data/templates/app/views/hq/countries/index.html.haml +18 -0
- data/templates/app/views/hq/countries/new.html.haml +3 -0
- data/templates/app/views/hq/countries/show.html.haml +14 -0
- data/templates/app/views/hq/dashboard/index.html.haml +8 -0
- data/templates/app/views/hq/passwords/edit.html.haml +12 -0
- data/templates/app/views/hq/passwords/new.html.haml +9 -0
- data/templates/app/views/hq/registrations/edit.html.haml +19 -0
- data/templates/app/views/hq/sessions/new.html.haml +7 -5
- data/templates/app/views/hq/users/_blank.html.haml +9 -0
- data/templates/app/views/hq/users/_filters.html.haml +20 -0
- data/templates/app/views/hq/users/_form.html.haml +18 -0
- data/templates/app/views/hq/users/_list.html.haml +15 -0
- data/templates/app/views/hq/users/_user.html.haml +20 -0
- data/templates/app/views/hq/users/edit.html.haml +3 -0
- data/templates/app/views/hq/users/index.html.haml +18 -0
- data/templates/app/views/hq/users/new.html.haml +5 -0
- data/templates/app/views/hq/users/show.html.haml +20 -0
- data/templates/app/views/layouts/application.html.haml.erb +16 -8
- data/templates/app/views/layouts/hq/application.html.haml.erb +55 -0
- data/templates/app/views/layouts/hq/login.html.haml.erb +35 -0
- data/templates/app/views/layouts/hq/partials/_dock.html.haml.erb +36 -0
- data/templates/app/views/layouts/hq/partials/_footer.html.haml.erb +0 -0
- data/templates/app/views/layouts/hq/partials/_navbar.html.haml.erb +22 -0
- data/templates/app/views/layouts/hq/partials/_trackers.html.haml.erb +0 -0
- data/templates/app/views/layouts/mailer.html.haml.erb +321 -0
- data/templates/app/views/layouts/mailer.text.haml +1 -0
- data/templates/app/views/layouts/partials/_footer.html.haml.erb +0 -0
- data/templates/app/views/layouts/partials/_trackers.html.haml.erb +0 -0
- data/templates/app/views/layouts/partials/_warnings.html.haml.erb +3 -0
- data/templates/app/views/user/dashboard/index.html.haml +8 -0
- data/templates/app/views/user/passwords/edit.html.haml +12 -0
- data/templates/app/views/user/passwords/new.html.haml +10 -0
- data/templates/app/views/{user_profiles → user/profiles}/_form.html.haml +4 -5
- data/templates/app/views/user/profiles/edit.html.haml +3 -0
- data/templates/app/views/user/profiles/show.html.haml +15 -0
- data/templates/app/views/user/registrations/edit.html.haml +19 -0
- data/templates/app/views/user/sessions/new.html.haml +11 -0
- data/templates/app/views/user_mailer/login_info.html.haml +13 -0
- data/templates/app/views/welcome/index.html.haml.erb +4 -4
- data/templates/config/initializers/devise_async.rb +6 -0
- data/templates/config/initializers/sidekiq.rb +13 -0
- data/templates/config/locales/email.tr.yml +28 -0
- data/templates/config/locales/models.tr.yml +72 -41
- data/templates/config/locales/responders.tr.yml +4 -1
- data/templates/config/locales/show_for.tr.yml +1 -3
- data/templates/config/locales/simple_form.tr.yml +8 -22
- data/templates/config/locales/tr.yml +33 -2
- data/templates/config/locales/view.tr.yml +64 -18
- data/templates/config/routes.erb +51 -0
- data/templates/config/schedule.yml +16 -0
- data/templates/config/settings/production.yml +0 -17
- data/templates/config/settings/staging.yml +0 -17
- data/templates/config/sidekiq.yml +13 -0
- data/templates/cybele_Gemfile +42 -5
- data/templates/cybele_gitignore +3 -1
- data/templates/cybele_version.txt +1 -0
- data/templates/env.sample.erb +11 -0
- data/templates/lib/data/cities.yml +163 -0
- data/templates/lib/tasks/dev.rake +29 -5
- data/templates/lib/tasks/sidekiq.rake +26 -0
- data/templates/lib/templates/rails/responders_controller/controller.rb +27 -22
- data/templates/public/images/favicon.png +0 -0
- data/templates/public/images/mail-logo.png +0 -0
- data/templates/public/images/missing_cover.png +0 -0
- data/templates/public/images/missing_cover@2x.png +0 -0
- data/templates/public/images/missing_logo.png +0 -0
- data/templates/public/images/missing_logo@2x.png +0 -0
- data/templates/public/images/sprite.png +0 -0
- data/templates/ruby-version +1 -1
- data/templates/vendor/assets/javascripts/jquery.datetimepicker.js +1871 -0
- data/templates/vendor/assets/javascripts/jquery.maskedinput.min.js +7 -0
- data/templates/vendor/assets/javascripts/nprogress.js +491 -0
- data/templates/vendor/assets/javascripts/trix.js +25 -0
- data/templates/vendor/assets/stylesheets/jquery.datetimepicker.css +418 -0
- data/templates/vendor/assets/stylesheets/nprogress.css +74 -0
- data/templates/vendor/assets/stylesheets/trix.css +209 -0
- metadata +125 -24
- data/templates/app/controllers/application_controller.rb +0 -19
- data/templates/app/controllers/hq/admin_profiles_controller.rb +0 -56
- data/templates/app/controllers/user_profiles_controller.rb +0 -56
- data/templates/app/views/hq/admin_profiles/_form.html.haml +0 -15
- data/templates/app/views/hq/admin_profiles/edit.html.haml +0 -3
- data/templates/app/views/hq/admin_profiles/new.html.haml +0 -3
- data/templates/app/views/hq/admin_profiles/show.html.haml +0 -13
- data/templates/app/views/hq/dashboard/index.html.haml.erb +0 -3
- data/templates/app/views/user_profiles/edit.html.haml +0 -3
- data/templates/app/views/user_profiles/new.html.haml +0 -3
- data/templates/app/views/user_profiles/show.html.haml +0 -13
- data/templates/config/locales/en.yml +0 -2
- data/templates/config/locales/models.en.yml +0 -54
- data/templates/config/locales/responders.en.yml +0 -10
- data/templates/config/locales/show_for.en.yml +0 -7
- data/templates/config/locales/simple_form.en.yml +0 -30
- data/templates/config/locales/view.en.yml +0 -51
@@ -2,7 +2,7 @@ namespace :dev do
|
|
2
2
|
# Just run development env
|
3
3
|
# This code run insert seed and agency data
|
4
4
|
# A simple trick to over migration problem
|
5
|
-
task :
|
5
|
+
task setup: [:environment] do
|
6
6
|
raise 'Nah, You are at production' if Rails.env.production?
|
7
7
|
Rake::Task['dev:kill_postgres_connections'].execute
|
8
8
|
Rake::Task['db:drop'].execute
|
@@ -12,12 +12,36 @@ namespace :dev do
|
|
12
12
|
Rake::Task['db:seed'].execute
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
desc 'seed test data'
|
16
|
+
task seed: [:environment] do
|
17
|
+
Rake::Task['db:seed'].execute
|
18
|
+
Rake::Task['dev:countries'].execute
|
19
|
+
Rake::Task['dev:cities'].execute
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'import countries'
|
23
|
+
task countries: [:environment] do
|
24
|
+
Country.destroy_all
|
25
|
+
Country.create!(name: 'Türkiye')
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'import turkey cities'
|
29
|
+
task cities: [:environment] do
|
30
|
+
City.destroy_all
|
31
|
+
cities = YAML.load_file( "#{Rails.root.to_s}/lib/data/cities.yml")
|
32
|
+
cities_array = []
|
33
|
+
turkey = Country.first
|
34
|
+
cities.each do |city|
|
35
|
+
print '.'
|
36
|
+
cities_array << {
|
37
|
+
name: city['name'],
|
38
|
+
country_id: turkey.id
|
39
|
+
}
|
40
|
+
end
|
41
|
+
City.create!(cities_array)
|
18
42
|
end
|
19
43
|
|
20
|
-
task :
|
44
|
+
task kill_postgres_connections: [:environment] do
|
21
45
|
db_name = "#{File.basename(Rails.root)}_#{Rails.env}"
|
22
46
|
sh = <<EOF
|
23
47
|
ps xa \
|
@@ -0,0 +1,26 @@
|
|
1
|
+
namespace :sidekiq do
|
2
|
+
|
3
|
+
desc 'Starts Sidekiq'
|
4
|
+
task start: [:environment] do
|
5
|
+
cmd = Cocaine::CommandLine.new('bundle exec sidekiq', '-C config/sidekiq.yml')
|
6
|
+
mes = cmd.run
|
7
|
+
if mes == ''
|
8
|
+
puts 'Sidekiq started successfully.'
|
9
|
+
else
|
10
|
+
mes
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Stops Sidekiq'
|
15
|
+
task stop: [:environment] do
|
16
|
+
cmd = Cocaine::CommandLine.new('sidekiqctl', 'stop tmp/pids/sidekiq.pid')
|
17
|
+
puts cmd.run
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Restarts Sidekiq'
|
21
|
+
task restart: [:environment] do
|
22
|
+
Rake::Task['sidekiq:stop'].execute
|
23
|
+
Rake::Task['sidekiq:start'].execute
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -1,51 +1,56 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
<% module_namespacing do -%>
|
3
3
|
class <%= controller_class_name %>Controller < ApplicationController
|
4
|
-
|
5
|
-
|
4
|
+
before_action :<%= "set_#{singular_table_name}" %>, only: [:show, :edit, :update, :destroy]
|
5
|
+
add_breadcrumb I18n.t('activerecord.models.<%= singular_table_name %>'), :<%= table_name %>_path
|
6
6
|
<% unless options[:singleton] -%>
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def index
|
8
|
+
@search = <%= class_name %>.order(id: :desc).search(params[:q])
|
9
|
+
@<%= table_name %> = @search.result(distinct: true).paginate(page: params[:page])
|
10
|
+
respond_with(@<%= table_name %>)
|
10
11
|
end
|
11
12
|
<% end -%>
|
12
13
|
|
13
14
|
def show
|
15
|
+
add_breadcrumb @<%= file_name %>.<%= attributes.first.name %>, <%= singular_table_name %>_path(@<%= file_name %>)
|
14
16
|
respond_with(@<%= file_name %>)
|
15
|
-
|
17
|
+
end
|
16
18
|
|
17
|
-
|
19
|
+
def new
|
20
|
+
add_breadcrumb t('tooltips.new'), new_<%= singular_table_name %>_path
|
18
21
|
@<%= file_name %> = <%= orm_class.build(class_name) %>
|
19
22
|
respond_with(@<%= file_name %>)
|
20
|
-
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
25
|
+
def edit
|
26
|
+
add_breadcrumb @<%= singular_table_name %>.id, <%= singular_table_name %>_path(@<%= singular_table_name %>)
|
27
|
+
add_breadcrumb t('tooltips.edit'), edit_<%= singular_table_name %>_path
|
28
|
+
end
|
24
29
|
|
25
|
-
|
26
|
-
|
30
|
+
def create
|
31
|
+
@<%= file_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
27
32
|
@<%= orm_instance.save %>
|
28
33
|
respond_with(@<%= file_name %>)
|
29
|
-
|
34
|
+
end
|
30
35
|
|
31
|
-
|
32
|
-
|
36
|
+
def update
|
37
|
+
@<%= orm_instance.update("#{singular_table_name}_params") %>
|
33
38
|
respond_with(@<%= file_name %>)
|
34
|
-
|
39
|
+
end
|
35
40
|
|
36
|
-
|
37
|
-
|
41
|
+
def destroy
|
42
|
+
@<%= orm_instance.destroy %>
|
38
43
|
respond_with(@<%= file_name %>)
|
39
|
-
|
44
|
+
end
|
40
45
|
|
41
|
-
|
46
|
+
private
|
42
47
|
|
43
|
-
|
48
|
+
def <%= "set_#{singular_table_name}" %>
|
44
49
|
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
45
50
|
end
|
46
51
|
|
47
52
|
def <%= "#{singular_table_name}_params" %>
|
48
53
|
params.require(<%= ":#{singular_table_name}" %>).permit(<%= attributes.map {|a| ":#{a.name}" }.sort.join(', ') %>)
|
49
|
-
|
54
|
+
end
|
50
55
|
end
|
51
56
|
<% end -%>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/templates/ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
@@ -0,0 +1,1871 @@
|
|
1
|
+
/**
|
2
|
+
* @preserve jQuery DateTimePicker plugin v2.4.1
|
3
|
+
* @homepage http://xdsoft.net/jqplugins/datetimepicker/
|
4
|
+
* (c) 2014, Chupurnov Valeriy.
|
5
|
+
*/
|
6
|
+
/*global document,window,jQuery,setTimeout,clearTimeout*/
|
7
|
+
(function ($) {
|
8
|
+
'use strict';
|
9
|
+
var default_options = {
|
10
|
+
i18n: {
|
11
|
+
ar: { // Arabic
|
12
|
+
months: [
|
13
|
+
"كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"
|
14
|
+
],
|
15
|
+
dayOfWeek: [
|
16
|
+
"ن", "ث", "ع", "خ", "ج", "س", "ح"
|
17
|
+
]
|
18
|
+
},
|
19
|
+
ro: { // Romanian
|
20
|
+
months: [
|
21
|
+
"ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"
|
22
|
+
],
|
23
|
+
dayOfWeek: [
|
24
|
+
"l", "ma", "mi", "j", "v", "s", "d"
|
25
|
+
]
|
26
|
+
},
|
27
|
+
id: { // Indonesian
|
28
|
+
months: [
|
29
|
+
"Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
|
30
|
+
],
|
31
|
+
dayOfWeek: [
|
32
|
+
"Sen", "Sel", "Rab", "Kam", "Jum", "Sab", "Min"
|
33
|
+
]
|
34
|
+
},
|
35
|
+
bg: { // Bulgarian
|
36
|
+
months: [
|
37
|
+
"Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
|
38
|
+
],
|
39
|
+
dayOfWeek: [
|
40
|
+
"Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
|
41
|
+
]
|
42
|
+
},
|
43
|
+
fa: { // Persian/Farsi
|
44
|
+
months: [
|
45
|
+
'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
|
46
|
+
],
|
47
|
+
dayOfWeek: [
|
48
|
+
'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
|
49
|
+
]
|
50
|
+
},
|
51
|
+
ru: { // Russian
|
52
|
+
months: [
|
53
|
+
'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
|
54
|
+
],
|
55
|
+
dayOfWeek: [
|
56
|
+
"Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
|
57
|
+
]
|
58
|
+
},
|
59
|
+
uk: { // Ukrainian
|
60
|
+
months: [
|
61
|
+
'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'
|
62
|
+
],
|
63
|
+
dayOfWeek: [
|
64
|
+
"Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
|
65
|
+
]
|
66
|
+
},
|
67
|
+
en: { // English
|
68
|
+
months: [
|
69
|
+
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
|
70
|
+
],
|
71
|
+
dayOfWeek: [
|
72
|
+
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
73
|
+
]
|
74
|
+
},
|
75
|
+
el: { // Ελληνικά
|
76
|
+
months: [
|
77
|
+
"Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
|
78
|
+
],
|
79
|
+
dayOfWeek: [
|
80
|
+
"Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
|
81
|
+
]
|
82
|
+
},
|
83
|
+
de: { // German
|
84
|
+
months: [
|
85
|
+
'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
|
86
|
+
],
|
87
|
+
dayOfWeek: [
|
88
|
+
"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
|
89
|
+
]
|
90
|
+
},
|
91
|
+
nl: { // Dutch
|
92
|
+
months: [
|
93
|
+
"januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
|
94
|
+
],
|
95
|
+
dayOfWeek: [
|
96
|
+
"zo", "ma", "di", "wo", "do", "vr", "za"
|
97
|
+
]
|
98
|
+
},
|
99
|
+
tr: { // Turkish
|
100
|
+
months: [
|
101
|
+
"Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
|
102
|
+
],
|
103
|
+
dayOfWeek: [
|
104
|
+
"Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
|
105
|
+
]
|
106
|
+
},
|
107
|
+
fr: { //French
|
108
|
+
months: [
|
109
|
+
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
|
110
|
+
],
|
111
|
+
dayOfWeek: [
|
112
|
+
"Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
|
113
|
+
]
|
114
|
+
},
|
115
|
+
es: { // Spanish
|
116
|
+
months: [
|
117
|
+
"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
|
118
|
+
],
|
119
|
+
dayOfWeek: [
|
120
|
+
"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
|
121
|
+
]
|
122
|
+
},
|
123
|
+
th: { // Thai
|
124
|
+
months: [
|
125
|
+
'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
|
126
|
+
],
|
127
|
+
dayOfWeek: [
|
128
|
+
'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'
|
129
|
+
]
|
130
|
+
},
|
131
|
+
pl: { // Polish
|
132
|
+
months: [
|
133
|
+
"styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
|
134
|
+
],
|
135
|
+
dayOfWeek: [
|
136
|
+
"nd", "pn", "wt", "śr", "cz", "pt", "sb"
|
137
|
+
]
|
138
|
+
},
|
139
|
+
pt: { // Portuguese
|
140
|
+
months: [
|
141
|
+
"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
|
142
|
+
],
|
143
|
+
dayOfWeek: [
|
144
|
+
"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
|
145
|
+
]
|
146
|
+
},
|
147
|
+
ch: { // Simplified Chinese
|
148
|
+
months: [
|
149
|
+
"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
|
150
|
+
],
|
151
|
+
dayOfWeek: [
|
152
|
+
"日", "一", "二", "三", "四", "五", "六"
|
153
|
+
]
|
154
|
+
},
|
155
|
+
se: { // Swedish
|
156
|
+
months: [
|
157
|
+
"Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
|
158
|
+
],
|
159
|
+
dayOfWeek: [
|
160
|
+
"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
|
161
|
+
]
|
162
|
+
},
|
163
|
+
kr: { // Korean
|
164
|
+
months: [
|
165
|
+
"1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
|
166
|
+
],
|
167
|
+
dayOfWeek: [
|
168
|
+
"일", "월", "화", "수", "목", "금", "토"
|
169
|
+
]
|
170
|
+
},
|
171
|
+
it: { // Italian
|
172
|
+
months: [
|
173
|
+
"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
|
174
|
+
],
|
175
|
+
dayOfWeek: [
|
176
|
+
"Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
|
177
|
+
]
|
178
|
+
},
|
179
|
+
da: { // Dansk
|
180
|
+
months: [
|
181
|
+
"January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
|
182
|
+
],
|
183
|
+
dayOfWeek: [
|
184
|
+
"Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
|
185
|
+
]
|
186
|
+
},
|
187
|
+
no: { // Norwegian
|
188
|
+
months: [
|
189
|
+
"Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
|
190
|
+
],
|
191
|
+
dayOfWeek: [
|
192
|
+
"Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
|
193
|
+
]
|
194
|
+
},
|
195
|
+
ja: { // Japanese
|
196
|
+
months: [
|
197
|
+
"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
|
198
|
+
],
|
199
|
+
dayOfWeek: [
|
200
|
+
"日", "月", "火", "水", "木", "金", "土"
|
201
|
+
]
|
202
|
+
},
|
203
|
+
vi: { // Vietnamese
|
204
|
+
months: [
|
205
|
+
"Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"
|
206
|
+
],
|
207
|
+
dayOfWeek: [
|
208
|
+
"CN", "T2", "T3", "T4", "T5", "T6", "T7"
|
209
|
+
]
|
210
|
+
},
|
211
|
+
sl: { // Slovenščina
|
212
|
+
months: [
|
213
|
+
"Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
|
214
|
+
],
|
215
|
+
dayOfWeek: [
|
216
|
+
"Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
|
217
|
+
]
|
218
|
+
},
|
219
|
+
cs: { // Čeština
|
220
|
+
months: [
|
221
|
+
"Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
|
222
|
+
],
|
223
|
+
dayOfWeek: [
|
224
|
+
"Ne", "Po", "Út", "St", "Čt", "Pá", "So"
|
225
|
+
]
|
226
|
+
},
|
227
|
+
hu: { // Hungarian
|
228
|
+
months: [
|
229
|
+
"Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
|
230
|
+
],
|
231
|
+
dayOfWeek: [
|
232
|
+
"Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
|
233
|
+
]
|
234
|
+
},
|
235
|
+
az: { //Azerbaijanian (Azeri)
|
236
|
+
months: [
|
237
|
+
"Yanvar", "Fevral", "Mart", "Aprel", "May", "Iyun", "Iyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr"
|
238
|
+
],
|
239
|
+
dayOfWeek: [
|
240
|
+
"B", "Be", "Ça", "Ç", "Ca", "C", "Ş"
|
241
|
+
]
|
242
|
+
},
|
243
|
+
bs: { //Bosanski
|
244
|
+
months: [
|
245
|
+
"Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
|
246
|
+
],
|
247
|
+
dayOfWeek: [
|
248
|
+
"Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
|
249
|
+
]
|
250
|
+
},
|
251
|
+
ca: { //Català
|
252
|
+
months: [
|
253
|
+
"Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"
|
254
|
+
],
|
255
|
+
dayOfWeek: [
|
256
|
+
"Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds"
|
257
|
+
]
|
258
|
+
},
|
259
|
+
'en-GB': { //English (British)
|
260
|
+
months: [
|
261
|
+
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
|
262
|
+
],
|
263
|
+
dayOfWeek: [
|
264
|
+
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
265
|
+
]
|
266
|
+
},
|
267
|
+
et: { //"Eesti"
|
268
|
+
months: [
|
269
|
+
"Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"
|
270
|
+
],
|
271
|
+
dayOfWeek: [
|
272
|
+
"P", "E", "T", "K", "N", "R", "L"
|
273
|
+
]
|
274
|
+
},
|
275
|
+
eu: { //Euskara
|
276
|
+
months: [
|
277
|
+
"Urtarrila", "Otsaila", "Martxoa", "Apirila", "Maiatza", "Ekaina", "Uztaila", "Abuztua", "Iraila", "Urria", "Azaroa", "Abendua"
|
278
|
+
],
|
279
|
+
dayOfWeek: [
|
280
|
+
"Ig.", "Al.", "Ar.", "Az.", "Og.", "Or.", "La."
|
281
|
+
]
|
282
|
+
},
|
283
|
+
fi: { //Finnish (Suomi)
|
284
|
+
months: [
|
285
|
+
"Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"
|
286
|
+
],
|
287
|
+
dayOfWeek: [
|
288
|
+
"Su", "Ma", "Ti", "Ke", "To", "Pe", "La"
|
289
|
+
]
|
290
|
+
},
|
291
|
+
gl: { //Galego
|
292
|
+
months: [
|
293
|
+
"Xan", "Feb", "Maz", "Abr", "Mai", "Xun", "Xul", "Ago", "Set", "Out", "Nov", "Dec"
|
294
|
+
],
|
295
|
+
dayOfWeek: [
|
296
|
+
"Dom", "Lun", "Mar", "Mer", "Xov", "Ven", "Sab"
|
297
|
+
]
|
298
|
+
},
|
299
|
+
hr: { //Hrvatski
|
300
|
+
months: [
|
301
|
+
"Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"
|
302
|
+
],
|
303
|
+
dayOfWeek: [
|
304
|
+
"Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
|
305
|
+
]
|
306
|
+
},
|
307
|
+
ko: { //Korean (한국어)
|
308
|
+
months: [
|
309
|
+
"1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
|
310
|
+
],
|
311
|
+
dayOfWeek: [
|
312
|
+
"일", "월", "화", "수", "목", "금", "토"
|
313
|
+
]
|
314
|
+
},
|
315
|
+
lt: { //Lithuanian (lietuvių)
|
316
|
+
months: [
|
317
|
+
"Sausio", "Vasario", "Kovo", "Balandžio", "Gegužės", "Birželio", "Liepos", "Rugpjūčio", "Rugsėjo", "Spalio", "Lapkričio", "Gruodžio"
|
318
|
+
],
|
319
|
+
dayOfWeek: [
|
320
|
+
"Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš"
|
321
|
+
]
|
322
|
+
},
|
323
|
+
lv: { //Latvian (Latviešu)
|
324
|
+
months: [
|
325
|
+
"Janvāris", "Februāris", "Marts", "Aprīlis ", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"
|
326
|
+
],
|
327
|
+
dayOfWeek: [
|
328
|
+
"Sv", "Pr", "Ot", "Tr", "Ct", "Pk", "St"
|
329
|
+
]
|
330
|
+
},
|
331
|
+
mk: { //Macedonian (Македонски)
|
332
|
+
months: [
|
333
|
+
"јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"
|
334
|
+
],
|
335
|
+
dayOfWeek: [
|
336
|
+
"нед", "пон", "вто", "сре", "чет", "пет", "саб"
|
337
|
+
]
|
338
|
+
},
|
339
|
+
mn: { //Mongolian (Монгол)
|
340
|
+
months: [
|
341
|
+
"1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"
|
342
|
+
],
|
343
|
+
dayOfWeek: [
|
344
|
+
"Дав", "Мяг", "Лха", "Пүр", "Бсн", "Бям", "Ням"
|
345
|
+
]
|
346
|
+
},
|
347
|
+
'pt-BR': { //Português(Brasil)
|
348
|
+
months: [
|
349
|
+
"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
|
350
|
+
],
|
351
|
+
dayOfWeek: [
|
352
|
+
"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"
|
353
|
+
]
|
354
|
+
},
|
355
|
+
sk: { //Slovenčina
|
356
|
+
months: [
|
357
|
+
"Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"
|
358
|
+
],
|
359
|
+
dayOfWeek: [
|
360
|
+
"Ne", "Po", "Ut", "St", "Št", "Pi", "So"
|
361
|
+
]
|
362
|
+
},
|
363
|
+
sq: { //Albanian (Shqip)
|
364
|
+
months: [
|
365
|
+
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
|
366
|
+
],
|
367
|
+
dayOfWeek: [
|
368
|
+
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
369
|
+
]
|
370
|
+
},
|
371
|
+
'sr-YU': { //Serbian (Srpski)
|
372
|
+
months: [
|
373
|
+
"Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
|
374
|
+
],
|
375
|
+
dayOfWeek: [
|
376
|
+
"Ned", "Pon", "Uto", "Sre", "čet", "Pet", "Sub"
|
377
|
+
]
|
378
|
+
},
|
379
|
+
sr: { //Serbian Cyrillic (Српски)
|
380
|
+
months: [
|
381
|
+
"јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"
|
382
|
+
],
|
383
|
+
dayOfWeek: [
|
384
|
+
"нед", "пон", "уто", "сре", "чет", "пет", "суб"
|
385
|
+
]
|
386
|
+
},
|
387
|
+
sv: { //Svenska
|
388
|
+
months: [
|
389
|
+
"Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
|
390
|
+
],
|
391
|
+
dayOfWeek: [
|
392
|
+
"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
|
393
|
+
]
|
394
|
+
},
|
395
|
+
'zh-TW': { //Traditional Chinese (繁體中文)
|
396
|
+
months: [
|
397
|
+
"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
|
398
|
+
],
|
399
|
+
dayOfWeek: [
|
400
|
+
"日", "一", "二", "三", "四", "五", "六"
|
401
|
+
]
|
402
|
+
},
|
403
|
+
zh: { //Simplified Chinese (简体中文)
|
404
|
+
months: [
|
405
|
+
"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
|
406
|
+
],
|
407
|
+
dayOfWeek: [
|
408
|
+
"日", "一", "二", "三", "四", "五", "六"
|
409
|
+
]
|
410
|
+
},
|
411
|
+
he: { //Hebrew (עברית)
|
412
|
+
months: [
|
413
|
+
'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'
|
414
|
+
],
|
415
|
+
dayOfWeek: [
|
416
|
+
'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'
|
417
|
+
]
|
418
|
+
},
|
419
|
+
hy: { // Armenian
|
420
|
+
months: [
|
421
|
+
"Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"
|
422
|
+
],
|
423
|
+
dayOfWeek: [
|
424
|
+
"Կի", "Երկ", "Երք", "Չոր", "Հնգ", "Ուրբ", "Շբթ"
|
425
|
+
]
|
426
|
+
}
|
427
|
+
},
|
428
|
+
value: '',
|
429
|
+
lang: 'en',
|
430
|
+
|
431
|
+
format: 'Y/m/d H:i',
|
432
|
+
formatTime: 'H:i',
|
433
|
+
formatDate: 'Y/m/d',
|
434
|
+
|
435
|
+
startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
|
436
|
+
step: 60,
|
437
|
+
monthChangeSpinner: true,
|
438
|
+
|
439
|
+
closeOnDateSelect: false,
|
440
|
+
closeOnWithoutClick: true,
|
441
|
+
closeOnInputClick: true,
|
442
|
+
|
443
|
+
timepicker: true,
|
444
|
+
datepicker: true,
|
445
|
+
weeks: false,
|
446
|
+
|
447
|
+
defaultTime: false, // use formatTime format (ex. '10:00' for formatTime: 'H:i')
|
448
|
+
defaultDate: false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
|
449
|
+
|
450
|
+
minDate: false,
|
451
|
+
maxDate: false,
|
452
|
+
minTime: false,
|
453
|
+
maxTime: false,
|
454
|
+
|
455
|
+
allowTimes: [],
|
456
|
+
opened: false,
|
457
|
+
initTime: true,
|
458
|
+
inline: false,
|
459
|
+
theme: '',
|
460
|
+
|
461
|
+
onSelectDate: function () {},
|
462
|
+
onSelectTime: function () {},
|
463
|
+
onChangeMonth: function () {},
|
464
|
+
onChangeYear: function () {},
|
465
|
+
onChangeDateTime: function () {},
|
466
|
+
onShow: function () {},
|
467
|
+
onClose: function () {},
|
468
|
+
onGenerate: function () {},
|
469
|
+
|
470
|
+
withoutCopyright: true,
|
471
|
+
inverseButton: false,
|
472
|
+
hours12: false,
|
473
|
+
next: 'xdsoft_next',
|
474
|
+
prev : 'xdsoft_prev',
|
475
|
+
dayOfWeekStart: 0,
|
476
|
+
parentID: 'body',
|
477
|
+
timeHeightInTimePicker: 25,
|
478
|
+
timepickerScrollbar: true,
|
479
|
+
todayButton: true,
|
480
|
+
defaultSelect: true,
|
481
|
+
|
482
|
+
scrollMonth: true,
|
483
|
+
scrollTime: true,
|
484
|
+
scrollInput: true,
|
485
|
+
|
486
|
+
lazyInit: false,
|
487
|
+
mask: false,
|
488
|
+
validateOnBlur: true,
|
489
|
+
allowBlank: true,
|
490
|
+
yearStart: 1950,
|
491
|
+
yearEnd: 2050,
|
492
|
+
style: '',
|
493
|
+
id: '',
|
494
|
+
fixed: false,
|
495
|
+
roundTime: 'round', // ceil, floor
|
496
|
+
className: '',
|
497
|
+
weekends: [],
|
498
|
+
disabledDates : [],
|
499
|
+
yearOffset: 0,
|
500
|
+
beforeShowDay: null,
|
501
|
+
|
502
|
+
enterLikeTab: true
|
503
|
+
};
|
504
|
+
// fix for ie8
|
505
|
+
if (!Array.prototype.indexOf) {
|
506
|
+
Array.prototype.indexOf = function (obj, start) {
|
507
|
+
var i, j;
|
508
|
+
for (i = (start || 0), j = this.length; i < j; i += 1) {
|
509
|
+
if (this[i] === obj) { return i; }
|
510
|
+
}
|
511
|
+
return -1;
|
512
|
+
};
|
513
|
+
}
|
514
|
+
Date.prototype.countDaysInMonth = function () {
|
515
|
+
return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
|
516
|
+
};
|
517
|
+
$.fn.xdsoftScroller = function (percent) {
|
518
|
+
return this.each(function () {
|
519
|
+
var timeboxparent = $(this),
|
520
|
+
pointerEventToXY = function (e) {
|
521
|
+
var out = {x: 0, y: 0},
|
522
|
+
touch;
|
523
|
+
if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
|
524
|
+
touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
|
525
|
+
out.x = touch.clientX;
|
526
|
+
out.y = touch.clientY;
|
527
|
+
} else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
|
528
|
+
out.x = e.clientX;
|
529
|
+
out.y = e.clientY;
|
530
|
+
}
|
531
|
+
return out;
|
532
|
+
},
|
533
|
+
move = 0,
|
534
|
+
timebox,
|
535
|
+
parentHeight,
|
536
|
+
height,
|
537
|
+
scrollbar,
|
538
|
+
scroller,
|
539
|
+
maximumOffset = 100,
|
540
|
+
start = false,
|
541
|
+
startY = 0,
|
542
|
+
startTop = 0,
|
543
|
+
h1 = 0,
|
544
|
+
touchStart = false,
|
545
|
+
startTopScroll = 0,
|
546
|
+
calcOffset = function () {};
|
547
|
+
if (percent === 'hide') {
|
548
|
+
timeboxparent.find('.xdsoft_scrollbar').hide();
|
549
|
+
return;
|
550
|
+
}
|
551
|
+
if (!$(this).hasClass('xdsoft_scroller_box')) {
|
552
|
+
timebox = timeboxparent.children().eq(0);
|
553
|
+
parentHeight = timeboxparent[0].clientHeight;
|
554
|
+
height = timebox[0].offsetHeight;
|
555
|
+
scrollbar = $('<div class="xdsoft_scrollbar"></div>');
|
556
|
+
scroller = $('<div class="xdsoft_scroller"></div>');
|
557
|
+
scrollbar.append(scroller);
|
558
|
+
|
559
|
+
timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
|
560
|
+
calcOffset = function calcOffset(event) {
|
561
|
+
var offset = pointerEventToXY(event).y - startY + startTopScroll;
|
562
|
+
if (offset < 0) {
|
563
|
+
offset = 0;
|
564
|
+
}
|
565
|
+
if (offset + scroller[0].offsetHeight > h1) {
|
566
|
+
offset = h1 - scroller[0].offsetHeight;
|
567
|
+
}
|
568
|
+
timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
|
569
|
+
};
|
570
|
+
|
571
|
+
scroller
|
572
|
+
.on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
|
573
|
+
if (!parentHeight) {
|
574
|
+
timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
|
575
|
+
}
|
576
|
+
|
577
|
+
startY = pointerEventToXY(event).y;
|
578
|
+
startTopScroll = parseInt(scroller.css('margin-top'), 10);
|
579
|
+
h1 = scrollbar[0].offsetHeight;
|
580
|
+
|
581
|
+
if (event.type === 'mousedown') {
|
582
|
+
if (document) {
|
583
|
+
$(document.body).addClass('xdsoft_noselect');
|
584
|
+
}
|
585
|
+
$([document.body, window]).on('mouseup.xdsoft_scroller', function arguments_callee() {
|
586
|
+
$([document.body, window]).off('mouseup.xdsoft_scroller', arguments_callee)
|
587
|
+
.off('mousemove.xdsoft_scroller', calcOffset)
|
588
|
+
.removeClass('xdsoft_noselect');
|
589
|
+
});
|
590
|
+
$(document.body).on('mousemove.xdsoft_scroller', calcOffset);
|
591
|
+
} else {
|
592
|
+
touchStart = true;
|
593
|
+
event.stopPropagation();
|
594
|
+
event.preventDefault();
|
595
|
+
}
|
596
|
+
})
|
597
|
+
.on('touchmove', function (event) {
|
598
|
+
if (touchStart) {
|
599
|
+
event.preventDefault();
|
600
|
+
calcOffset(event);
|
601
|
+
}
|
602
|
+
})
|
603
|
+
.on('touchend touchcancel', function (event) {
|
604
|
+
touchStart = false;
|
605
|
+
startTopScroll = 0;
|
606
|
+
});
|
607
|
+
|
608
|
+
timeboxparent
|
609
|
+
.on('scroll_element.xdsoft_scroller', function (event, percentage) {
|
610
|
+
if (!parentHeight) {
|
611
|
+
timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
|
612
|
+
}
|
613
|
+
percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
|
614
|
+
|
615
|
+
scroller.css('margin-top', maximumOffset * percentage);
|
616
|
+
|
617
|
+
setTimeout(function () {
|
618
|
+
timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
|
619
|
+
}, 10);
|
620
|
+
})
|
621
|
+
.on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
|
622
|
+
var percent, sh;
|
623
|
+
parentHeight = timeboxparent[0].clientHeight;
|
624
|
+
height = timebox[0].offsetHeight;
|
625
|
+
percent = parentHeight / height;
|
626
|
+
sh = percent * scrollbar[0].offsetHeight;
|
627
|
+
if (percent > 1) {
|
628
|
+
scroller.hide();
|
629
|
+
} else {
|
630
|
+
scroller.show();
|
631
|
+
scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
|
632
|
+
maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
|
633
|
+
if (noTriggerScroll !== true) {
|
634
|
+
timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
|
635
|
+
}
|
636
|
+
}
|
637
|
+
});
|
638
|
+
|
639
|
+
timeboxparent.on('mousewheel', function (event) {
|
640
|
+
var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
|
641
|
+
|
642
|
+
top = top - (event.deltaY * 20);
|
643
|
+
if (top < 0) {
|
644
|
+
top = 0;
|
645
|
+
}
|
646
|
+
|
647
|
+
timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
|
648
|
+
event.stopPropagation();
|
649
|
+
return false;
|
650
|
+
});
|
651
|
+
|
652
|
+
timeboxparent.on('touchstart', function (event) {
|
653
|
+
start = pointerEventToXY(event);
|
654
|
+
startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
|
655
|
+
});
|
656
|
+
|
657
|
+
timeboxparent.on('touchmove', function (event) {
|
658
|
+
if (start) {
|
659
|
+
event.preventDefault();
|
660
|
+
var coord = pointerEventToXY(event);
|
661
|
+
timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
|
662
|
+
}
|
663
|
+
});
|
664
|
+
|
665
|
+
timeboxparent.on('touchend touchcancel', function (event) {
|
666
|
+
start = false;
|
667
|
+
startTop = 0;
|
668
|
+
});
|
669
|
+
}
|
670
|
+
timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
|
671
|
+
});
|
672
|
+
};
|
673
|
+
|
674
|
+
$.fn.datetimepicker = function (opt) {
|
675
|
+
var KEY0 = 48,
|
676
|
+
KEY9 = 57,
|
677
|
+
_KEY0 = 96,
|
678
|
+
_KEY9 = 105,
|
679
|
+
CTRLKEY = 17,
|
680
|
+
DEL = 46,
|
681
|
+
ENTER = 13,
|
682
|
+
ESC = 27,
|
683
|
+
BACKSPACE = 8,
|
684
|
+
ARROWLEFT = 37,
|
685
|
+
ARROWUP = 38,
|
686
|
+
ARROWRIGHT = 39,
|
687
|
+
ARROWDOWN = 40,
|
688
|
+
TAB = 9,
|
689
|
+
F5 = 116,
|
690
|
+
AKEY = 65,
|
691
|
+
CKEY = 67,
|
692
|
+
VKEY = 86,
|
693
|
+
ZKEY = 90,
|
694
|
+
YKEY = 89,
|
695
|
+
ctrlDown = false,
|
696
|
+
options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
|
697
|
+
|
698
|
+
lazyInitTimer = 0,
|
699
|
+
createDateTimePicker,
|
700
|
+
destroyDateTimePicker,
|
701
|
+
|
702
|
+
lazyInit = function (input) {
|
703
|
+
input
|
704
|
+
.on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initOnActionCallback(event) {
|
705
|
+
if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
|
706
|
+
return;
|
707
|
+
}
|
708
|
+
clearTimeout(lazyInitTimer);
|
709
|
+
lazyInitTimer = setTimeout(function () {
|
710
|
+
|
711
|
+
if (!input.data('xdsoft_datetimepicker')) {
|
712
|
+
createDateTimePicker(input);
|
713
|
+
}
|
714
|
+
input
|
715
|
+
.off('open.xdsoft focusin.xdsoft mousedown.xdsoft', initOnActionCallback)
|
716
|
+
.trigger('open.xdsoft');
|
717
|
+
}, 100);
|
718
|
+
});
|
719
|
+
};
|
720
|
+
|
721
|
+
createDateTimePicker = function (input) {
|
722
|
+
var datetimepicker = $('<div ' + (options.id ? 'id="' + options.id + '"' : '') + ' ' + (options.style ? 'style="' + options.style + '"' : '') + ' class="xdsoft_datetimepicker xdsoft_' + options.theme + ' xdsoft_noselect ' + (options.weeks ? ' xdsoft_showweeks' : '') + options.className + '"></div>'),
|
723
|
+
xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
|
724
|
+
datepicker = $('<div class="xdsoft_datepicker active"></div>'),
|
725
|
+
mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
|
726
|
+
'<div class="xdsoft_label xdsoft_month"><span></span><i></i></div>' +
|
727
|
+
'<div class="xdsoft_label xdsoft_year"><span></span><i></i></div>' +
|
728
|
+
'<button type="button" class="xdsoft_next"></button></div>'),
|
729
|
+
calendar = $('<div class="xdsoft_calendar"></div>'),
|
730
|
+
timepicker = $('<div class="xdsoft_timepicker active"><button type="button" class="xdsoft_prev"></button><div class="xdsoft_time_box"></div><button type="button" class="xdsoft_next"></button></div>'),
|
731
|
+
timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
|
732
|
+
timebox = $('<div class="xdsoft_time_variant"></div>'),
|
733
|
+
/*scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
|
734
|
+
scroller = $('<div class="xdsoft_scroller"></div>'),*/
|
735
|
+
monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
|
736
|
+
yearselect = $('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'),
|
737
|
+
triggerAfterOpen = false,
|
738
|
+
XDSoft_datetime,
|
739
|
+
//scroll_element,
|
740
|
+
xchangeTimer,
|
741
|
+
timerclick,
|
742
|
+
current_time_index,
|
743
|
+
setPos,
|
744
|
+
timer = 0,
|
745
|
+
timer1 = 0,
|
746
|
+
_xdsoft_datetime;
|
747
|
+
|
748
|
+
mounth_picker
|
749
|
+
.find('.xdsoft_month span')
|
750
|
+
.after(monthselect);
|
751
|
+
mounth_picker
|
752
|
+
.find('.xdsoft_year span')
|
753
|
+
.after(yearselect);
|
754
|
+
|
755
|
+
mounth_picker
|
756
|
+
.find('.xdsoft_month,.xdsoft_year')
|
757
|
+
.on('mousedown.xdsoft', function (event) {
|
758
|
+
var select = $(this).find('.xdsoft_select').eq(0),
|
759
|
+
val = 0,
|
760
|
+
top = 0,
|
761
|
+
visible = select.is(':visible'),
|
762
|
+
items,
|
763
|
+
i;
|
764
|
+
|
765
|
+
mounth_picker
|
766
|
+
.find('.xdsoft_select')
|
767
|
+
.hide();
|
768
|
+
if (_xdsoft_datetime.currentTime) {
|
769
|
+
val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
|
770
|
+
}
|
771
|
+
|
772
|
+
select[visible ? 'hide' : 'show']();
|
773
|
+
for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
|
774
|
+
if (items.eq(i).data('value') === val) {
|
775
|
+
break;
|
776
|
+
} else {
|
777
|
+
top += items[0].offsetHeight;
|
778
|
+
}
|
779
|
+
}
|
780
|
+
|
781
|
+
select.xdsoftScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
|
782
|
+
event.stopPropagation();
|
783
|
+
return false;
|
784
|
+
});
|
785
|
+
|
786
|
+
mounth_picker
|
787
|
+
.find('.xdsoft_select')
|
788
|
+
.xdsoftScroller()
|
789
|
+
.on('mousedown.xdsoft', function (event) {
|
790
|
+
event.stopPropagation();
|
791
|
+
event.preventDefault();
|
792
|
+
})
|
793
|
+
.on('mousedown.xdsoft', '.xdsoft_option', function (event) {
|
794
|
+
var year = _xdsoft_datetime.currentTime.getFullYear();
|
795
|
+
if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
|
796
|
+
_xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
|
797
|
+
}
|
798
|
+
|
799
|
+
$(this).parent().parent().hide();
|
800
|
+
|
801
|
+
datetimepicker.trigger('xchange.xdsoft');
|
802
|
+
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
|
803
|
+
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
804
|
+
}
|
805
|
+
|
806
|
+
if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
|
807
|
+
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
808
|
+
}
|
809
|
+
});
|
810
|
+
|
811
|
+
datetimepicker.setOptions = function (_options) {
|
812
|
+
options = $.extend(true, {}, options, _options);
|
813
|
+
|
814
|
+
if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
|
815
|
+
options.allowTimes = $.extend(true, [], _options.allowTimes);
|
816
|
+
}
|
817
|
+
|
818
|
+
if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
|
819
|
+
options.weekends = $.extend(true, [], _options.weekends);
|
820
|
+
}
|
821
|
+
|
822
|
+
if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
|
823
|
+
options.disabledDates = $.extend(true, [], _options.disabledDates);
|
824
|
+
}
|
825
|
+
|
826
|
+
if ((options.open || options.opened) && (!options.inline)) {
|
827
|
+
input.trigger('open.xdsoft');
|
828
|
+
}
|
829
|
+
|
830
|
+
if (options.inline) {
|
831
|
+
triggerAfterOpen = true;
|
832
|
+
datetimepicker.addClass('xdsoft_inline');
|
833
|
+
input.after(datetimepicker).hide();
|
834
|
+
}
|
835
|
+
|
836
|
+
if (options.inverseButton) {
|
837
|
+
options.next = 'xdsoft_prev';
|
838
|
+
options.prev = 'xdsoft_next';
|
839
|
+
}
|
840
|
+
|
841
|
+
if (options.datepicker) {
|
842
|
+
datepicker.addClass('active');
|
843
|
+
} else {
|
844
|
+
datepicker.removeClass('active');
|
845
|
+
}
|
846
|
+
|
847
|
+
if (options.timepicker) {
|
848
|
+
timepicker.addClass('active');
|
849
|
+
} else {
|
850
|
+
timepicker.removeClass('active');
|
851
|
+
}
|
852
|
+
|
853
|
+
if (options.value) {
|
854
|
+
if (input && input.val) {
|
855
|
+
input.val(options.value);
|
856
|
+
}
|
857
|
+
_xdsoft_datetime.setCurrentTime(options.value);
|
858
|
+
}
|
859
|
+
|
860
|
+
if (isNaN(options.dayOfWeekStart)) {
|
861
|
+
options.dayOfWeekStart = 0;
|
862
|
+
} else {
|
863
|
+
options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
|
864
|
+
}
|
865
|
+
|
866
|
+
if (!options.timepickerScrollbar) {
|
867
|
+
timeboxparent.xdsoftScroller('hide');
|
868
|
+
}
|
869
|
+
|
870
|
+
if (options.minDate && /^-(.*)$/.test(options.minDate)) {
|
871
|
+
options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
|
872
|
+
}
|
873
|
+
|
874
|
+
if (options.maxDate && /^\+(.*)$/.test(options.maxDate)) {
|
875
|
+
options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
|
876
|
+
}
|
877
|
+
|
878
|
+
mounth_picker
|
879
|
+
.find('.xdsoft_today_button')
|
880
|
+
.css('visibility', !options.todayButton ? 'hidden' : 'visible');
|
881
|
+
|
882
|
+
if (options.mask) {
|
883
|
+
var e,
|
884
|
+
getCaretPos = function (input) {
|
885
|
+
try {
|
886
|
+
if (document.selection && document.selection.createRange) {
|
887
|
+
var range = document.selection.createRange();
|
888
|
+
return range.getBookmark().charCodeAt(2) - 2;
|
889
|
+
}
|
890
|
+
if (input.setSelectionRange) {
|
891
|
+
return input.selectionStart;
|
892
|
+
}
|
893
|
+
} catch (e) {
|
894
|
+
return 0;
|
895
|
+
}
|
896
|
+
},
|
897
|
+
setCaretPos = function (node, pos) {
|
898
|
+
node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
|
899
|
+
if (!node) {
|
900
|
+
return false;
|
901
|
+
}
|
902
|
+
if (node.createTextRange) {
|
903
|
+
var textRange = node.createTextRange();
|
904
|
+
textRange.collapse(true);
|
905
|
+
textRange.moveEnd('character', pos);
|
906
|
+
textRange.moveStart('character', pos);
|
907
|
+
textRange.select();
|
908
|
+
return true;
|
909
|
+
}
|
910
|
+
if (node.setSelectionRange) {
|
911
|
+
node.setSelectionRange(pos, pos);
|
912
|
+
return true;
|
913
|
+
}
|
914
|
+
return false;
|
915
|
+
},
|
916
|
+
isValidValue = function (mask, value) {
|
917
|
+
var reg = mask
|
918
|
+
.replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
|
919
|
+
.replace(/_/g, '{digit+}')
|
920
|
+
.replace(/([0-9]{1})/g, '{digit$1}')
|
921
|
+
.replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
|
922
|
+
.replace(/\{digit[\+]\}/g, '[0-9_]{1}');
|
923
|
+
return (new RegExp(reg)).test(value);
|
924
|
+
};
|
925
|
+
input.off('keydown.xdsoft');
|
926
|
+
|
927
|
+
if (options.mask === true) {
|
928
|
+
options.mask = options.format
|
929
|
+
.replace(/Y/g, '9999')
|
930
|
+
.replace(/F/g, '9999')
|
931
|
+
.replace(/m/g, '19')
|
932
|
+
.replace(/d/g, '39')
|
933
|
+
.replace(/H/g, '29')
|
934
|
+
.replace(/i/g, '59')
|
935
|
+
.replace(/s/g, '59');
|
936
|
+
}
|
937
|
+
|
938
|
+
if ($.type(options.mask) === 'string') {
|
939
|
+
if (!isValidValue(options.mask, input.val())) {
|
940
|
+
input.val(options.mask.replace(/[0-9]/g, '_'));
|
941
|
+
}
|
942
|
+
|
943
|
+
input.on('keydown.xdsoft', function (event) {
|
944
|
+
var val = this.value,
|
945
|
+
key = event.which,
|
946
|
+
pos,
|
947
|
+
digit;
|
948
|
+
|
949
|
+
if (((key >= KEY0 && key <= KEY9) || (key >= _KEY0 && key <= _KEY9)) || (key === BACKSPACE || key === DEL)) {
|
950
|
+
pos = getCaretPos(this);
|
951
|
+
digit = (key !== BACKSPACE && key !== DEL) ? String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key) : '_';
|
952
|
+
|
953
|
+
if ((key === BACKSPACE || key === DEL) && pos) {
|
954
|
+
pos -= 1;
|
955
|
+
digit = '_';
|
956
|
+
}
|
957
|
+
|
958
|
+
while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
|
959
|
+
pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
|
960
|
+
}
|
961
|
+
|
962
|
+
val = val.substr(0, pos) + digit + val.substr(pos + 1);
|
963
|
+
if ($.trim(val) === '') {
|
964
|
+
val = options.mask.replace(/[0-9]/g, '_');
|
965
|
+
} else {
|
966
|
+
if (pos === options.mask.length) {
|
967
|
+
event.preventDefault();
|
968
|
+
return false;
|
969
|
+
}
|
970
|
+
}
|
971
|
+
|
972
|
+
pos += (key === BACKSPACE || key === DEL) ? 0 : 1;
|
973
|
+
while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
|
974
|
+
pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
|
975
|
+
}
|
976
|
+
|
977
|
+
if (isValidValue(options.mask, val)) {
|
978
|
+
this.value = val;
|
979
|
+
setCaretPos(this, pos);
|
980
|
+
} else if ($.trim(val) === '') {
|
981
|
+
this.value = options.mask.replace(/[0-9]/g, '_');
|
982
|
+
} else {
|
983
|
+
input.trigger('error_input.xdsoft');
|
984
|
+
}
|
985
|
+
} else {
|
986
|
+
if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
|
987
|
+
return true;
|
988
|
+
}
|
989
|
+
}
|
990
|
+
|
991
|
+
event.preventDefault();
|
992
|
+
return false;
|
993
|
+
});
|
994
|
+
}
|
995
|
+
}
|
996
|
+
if (options.validateOnBlur) {
|
997
|
+
input
|
998
|
+
.off('blur.xdsoft')
|
999
|
+
.on('blur.xdsoft', function () {
|
1000
|
+
if (options.allowBlank && !$.trim($(this).val()).length) {
|
1001
|
+
$(this).val(null);
|
1002
|
+
datetimepicker.data('xdsoft_datetime').empty();
|
1003
|
+
} else if (!Date.parseDate($(this).val(), options.format)) {
|
1004
|
+
var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
|
1005
|
+
splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
|
1006
|
+
|
1007
|
+
// parse the numbers as 0312 => 03:12
|
1008
|
+
if(!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
|
1009
|
+
$(this).val([splittedHours, splittedMinutes].map(function(item) {
|
1010
|
+
return item > 9 ? item : '0' + item
|
1011
|
+
}).join(':'));
|
1012
|
+
} else {
|
1013
|
+
$(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
|
1017
|
+
} else {
|
1018
|
+
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
datetimepicker.trigger('changedatetime.xdsoft');
|
1022
|
+
});
|
1023
|
+
}
|
1024
|
+
options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
|
1025
|
+
|
1026
|
+
datetimepicker
|
1027
|
+
.trigger('xchange.xdsoft')
|
1028
|
+
.trigger('afterOpen.xdsoft');
|
1029
|
+
};
|
1030
|
+
|
1031
|
+
datetimepicker
|
1032
|
+
.data('options', options)
|
1033
|
+
.on('mousedown.xdsoft', function (event) {
|
1034
|
+
event.stopPropagation();
|
1035
|
+
event.preventDefault();
|
1036
|
+
yearselect.hide();
|
1037
|
+
monthselect.hide();
|
1038
|
+
return false;
|
1039
|
+
});
|
1040
|
+
|
1041
|
+
//scroll_element = timepicker.find('.xdsoft_time_box');
|
1042
|
+
timeboxparent.append(timebox);
|
1043
|
+
timeboxparent.xdsoftScroller();
|
1044
|
+
|
1045
|
+
datetimepicker.on('afterOpen.xdsoft', function () {
|
1046
|
+
timeboxparent.xdsoftScroller();
|
1047
|
+
});
|
1048
|
+
|
1049
|
+
datetimepicker
|
1050
|
+
.append(datepicker)
|
1051
|
+
.append(timepicker);
|
1052
|
+
|
1053
|
+
if (options.withoutCopyright !== true) {
|
1054
|
+
datetimepicker
|
1055
|
+
.append(xdsoft_copyright);
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
datepicker
|
1059
|
+
.append(mounth_picker)
|
1060
|
+
.append(calendar);
|
1061
|
+
|
1062
|
+
$(options.parentID)
|
1063
|
+
.append(datetimepicker);
|
1064
|
+
|
1065
|
+
XDSoft_datetime = function () {
|
1066
|
+
var _this = this;
|
1067
|
+
_this.now = function (norecursion) {
|
1068
|
+
var d = new Date(),
|
1069
|
+
date,
|
1070
|
+
time;
|
1071
|
+
|
1072
|
+
if (!norecursion && options.defaultDate) {
|
1073
|
+
date = _this.strToDate(options.defaultDate);
|
1074
|
+
d.setFullYear(date.getFullYear());
|
1075
|
+
d.setMonth(date.getMonth());
|
1076
|
+
d.setDate(date.getDate());
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
if (options.yearOffset) {
|
1080
|
+
d.setFullYear(d.getFullYear() + options.yearOffset);
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
if (!norecursion && options.defaultTime) {
|
1084
|
+
time = _this.strtotime(options.defaultTime);
|
1085
|
+
d.setHours(time.getHours());
|
1086
|
+
d.setMinutes(time.getMinutes());
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
return d;
|
1090
|
+
};
|
1091
|
+
|
1092
|
+
_this.isValidDate = function (d) {
|
1093
|
+
if (Object.prototype.toString.call(d) !== "[object Date]") {
|
1094
|
+
return false;
|
1095
|
+
}
|
1096
|
+
return !isNaN(d.getTime());
|
1097
|
+
};
|
1098
|
+
|
1099
|
+
_this.setCurrentTime = function (dTime) {
|
1100
|
+
_this.currentTime = (typeof dTime === 'string') ? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime : _this.now();
|
1101
|
+
datetimepicker.trigger('xchange.xdsoft');
|
1102
|
+
};
|
1103
|
+
|
1104
|
+
_this.empty = function () {
|
1105
|
+
_this.currentTime = null;
|
1106
|
+
};
|
1107
|
+
|
1108
|
+
_this.getCurrentTime = function (dTime) {
|
1109
|
+
return _this.currentTime;
|
1110
|
+
};
|
1111
|
+
|
1112
|
+
_this.nextMonth = function () {
|
1113
|
+
var month = _this.currentTime.getMonth() + 1,
|
1114
|
+
year;
|
1115
|
+
if (month === 12) {
|
1116
|
+
_this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
|
1117
|
+
month = 0;
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
year = _this.currentTime.getFullYear();
|
1121
|
+
|
1122
|
+
_this.currentTime.setDate(
|
1123
|
+
Math.min(
|
1124
|
+
new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
|
1125
|
+
_this.currentTime.getDate()
|
1126
|
+
)
|
1127
|
+
);
|
1128
|
+
_this.currentTime.setMonth(month);
|
1129
|
+
|
1130
|
+
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
|
1131
|
+
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
|
1135
|
+
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
datetimepicker.trigger('xchange.xdsoft');
|
1139
|
+
return month;
|
1140
|
+
};
|
1141
|
+
|
1142
|
+
_this.prevMonth = function () {
|
1143
|
+
var month = _this.currentTime.getMonth() - 1;
|
1144
|
+
if (month === -1) {
|
1145
|
+
_this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
|
1146
|
+
month = 11;
|
1147
|
+
}
|
1148
|
+
_this.currentTime.setDate(
|
1149
|
+
Math.min(
|
1150
|
+
new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
|
1151
|
+
_this.currentTime.getDate()
|
1152
|
+
)
|
1153
|
+
);
|
1154
|
+
_this.currentTime.setMonth(month);
|
1155
|
+
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
|
1156
|
+
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
1157
|
+
}
|
1158
|
+
datetimepicker.trigger('xchange.xdsoft');
|
1159
|
+
return month;
|
1160
|
+
};
|
1161
|
+
|
1162
|
+
_this.getWeekOfYear = function (datetime) {
|
1163
|
+
var onejan = new Date(datetime.getFullYear(), 0, 1);
|
1164
|
+
return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
|
1165
|
+
};
|
1166
|
+
|
1167
|
+
_this.strToDateTime = function (sDateTime) {
|
1168
|
+
var tmpDate = [], timeOffset, currentTime;
|
1169
|
+
|
1170
|
+
if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
|
1171
|
+
return sDateTime;
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime);
|
1175
|
+
if (tmpDate) {
|
1176
|
+
tmpDate[2] = Date.parseDate(tmpDate[2], options.formatDate);
|
1177
|
+
}
|
1178
|
+
if (tmpDate && tmpDate[2]) {
|
1179
|
+
timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
|
1180
|
+
currentTime = new Date((_xdsoft_datetime.now()).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
|
1181
|
+
} else {
|
1182
|
+
currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
if (!_this.isValidDate(currentTime)) {
|
1186
|
+
currentTime = _this.now();
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
return currentTime;
|
1190
|
+
};
|
1191
|
+
|
1192
|
+
_this.strToDate = function (sDate) {
|
1193
|
+
if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
|
1194
|
+
return sDate;
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
var currentTime = sDate ? Date.parseDate(sDate, options.formatDate) : _this.now(true);
|
1198
|
+
if (!_this.isValidDate(currentTime)) {
|
1199
|
+
currentTime = _this.now(true);
|
1200
|
+
}
|
1201
|
+
return currentTime;
|
1202
|
+
};
|
1203
|
+
|
1204
|
+
_this.strtotime = function (sTime) {
|
1205
|
+
if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
|
1206
|
+
return sTime;
|
1207
|
+
}
|
1208
|
+
var currentTime = sTime ? Date.parseDate(sTime, options.formatTime) : _this.now(true);
|
1209
|
+
if (!_this.isValidDate(currentTime)) {
|
1210
|
+
currentTime = _this.now(true);
|
1211
|
+
}
|
1212
|
+
return currentTime;
|
1213
|
+
};
|
1214
|
+
|
1215
|
+
_this.str = function () {
|
1216
|
+
return _this.currentTime.dateFormat(options.format);
|
1217
|
+
};
|
1218
|
+
_this.currentTime = this.now();
|
1219
|
+
};
|
1220
|
+
|
1221
|
+
_xdsoft_datetime = new XDSoft_datetime();
|
1222
|
+
|
1223
|
+
mounth_picker
|
1224
|
+
.find('.xdsoft_today_button')
|
1225
|
+
.on('mousedown.xdsoft', function () {
|
1226
|
+
datetimepicker.data('changed', true);
|
1227
|
+
_xdsoft_datetime.setCurrentTime(0);
|
1228
|
+
datetimepicker.trigger('afterOpen.xdsoft');
|
1229
|
+
}).on('dblclick.xdsoft', function () {
|
1230
|
+
input.val(_xdsoft_datetime.str());
|
1231
|
+
datetimepicker.trigger('close.xdsoft');
|
1232
|
+
});
|
1233
|
+
mounth_picker
|
1234
|
+
.find('.xdsoft_prev,.xdsoft_next')
|
1235
|
+
.on('mousedown.xdsoft', function () {
|
1236
|
+
var $this = $(this),
|
1237
|
+
timer = 0,
|
1238
|
+
stop = false;
|
1239
|
+
|
1240
|
+
(function arguments_callee1(v) {
|
1241
|
+
var month = _xdsoft_datetime.currentTime.getMonth();
|
1242
|
+
if ($this.hasClass(options.next)) {
|
1243
|
+
_xdsoft_datetime.nextMonth();
|
1244
|
+
} else if ($this.hasClass(options.prev)) {
|
1245
|
+
_xdsoft_datetime.prevMonth();
|
1246
|
+
}
|
1247
|
+
if (options.monthChangeSpinner) {
|
1248
|
+
if (!stop) {
|
1249
|
+
timer = setTimeout(arguments_callee1, v || 100);
|
1250
|
+
}
|
1251
|
+
}
|
1252
|
+
}(500));
|
1253
|
+
|
1254
|
+
$([document.body, window]).on('mouseup.xdsoft', function arguments_callee2() {
|
1255
|
+
clearTimeout(timer);
|
1256
|
+
stop = true;
|
1257
|
+
$([document.body, window]).off('mouseup.xdsoft', arguments_callee2);
|
1258
|
+
});
|
1259
|
+
});
|
1260
|
+
|
1261
|
+
timepicker
|
1262
|
+
.find('.xdsoft_prev,.xdsoft_next')
|
1263
|
+
.on('mousedown.xdsoft', function () {
|
1264
|
+
var $this = $(this),
|
1265
|
+
timer = 0,
|
1266
|
+
stop = false,
|
1267
|
+
period = 110;
|
1268
|
+
(function arguments_callee4(v) {
|
1269
|
+
var pheight = timeboxparent[0].clientHeight,
|
1270
|
+
height = timebox[0].offsetHeight,
|
1271
|
+
top = Math.abs(parseInt(timebox.css('marginTop'), 10));
|
1272
|
+
if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
|
1273
|
+
timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
|
1274
|
+
} else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
|
1275
|
+
timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
|
1276
|
+
}
|
1277
|
+
timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox.css('marginTop'), 10) / (height - pheight))]);
|
1278
|
+
period = (period > 10) ? 10 : period - 10;
|
1279
|
+
if (!stop) {
|
1280
|
+
timer = setTimeout(arguments_callee4, v || period);
|
1281
|
+
}
|
1282
|
+
}(500));
|
1283
|
+
$([document.body, window]).on('mouseup.xdsoft', function arguments_callee5() {
|
1284
|
+
clearTimeout(timer);
|
1285
|
+
stop = true;
|
1286
|
+
$([document.body, window])
|
1287
|
+
.off('mouseup.xdsoft', arguments_callee5);
|
1288
|
+
});
|
1289
|
+
});
|
1290
|
+
|
1291
|
+
xchangeTimer = 0;
|
1292
|
+
// base handler - generating a calendar and timepicker
|
1293
|
+
datetimepicker
|
1294
|
+
.on('xchange.xdsoft', function (event) {
|
1295
|
+
clearTimeout(xchangeTimer);
|
1296
|
+
xchangeTimer = setTimeout(function () {
|
1297
|
+
var table = '',
|
1298
|
+
start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
|
1299
|
+
i = 0,
|
1300
|
+
j,
|
1301
|
+
today = _xdsoft_datetime.now(),
|
1302
|
+
maxDate = false,
|
1303
|
+
minDate = false,
|
1304
|
+
d,
|
1305
|
+
y,
|
1306
|
+
m,
|
1307
|
+
w,
|
1308
|
+
classes = [],
|
1309
|
+
customDateSettings,
|
1310
|
+
newRow = true,
|
1311
|
+
time = '',
|
1312
|
+
h = '',
|
1313
|
+
line_time;
|
1314
|
+
|
1315
|
+
while (start.getDay() !== options.dayOfWeekStart) {
|
1316
|
+
start.setDate(start.getDate() - 1);
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
table += '<table><thead><tr>';
|
1320
|
+
|
1321
|
+
if (options.weeks) {
|
1322
|
+
table += '<th></th>';
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
for (j = 0; j < 7; j += 1) {
|
1326
|
+
table += '<th>' + options.i18n[options.lang].dayOfWeek[(j + options.dayOfWeekStart) % 7] + '</th>';
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
table += '</tr></thead>';
|
1330
|
+
table += '<tbody>';
|
1331
|
+
|
1332
|
+
if (options.maxDate !== false) {
|
1333
|
+
maxDate = _xdsoft_datetime.strToDate(options.maxDate);
|
1334
|
+
maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
if (options.minDate !== false) {
|
1338
|
+
minDate = _xdsoft_datetime.strToDate(options.minDate);
|
1339
|
+
minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
|
1340
|
+
}
|
1341
|
+
|
1342
|
+
while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
|
1343
|
+
classes = [];
|
1344
|
+
i += 1;
|
1345
|
+
|
1346
|
+
d = start.getDate();
|
1347
|
+
y = start.getFullYear();
|
1348
|
+
m = start.getMonth();
|
1349
|
+
w = _xdsoft_datetime.getWeekOfYear(start);
|
1350
|
+
|
1351
|
+
classes.push('xdsoft_date');
|
1352
|
+
|
1353
|
+
if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
|
1354
|
+
customDateSettings = options.beforeShowDay.call(datetimepicker, start);
|
1355
|
+
} else {
|
1356
|
+
customDateSettings = null;
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
if ((maxDate !== false && start > maxDate) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
|
1360
|
+
classes.push('xdsoft_disabled');
|
1361
|
+
} else if (options.disabledDates.indexOf(start.dateFormat(options.formatDate)) !== -1) {
|
1362
|
+
classes.push('xdsoft_disabled');
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
if (customDateSettings && customDateSettings[1] !== "") {
|
1366
|
+
classes.push(customDateSettings[1]);
|
1367
|
+
}
|
1368
|
+
|
1369
|
+
if (_xdsoft_datetime.currentTime.getMonth() !== m) {
|
1370
|
+
classes.push('xdsoft_other_month');
|
1371
|
+
}
|
1372
|
+
|
1373
|
+
if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
|
1374
|
+
classes.push('xdsoft_current');
|
1375
|
+
}
|
1376
|
+
|
1377
|
+
if (today.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
|
1378
|
+
classes.push('xdsoft_today');
|
1379
|
+
}
|
1380
|
+
|
1381
|
+
if (start.getDay() === 0 || start.getDay() === 6 || ~options.weekends.indexOf(start.dateFormat(options.formatDate))) {
|
1382
|
+
classes.push('xdsoft_weekend');
|
1383
|
+
}
|
1384
|
+
|
1385
|
+
if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
|
1386
|
+
classes.push(options.beforeShowDay(start));
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
if (newRow) {
|
1390
|
+
table += '<tr>';
|
1391
|
+
newRow = false;
|
1392
|
+
if (options.weeks) {
|
1393
|
+
table += '<th>' + w + '</th>';
|
1394
|
+
}
|
1395
|
+
}
|
1396
|
+
|
1397
|
+
table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '">' +
|
1398
|
+
'<div>' + d + '</div>' +
|
1399
|
+
'</td>';
|
1400
|
+
|
1401
|
+
if (start.getDay() === options.dayOfWeekStartPrev) {
|
1402
|
+
table += '</tr>';
|
1403
|
+
newRow = true;
|
1404
|
+
}
|
1405
|
+
|
1406
|
+
start.setDate(d + 1);
|
1407
|
+
}
|
1408
|
+
table += '</tbody></table>';
|
1409
|
+
|
1410
|
+
calendar.html(table);
|
1411
|
+
|
1412
|
+
mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
|
1413
|
+
mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
|
1414
|
+
|
1415
|
+
// generate timebox
|
1416
|
+
time = '';
|
1417
|
+
h = '';
|
1418
|
+
m = '';
|
1419
|
+
line_time = function line_time(h, m) {
|
1420
|
+
var now = _xdsoft_datetime.now();
|
1421
|
+
now.setHours(h);
|
1422
|
+
h = parseInt(now.getHours(), 10);
|
1423
|
+
now.setMinutes(m);
|
1424
|
+
m = parseInt(now.getMinutes(), 10);
|
1425
|
+
var optionDateTime = new Date(_xdsoft_datetime.currentTime);
|
1426
|
+
optionDateTime.setHours(h);
|
1427
|
+
optionDateTime.setMinutes(m);
|
1428
|
+
classes = [];
|
1429
|
+
if((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
|
1430
|
+
classes.push('xdsoft_disabled');
|
1431
|
+
}
|
1432
|
+
if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
|
1433
|
+
if (options.defaultSelect || datetimepicker.data('changed')) {
|
1434
|
+
classes.push('xdsoft_current');
|
1435
|
+
} else if (options.initTime) {
|
1436
|
+
classes.push('xdsoft_init_time');
|
1437
|
+
}
|
1438
|
+
}
|
1439
|
+
if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
|
1440
|
+
classes.push('xdsoft_today');
|
1441
|
+
}
|
1442
|
+
time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + now.dateFormat(options.formatTime) + '</div>';
|
1443
|
+
};
|
1444
|
+
|
1445
|
+
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
|
1446
|
+
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
|
1447
|
+
for (j = 0; j < 60; j += options.step) {
|
1448
|
+
h = (i < 10 ? '0' : '') + i;
|
1449
|
+
m = (j < 10 ? '0' : '') + j;
|
1450
|
+
line_time(h, m);
|
1451
|
+
}
|
1452
|
+
}
|
1453
|
+
} else {
|
1454
|
+
for (i = 0; i < options.allowTimes.length; i += 1) {
|
1455
|
+
h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
|
1456
|
+
m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
|
1457
|
+
line_time(h, m);
|
1458
|
+
}
|
1459
|
+
}
|
1460
|
+
|
1461
|
+
timebox.html(time);
|
1462
|
+
|
1463
|
+
opt = '';
|
1464
|
+
i = 0;
|
1465
|
+
|
1466
|
+
for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
|
1467
|
+
opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getFullYear() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + i + '</div>';
|
1468
|
+
}
|
1469
|
+
yearselect.children().eq(0)
|
1470
|
+
.html(opt);
|
1471
|
+
|
1472
|
+
for (i = 0, opt = ''; i <= 11; i += 1) {
|
1473
|
+
opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[options.lang].months[i] + '</div>';
|
1474
|
+
}
|
1475
|
+
monthselect.children().eq(0).html(opt);
|
1476
|
+
$(datetimepicker)
|
1477
|
+
.trigger('generate.xdsoft');
|
1478
|
+
}, 10);
|
1479
|
+
event.stopPropagation();
|
1480
|
+
})
|
1481
|
+
.on('afterOpen.xdsoft', function () {
|
1482
|
+
if (options.timepicker) {
|
1483
|
+
var classType, pheight, height, top;
|
1484
|
+
if (timebox.find('.xdsoft_current').length) {
|
1485
|
+
classType = '.xdsoft_current';
|
1486
|
+
} else if (timebox.find('.xdsoft_init_time').length) {
|
1487
|
+
classType = '.xdsoft_init_time';
|
1488
|
+
}
|
1489
|
+
if (classType) {
|
1490
|
+
pheight = timeboxparent[0].clientHeight;
|
1491
|
+
height = timebox[0].offsetHeight;
|
1492
|
+
top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
|
1493
|
+
if ((height - pheight) < top) {
|
1494
|
+
top = height - pheight;
|
1495
|
+
}
|
1496
|
+
timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
|
1497
|
+
} else {
|
1498
|
+
timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
|
1499
|
+
}
|
1500
|
+
}
|
1501
|
+
});
|
1502
|
+
|
1503
|
+
timerclick = 0;
|
1504
|
+
calendar
|
1505
|
+
.on('click.xdsoft', 'td', function (xdevent) {
|
1506
|
+
xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
|
1507
|
+
timerclick += 1;
|
1508
|
+
var $this = $(this),
|
1509
|
+
currentTime = _xdsoft_datetime.currentTime;
|
1510
|
+
|
1511
|
+
if (currentTime === undefined || currentTime === null) {
|
1512
|
+
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
|
1513
|
+
currentTime = _xdsoft_datetime.currentTime;
|
1514
|
+
}
|
1515
|
+
|
1516
|
+
if ($this.hasClass('xdsoft_disabled')) {
|
1517
|
+
return false;
|
1518
|
+
}
|
1519
|
+
|
1520
|
+
currentTime.setDate(1);
|
1521
|
+
currentTime.setFullYear($this.data('year'));
|
1522
|
+
currentTime.setMonth($this.data('month'));
|
1523
|
+
currentTime.setDate($this.data('date'));
|
1524
|
+
|
1525
|
+
datetimepicker.trigger('select.xdsoft', [currentTime]);
|
1526
|
+
|
1527
|
+
input.val(_xdsoft_datetime.str());
|
1528
|
+
if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === 0 && !options.timepicker))) && !options.inline) {
|
1529
|
+
datetimepicker.trigger('close.xdsoft');
|
1530
|
+
}
|
1531
|
+
|
1532
|
+
if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
|
1533
|
+
options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
|
1534
|
+
}
|
1535
|
+
|
1536
|
+
datetimepicker.data('changed', true);
|
1537
|
+
datetimepicker.trigger('xchange.xdsoft');
|
1538
|
+
datetimepicker.trigger('changedatetime.xdsoft');
|
1539
|
+
setTimeout(function () {
|
1540
|
+
timerclick = 0;
|
1541
|
+
}, 200);
|
1542
|
+
});
|
1543
|
+
|
1544
|
+
timebox
|
1545
|
+
.on('click.xdsoft', 'div', function (xdevent) {
|
1546
|
+
xdevent.stopPropagation();
|
1547
|
+
var $this = $(this),
|
1548
|
+
currentTime = _xdsoft_datetime.currentTime;
|
1549
|
+
|
1550
|
+
if (currentTime === undefined || currentTime === null) {
|
1551
|
+
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
|
1552
|
+
currentTime = _xdsoft_datetime.currentTime;
|
1553
|
+
}
|
1554
|
+
|
1555
|
+
if ($this.hasClass('xdsoft_disabled')) {
|
1556
|
+
return false;
|
1557
|
+
}
|
1558
|
+
currentTime.setHours($this.data('hour'));
|
1559
|
+
currentTime.setMinutes($this.data('minute'));
|
1560
|
+
datetimepicker.trigger('select.xdsoft', [currentTime]);
|
1561
|
+
|
1562
|
+
datetimepicker.data('input').val(_xdsoft_datetime.str());
|
1563
|
+
if (!options.inline) {
|
1564
|
+
datetimepicker.trigger('close.xdsoft');
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
|
1568
|
+
options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
|
1569
|
+
}
|
1570
|
+
datetimepicker.data('changed', true);
|
1571
|
+
datetimepicker.trigger('xchange.xdsoft');
|
1572
|
+
datetimepicker.trigger('changedatetime.xdsoft');
|
1573
|
+
});
|
1574
|
+
|
1575
|
+
|
1576
|
+
datepicker
|
1577
|
+
.on('mousewheel.xdsoft', function (event) {
|
1578
|
+
if (!options.scrollMonth) {
|
1579
|
+
return true;
|
1580
|
+
}
|
1581
|
+
if (event.deltaY < 0) {
|
1582
|
+
_xdsoft_datetime.nextMonth();
|
1583
|
+
} else {
|
1584
|
+
_xdsoft_datetime.prevMonth();
|
1585
|
+
}
|
1586
|
+
return false;
|
1587
|
+
});
|
1588
|
+
|
1589
|
+
input
|
1590
|
+
.on('mousewheel.xdsoft', function (event) {
|
1591
|
+
if (!options.scrollInput) {
|
1592
|
+
return true;
|
1593
|
+
}
|
1594
|
+
if (!options.datepicker && options.timepicker) {
|
1595
|
+
current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
|
1596
|
+
if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
|
1597
|
+
current_time_index += event.deltaY;
|
1598
|
+
}
|
1599
|
+
if (timebox.children().eq(current_time_index).length) {
|
1600
|
+
timebox.children().eq(current_time_index).trigger('mousedown');
|
1601
|
+
}
|
1602
|
+
return false;
|
1603
|
+
}
|
1604
|
+
if (options.datepicker && !options.timepicker) {
|
1605
|
+
datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
|
1606
|
+
if (input.val) {
|
1607
|
+
input.val(_xdsoft_datetime.str());
|
1608
|
+
}
|
1609
|
+
datetimepicker.trigger('changedatetime.xdsoft');
|
1610
|
+
return false;
|
1611
|
+
}
|
1612
|
+
});
|
1613
|
+
|
1614
|
+
datetimepicker
|
1615
|
+
.on('changedatetime.xdsoft', function (event) {
|
1616
|
+
if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
|
1617
|
+
var $input = datetimepicker.data('input');
|
1618
|
+
options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
|
1619
|
+
delete options.value;
|
1620
|
+
$input.trigger('change');
|
1621
|
+
}
|
1622
|
+
})
|
1623
|
+
.on('generate.xdsoft', function () {
|
1624
|
+
if (options.onGenerate && $.isFunction(options.onGenerate)) {
|
1625
|
+
options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
|
1626
|
+
}
|
1627
|
+
if (triggerAfterOpen) {
|
1628
|
+
datetimepicker.trigger('afterOpen.xdsoft');
|
1629
|
+
triggerAfterOpen = false;
|
1630
|
+
}
|
1631
|
+
})
|
1632
|
+
.on('click.xdsoft', function (xdevent) {
|
1633
|
+
xdevent.stopPropagation();
|
1634
|
+
});
|
1635
|
+
|
1636
|
+
current_time_index = 0;
|
1637
|
+
|
1638
|
+
setPos = function () {
|
1639
|
+
var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute";
|
1640
|
+
if (options.fixed) {
|
1641
|
+
top -= $(window).scrollTop();
|
1642
|
+
left -= $(window).scrollLeft();
|
1643
|
+
position = "fixed";
|
1644
|
+
} else {
|
1645
|
+
if (top + datetimepicker[0].offsetHeight > $(window).height() + $(window).scrollTop()) {
|
1646
|
+
top = offset.top - datetimepicker[0].offsetHeight + 1;
|
1647
|
+
}
|
1648
|
+
if (top < 0) {
|
1649
|
+
top = 0;
|
1650
|
+
}
|
1651
|
+
if (left + datetimepicker[0].offsetWidth > $(window).width()) {
|
1652
|
+
left = $(window).width() - datetimepicker[0].offsetWidth;
|
1653
|
+
}
|
1654
|
+
}
|
1655
|
+
datetimepicker.css({
|
1656
|
+
left: left,
|
1657
|
+
top: top,
|
1658
|
+
position: position
|
1659
|
+
});
|
1660
|
+
};
|
1661
|
+
datetimepicker
|
1662
|
+
.on('open.xdsoft', function (event) {
|
1663
|
+
var onShow = true;
|
1664
|
+
if (options.onShow && $.isFunction(options.onShow)) {
|
1665
|
+
onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
|
1666
|
+
}
|
1667
|
+
if (onShow !== false) {
|
1668
|
+
datetimepicker.show();
|
1669
|
+
setPos();
|
1670
|
+
$(window)
|
1671
|
+
.off('resize.xdsoft', setPos)
|
1672
|
+
.on('resize.xdsoft', setPos);
|
1673
|
+
|
1674
|
+
if (options.closeOnWithoutClick) {
|
1675
|
+
$([document.body, window]).on('mousedown.xdsoft', function arguments_callee6() {
|
1676
|
+
datetimepicker.trigger('close.xdsoft');
|
1677
|
+
$([document.body, window]).off('mousedown.xdsoft', arguments_callee6);
|
1678
|
+
});
|
1679
|
+
}
|
1680
|
+
}
|
1681
|
+
})
|
1682
|
+
.on('close.xdsoft', function (event) {
|
1683
|
+
var onClose = true;
|
1684
|
+
mounth_picker
|
1685
|
+
.find('.xdsoft_month,.xdsoft_year')
|
1686
|
+
.find('.xdsoft_select')
|
1687
|
+
.hide();
|
1688
|
+
if (options.onClose && $.isFunction(options.onClose)) {
|
1689
|
+
onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
|
1690
|
+
}
|
1691
|
+
if (onClose !== false && !options.opened && !options.inline) {
|
1692
|
+
datetimepicker.hide();
|
1693
|
+
}
|
1694
|
+
event.stopPropagation();
|
1695
|
+
})
|
1696
|
+
.on('toggle.xdsoft', function (event) {
|
1697
|
+
if (datetimepicker.is(':visible')) {
|
1698
|
+
datetimepicker.trigger('close.xdsoft');
|
1699
|
+
} else {
|
1700
|
+
datetimepicker.trigger('open.xdsoft');
|
1701
|
+
}
|
1702
|
+
})
|
1703
|
+
.data('input', input);
|
1704
|
+
|
1705
|
+
timer = 0;
|
1706
|
+
timer1 = 0;
|
1707
|
+
|
1708
|
+
datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
|
1709
|
+
datetimepicker.setOptions(options);
|
1710
|
+
|
1711
|
+
function getCurrentValue() {
|
1712
|
+
|
1713
|
+
var ct = false, time;
|
1714
|
+
|
1715
|
+
if (options.startDate) {
|
1716
|
+
ct = _xdsoft_datetime.strToDate(options.startDate);
|
1717
|
+
} else {
|
1718
|
+
ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
|
1719
|
+
if (ct) {
|
1720
|
+
ct = _xdsoft_datetime.strToDateTime(ct);
|
1721
|
+
} else if (options.defaultDate) {
|
1722
|
+
ct = _xdsoft_datetime.strToDate(options.defaultDate);
|
1723
|
+
if (options.defaultTime) {
|
1724
|
+
time = _xdsoft_datetime.strtotime(options.defaultTime);
|
1725
|
+
ct.setHours(time.getHours());
|
1726
|
+
ct.setMinutes(time.getMinutes());
|
1727
|
+
}
|
1728
|
+
}
|
1729
|
+
}
|
1730
|
+
|
1731
|
+
if (ct && _xdsoft_datetime.isValidDate(ct)) {
|
1732
|
+
datetimepicker.data('changed', true);
|
1733
|
+
} else {
|
1734
|
+
ct = '';
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
return ct || 0;
|
1738
|
+
}
|
1739
|
+
|
1740
|
+
_xdsoft_datetime.setCurrentTime(getCurrentValue());
|
1741
|
+
|
1742
|
+
input
|
1743
|
+
.data('xdsoft_datetimepicker', datetimepicker)
|
1744
|
+
.on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) {
|
1745
|
+
if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
|
1746
|
+
return;
|
1747
|
+
}
|
1748
|
+
clearTimeout(timer);
|
1749
|
+
timer = setTimeout(function () {
|
1750
|
+
if (input.is(':disabled')) {
|
1751
|
+
return;
|
1752
|
+
}
|
1753
|
+
|
1754
|
+
triggerAfterOpen = true;
|
1755
|
+
_xdsoft_datetime.setCurrentTime(getCurrentValue());
|
1756
|
+
|
1757
|
+
datetimepicker.trigger('open.xdsoft');
|
1758
|
+
}, 100);
|
1759
|
+
})
|
1760
|
+
.on('keydown.xdsoft', function (event) {
|
1761
|
+
var val = this.value, elementSelector,
|
1762
|
+
key = event.which;
|
1763
|
+
if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
|
1764
|
+
elementSelector = $("input:visible,textarea:visible");
|
1765
|
+
datetimepicker.trigger('close.xdsoft');
|
1766
|
+
elementSelector.eq(elementSelector.index(this) + 1).focus();
|
1767
|
+
return false;
|
1768
|
+
}
|
1769
|
+
if ([TAB].indexOf(key) !== -1) {
|
1770
|
+
datetimepicker.trigger('close.xdsoft');
|
1771
|
+
return true;
|
1772
|
+
}
|
1773
|
+
});
|
1774
|
+
};
|
1775
|
+
destroyDateTimePicker = function (input) {
|
1776
|
+
var datetimepicker = input.data('xdsoft_datetimepicker');
|
1777
|
+
if (datetimepicker) {
|
1778
|
+
datetimepicker.data('xdsoft_datetime', null);
|
1779
|
+
datetimepicker.remove();
|
1780
|
+
input
|
1781
|
+
.data('xdsoft_datetimepicker', null)
|
1782
|
+
.off('.xdsoft');
|
1783
|
+
$(window).off('resize.xdsoft');
|
1784
|
+
$([window, document.body]).off('mousedown.xdsoft');
|
1785
|
+
if (input.unmousewheel) {
|
1786
|
+
input.unmousewheel();
|
1787
|
+
}
|
1788
|
+
}
|
1789
|
+
};
|
1790
|
+
$(document)
|
1791
|
+
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
1792
|
+
.on('keydown.xdsoftctrl', function (e) {
|
1793
|
+
if (e.keyCode === CTRLKEY) {
|
1794
|
+
ctrlDown = true;
|
1795
|
+
}
|
1796
|
+
})
|
1797
|
+
.on('keyup.xdsoftctrl', function (e) {
|
1798
|
+
if (e.keyCode === CTRLKEY) {
|
1799
|
+
ctrlDown = false;
|
1800
|
+
}
|
1801
|
+
});
|
1802
|
+
return this.each(function () {
|
1803
|
+
var datetimepicker = $(this).data('xdsoft_datetimepicker');
|
1804
|
+
if (datetimepicker) {
|
1805
|
+
if ($.type(opt) === 'string') {
|
1806
|
+
switch (opt) {
|
1807
|
+
case 'show':
|
1808
|
+
$(this).select().focus();
|
1809
|
+
datetimepicker.trigger('open.xdsoft');
|
1810
|
+
break;
|
1811
|
+
case 'hide':
|
1812
|
+
datetimepicker.trigger('close.xdsoft');
|
1813
|
+
break;
|
1814
|
+
case 'toggle':
|
1815
|
+
datetimepicker.trigger('toggle.xdsoft');
|
1816
|
+
break;
|
1817
|
+
case 'destroy':
|
1818
|
+
destroyDateTimePicker($(this));
|
1819
|
+
break;
|
1820
|
+
case 'reset':
|
1821
|
+
this.value = this.defaultValue;
|
1822
|
+
if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format))) {
|
1823
|
+
datetimepicker.data('changed', false);
|
1824
|
+
}
|
1825
|
+
datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
|
1826
|
+
break;
|
1827
|
+
}
|
1828
|
+
} else {
|
1829
|
+
datetimepicker
|
1830
|
+
.setOptions(opt);
|
1831
|
+
}
|
1832
|
+
return 0;
|
1833
|
+
}
|
1834
|
+
if ($.type(opt) !== 'string') {
|
1835
|
+
if (!options.lazyInit || options.open || options.inline) {
|
1836
|
+
createDateTimePicker($(this));
|
1837
|
+
} else {
|
1838
|
+
lazyInit($(this));
|
1839
|
+
}
|
1840
|
+
}
|
1841
|
+
});
|
1842
|
+
};
|
1843
|
+
$.fn.datetimepicker.defaults = default_options;
|
1844
|
+
}(jQuery));
|
1845
|
+
(function () {
|
1846
|
+
|
1847
|
+
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
|
1848
|
+
* Licensed under the MIT License (LICENSE.txt).
|
1849
|
+
*
|
1850
|
+
* Version: 3.1.12
|
1851
|
+
*
|
1852
|
+
* Requires: jQuery 1.2.2+
|
1853
|
+
*/
|
1854
|
+
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
|
1855
|
+
|
1856
|
+
// Parse and Format Library
|
1857
|
+
//http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
|
1858
|
+
/*
|
1859
|
+
* Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
|
1860
|
+
*
|
1861
|
+
* This program is free software; you can redistribute it and/or modify it
|
1862
|
+
* under the terms of the GNU Lesser General Public License as published by the
|
1863
|
+
* Free Software Foundation, version 2.1.
|
1864
|
+
*
|
1865
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT
|
1866
|
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
1867
|
+
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
1868
|
+
* details.
|
1869
|
+
*/
|
1870
|
+
Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+" = function() {return ";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;code+="'"+String.escape(ch)+"' + ";}else{code+=Date.getFormatCode(ch);}}}eval(code.substring(0,code.length-3)+";}");};Date.getFormatCode=function(a){switch(a){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(a)+"' + ";}};Date.parseDate=function(a,c){if(c=="unixtime"){return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);}if(Date.parseFunctions[c]==null){Date.createParser(c);}var b=Date.parseFunctions[c];return Date[b](a);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes["+regexNum+"]);\nif (results && results.length > 0) {";var regex="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;regex+=String.escape(ch);}else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}}code+="if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b<this.getMonth();++b){a+=Date.daysInMonth[b];}return a+this.getDate();};Date.prototype.getWeekOfYear=function(){var b=this.getDayOfYear()+(4-this.getDay());var a=new Date(this.getFullYear(),0,1);var c=(7-a.getDay()+4);return String.leftPad(Math.ceil((b-c)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return((a&3)==0&&(a%100||(a%400==0&&a)));};Date.prototype.getFirstDayOfMonth=function(){var a=(this.getDay()-(this.getDate()-1))%7;return(a<0)?(a+7):a;};Date.prototype.getLastDayOfMonth=function(){var a=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(a<0)?(a+7):a;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};String.escape=function(a){return a.replace(/('|\\)/g,"\\$1");};String.leftPad=function(d,b,c){var a=new String(d);if(c==null){c=" ";}while(a.length<b){a=c+a;}return a;};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.patterns={ISO8601LongPattern:"Y-m-d H:i:s",ISO8601ShortPattern:"Y-m-d",ShortDatePattern:"n/j/Y",LongDatePattern:"l, F d, Y",FullDateTimePattern:"l, F d, Y g:i:s A",MonthDayPattern:"F d",ShortTimePattern:"g:i A",LongTimePattern:"g:i:s A",SortableDateTimePattern:"Y-m-d\\TH:i:s",UniversalSortableDateTimePattern:"Y-m-d H:i:sO",YearMonthPattern:"F, Y"};
|
1871
|
+
}());
|