pdfjs_viewer 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 303c59e21fb3f5296cee201dd908249346330da8e7f0c5d0dae6dafaeaec9623
4
- data.tar.gz: 384a29bfc0275723054a18a083c1af8f43fe887a043a7237fd900b03dcc537b2
3
+ metadata.gz: 6e210ad85396ea6b8f0a5e68d4d31c181ccf2c5f08e53b86ece4fc6bd5376b12
4
+ data.tar.gz: 908d85a7ec07147c56cd5efbe6f2e7199f6f2babef079e55d9624d5e70cc159d
5
5
  SHA512:
6
- metadata.gz: ba3884a9408dd07ad8b67ea7cd656a625994b91cbf62b88b6d1e8ecc5c059a74d97bc747d572b9ff7a6fbf05f31a32ca9be49373c184143ad37fc995e1bb26f6
7
- data.tar.gz: 525b99604b13604181d6254bfea05ba61efa23e7185a2e18d534d8df018690eba4668ce2bea46af3cafde2ebf6d61cda671852820d7f30ac0c22acee7a54eaaf
6
+ metadata.gz: 9ac6ab17137ca2c06081545975dac59b3b802fea7bf8c8a112d5bc840c644d0c499836c7ece6e1b30027e73d76cad121ab9e0ed5512f4acbb9f2fd597319a37c
7
+ data.tar.gz: 9ed70d1ab9ea5f299657232553ee58cd72ca6e0303fb91e32b7d071280a92d3acf12468431338d2a8ac73000690aad6a014d08a9eef6401a0e699cb104243774
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pdfjs_viewer (0.1.0)
4
+ pdfjs_viewer (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -6,6 +6,15 @@
6
6
  class PdfjsViewer::ViewerController < ActionController::Base
7
7
  def show
8
8
  @file_url = params[:file]
9
+ @show_buttons = parse_show_buttons(params[:show_buttons])
9
10
  render layout: false
10
11
  end
12
+
13
+ private
14
+
15
+ def parse_show_buttons(show_buttons_param)
16
+ return [] if show_buttons_param.blank?
17
+
18
+ show_buttons_param.is_a?(String) ? show_buttons_param.split(',').map(&:strip) : show_buttons_param
19
+ end
11
20
  end
@@ -4,10 +4,20 @@
4
4
 
5
5
  # PdfjsViewer Application Helper
6
6
  module PdfjsViewer::ApplicationHelper
7
+ BUTTON_CONFIG_MAPPING = {
8
+ 'editorHighlightButton' => :show_highlight_button,
9
+ 'editorFreeTextButton' => :show_text_button,
10
+ 'editorInkButton' => :show_draw_button,
11
+ 'editorStampButton' => :show_add_edit_image_button,
12
+ 'printButton' => :show_print_button,
13
+ 'downloadButton' => :show_save_button,
14
+ 'secondaryOpenFile' => :show_open_file_button
15
+ }.freeze
16
+
7
17
  def toggle_action(key = nil)
8
18
  return if PdfjsViewer.configuration.send(key)
9
19
 
10
- 'display: none'
20
+ 'hide'
11
21
  end
12
22
 
13
23
  def stylesheet_path
@@ -17,4 +27,21 @@ module PdfjsViewer::ApplicationHelper
17
27
  def pdfjs_viewer_path
18
28
  PdfjsViewer::Engine.routes.url_helpers.root_path
19
29
  end
30
+
31
+ def button_visibility(button_id)
32
+ return default_button_visibility(button_id) if @show_buttons.blank?
33
+
34
+ @show_buttons.include?(button_id.to_s) ? '' : 'hide'
35
+ end
36
+
37
+ private
38
+
39
+ def button_config_key(button_id)
40
+ BUTTON_CONFIG_MAPPING[button_id.to_s]
41
+ end
42
+
43
+ def default_button_visibility(button_id)
44
+ config_key = button_config_key(button_id)
45
+ config_key ? toggle_action(config_key) : ''
46
+ end
20
47
  end
@@ -89,12 +89,12 @@ See https://github.com/adobe-type-tools/cmap-resources
89
89
  <div id="toolbarContainer">
90
90
  <div id="toolbarViewer" class="toolbarHorizontalGroup">
91
91
  <div id="toolbarViewerLeft" class="toolbarHorizontalGroup">
92
- <button id="sidebarToggleButton" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-toggle-sidebar-button" aria-expanded="false" aria-haspopup="true" aria-controls="sidebarContainer">
92
+ <button id="sidebarToggleButton" class="toolbarButton <%= button_visibility('sidebarToggleButton') %>" type="button" tabindex="0" data-l10n-id="pdfjs-toggle-sidebar-button" aria-expanded="false" aria-haspopup="true" aria-controls="sidebarContainer">
93
93
  <span data-l10n-id="pdfjs-toggle-sidebar-button-label"></span>
94
94
  </button>
95
95
  <div class="toolbarButtonSpacer"></div>
96
96
  <div class="toolbarButtonWithContainer">
97
- <button id="viewFindButton" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-findbar-button" aria-expanded="false" aria-controls="findbar">
97
+ <button id="viewFindButton" class="toolbarButton <%= button_visibility('viewFindButton') %>" type="button" tabindex="0" data-l10n-id="pdfjs-findbar-button" aria-expanded="false" aria-controls="findbar">
98
98
  <span data-l10n-id="pdfjs-findbar-button-label"></span>
99
99
  </button>
100
100
  <div class="hidden doorHanger toolbarHorizontalGroup" id="findbar">
@@ -141,11 +141,11 @@ See https://github.com/adobe-type-tools/cmap-resources
141
141
  </div> <!-- findbar -->
142
142
  </div>
143
143
  <div class="toolbarHorizontalGroup hiddenSmallView">
144
- <button class="toolbarButton" type="button" id="previous" tabindex="0" data-l10n-id="pdfjs-previous-button">
144
+ <button class="toolbarButton <%= button_visibility('previous') %>" type="button" id="previous" tabindex="0" data-l10n-id="pdfjs-previous-button">
145
145
  <span data-l10n-id="pdfjs-previous-button-label"></span>
146
146
  </button>
147
147
  <div class="splitToolbarButtonSeparator"></div>
148
- <button class="toolbarButton" type="button" id="next" tabindex="0" data-l10n-id="pdfjs-next-button">
148
+ <button class="toolbarButton <%= button_visibility('next') %>" type="button" id="next" tabindex="0" data-l10n-id="pdfjs-next-button">
149
149
  <span data-l10n-id="pdfjs-next-button-label"></span>
150
150
  </button>
151
151
  </div>
@@ -158,11 +158,11 @@ See https://github.com/adobe-type-tools/cmap-resources
158
158
  </div>
159
159
  <div id="toolbarViewerMiddle" class="toolbarHorizontalGroup">
160
160
  <div class="toolbarHorizontalGroup">
161
- <button id="zoomOutButton" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-zoom-out-button">
161
+ <button id="zoomOutButton" class="toolbarButton <%= button_visibility('zoomOutButton') %>" type="button" tabindex="0" data-l10n-id="pdfjs-zoom-out-button">
162
162
  <span data-l10n-id="pdfjs-zoom-out-button-label"></span>
163
163
  </button>
164
164
  <div class="splitToolbarButtonSeparator"></div>
165
- <button id="zoomInButton" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-zoom-in-button">
165
+ <button id="zoomInButton" class="toolbarButton <%= button_visibility('zoomInButton') %>" type="button" tabindex="0" data-l10n-id="pdfjs-zoom-in-button">
166
166
  <span data-l10n-id="pdfjs-zoom-in-button-label"></span>
167
167
  </button>
168
168
  </div>
@@ -199,7 +199,7 @@ See https://github.com/adobe-type-tools/cmap-resources
199
199
  </div>
200
200
  </div>
201
201
  <div id="editorHighlight" class="toolbarButtonWithContainer">
202
- <button id="editorHighlightButton" style="<%= toggle_action(:show_highlight_button) %>" class="toolbarButton" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorHighlightParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-highlight-button">
202
+ <button id="editorHighlightButton" class="toolbarButton <%= button_visibility('editorHighlightButton') %>" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorHighlightParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-highlight-button">
203
203
  <span data-l10n-id="pdfjs-editor-highlight-button-label"></span>
204
204
  </button>
205
205
  <div class="editorParamsToolbar hidden doorHangerRight" id="editorHighlightParamsToolbar">
@@ -224,7 +224,7 @@ See https://github.com/adobe-type-tools/cmap-resources
224
224
  </div>
225
225
  </div>
226
226
  <div id="editorFreeText" class="toolbarButtonWithContainer">
227
- <button id="editorFreeTextButton" style="<%= toggle_action(:show_text_button) %>" class="toolbarButton" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorFreeTextParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-free-text-button">
227
+ <button id="editorFreeTextButton" class="toolbarButton <%= button_visibility('editorFreeTextButton') %>" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorFreeTextParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-free-text-button">
228
228
  <span data-l10n-id="pdfjs-editor-free-text-button-label"></span>
229
229
  </button>
230
230
  <div class="editorParamsToolbar hidden doorHangerRight" id="editorFreeTextParamsToolbar">
@@ -241,7 +241,7 @@ See https://github.com/adobe-type-tools/cmap-resources
241
241
  </div>
242
242
  </div>
243
243
  <div id="editorInk" class="toolbarButtonWithContainer">
244
- <button id="editorInkButton" style="<%= toggle_action(:show_draw_button) %>" class="toolbarButton" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorInkParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-ink-button">
244
+ <button id="editorInkButton" class="toolbarButton <%= button_visibility('editorInkButton') %>" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorInkParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-ink-button">
245
245
  <span data-l10n-id="pdfjs-editor-ink-button-label"></span>
246
246
  </button>
247
247
  <div class="editorParamsToolbar hidden doorHangerRight" id="editorInkParamsToolbar">
@@ -262,7 +262,7 @@ See https://github.com/adobe-type-tools/cmap-resources
262
262
  </div>
263
263
  </div>
264
264
  <div id="editorStamp" class="toolbarButtonWithContainer">
265
- <button id="editorStampButton" style="<%= toggle_action(:show_add_edit_image_button) %>" class="toolbarButton" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorStampParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-stamp-button">
265
+ <button id="editorStampButton" class="toolbarButton <%= button_visibility('editorStampButton') %>" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorStampParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-stamp-button">
266
266
  <span data-l10n-id="pdfjs-editor-stamp-button-label"></span>
267
267
  </button>
268
268
  <div class="editorParamsToolbar hidden doorHangerRight menu" id="editorStampParamsToolbar">
@@ -278,10 +278,10 @@ See https://github.com/adobe-type-tools/cmap-resources
278
278
  <div id="editorModeSeparator" class="verticalToolbarSeparator"></div>
279
279
 
280
280
  <div class="toolbarHorizontalGroup hiddenMediumView">
281
- <button id="printButton" style="<%= toggle_action(:show_print_button) %>" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-print-button">
281
+ <button id="printButton" class="toolbarButton <%= button_visibility('printButton') %>" type="button" tabindex="0" data-l10n-id="pdfjs-print-button">
282
282
  <span data-l10n-id="pdfjs-print-button-label"></span>
283
283
  </button>
284
- <button id="downloadButton" style="<%= toggle_action(:show_save_button) %>" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-save-button">
284
+ <button id="downloadButton" class="toolbarButton <%= button_visibility('downloadButton') %>" type="button" tabindex="0" data-l10n-id="pdfjs-save-button">
285
285
  <span data-l10n-id="pdfjs-save-button-label"></span>
286
286
  </button>
287
287
  </div>
@@ -289,12 +289,12 @@ See https://github.com/adobe-type-tools/cmap-resources
289
289
  <div class="verticalToolbarSeparator hiddenMediumView"></div>
290
290
 
291
291
  <div id="secondaryToolbarToggle" class="toolbarButtonWithContainer">
292
- <button id="secondaryToolbarToggleButton" class="toolbarButton" type="button" tabindex="0" data-l10n-id="pdfjs-tools-button" aria-expanded="false" aria-haspopup="true" aria-controls="secondaryToolbar">
292
+ <button id="secondaryToolbarToggleButton" class="toolbarButton <%= button_visibility('secondaryToolbarToggleButton') %>" type="button" tabindex="0" data-l10n-id="pdfjs-tools-button" aria-expanded="false" aria-haspopup="true" aria-controls="secondaryToolbar">
293
293
  <span data-l10n-id="pdfjs-tools-button-label"></span>
294
294
  </button>
295
295
  <div id="secondaryToolbar" class="hidden doorHangerRight menu">
296
296
  <div id="secondaryToolbarButtonContainer" class="menuContainer">
297
- <button id="secondaryOpenFile" style="<%= toggle_action(:show_open_file_button) %>" class="toolbarButton labeled" type="button" tabindex="0" data-l10n-id="pdfjs-open-file-button">
297
+ <button id="secondaryOpenFile" class="toolbarButton labeled <%= button_visibility('secondaryOpenFile') %>" type="button" tabindex="0" data-l10n-id="pdfjs-open-file-button">
298
298
  <span data-l10n-id="pdfjs-open-file-button-label"></span>
299
299
  </button>
300
300
 
@@ -309,7 +309,7 @@ See https://github.com/adobe-type-tools/cmap-resources
309
309
 
310
310
  </div>
311
311
 
312
- <div class="horizontalToolbarSeparator" style="<%= toggle_action(:show_open_file_button) %>"></div>
312
+ <div class="horizontalToolbarSeparator" class="<%= toggle_action(:show_open_file_button) %>"></div>
313
313
 
314
314
  <button id="presentationMode" class="toolbarButton labeled" type="button" tabindex="0" data-l10n-id="pdfjs-presentation-mode-button">
315
315
  <span data-l10n-id="pdfjs-presentation-mode-button-label"></span>
@@ -735,7 +735,7 @@ See https://github.com/adobe-type-tools/cmap-resources
735
735
  </div>
736
736
  </dialog>
737
737
 
738
- <dialog id="printServiceDialog" style="min-width: 200px;">
738
+ <dialog id="printServiceDialog" class="w-200">
739
739
  <div class="row">
740
740
  <span data-l10n-id="pdfjs-print-progress-message"></span>
741
741
  </div>
@@ -3,5 +3,5 @@
3
3
  # Copyright (c) 2014 - 2025 Salus. All rights reserved.
4
4
 
5
5
  module PdfjsViewer
6
- VERSION = '0.1.1'
6
+ VERSION = '0.1.3'
7
7
  end
@@ -13,6 +13,16 @@
13
13
  * limitations under the License.
14
14
  */
15
15
 
16
+ /* Added to satisfy csp, ensure this stays if pdf viewer package is updated */
17
+ .w-200 {
18
+ width: 200px
19
+ }
20
+
21
+ .hide {
22
+ display: none !important;
23
+ }
24
+ /* end */
25
+
16
26
  .messageBar{
17
27
  --closing-button-icon:url(images/messageBar_closingButton.svg);
18
28
  --message-bar-close-button-color:var(--text-primary-color);
@@ -734,7 +734,7 @@ See https://github.com/adobe-type-tools/cmap-resources
734
734
  </div>
735
735
  </dialog>
736
736
 
737
- <dialog id="printServiceDialog" style="min-width: 200px;">
737
+ <dialog id="printServiceDialog" class="w-200">
738
738
  <div class="row">
739
739
  <span data-l10n-id="pdfjs-print-progress-message"></span>
740
740
  </div>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfjs_viewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toliver
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-26 00:00:00.000000000 Z
11
+ date: 2025-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler