renalware-core 2.0.123 → 2.0.124

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -6
  3. data/app/assets/config/renalware/core/manifest.js +5 -0
  4. data/app/assets/images/renalware/icons/chevron-down.svg +1 -0
  5. data/app/assets/images/renalware/icons/chevron-up.svg +1 -0
  6. data/app/assets/images/renalware/icons/chevrons-down.svg +1 -0
  7. data/app/assets/images/renalware/icons/chevrons-up.svg +1 -0
  8. data/app/assets/javascripts/renalware/README.md +9 -0
  9. data/app/assets/javascripts/renalware/{charting/charting.js.erb → charting.js} +0 -2
  10. data/app/assets/javascripts/renalware/{ajax_errors.js → components/ajax_errors.js} +0 -0
  11. data/app/assets/javascripts/renalware/{aki_alerts.js → components/aki_alerts.js} +0 -0
  12. data/app/assets/javascripts/renalware/{appointments.js → components/appointments.js} +0 -0
  13. data/app/assets/javascripts/renalware/{behaviours.js → components/behaviours.js} +0 -0
  14. data/app/assets/javascripts/renalware/components/bla.es6 +1 -0
  15. data/app/assets/javascripts/renalware/{clipboard_setup.js → components/clipboard_setup.js} +0 -0
  16. data/app/assets/javascripts/renalware/components/clockpicker.js +742 -0
  17. data/app/assets/javascripts/renalware/{contacts.js → components/contacts.js} +0 -0
  18. data/app/assets/javascripts/renalware/{dialogs.js.erb → components/dialogs.js.erb} +0 -0
  19. data/app/assets/javascripts/renalware/{drugs.js → components/drugs.js} +0 -0
  20. data/app/assets/javascripts/renalware/{events.js → components/events.js} +0 -0
  21. data/app/assets/javascripts/renalware/{feed_only_inputs.js.erb → components/feed_only_inputs.js.erb} +0 -0
  22. data/app/assets/javascripts/renalware/{feeds.js → components/feeds.js} +0 -0
  23. data/app/assets/javascripts/renalware/{forms.js → components/forms.js} +0 -0
  24. data/app/assets/javascripts/renalware/{full_screen.js → components/full_screen.js} +0 -0
  25. data/app/assets/javascripts/renalware/{hd.js → components/hd.js} +0 -0
  26. data/app/assets/javascripts/renalware/{iframe.js → components/iframe.js} +0 -0
  27. data/app/assets/javascripts/renalware/{keyboard_shortcuts.js → components/keyboard_shortcuts.js} +0 -0
  28. data/app/assets/javascripts/renalware/{layout.js → components/layout.js} +0 -0
  29. data/app/assets/javascripts/renalware/{letters.js → components/letters.js} +0 -0
  30. data/app/assets/javascripts/renalware/{masonry.run.js → components/masonry.run.js} +0 -0
  31. data/app/assets/javascripts/renalware/{messaging.js → components/messaging.js} +0 -0
  32. data/app/assets/javascripts/renalware/{modality_codes.js → components/modality_codes.js} +0 -0
  33. data/app/assets/javascripts/renalware/{modality_reasons.js → components/modality_reasons.js} +0 -0
  34. data/app/assets/javascripts/renalware/{navigation.js → components/navigation.js} +0 -0
  35. data/app/assets/javascripts/renalware/{patient_ajax_search.js → components/patient_ajax_search.js} +0 -0
  36. data/app/assets/javascripts/renalware/{patient_menu.js → components/patient_menu.js} +0 -0
  37. data/app/assets/javascripts/renalware/{pd.js → components/pd.js} +0 -0
  38. data/app/assets/javascripts/renalware/{pdf.js → components/pdf.js} +0 -0
  39. data/app/assets/javascripts/renalware/{person_ajax_search.js → components/person_ajax_search.js} +0 -0
  40. data/app/assets/javascripts/renalware/{primary_care_physician_search.js → components/primary_care_physician_search.js} +0 -0
  41. data/app/assets/javascripts/renalware/{primary_care_physicians.js → components/primary_care_physicians.js} +0 -0
  42. data/app/assets/javascripts/renalware/{problems.js → components/problems.js} +0 -0
  43. data/app/assets/javascripts/renalware/{renal.js → components/renal.js} +0 -0
  44. data/app/assets/javascripts/renalware/{reporting.js.erb → components/reporting.js.erb} +0 -0
  45. data/app/assets/javascripts/renalware/{searchables.js → components/searchables.js} +0 -0
  46. data/app/assets/javascripts/renalware/{select2-ajax-search.js → components/select2-ajax-search.js} +0 -0
  47. data/app/assets/javascripts/renalware/{session_timeout_redirect.js.erb → components/session_timeout_redirect.js.erb} +0 -0
  48. data/app/assets/javascripts/renalware/{sortable.js → components/sortable.js} +0 -0
  49. data/app/assets/javascripts/renalware/{table.js → components/table.js} +0 -0
  50. data/app/assets/javascripts/renalware/{tabs.js → components/tabs.js} +0 -0
  51. data/app/assets/javascripts/renalware/components/toggler.js +64 -0
  52. data/app/assets/javascripts/renalware/{transplants.js → components/transplants.js} +0 -0
  53. data/app/assets/javascripts/renalware/{application.js.erb → core.js.erb} +1 -2
  54. data/app/assets/stylesheets/renalware/README.md +16 -0
  55. data/app/assets/stylesheets/renalware/base/_variables.scss +1 -0
  56. data/app/assets/stylesheets/renalware/{application.scss → core.scss} +0 -0
  57. data/app/assets/stylesheets/renalware/lib/_clockpicker.css +98 -98
  58. data/app/assets/stylesheets/renalware/partials/_button.scss +49 -0
  59. data/app/assets/stylesheets/renalware/{clipboard.scss → partials/_clipboard.scss} +0 -0
  60. data/app/assets/stylesheets/renalware/partials/_tables.scss +63 -1
  61. data/app/assets/stylesheets/renalware/partials/_toggling.scss +38 -0
  62. data/app/assets/stylesheets/renalware/{print/pathology_request_forms.scss → pathology_request_forms.scss} +0 -0
  63. data/app/controllers/renalware/letters/letters_controller.rb +1 -1
  64. data/app/controllers/renalware/problems/notes_controller.rb +6 -0
  65. data/app/helpers/renalware/application_helper.rb +0 -7
  66. data/app/helpers/renalware/link_helper.rb +13 -0
  67. data/app/helpers/renalware/mdm_helper.rb +2 -1
  68. data/app/helpers/renalware/toggle_helper.rb +22 -0
  69. data/app/javascript/controllers/{clipboard_controller.js → clipboard_controller.js.dead} +0 -0
  70. data/app/models/concerns/renalware/transaction_retry.rb +38 -0
  71. data/app/models/renalware/accesses/patient.rb +1 -1
  72. data/app/models/renalware/hd/session.rb +1 -0
  73. data/app/models/renalware/letters/letter.rb +1 -0
  74. data/app/models/renalware/modalities/modality.rb +1 -1
  75. data/app/models/renalware/patient.rb +9 -4
  76. data/app/models/renalware/patients/ingestion/commands/add_or_update_patient.rb +6 -0
  77. data/app/views/renalware/clinical/body_compositions/_table.html.slim +9 -2
  78. data/app/views/renalware/clinics/clinic_visits/_table.html.slim +2 -1
  79. data/app/views/renalware/clinics/clinic_visits/_table_row.html.slim +3 -8
  80. data/app/views/renalware/clinics/visits/_table.html.slim +6 -5
  81. data/app/views/renalware/clinics/visits/_table_row.html.slim +34 -12
  82. data/app/views/renalware/dashboard/letters/_letter.html.slim +0 -2
  83. data/app/views/renalware/events/events/_event.html.slim +6 -9
  84. data/app/views/renalware/events/events/_table.html.slim +3 -1
  85. data/app/views/renalware/hd/sessions/_row.html.slim +2 -6
  86. data/app/views/renalware/hd/sessions/_thead.html.slim +1 -0
  87. data/app/views/renalware/hd/sessions/dna/_row.html.slim +3 -6
  88. data/app/views/renalware/hospitals/units/index.html.slim +0 -2
  89. data/app/views/renalware/layouts/error.html.slim +1 -1
  90. data/app/views/renalware/letters/electronic_receipts/_table.html.slim +0 -1
  91. data/app/views/renalware/letters/electronic_receipts/sent.html.slim +0 -1
  92. data/app/views/renalware/letters/letters/_letter.html.slim +4 -7
  93. data/app/views/renalware/letters/letters/_table.html.slim +2 -1
  94. data/app/views/renalware/letters/lists/_letter.html.slim +8 -12
  95. data/app/views/renalware/letters/lists/_table.html.slim +4 -3
  96. data/app/views/renalware/mdm/_clinic_visits.html.slim +5 -0
  97. data/app/views/renalware/pathology/requests/requests/create.pdf.slim +1 -1
  98. data/app/views/renalware/pathology/requests/requests/new.html.slim +2 -19
  99. data/app/views/renalware/pathology/requests/requests/show.pdf.slim +1 -1
  100. data/app/views/renalware/problems/notes/_table.html.slim +12 -3
  101. data/app/views/renalware/snippets/snippets/_row.html.slim +0 -2
  102. data/app/views/renalware/surveys/_eq5d_summary_part.html.slim +1 -1
  103. data/app/views/renalware/surveys/_pos_s_summary_part.html.slim +1 -1
  104. data/config/routes/patients.rb +1 -1
  105. data/lib/renalware.rb +0 -13
  106. data/lib/renalware/engine.rb +3 -60
  107. data/lib/renalware/version.rb +1 -1
  108. data/lib/tasks/renalware.rake +3 -100
  109. metadata +63 -58
  110. data/app/assets/javascripts/renalware/clockpicker.js +0 -742
  111. data/app/assets/javascripts/renalware/toggler.js +0 -41
  112. data/app/javascript/packs/renalware_core.js +0 -20
  113. data/config/webpack/development.js +0 -5
  114. data/config/webpack/environment.js +0 -3
  115. data/config/webpack/production.js +0 -5
  116. data/config/webpack/test.js +0 -5
  117. data/config/webpacker.yml +0 -103
