diva.js 7.2.4 → 7.2.6

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.
@@ -1,189 +0,0 @@
1
- module View.Toolbar exposing (viewToolbar)
2
-
3
- import Html exposing (Html, div, text)
4
- import Html.Attributes as HA exposing (classList)
5
- import Html.Lazy as Lazy
6
- import Model exposing (Model, SidebarState(..), ViewMode(..), currentManifest, getPageAt, pageViewStartIndex)
7
- import Msg exposing (Msg(..))
8
- import Utilities exposing (disabledIf, isNothing)
9
- import View.Helpers exposing (viewButton)
10
- import View.Icons as Icons
11
-
12
-
13
- viewToolbar : Model -> Html Msg
14
- viewToolbar model =
15
- let
16
- controlsDisabled =
17
- currentManifest model |> isNothing
18
-
19
- currentLabelText =
20
- currentLabelFor model
21
- in
22
- div [ HA.class "canvas-toolbar-stack" ]
23
- [ div [ HA.class "canvas-toolbar" ]
24
- [ div [ HA.class "canvas-toolbar-section" ]
25
- [ viewButton
26
- { label = "Zoom Out"
27
- , icon = Icons.zoomOut
28
- , onClickMsg = disabledIf controlsDisabled UserClickedZoomOut
29
- , isFullscreen = model.fullscreen
30
- }
31
- , viewButton
32
- { label = "Zoom In"
33
- , icon = Icons.zoomIn
34
- , onClickMsg = disabledIf controlsDisabled UserClickedZoomIn
35
- , isFullscreen = model.fullscreen
36
- }
37
- ]
38
- , div [ HA.class "canvas-toolbar-section is-right" ]
39
- [ viewButton
40
- { label = "Page View"
41
- , icon = Icons.pageViewOpen
42
- , onClickMsg = disabledIf controlsDisabled UserClickedOpenPageView
43
- , isFullscreen = model.fullscreen
44
- }
45
- , viewButton
46
- { label = "Manifest Info"
47
- , icon = Icons.info
48
- , onClickMsg = disabledIf controlsDisabled UserClickedOpenManifestInfo
49
- , isFullscreen = model.fullscreen
50
- }
51
- , viewButton
52
- { label =
53
- if model.viewMode == OneUp then
54
- "Two Page"
55
-
56
- else
57
- "One Page"
58
- , icon =
59
- if model.viewMode == OneUp then
60
- Icons.openingPageView
61
-
62
- else
63
- Icons.scrollingPageView
64
- , onClickMsg = disabledIf controlsDisabled UserToggledTwoUp
65
- , isFullscreen = model.fullscreen
66
- }
67
- , viewButton
68
- { label = "Shift Pages"
69
- , icon =
70
- if model.shiftByOne then
71
- Icons.shiftLeft
72
-
73
- else
74
- Icons.shiftRight
75
- , onClickMsg = disabledIf (controlsDisabled || model.viewMode == OneUp) UserToggledShiftByOne
76
- , isFullscreen = model.fullscreen
77
- }
78
- , viewButton
79
- (let
80
- sidebarVisible =
81
- if model.isMobile then
82
- model.mobileSidebarOpen
83
-
84
- else
85
- model.sidebarState /= SidebarHidden
86
- in
87
- { label =
88
- if sidebarVisible then
89
- "Hide Sidebar"
90
-
91
- else
92
- "Show Sidebar"
93
- , icon =
94
- if sidebarVisible then
95
- Icons.hideSidebar
96
-
97
- else
98
- Icons.showSidebar
99
- , onClickMsg = disabledIf controlsDisabled UserToggledSidebar
100
- , isFullscreen = model.fullscreen
101
- }
102
- )
103
- , viewButton
104
- { label =
105
- if model.fullscreen then
106
- "Exit Full"
107
-
108
- else
109
- "Fullscreen"
110
- , icon =
111
- if model.fullscreen then
112
- Icons.fromFullscreen
113
-
114
- else
115
- Icons.toFullscreen
116
- , onClickMsg = Just UserToggledFullscreen
117
- , isFullscreen = model.fullscreen
118
- }
119
- ]
120
- ]
121
- , Lazy.lazy2 viewCurrentLabel model.fullscreen currentLabelText
122
- ]
123
-
124
-
125
- currentLabelFor : Model -> String
126
- currentLabelFor model =
127
- let
128
- fullLabelText =
129
- case model.selectedIndex of
130
- Just index ->
131
- case model.viewMode of
132
- OneUp ->
133
- getPageAt index model.pages
134
- |> Maybe.map .label
135
- |> Maybe.withDefault ""
136
-
137
- TwoUp ->
138
- let
139
- startIndex =
140
- pageViewStartIndex model.viewMode model.shiftByOne index
141
-
142
- firstLabel =
143
- getPageAt startIndex model.pages
144
- |> Maybe.map .label
145
-
146
- secondLabel =
147
- getPageAt (startIndex + 1) model.pages
148
- |> Maybe.map .label
149
- in
150
- case ( firstLabel, secondLabel ) of
151
- ( Just left, _ ) ->
152
- if model.shiftByOne && startIndex == 0 then
153
- left
154
-
155
- else
156
- case secondLabel of
157
- Just right ->
158
- left ++ " / " ++ right
159
-
160
- Nothing ->
161
- left
162
-
163
- _ ->
164
- ""
165
-
166
- Nothing ->
167
- ""
168
- in
169
- truncateLabel 140 fullLabelText
170
-
171
-
172
- truncateLabel : Int -> String -> String
173
- truncateLabel maxLength label =
174
- if String.length label > maxLength then
175
- String.left (maxLength - 3) label ++ "..."
176
-
177
- else
178
- label
179
-
180
-
181
- viewCurrentLabel : Bool -> String -> Html Msg
182
- viewCurrentLabel fullscreen labelText =
183
- div
184
- [ classList
185
- [ ( "canvas-label", True )
186
- , ( "is-fullscreen", fullscreen )
187
- ]
188
- ]
189
- [ text labelText ]
package/src/View.elm DELETED
@@ -1,244 +0,0 @@
1
- module View exposing (view)
2
-
3
- import Html exposing (Html, div, h1, node, text)
4
- import Html.Attributes as HA exposing (classList, id)
5
- import Html.Lazy as Lazy
6
- import IIIF.Language exposing (extractLabelFromLanguageMap)
7
- import IIIF.Presentation exposing (toLabel, toRequiredStatement)
8
- import Model exposing (Model, ResourceResponse(..), Response(..), currentManifest)
9
- import Msg exposing (Msg)
10
- import View.CollectionExplorer
11
- import View.Helpers exposing (emptyHtml, viewIf, viewMaybe)
12
- import View.HtmlRenderer as HtmlRenderer
13
- import View.ManifestInfoModal
14
- import View.PageViewModal
15
- import View.Sidebar
16
- import View.Toolbar exposing (viewToolbar)
17
-
18
-
19
- view : Model -> Html Msg
20
- view model =
21
- let
22
- maybeStatus =
23
- viewerStatus model
24
- in
25
- div [ id model.rootElementId ]
26
- [ div
27
- [ classList
28
- [ ( "diva-app", True )
29
- , ( "is-fullscreen", model.fullscreen )
30
- ]
31
- ]
32
- [ Lazy.lazy3 viewManifestTitle
33
- model.showTitle
34
- model.fullscreen
35
- (manifestTitleFor model)
36
- , div [ HA.class "diva-app-header" ]
37
- [ viewToolbar model
38
- ]
39
- , div
40
- [ classList
41
- [ ( "diva-app-body", True )
42
- , ( "is-fullscreen", model.fullscreen )
43
- ]
44
- ]
45
- [ View.CollectionExplorer.viewCollectionSidebar model
46
- , View.CollectionExplorer.viewCollectionResizer model
47
- , div
48
- [ classList
49
- [ ( "diva-canvas-column", True )
50
- , ( "is-fullscreen", model.fullscreen )
51
- ]
52
- ]
53
- [ Lazy.lazy5 viewCanvas
54
- model.fullscreen
55
- (isCanvasLoading model)
56
- (hasCollectionSidebar model)
57
- maybeStatus
58
- (zoomPercentageLabel model)
59
- ]
60
- , View.Sidebar.viewSidebarResizer model
61
- , View.Sidebar.viewSidebarPanel model
62
- ]
63
- , div [ HA.class "required-statement-dock" ]
64
- [ viewMaybe (Lazy.lazy viewRequiredStatement) (requiredStatementTextFor model) ]
65
- , View.PageViewModal.viewPageViewModal model
66
- , View.ManifestInfoModal.viewManifestInfoModal model
67
- ]
68
- ]
69
-
70
-
71
- hasCollectionSidebar : Model -> Bool
72
- hasCollectionSidebar model =
73
- case model.resourceResponse of
74
- ResourceLoadedCollection _ ->
75
- model.collectionSidebarVisible
76
-
77
- _ ->
78
- False
79
-
80
-
81
- isCanvasLoading : Model -> Bool
82
- isCanvasLoading model =
83
- (model.isViewerLoading || model.resourceResponse == ResourceLoading) || (model.response == Loading)
84
-
85
-
86
- manifestTitleFor : Model -> String
87
- manifestTitleFor model =
88
- currentManifest model
89
- |> Maybe.map (\manifest -> toLabel manifest |> extractLabelFromLanguageMap model.detectedLanguage)
90
- |> Maybe.withDefault ""
91
-
92
-
93
- requiredStatementTextFor : Model -> Maybe String
94
- requiredStatementTextFor model =
95
- currentManifest model
96
- |> Maybe.andThen toRequiredStatement
97
- |> Maybe.map (\statement -> extractLabelFromLanguageMap model.detectedLanguage statement.value)
98
-
99
-
100
- viewCanvas : Bool -> Bool -> Bool -> Maybe ( String, String, Bool ) -> Maybe String -> Html Msg
101
- viewCanvas fullscreen isLoading showCollectionSidebar maybeStatus maybeZoomLabel =
102
- div [ HA.class "diva-canvas-wrapper" ]
103
- [ node "osd-viewer"
104
- [ classList
105
- [ ( "diva-canvas", True )
106
- , ( "is-fullscreen", fullscreen )
107
- , ( "has-collection", showCollectionSidebar )
108
- ]
109
- , id "main-viewer"
110
- ]
111
- []
112
- , viewIf viewThrobber isLoading
113
- , viewMaybe viewViewerStatusModal maybeStatus
114
- , viewMaybe viewZoomIndicator maybeZoomLabel
115
- ]
116
-
117
-
118
- viewManifestTitle : Bool -> Bool -> String -> Html Msg
119
- viewManifestTitle showTitle fullscreen title =
120
- if showTitle && not (String.isEmpty title) then
121
- h1
122
- [ classList
123
- [ ( "diva-app-title", True )
124
- , ( "is-fullscreen", fullscreen )
125
- ]
126
- ]
127
- [ text title ]
128
-
129
- else
130
- emptyHtml
131
-
132
-
133
- viewRequiredStatement : String -> Html Msg
134
- viewRequiredStatement valueText =
135
- if String.isEmpty valueText then
136
- emptyHtml
137
-
138
- else
139
- div
140
- [ HA.class "required-statement" ]
141
- (HtmlRenderer.renderHtml valueText)
142
-
143
-
144
- viewThrobber : Html Msg
145
- viewThrobber =
146
- let
147
- delays =
148
- [ 0.2
149
- , 0.3
150
- , 0.4
151
- , 0.1
152
- , 0.2
153
- , 0.3
154
- , 0.0
155
- , 0.1
156
- , 0.2
157
- ]
158
- in
159
- div
160
- [ HA.class "throbber-overlay" ]
161
- [ div
162
- [ HA.class "throbber" ]
163
- (List.map
164
- (\delay ->
165
- div
166
- [ HA.class "throbber-cube"
167
- , HA.style "animation-delay" (String.fromFloat delay ++ "s")
168
- ]
169
- []
170
- )
171
- delays
172
- )
173
- ]
174
-
175
-
176
- viewViewerStatusModal : ( String, String, Bool ) -> Html Msg
177
- viewViewerStatusModal ( titleText, message, isError ) =
178
- div
179
- [ HA.class "viewer-status-overlay" ]
180
- [ div
181
- [ HA.class "modal is-narrow" ]
182
- [ div
183
- [ HA.class "modal-header" ]
184
- [ div [ HA.class "modal-title" ] [ text titleText ] ]
185
- , div
186
- [ HA.class "modal-body is-no-sidebar" ]
187
- [ div
188
- [ classList [ ( "status", True ), ( "is-error", isError ) ] ]
189
- [ text message ]
190
- ]
191
- ]
192
- ]
193
-
194
-
195
- viewZoomIndicator : String -> Html Msg
196
- viewZoomIndicator zoomText =
197
- div [ HA.class "viewer-zoom-indicator" ] [ text zoomText ]
198
-
199
-
200
- viewerStatus : Model -> Maybe ( String, String, Bool )
201
- viewerStatus model =
202
- case model.resourceResponse of
203
- ResourceLoadedManifest _ ->
204
- if model.hasTileSources then
205
- Nothing
206
-
207
- else
208
- Just ( "Unable to display manifest", "No canvases found in this manifest.", False )
209
-
210
- ResourceLoadedCollection _ ->
211
- case model.response of
212
- Failed message ->
213
- Just ( "Unable to load manifest", message, True )
214
-
215
- _ ->
216
- if model.hasTileSources then
217
- Nothing
218
-
219
- else
220
- Just ( "No Manifest Selected", "Select a manifest from the collection to view.", False )
221
-
222
- ResourceFailed message ->
223
- Just ( "Unable to load manifest", message, True )
224
-
225
- _ ->
226
- Nothing
227
-
228
-
229
- zoomPercentageLabel : Model -> Maybe String
230
- zoomPercentageLabel model =
231
- case ( model.initialZoom, model.currentZoom ) of
232
- ( Just initialZoom, Just currentZoom ) ->
233
- if initialZoom > 0 then
234
- let
235
- percent =
236
- (currentZoom / initialZoom) * 100
237
- in
238
- Just (String.fromInt (round percent) ++ "%")
239
-
240
- else
241
- Nothing
242
-
243
- _ ->
244
- Nothing