@@ -53,7 +53,6 @@ require "trix"
53
53
  require "uglifier"
54
54
  require "validates_timeliness"
55
55
  require "virtus"
56
- require "webpacker"
57
56
  require "wicked_pdf"
58
57
  require "wisper"
59
58
  require "wisper/activejob"
@@ -65,36 +64,9 @@ module Renalware
65
64
  # This will keep Rails Engine from generating all table prefixes with the engines name
66
65
  def self.table_name_prefix; end
67
66
 
68
- # rubocop:disable Metrics/ClassLength
69
67
  class Engine < ::Rails::Engine
70
68
  isolate_namespace Renalware
71
69
 
72
- # Configure webpacker dev server proxy
73
- # rubocop:disable Style/RescueStandardError
74
- initializer "webpacker.proxy" do |app|
75
- insert_middleware = begin
76
- Renalware.webpacker.config.dev_server.present?
77
- rescue
78
- nil
79
- end
80
- next unless insert_middleware
81
-
82
- app.middleware.insert_before(
83
- 0, Webpacker::DevServerProxy, # "Webpacker::DevServerProxy" if Rails version < 5
84
- ssl_verify_none: true,
85
- webpacker: Renalware.webpacker
86
- )
87
- end
88
- # rubocop:enable Style/RescueStandardError
89
-
90
- # Allow the host app to consume webpacker-compiled packs in the engine's public folder.
91
- initializer :packs do |_app|
92
- config.app_middleware.use(
93
- Rack::Static,
94
- urls: ["/renalware-core-packs"], root: Engine.root.join("public")
95
- )
96
- end
97
-
98
70
  # Define a attr on the Engine's eigenclass so a host application
99
71
  # can set an exception handler instance. It must accept a .notify(excetion) method.
100
72
  # We use the exception handler when logging errors in background jobs only.
@@ -150,37 +122,9 @@ module Renalware
150
122
  end
151
123
 
152
124
  initializer :assets do |app|
153
- app.config.assets.precompile += %w(renalware/print/pathology_request_forms.css)
154
- app.config.assets.precompile += %w(renalware/modernizr.js)
155
- app.config.assets.precompile += %w(renalware/charting/charting.js)
156
- app.config.assets.precompile += %w(renalware/iframeResizer.contentWindow.js)
157
- app.config.assets.precompile += %w(renalware/pdf.css renalware/watermark.css)
158
- app.config.assets.precompile += %w(renalware/protocol_pdf.css)
159
- app.config.assets.precompile += %w(renalware/medications_pdf.css)
160
- app.config.assets.precompile += %w(renalware/medications/prescriptions_pdf.css)
161
- app.config.assets.precompile += %w(renalware/hd_diary_pdf.css)
162
- app.config.assets.precompile += %w(renalware/table_pdf.css)
163
- app.config.assets.precompile += %w(
164
- renalware/nhs_a4_letter_logo_blue.png
165
- renalware/nhs_a4_letter_logo_black.png
166
- renalware/NHS-Black.jpg
167
- renalware/favicon/manifest.json
168
- renalware/favicon/apple-touch-icon.png
169
- renalware/favicon/favicon-32x32.png
170
- renalware/favicon/favicon-16x16.png
171
- renalware/favicon/favicon.ico
172
- renalware/favicon/android-chrome-192x192.png
173
- renalware/favicon/android-chrome-512x512.png
174
- renalware/favicon/mstile-150x150.png
175
- renalware/favicon/safari-pinned-tab.svg
176
- renalware/clippy.svg
177
- renalware/print-button-example.png
178
- renalware/hd/mr_victor.jpg
179
- renalware/hd/avf_avg_assessment.jpg
180
- renalware/loading-gears-animation.gif
181
- )
182
- app.config.assets.paths <<
183
- Rails.root.join(config.root, "vendor", "assets", "javascripts", "renalware")
125
+ # Add some extra paths so sprocket asset directives can locate dependent files
126
+ vendor_js_path = Rails.root.join(config.root, "vendor", "assets", "javascripts", "renalware")
127
+ app.config.assets.paths << vendor_js_path
184
128
  app.config.assets.paths << Engine.root.join("node_modules")
185
129
  end
186
130
 
@@ -222,4 +166,3 @@ module Renalware
222
166
  end
223
167
  end
224
168
  end
225
- # rubocop:enable Metrics/ClassLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.123"
4
+ VERSION = "2.0.124"
5
5
  end
@@ -1,13 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- def ensure_log_goes_to_stdout
4
- old_logger = Webpacker.logger
5
- Webpacker.logger = ActiveSupport::Logger.new(STDOUT)
6
- yield
7
- ensure
8
- Webpacker.logger = old_logger
9
- end
10
-
11
3
  namespace :renalware do
12
4
  desc "Install package.json dependencies with yarn for the renalware-core engine - "\
13
5
  "without this <path to installed gem>/renalware-core/node_modules is not populated "\
@@ -18,99 +10,10 @@ namespace :renalware do
18
10
  system "yarn install --no-progress --production"
19
11
  end
20
12
  end
21
-
22
- desc "Cleans the Webpack output folder (public/renalware-core-packs)"
23
- task :clean_webpack_output_folder do
24
- puts "Destroying packs output folder ..."
25
- Dir.chdir(File.join(__dir__, "..", "..")) do
26
- # TODO : Load packs output from config/webpacker.yml
27
- system "rm -rf public/renalware-core-packs"
28
- end
29
- end
30
-
31
- # I have found that it is necessary to force remove public/renalware-core-packs with the
32
- # clean_webpack_output_folder task above before compiling, otherwise webpack does not
33
- # always find changes in js/controllers/*.js. I think this is safe to do in a capistrano deploy
34
- # because the symlink to public is only applied after a successful execution of (among other
35
- # things) assets:precompile.
36
- desc "Compile JavaScript packs using webpack for production with digests"
37
- task webpacker_compile: %i(clean_webpack_output_folder yarn_install environment) do
38
- puts "Compiling renalware-core packs with webpack.."
39
- if Rails.env.development? || Rails.env.test?
40
- compile_webpacker_output
41
- else
42
- temporarily_point_webpacker_config_public_root_path_to_rails_app_root do
43
- compile_webpacker_output
44
- end
45
- end
46
- end
47
- end
48
-
49
- def compile_webpacker_output
50
- Webpacker.with_node_env("production") do
51
- ensure_log_goes_to_stdout do
52
- if Renalware.webpacker.commands.compile
53
- # Successful compilation!
54
- else
55
- # Failed compilation
56
- exit!
57
- end
58
- end
59
- end
60
- end
61
-
62
- # This is something of a hack to get webpacker to compile the renalware-core-packs in the
63
- # host Rails app's public folder. We change out config/webpacker.yml to point to the host app's
64
- # public path, do the compile, then revert out change.
65
- # The downside of this approach is that if running staging or production env locally without
66
- # nginx to find and serve public/renalware-core-packs, the pack files will not be found by the host
67
- # because the Rack::Static middleware we setup in engine.rb will not find them.
68
- # An alternative is for us to do the compile inside the engine and then cp -R or rsync (better
69
- # if we are symlinking renawlare-core-packs to shared in deploy.rb) the
70
- # folder into the host's public app where it can be served by nginx (if configured).
71
- # This has the advantage that the same files are available in the engine's public folder (so they
72
- # can be servered by Rack::Static - see engine.rb) and also in the host apps public folder
73
- # where nginx can server them if we are in a real 'environment'
74
- def temporarily_point_webpacker_config_public_root_path_to_rails_app_root
75
- engine_config_folder = Renalware::Engine.root.join("config")
76
- find = "public_root_path: .*$"
77
- replace = "public_root_path: #{Rails.root.join('public')}"
78
-
79
- # This changes the contents of file, creating a backup in webpacker.yml.bak
80
- `ruby -pi.bak -e "gsub(/#{find}/, '#{replace}')" #{engine_config_folder}/webpacker.yml`
81
-
82
- yield if block_given?
83
- ensure
84
- # Ensure that we always restore the backup webpacker.yml
85
- FileUtils.mv(
86
- engine_config_folder.join("webpacker.yml.bak"),
87
- engine_config_folder.join("webpacker.yml")
88
- )
89
- end
90
-
91
- def enhance_assets_precompile_with_renalware_webpacker_compile
92
- # Becuase of an issue deploying BLT (not affecting KCH for some reason) I am temporarily
93
- # removing the engine webpacker_precompile and insterad just doing yarn_install.
94
- # The utter mess of webpacker in an engine means I think that I will need to publish a
95
- # @renalware/core npm package at gem publish time and reference that from the host app.
96
- # Rake::Task["assets:precompile"].enhance(["renalware:webpacker_compile"])
97
- Rake::Task["assets:precompile"].enhance(["renalware:yarn_install"])
98
13
  end
99
14
 
100
- # When a host app runs rake assets:precompile, hook into this and enhance the
101
- # task so it runs webpacker install for (and relative to) the engine, wherever it is installed.
102
- # Without that, assets:precompile will fail because the engine references various js and css files
103
- # in ./node_modules, and these are not included in the source, but need to be installed with yarn
104
- # at deploy time.
105
- #
106
- # Note that when runnning in the engine in development, we need to set the ENV
107
- # var WEBPACKER_PRECOMPILE=no (e.g. in ./.env) otherwise wepacker will enhance the
108
- # 'assets:precompile' task with 'webpacker:compile' task, and the latter task does not exist
109
- # in out context (for us its called app:webpacker:compile).
110
- # A possible downside of this is that webpacker compilation in the dummy app, if ever required, may
111
- # not work, I'm not sure.
112
- if Rake::Task.task_defined?("assets:precompile")
113
- enhance_assets_precompile_with_renalware_webpacker_compile
15
+ if Rake::Task.task_defined?("yarn:install")
16
+ Rake::Task["yarn:install"].enhance(["renalware:yarn_install"])
114
17
  else
115
- Rake::Task.define_task("assets:precompile" => "renalware:webpacker:compile")
18
+ Rake::Task.define_task("yarn:install" => "renalware:yarn_install")
116
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.123
4
+ version: 2.0.124
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-13 00:00:00.000000000 Z
11
+ date: 2019-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview-component
@@ -828,14 +828,14 @@ dependencies:
828
828
  requirements:
829
829
  - - "~>"
830
830
  - !ruby/object:Gem::Version
831
- version: 3.7.2
831
+ version: 4.0.0
832
832
  type: :runtime
833
833
  prerelease: false
834
834
  version_requirements: !ruby/object:Gem::Requirement
835
835
  requirements:
836
836
  - - "~>"
837
837
  - !ruby/object:Gem::Version
838
- version: 3.7.2
838
+ version: 4.0.0
839
839
  - !ruby/object:Gem::Dependency
840
840
  name: uglifier
841
841
  requirement: !ruby/object:Gem::Requirement
@@ -974,6 +974,7 @@ files:
974
974
  - MIT-LICENSE
975
975
  - README.md
976
976
  - Rakefile
977
+ - app/assets/config/renalware/core/manifest.js
977
978
  - app/assets/images/renalware/NHS-Black.jpg
978
979
  - app/assets/images/renalware/ajax-loader.gif
979
980
  - app/assets/images/renalware/barts_health_nhs_logo.png
@@ -995,60 +996,66 @@ files:
995
996
  - app/assets/images/renalware/favicon/safari-pinned-tab.svg
996
997
  - app/assets/images/renalware/hd/avf_avg_assessment.jpg
997
998
  - app/assets/images/renalware/hd/mr_victor.jpg
999
+ - app/assets/images/renalware/icons/chevron-down.svg
1000
+ - app/assets/images/renalware/icons/chevron-up.svg
1001
+ - app/assets/images/renalware/icons/chevrons-down.svg
1002
+ - app/assets/images/renalware/icons/chevrons-up.svg
998
1003
  - app/assets/images/renalware/kidney.png
999
1004
  - app/assets/images/renalware/loading-gears-animation.gif
1000
1005
  - app/assets/images/renalware/nhs_a4_letter_logo_black.png
1001
1006
  - app/assets/images/renalware/nhs_a4_letter_logo_blue.png
1002
1007
  - app/assets/images/renalware/print-button-example.png
1003
- - app/assets/javascripts/renalware/ajax_errors.js
1004
- - app/assets/javascripts/renalware/aki_alerts.js
1005
- - app/assets/javascripts/renalware/application.js.erb
1006
- - app/assets/javascripts/renalware/appointments.js
1007
- - app/assets/javascripts/renalware/behaviours.js
1008
- - app/assets/javascripts/renalware/charting/charting.js.erb
1009
- - app/assets/javascripts/renalware/clipboard_setup.js
1010
- - app/assets/javascripts/renalware/clockpicker.js
1011
- - app/assets/javascripts/renalware/contacts.js
1012
- - app/assets/javascripts/renalware/dialogs.js.erb
1013
- - app/assets/javascripts/renalware/drugs.js
1014
- - app/assets/javascripts/renalware/events.js
1015
- - app/assets/javascripts/renalware/feed_only_inputs.js.erb
1016
- - app/assets/javascripts/renalware/feeds.js
1017
- - app/assets/javascripts/renalware/forms.js
1018
- - app/assets/javascripts/renalware/full_screen.js
1019
- - app/assets/javascripts/renalware/hd.js
1020
- - app/assets/javascripts/renalware/iframe.js
1021
- - app/assets/javascripts/renalware/keyboard_shortcuts.js
1022
- - app/assets/javascripts/renalware/layout.js
1023
- - app/assets/javascripts/renalware/letters.js
1024
- - app/assets/javascripts/renalware/masonry.run.js
1025
- - app/assets/javascripts/renalware/messaging.js
1026
- - app/assets/javascripts/renalware/modality_codes.js
1027
- - app/assets/javascripts/renalware/modality_reasons.js
1028
- - app/assets/javascripts/renalware/navigation.js
1029
- - app/assets/javascripts/renalware/patient_ajax_search.js
1030
- - app/assets/javascripts/renalware/patient_menu.js
1031
- - app/assets/javascripts/renalware/pd.js
1032
- - app/assets/javascripts/renalware/pdf.js
1033
- - app/assets/javascripts/renalware/person_ajax_search.js
1034
- - app/assets/javascripts/renalware/primary_care_physician_search.js
1035
- - app/assets/javascripts/renalware/primary_care_physicians.js
1036
- - app/assets/javascripts/renalware/problems.js
1037
- - app/assets/javascripts/renalware/renal.js
1038
- - app/assets/javascripts/renalware/reporting.js.erb
1039
- - app/assets/javascripts/renalware/searchables.js
1040
- - app/assets/javascripts/renalware/select2-ajax-search.js
1041
- - app/assets/javascripts/renalware/session_timeout_redirect.js.erb
1042
- - app/assets/javascripts/renalware/sortable.js
1043
- - app/assets/javascripts/renalware/table.js
1044
- - app/assets/javascripts/renalware/tabs.js
1045
- - app/assets/javascripts/renalware/toggler.js
1046
- - app/assets/javascripts/renalware/transplants.js
1008
+ - app/assets/javascripts/renalware/README.md
1009
+ - app/assets/javascripts/renalware/charting.js
1010
+ - app/assets/javascripts/renalware/components/ajax_errors.js
1011
+ - app/assets/javascripts/renalware/components/aki_alerts.js
1012
+ - app/assets/javascripts/renalware/components/appointments.js
1013
+ - app/assets/javascripts/renalware/components/behaviours.js
1014
+ - app/assets/javascripts/renalware/components/bla.es6
1015
+ - app/assets/javascripts/renalware/components/clipboard_setup.js
1016
+ - app/assets/javascripts/renalware/components/clockpicker.js
1017
+ - app/assets/javascripts/renalware/components/contacts.js
1018
+ - app/assets/javascripts/renalware/components/dialogs.js.erb
1019
+ - app/assets/javascripts/renalware/components/drugs.js
1020
+ - app/assets/javascripts/renalware/components/events.js
1021
+ - app/assets/javascripts/renalware/components/feed_only_inputs.js.erb
1022
+ - app/assets/javascripts/renalware/components/feeds.js
1023
+ - app/assets/javascripts/renalware/components/forms.js
1024
+ - app/assets/javascripts/renalware/components/full_screen.js
1025
+ - app/assets/javascripts/renalware/components/hd.js
1026
+ - app/assets/javascripts/renalware/components/iframe.js
1027
+ - app/assets/javascripts/renalware/components/keyboard_shortcuts.js
1028
+ - app/assets/javascripts/renalware/components/layout.js
1029
+ - app/assets/javascripts/renalware/components/letters.js
1030
+ - app/assets/javascripts/renalware/components/masonry.run.js
1031
+ - app/assets/javascripts/renalware/components/messaging.js
1032
+ - app/assets/javascripts/renalware/components/modality_codes.js
1033
+ - app/assets/javascripts/renalware/components/modality_reasons.js
1034
+ - app/assets/javascripts/renalware/components/navigation.js
1035
+ - app/assets/javascripts/renalware/components/patient_ajax_search.js
1036
+ - app/assets/javascripts/renalware/components/patient_menu.js
1037
+ - app/assets/javascripts/renalware/components/pd.js
1038
+ - app/assets/javascripts/renalware/components/pdf.js
1039
+ - app/assets/javascripts/renalware/components/person_ajax_search.js
1040
+ - app/assets/javascripts/renalware/components/primary_care_physician_search.js
1041
+ - app/assets/javascripts/renalware/components/primary_care_physicians.js
1042
+ - app/assets/javascripts/renalware/components/problems.js
1043
+ - app/assets/javascripts/renalware/components/renal.js
1044
+ - app/assets/javascripts/renalware/components/reporting.js.erb
1045
+ - app/assets/javascripts/renalware/components/searchables.js
1046
+ - app/assets/javascripts/renalware/components/select2-ajax-search.js
1047
+ - app/assets/javascripts/renalware/components/session_timeout_redirect.js.erb
1048
+ - app/assets/javascripts/renalware/components/sortable.js
1049
+ - app/assets/javascripts/renalware/components/table.js
1050
+ - app/assets/javascripts/renalware/components/tabs.js
1051
+ - app/assets/javascripts/renalware/components/toggler.js
1052
+ - app/assets/javascripts/renalware/components/transplants.js
1053
+ - app/assets/javascripts/renalware/core.js.erb
1047
1054
  - app/assets/pdf/blank_page.pdf
1048
- - app/assets/stylesheets/renalware/application.scss
1055
+ - app/assets/stylesheets/renalware/README.md
1049
1056
  - app/assets/stylesheets/renalware/base/_mixins.scss
1050
1057
  - app/assets/stylesheets/renalware/base/_variables.scss
1051
- - app/assets/stylesheets/renalware/clipboard.scss
1058
+ - app/assets/stylesheets/renalware/core.scss
1052
1059
  - app/assets/stylesheets/renalware/hd_diary_pdf.scss
1053
1060
  - app/assets/stylesheets/renalware/lib/_clockpicker.css
1054
1061
  - app/assets/stylesheets/renalware/lib/_foundation_and_overrides.scss
@@ -1084,6 +1091,7 @@ files:
1084
1091
  - app/assets/stylesheets/renalware/partials/_autocomplete.scss
1085
1092
  - app/assets/stylesheets/renalware/partials/_beta_banner.scss
1086
1093
  - app/assets/stylesheets/renalware/partials/_button.scss
1094
+ - app/assets/stylesheets/renalware/partials/_clipboard.scss
1087
1095
  - app/assets/stylesheets/renalware/partials/_clockpicker.scss
1088
1096
  - app/assets/stylesheets/renalware/partials/_components.scss
1089
1097
  - app/assets/stylesheets/renalware/partials/_datepicker.scss
@@ -1107,11 +1115,12 @@ files:
1107
1115
  - app/assets/stylesheets/renalware/partials/_tables.scss
1108
1116
  - app/assets/stylesheets/renalware/partials/_tabs.scss
1109
1117
  - app/assets/stylesheets/renalware/partials/_toggle.scss
1118
+ - app/assets/stylesheets/renalware/partials/_toggling.scss
1110
1119
  - app/assets/stylesheets/renalware/partials/_tooltip.scss
1111
1120
  - app/assets/stylesheets/renalware/partials/_typography.scss
1112
1121
  - app/assets/stylesheets/renalware/partials/_utilities.scss
1122
+ - app/assets/stylesheets/renalware/pathology_request_forms.scss
1113
1123
  - app/assets/stylesheets/renalware/pdf.scss
1114
- - app/assets/stylesheets/renalware/print/pathology_request_forms.scss
1115
1124
  - app/assets/stylesheets/renalware/protocol_pdf.scss
1116
1125
  - app/assets/stylesheets/renalware/table_pdf.scss
1117
1126
  - app/assets/stylesheets/renalware/watermark.scss
@@ -1345,6 +1354,7 @@ files:
1345
1354
  - app/helpers/renalware/infection_organisms_helper.rb
1346
1355
  - app/helpers/renalware/layout_helper.rb
1347
1356
  - app/helpers/renalware/letters_helper.rb
1357
+ - app/helpers/renalware/link_helper.rb
1348
1358
  - app/helpers/renalware/mdm_helper.rb
1349
1359
  - app/helpers/renalware/navigation_helper.rb
1350
1360
  - app/helpers/renalware/patient_helper.rb
@@ -1374,8 +1384,7 @@ files:
1374
1384
  - app/inputs/select_container_input.rb
1375
1385
  - app/inputs/simple_time_input.rb
1376
1386
  - app/inputs/user_picker_input.rb
1377
- - app/javascript/controllers/clipboard_controller.js
1378
- - app/javascript/packs/renalware_core.js
1387
+ - app/javascript/controllers/clipboard_controller.js.dead
1379
1388
  - app/jobs/application_job.rb
1380
1389
  - app/jobs/feed_job.rb
1381
1390
  - app/jobs/hl7_message_example.txt
@@ -1420,6 +1429,7 @@ files:
1420
1429
  - app/models/concerns/renalware/personable.rb
1421
1430
  - app/models/concerns/renalware/string_logging.rb
1422
1431
  - app/models/concerns/renalware/supersedeable.rb
1432
+ - app/models/concerns/renalware/transaction_retry.rb
1423
1433
  - app/models/concerns/renalware/using_temp_folder.rb
1424
1434
  - app/models/null_exception_notifier.rb
1425
1435
  - app/models/renalware.rb
@@ -3186,11 +3196,6 @@ files:
3186
3196
  - config/routes/virology.rb
3187
3197
  - config/schedule.rb.example
3188
3198
  - config/spring.rb
3189
- - config/webpack/development.js
3190
- - config/webpack/environment.js
3191
- - config/webpack/production.js
3192
- - config/webpack/test.js
3193
- - config/webpacker.yml
3194
3199
  - db/functions/audit_view_as_json_v01.sql
3195
3200
  - db/functions/convert_to_float_v01.sql
3196
3201
  - db/functions/count_estimate_v01.sql
@@ -1,742 +0,0 @@
1
- /*!
2
- * This file moved (and its .css counterpart) to app/assets (rather than included via a gem or
3
- * living in ./vendor) because we have fixed a bug here and I want to make it explicit
4
- * that we now have ownership of both files, and to prevent them being accidentally
5
- * refreshed and thereby losing our changes.
6
- *
7
- * ClockPicker v0.0.7 (http://weareoutman.github.io/clockpicker/)
8
- * Copyright 2014 Wang Shenwei.
9
- * Licensed under MIT (https://github.com/weareoutman/clockpicker/blob/gh-pages/LICENSE)
10
- */
11
-
12
- ;(function(){
13
- var $ = window.jQuery,
14
- $win = $(window),
15
- $doc = $(document),
16
- $body;
17
-
18
- // Can I use inline svg ?
19
- var svgNS = 'http://www.w3.org/2000/svg',
20
- svgSupported = 'SVGAngle' in window && (function(){
21
- var supported,
22
- el = document.createElement('div');
23
- el.innerHTML = '<svg/>';
24
- supported = (el.firstChild && el.firstChild.namespaceURI) == svgNS;
25
- el.innerHTML = '';
26
- return supported;
27
- }());
28
-
29
- // Can I use transition ?
30
- var transitionSupported = (function(){
31
- var style = document.createElement('div').style;
32
- return 'transition' in style ||
33
- 'WebkitTransition' in style ||
34
- 'MozTransition' in style ||
35
- 'msTransition' in style ||
36
- 'OTransition' in style;
37
- }());
38
-
39
- // Listen touch events in touch screen device, instead of mouse events in desktop.
40
- var touchSupported = 'ontouchstart' in window,
41
- mousedownEvent = 'mousedown' + ( touchSupported ? ' touchstart' : ''),
42
- mousemoveEvent = 'mousemove.clockpicker' + ( touchSupported ? ' touchmove.clockpicker' : ''),
43
- mouseupEvent = 'mouseup.clockpicker' + ( touchSupported ? ' touchend.clockpicker' : '');
44
-
45
- // Vibrate the device if supported
46
- var vibrate = navigator.vibrate ? 'vibrate' : navigator.webkitVibrate ? 'webkitVibrate' : null;
47
-
48
- function createSvgElement(name) {
49
- return document.createElementNS(svgNS, name);
50
- }
51
-
52
- function leadingZero(num) {
53
- return (num < 10 ? '0' : '') + num;
54
- }
55
-
56
- // Get a unique id
57
- var idCounter = 0;
58
- function uniqueId(prefix) {
59
- var id = ++idCounter + '';
60
- return prefix ? prefix + id : id;
61
- }
62
-
63
- // Clock size
64
- var dialRadius = 100,
65
- outerRadius = 80,
66
- // innerRadius = 80 on 12 hour clock
67
- innerRadius = 54,
68
- tickRadius = 13,
69
- diameter = dialRadius * 2,
70
- duration = transitionSupported ? 350 : 1;
71
-
72
- // Popover template
73
- var tpl = [
74
- '<div class="popover clockpicker-popover">',
75
- '<div class="arrow"></div>',
76
- '<div class="popover-title">',
77
- '<span class="clockpicker-span-hours text-primary"></span>',
78
- ' : ',
79
- '<span class="clockpicker-span-minutes"></span>',
80
- '<span class="clockpicker-span-am-pm"></span>',
81
- '</div>',
82
- '<div class="popover-content">',
83
- '<div class="clockpicker-plate">',
84
- '<div class="clockpicker-canvas"></div>',
85
- '<div class="clockpicker-dial clockpicker-hours"></div>',
86
- '<div class="clockpicker-dial clockpicker-minutes clockpicker-dial-out"></div>',
87
- '</div>',
88
- '<span class="clockpicker-am-pm-block">',
89
- '</span>',
90
- '</div>',
91
- '</div>'
92
- ].join('');
93
-
94
- // ClockPicker
95
- function ClockPicker(element, options) {
96
- var popover = $(tpl),
97
- plate = popover.find('.clockpicker-plate'),
98
- hoursView = popover.find('.clockpicker-hours'),
99
- minutesView = popover.find('.clockpicker-minutes'),
100
- amPmBlock = popover.find('.clockpicker-am-pm-block'),
101
- isInput = element.prop('tagName') === 'INPUT',
102
- input = isInput ? element : element.find('input'),
103
- addon = element.find('.input-group-addon .prefix'),
104
- self = this,
105
- timer;
106
-
107
- this.id = uniqueId('cp');
108
- this.element = element;
109
- this.options = options;
110
- this.isAppended = false;
111
- this.isShown = false;
112
- this.currentView = 'hours';
113
- this.isInput = isInput;
114
- this.input = input;
115
- this.addon = addon;
116
- this.popover = popover;
117
- this.plate = plate;
118
- this.hoursView = hoursView;
119
- this.minutesView = minutesView;
120
- this.amPmBlock = amPmBlock;
121
- this.spanHours = popover.find('.clockpicker-span-hours');
122
- this.spanMinutes = popover.find('.clockpicker-span-minutes');
123
- this.spanAmPm = popover.find('.clockpicker-span-am-pm');
124
- this.amOrPm = "PM";
125
-
126
- // Setup for for 12 hour clock if option is selected
127
- if (options.twelvehour) {
128
-
129
- var amPmButtonsTemplate = ['<div class="clockpicker-am-pm-block">',
130
- '<button type="button" class="btn btn-sm btn-default clockpicker-button clockpicker-am-button">',
131
- 'AM</button>',
132
- '<button type="button" class="btn btn-sm btn-default clockpicker-button clockpicker-pm-button">',
133
- 'PM</button>',
134
- '</div>'].join('');
135
-
136
- var amPmButtons = $(amPmButtonsTemplate);
137
- //amPmButtons.appendTo(plate);
138
-
139
- ////Not working b/c they are not shown when this runs
140
- //$('clockpicker-am-button')
141
- // .on("click", function() {
142
- // self.amOrPm = "AM";
143
- // $('.clockpicker-span-am-pm').empty().append('AM');
144
- // });
145
- //
146
- //$('clockpicker-pm-button')
147
- // .on("click", function() {
148
- // self.amOrPm = "PM";
149
- // $('.clockpicker-span-am-pm').empty().append('PM');
150
- // });
151
-
152
- $('<button type="button" class="btn btn-sm btn-default clockpicker-button am-button">' + "AM" + '</button>')
153
- .on("click", function() {
154
- self.amOrPm = "AM";
155
- $('.clockpicker-span-am-pm').empty().append('AM');
156
- }).appendTo(this.amPmBlock);
157
-
158
-
159
- $('<button type="button" class="btn btn-sm btn-default clockpicker-button pm-button">' + "PM" + '</button>')
160
- .on("click", function() {
161
- self.amOrPm = 'PM';
162
- $('.clockpicker-span-am-pm').empty().append('PM');
163
- }).appendTo(this.amPmBlock);
164
-
165
- }
166
-
167
- if (! options.autoclose) {
168
- // If autoclose is not setted, append a button
169
- $('<button type="button" class="btn btn-sm btn-default btn-block clockpicker-button">' + options.donetext + '</button>')
170
- .click($.proxy(this.done, this))
171
- .appendTo(popover);
172
- }
173
-
174
- // Placement and arrow align - make sure they make sense.
175
- if ((options.placement === 'top' || options.placement === 'bottom') && (options.align === 'top' || options.align === 'bottom')) options.align = 'left';
176
- if ((options.placement === 'left' || options.placement === 'right') && (options.align === 'left' || options.align === 'right')) options.align = 'top';
177
-
178
- popover.addClass(options.placement);
179
- popover.addClass('clockpicker-align-' + options.align);
180
-
181
- this.spanHours.click($.proxy(this.toggleView, this, 'hours'));
182
- this.spanMinutes.click($.proxy(this.toggleView, this, 'minutes'));
183
-
184
- // Show or toggle
185
- input.on('focus.clockpicker click.clockpicker', $.proxy(this.show, this));
186
- addon.on('click.clockpicker', $.proxy(this.toggle, this));
187
-
188
- // Build ticks
189
- var tickTpl = $('<div class="clockpicker-tick"></div>'),
190
- i, tick, radian, radius;
191
-
192
- // Hours view
193
- if (options.twelvehour) {
194
- for (i = 1; i < 13; i += 1) {
195
- tick = tickTpl.clone();
196
- radian = i / 6 * Math.PI;
197
- radius = outerRadius;
198
- tick.css('font-size', '120%');
199
- tick.css({
200
- left: dialRadius + Math.sin(radian) * radius - tickRadius,
201
- top: dialRadius - Math.cos(radian) * radius - tickRadius
202
- });
203
- tick.html(i === 0 ? '00' : i);
204
- hoursView.append(tick);
205
- tick.on(mousedownEvent, mousedown);
206
- }
207
- } else {
208
- for (i = 0; i < 24; i += 1) {
209
- tick = tickTpl.clone();
210
- radian = i / 6 * Math.PI;
211
- var inner = i > 0 && i < 13;
212
- radius = inner ? innerRadius : outerRadius;
213
- tick.css({
214
- left: dialRadius + Math.sin(radian) * radius - tickRadius,
215
- top: dialRadius - Math.cos(radian) * radius - tickRadius
216
- });
217
- if (inner) {
218
- tick.css('font-size', '120%');
219
- }
220
- tick.html(i === 0 ? '00' : i);
221
- hoursView.append(tick);
222
- tick.on(mousedownEvent, mousedown);
223
- }
224
- }
225
-
226
- // Minutes view
227
- for (i = 0; i < 60; i += 5) {
228
- tick = tickTpl.clone();
229
- radian = i / 30 * Math.PI;
230
- tick.css({
231
- left: dialRadius + Math.sin(radian) * outerRadius - tickRadius,
232
- top: dialRadius - Math.cos(radian) * outerRadius - tickRadius
233
- });
234
- tick.css('font-size', '120%');
235
- tick.html(leadingZero(i));
236
- minutesView.append(tick);
237
- tick.on(mousedownEvent, mousedown);
238
- }
239
-
240
- // Clicking on minutes view space
241
- plate.on(mousedownEvent, function(e){
242
- if ($(e.target).closest('.clockpicker-tick').length === 0) {
243
- mousedown(e, true);
244
- }
245
- });
246
-
247
- // Mousedown or touchstart
248
- function mousedown(e, space) {
249
- var offset = plate.offset(),
250
- isTouch = /^touch/.test(e.type),
251
- x0 = offset.left + dialRadius,
252
- y0 = offset.top + dialRadius,
253
- dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
254
- dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0,
255
- z = Math.sqrt(dx * dx + dy * dy),
256
- moved = false;
257
-
258
- // When clicking on minutes view space, check the mouse position
259
- if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius)) {
260
- return;
261
- }
262
- e.preventDefault();
263
-
264
- // Set cursor style of body after 200ms
265
- var movingTimer = setTimeout(function(){
266
- $body.addClass('clockpicker-moving');
267
- }, 200);
268
-
269
- // Place the canvas to top
270
- if (svgSupported) {
271
- plate.append(self.canvas);
272
- }
273
-
274
- // Clock
275
- self.setHand(dx, dy, ! space, true);
276
-
277
- // Mousemove on document
278
- $doc.off(mousemoveEvent).on(mousemoveEvent, function(e){
279
- e.preventDefault();
280
- var isTouch = /^touch/.test(e.type),
281
- x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
282
- y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
283
- if (! moved && x === dx && y === dy) {
284
- // Clicking in chrome on windows will trigger a mousemove event
285
- return;
286
- }
287
- moved = true;
288
- self.setHand(x, y, false, true);
289
- });
290
-
291
- // Mouseup on document
292
- $doc.off(mouseupEvent).on(mouseupEvent, function(e){
293
- $doc.off(mouseupEvent);
294
- e.preventDefault();
295
- var isTouch = /^touch/.test(e.type),
296
- x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,
297
- y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
298
- if ((space || moved) && x === dx && y === dy) {
299
- self.setHand(x, y);
300
- }
301
- if (self.currentView === 'hours') {
302
- self.toggleView('minutes', duration / 2);
303
- } else {
304
- if (options.autoclose) {
305
- self.minutesView.addClass('clockpicker-dial-out');
306
- setTimeout(function(){
307
- self.done();
308
- }, duration / 2);
309
- }
310
- }
311
- plate.prepend(canvas);
312
-
313
- // Reset cursor style of body
314
- clearTimeout(movingTimer);
315
- $body.removeClass('clockpicker-moving');
316
-
317
- // Unbind mousemove event
318
- $doc.off(mousemoveEvent);
319
- });
320
- }
321
-
322
- if (svgSupported) {
323
- // Draw clock hands and others
324
- var canvas = popover.find('.clockpicker-canvas'),
325
- svg = createSvgElement('svg');
326
- svg.setAttribute('class', 'clockpicker-svg');
327
- svg.setAttribute('width', diameter);
328
- svg.setAttribute('height', diameter);
329
- var g = createSvgElement('g');
330
- g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')');
331
- var bearing = createSvgElement('circle');
332
- bearing.setAttribute('class', 'clockpicker-canvas-bearing');
333
- bearing.setAttribute('cx', 0);
334
- bearing.setAttribute('cy', 0);
335
- bearing.setAttribute('r', 2);
336
- var hand = createSvgElement('line');
337
- hand.setAttribute('x1', 0);
338
- hand.setAttribute('y1', 0);
339
- var bg = createSvgElement('circle');
340
- bg.setAttribute('class', 'clockpicker-canvas-bg');
341
- bg.setAttribute('r', tickRadius);
342
- var fg = createSvgElement('circle');
343
- fg.setAttribute('class', 'clockpicker-canvas-fg');
344
- fg.setAttribute('r', 3.5);
345
- g.appendChild(hand);
346
- g.appendChild(bg);
347
- g.appendChild(fg);
348
- g.appendChild(bearing);
349
- svg.appendChild(g);
350
- canvas.append(svg);
351
-
352
- this.hand = hand;
353
- this.bg = bg;
354
- this.fg = fg;
355
- this.bearing = bearing;
356
- this.g = g;
357
- this.canvas = canvas;
358
- }
359
-
360
- raiseCallback(this.options.init);
361
- }
362
-
363
- function raiseCallback(callbackFunction) {
364
- if (callbackFunction && typeof callbackFunction === "function") {
365
- callbackFunction();
366
- }
367
- }
368
-
369
- // Default options
370
- ClockPicker.DEFAULTS = {
371
- 'default': '', // default time, 'now' or '13:14' e.g.
372
- fromnow: 0, // set default time to * milliseconds from now (using with default = 'now')
373
- placement: 'bottom', // clock popover placement
374
- align: 'left', // popover arrow align
375
- donetext: '完成', // done button text
376
- autoclose: false, // auto close when minute is selected
377
- twelvehour: false, // change to 12 hour AM/PM clock from 24 hour
378
- vibrate: true // vibrate the device when dragging clock hand
379
- };
380
-
381
- // Show or hide popover
382
- ClockPicker.prototype.toggle = function(){
383
- this[this.isShown ? 'hide' : 'show']();
384
- };
385
-
386
- // Set popover position
387
- ClockPicker.prototype.locate = function(){
388
- var element = this.element,
389
- popover = this.popover,
390
- offset = element.offset(),
391
- width = element.outerWidth(),
392
- height = element.outerHeight(),
393
- placement = this.options.placement,
394
- align = this.options.align,
395
- styles = {},
396
- self = this;
397
-
398
- popover.show();
399
-
400
- // Place the popover
401
- switch (placement) {
402
- case 'bottom':
403
- styles.top = offset.top + height;
404
- break;
405
- case 'right':
406
- styles.left = offset.left + width;
407
- break;
408
- case 'top':
409
- styles.top = offset.top - popover.outerHeight();
410
- break;
411
- case 'left':
412
- styles.left = offset.left - popover.outerWidth();
413
- break;
414
- }
415
-
416
- // Align the popover arrow
417
- switch (align) {
418
- case 'left':
419
- styles.left = offset.left;
420
- break;
421
- case 'right':
422
- styles.left = offset.left + width - popover.outerWidth();
423
- break;
424
- case 'top':
425
- styles.top = offset.top;
426
- break;
427
- case 'bottom':
428
- styles.top = offset.top + height - popover.outerHeight();
429
- break;
430
- }
431
-
432
- popover.css(styles);
433
- };
434
-
435
- // Show popover
436
- ClockPicker.prototype.show = function(e){
437
- // Not show again
438
- if (this.isShown) {
439
- return;
440
- }
441
-
442
- raiseCallback(this.options.beforeShow);
443
-
444
- var self = this;
445
-
446
- // Initialize
447
- if (! this.isAppended) {
448
- // Append popover to body
449
- $body = $(document.body).append(this.popover);
450
-
451
- // Reset position when resize
452
- $win.on('resize.clockpicker' + this.id, function(){
453
- if (self.isShown) {
454
- self.locate();
455
- }
456
- });
457
-
458
- this.isAppended = true;
459
- }
460
-
461
- // Get the time
462
- var value = ((this.input.prop('value') || this.options['default'] || '') + '').split(':');
463
- if (value[0] === 'now') {
464
- var now = new Date(+ new Date() + this.options.fromnow);
465
- value = [
466
- now.getHours(),
467
- now.getMinutes()
468
- ];
469
- }
470
- this.hours = + value[0] || 0;
471
- this.minutes = + value[1] || 0;
472
- this.spanHours.html(leadingZero(this.hours));
473
- this.spanMinutes.html(leadingZero(this.minutes));
474
-
475
- // Toggle to hours view
476
- this.toggleView('hours');
477
-
478
- // Set position
479
- this.locate();
480
-
481
- this.isShown = true;
482
-
483
- // Hide when clicking or tabbing on any element except the clock, input and addon
484
- $doc.on('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id, function(e){
485
-
486
- /* TC 13/7/17
487
- Fixed a bug here - changed
488
- target.closest(self.addon).length === 0 &&
489
- to
490
- target.closest(self.addon.selector).length === 0 &&
491
- Without this it is not possible to click on the clock icon to open the popover.
492
- */
493
- var target = $(e.target);
494
- if (target.closest(self.popover).length === 0 &&
495
- target.closest(self.addon.selector).length === 0 &&
496
- target.closest(self.input).length === 0) {
497
- self.hide();
498
- }
499
- });
500
-
501
- // Hide when ESC is pressed
502
- $doc.on('keyup.clockpicker.' + this.id, function(e){
503
- if (e.keyCode === 27) {
504
- self.hide();
505
- }
506
- });
507
-
508
- raiseCallback(this.options.afterShow);
509
- };
510
-
511
- // Hide popover
512
- ClockPicker.prototype.hide = function(){
513
- raiseCallback(this.options.beforeHide);
514
-
515
- this.isShown = false;
516
-
517
- // Unbinding events on document
518
- $doc.off('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id);
519
- $doc.off('keyup.clockpicker.' + this.id);
520
-
521
- this.popover.hide();
522
-
523
- raiseCallback(this.options.afterHide);
524
- };
525
-
526
- // Toggle to hours or minutes view
527
- ClockPicker.prototype.toggleView = function(view, delay){
528
- var raiseAfterHourSelect = false;
529
- if (view === 'minutes' && $(this.hoursView).css("visibility") === "visible") {
530
- raiseCallback(this.options.beforeHourSelect);
531
- raiseAfterHourSelect = true;
532
- }
533
- var isHours = view === 'hours',
534
- nextView = isHours ? this.hoursView : this.minutesView,
535
- hideView = isHours ? this.minutesView : this.hoursView;
536
-
537
- this.currentView = view;
538
-
539
- this.spanHours.toggleClass('text-primary', isHours);
540
- this.spanMinutes.toggleClass('text-primary', ! isHours);
541
-
542
- // Let's make transitions
543
- hideView.addClass('clockpicker-dial-out');
544
- nextView.css('visibility', 'visible').removeClass('clockpicker-dial-out');
545
-
546
- // Reset clock hand
547
- this.resetClock(delay);
548
-
549
- // After transitions ended
550
- clearTimeout(this.toggleViewTimer);
551
- this.toggleViewTimer = setTimeout(function(){
552
- hideView.css('visibility', 'hidden');
553
- }, duration);
554
-
555
- if (raiseAfterHourSelect) {
556
- raiseCallback(this.options.afterHourSelect);
557
- }
558
- };
559
-
560
- // Reset clock hand
561
- ClockPicker.prototype.resetClock = function(delay){
562
- var view = this.currentView,
563
- value = this[view],
564
- isHours = view === 'hours',
565
- unit = Math.PI / (isHours ? 6 : 30),
566
- radian = value * unit,
567
- radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius,
568
- x = Math.sin(radian) * radius,
569
- y = - Math.cos(radian) * radius,
570
- self = this;
571
- if (svgSupported && delay) {
572
- self.canvas.addClass('clockpicker-canvas-out');
573
- setTimeout(function(){
574
- self.canvas.removeClass('clockpicker-canvas-out');
575
- self.setHand(x, y);
576
- }, delay);
577
- } else {
578
- this.setHand(x, y);
579
- }
580
- };
581
-
582
- // Set clock hand to (x, y)
583
- ClockPicker.prototype.setHand = function(x, y, roundBy5, dragging){
584
- var radian = Math.atan2(x, - y),
585
- isHours = this.currentView === 'hours',
586
- unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
587
- z = Math.sqrt(x * x + y * y),
588
- options = this.options,
589
- inner = isHours && z < (outerRadius + innerRadius) / 2,
590
- radius = inner ? innerRadius : outerRadius,
591
- value;
592
-
593
- if (options.twelvehour) {
594
- radius = outerRadius;
595
- }
596
-
597
- // Radian should in range [0, 2PI]
598
- if (radian < 0) {
599
- radian = Math.PI * 2 + radian;
600
- }
601
-
602
- // Get the round value
603
- value = Math.round(radian / unit);
604
-
605
- // Get the round radian
606
- radian = value * unit;
607
-
608
- // Correct the hours or minutes
609
- if (options.twelvehour) {
610
- if (isHours) {
611
- if (value === 0) {
612
- value = 12;
613
- }
614
- } else {
615
- if (roundBy5) {
616
- value *= 5;
617
- }
618
- if (value === 60) {
619
- value = 0;
620
- }
621
- }
622
- } else {
623
- if (isHours) {
624
- if (value === 12) {
625
- value = 0;
626
- }
627
- value = inner ? (value === 0 ? 12 : value) : value === 0 ? 0 : value + 12;
628
- } else {
629
- if (roundBy5) {
630
- value *= 5;
631
- }
632
- if (value === 60) {
633
- value = 0;
634
- }
635
- }
636
- }
637
-
638
- // Once hours or minutes changed, vibrate the device
639
- if (this[this.currentView] !== value) {
640
- if (vibrate && this.options.vibrate) {
641
- // Do not vibrate too frequently
642
- if (! this.vibrateTimer) {
643
- navigator[vibrate](10);
644
- this.vibrateTimer = setTimeout($.proxy(function(){
645
- this.vibrateTimer = null;
646
- }, this), 100);
647
- }
648
- }
649
- }
650
-
651
- this[this.currentView] = value;
652
- this[isHours ? 'spanHours' : 'spanMinutes'].html(leadingZero(value));
653
-
654
- // If svg is not supported, just add an active class to the tick
655
- if (! svgSupported) {
656
- this[isHours ? 'hoursView' : 'minutesView'].find('.clockpicker-tick').each(function(){
657
- var tick = $(this);
658
- tick.toggleClass('active', value === + tick.html());
659
- });
660
- return;
661
- }
662
-
663
- // Place clock hand at the top when dragging
664
- if (dragging || (! isHours && value % 5)) {
665
- this.g.insertBefore(this.hand, this.bearing);
666
- this.g.insertBefore(this.bg, this.fg);
667
- this.bg.setAttribute('class', 'clockpicker-canvas-bg clockpicker-canvas-bg-trans');
668
- } else {
669
- // Or place it at the bottom
670
- this.g.insertBefore(this.hand, this.bg);
671
- this.g.insertBefore(this.fg, this.bg);
672
- this.bg.setAttribute('class', 'clockpicker-canvas-bg');
673
- }
674
-
675
- // Set clock hand and others' position
676
- var cx = Math.sin(radian) * radius,
677
- cy = - Math.cos(radian) * radius;
678
- this.hand.setAttribute('x2', cx);
679
- this.hand.setAttribute('y2', cy);
680
- this.bg.setAttribute('cx', cx);
681
- this.bg.setAttribute('cy', cy);
682
- this.fg.setAttribute('cx', cx);
683
- this.fg.setAttribute('cy', cy);
684
- };
685
-
686
- // Hours and minutes are selected
687
- ClockPicker.prototype.done = function() {
688
- raiseCallback(this.options.beforeDone);
689
- this.hide();
690
- var last = this.input.prop('value'),
691
- value = leadingZero(this.hours) + ':' + leadingZero(this.minutes);
692
- if (this.options.twelvehour) {
693
- value = value + this.amOrPm;
694
- }
695
-
696
- this.input.prop('value', value);
697
- if (value !== last) {
698
- this.input.triggerHandler('change');
699
- if (! this.isInput) {
700
- this.element.trigger('change');
701
- }
702
- }
703
-
704
- if (this.options.autoclose) {
705
- this.input.trigger('blur');
706
- }
707
-
708
- raiseCallback(this.options.afterDone);
709
- };
710
-
711
- // Remove clockpicker from input
712
- ClockPicker.prototype.remove = function() {
713
- this.element.removeData('clockpicker');
714
- this.input.off('focus.clockpicker click.clockpicker');
715
- this.addon.off('click.clockpicker');
716
- if (this.isShown) {
717
- this.hide();
718
- }
719
- if (this.isAppended) {
720
- $win.off('resize.clockpicker' + this.id);
721
- this.popover.remove();
722
- }
723
- };
724
-
725
- // Extends $.fn.clockpicker
726
- $.fn.clockpicker = function(option){
727
- var args = Array.prototype.slice.call(arguments, 1);
728
- return this.each(function(){
729
- var $this = $(this),
730
- data = $this.data('clockpicker');
731
- if (! data) {
732
- var options = $.extend({}, ClockPicker.DEFAULTS, $this.data(), typeof option == 'object' && option);
733
- $this.data('clockpicker', new ClockPicker($this, options));
734
- } else {
735
- // Manual operatsions. show, hide, remove, e.g.
736
- if (typeof data[option] === 'function') {
737
- data[option].apply(data, args);
738
- }
739
- }
740
- });
741
- };
742
- }());