ela 3.4.3 → 4.0.0

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: 689072c0c174cb2fc730ee5b2e50caa2d83c12e11fcbe89470d74f643f705ad3
4
- data.tar.gz: 8d93ad13f253c579357466bc1002ce5c6f3ba35be90205f1e48d792a77491538
3
+ metadata.gz: 65471b954f418d935377faff787750449bc19f96946b2322283c393e30baf77e
4
+ data.tar.gz: bda2b54b6b704a9dcd633898a779243bea1c57a3e76869b027fac6196cba69f8
5
5
  SHA512:
6
- metadata.gz: 9a66a26937dbfafa5b880ab4e677a6bd18b08f14d104e2f4a6ab8a9a72d15325a78b05b2e2abe72dfac4f61e6e09f98f5b3f48e31b124e7f03687a8547535b2a
7
- data.tar.gz: 6c9e0bffab250d3a94764509af73039675879607908f2b16c9f8bc142af939fb97829c56d88a0e2481722c448f47e78bfd9d27ad6e4d23745f50178c8e5b5e73
6
+ metadata.gz: '085a800daff9349af2d8b4c86167ea5874d9e9dbba435531a22f45485f15c5e3cff94a16527823cdbc5355e17758ba3404f32f0ad478fba5af27d668e622e323'
7
+ data.tar.gz: '041857e395ad02c6e533f72f6f92ba0c0e79084e2d7c400615e6640d677f58b89ac61936429e289657cec75b7dce77edba98a92cf02e76f7d99fe861ec3d1caf'
@@ -121,13 +121,32 @@ article.viewport
121
121
  border-right 1px solid #bbb
122
122
  overflow hidden
123
123
 
124
- &:last-child
125
- border-right: none
124
+ a#upstream
125
+ display none
126
+
127
+ img
128
+ absolute none 0 0 none
129
+ height $axis-handler-size
130
+ z-layer 'section', 'graph'
131
+ opacity 0.4
132
+ transition opacity 100ms
133
+
134
+ &:hover
135
+ opacity 1
136
+
137
+ @media $media-lt-phone
138
+ pointer-events none
126
139
 
127
140
  .horizontal-wrapper
128
141
  display flex
129
142
  flex 1
130
143
 
144
+ &:last-child
145
+ border-right: none
146
+
147
+ a#upstream
148
+ display block
149
+
131
150
  div.legend
132
151
  z-layer 'section', 'legend'
133
152
  font-size .75em
@@ -219,6 +238,9 @@ article.viewport
219
238
  overflow hidden
220
239
  position relative
221
240
 
241
+ canvas
242
+ display block
243
+
222
244
  div.graph-overlay-wrapper
223
245
  height 0
224
246
  font-size .75em
@@ -230,18 +252,29 @@ article.viewport
230
252
 
231
253
  div.axis-handler
232
254
  text-align center
233
- cursor pointer
234
255
  background $legend-background
235
- padding 14px 5px
256
+
257
+ label
258
+ padding 14px 5px
259
+ display block
260
+ cursor pointer
261
+
262
+ &.has-input
263
+ padding 7.5px 5px
264
+ cursor inherit
265
+
266
+ .poised.textfield
267
+ display inline-block
268
+ width 140px
236
269
 
237
270
  &.axis-handler-left
238
271
  width $axis-handler-size
272
+ white-space nowrap
239
273
  position relative
240
274
 
241
- span.hint
275
+ label
242
276
  absolute 50% none none 50%
243
277
  transform translateX(-50%) translateY(-50%) rotate(-90deg)
244
- width 500px // ugly, but no alternative
245
278
 
246
279
  // vertical range slider and large, non-transparent legend with values
247
280
  #international-standard-atmosphere article.graph div.graph
@@ -358,14 +391,6 @@ aside.curves
358
391
  content "\f05a"
359
392
  margin-right 0.4em
360
393
 
361
- img.logo
362
- absolute none 0 0 none
363
- height $axis-handler-size
364
- z-layer 'section', 'graph'
365
-
366
- @media $media-lt-phone
367
- display none
368
-
369
394
  span.mark
370
395
  background-color yellow
371
396
 
@@ -1,4 +1,9 @@
1
1
  ELA.Views ?= {}
2
2
 
3
3
  class ELA.Views.ViewportView extends Backbone.Poised.View
4
- className: 'view active'
4
+ className: 'view'
5
+
6
+ render: =>
7
+ @$el.empty()
8
+
9
+ this
@@ -3,17 +3,22 @@ class ELA.Views.AxisHandler extends Backbone.Poised.View
3
3
  className: 'axis-handler'
4
4
 
5
5
  events:
6
- 'pan': 'updateValue'
7
- 'tap': 'updateValue'
6
+ 'pan': 'handlePan'
7
+ 'tap': 'handleTap'
8
+ 'press': 'showInputField'
9
+ 'doubletap': 'showInputField'
10
+ 'pressup': 'focusInputField'
11
+ 'tap input': 'handleInputTap'
8
12
 
9
13
  hammerjs:
10
14
  recognizers: [
11
15
  [Hammer.Rotate, { enable: false }],
12
16
  [Hammer.Pinch, { enable: false }, ['rotate']],
13
17
  [Hammer.Swipe, { enable: false }],
14
- [Hammer.Pan, { direction: Hammer.DIRECTION_ALL, threshold: 1 }, ['swipe']],
18
+ [Hammer.Pan, { direction: Hammer.DIRECTION_ALL, threshold: 10 }, ['swipe']],
15
19
  [Hammer.Tap, { threshold: 5 }],
16
- [Hammer.Press, { enable: false }]
20
+ [Hammer.Tap, { event: 'doubletap', taps: 2, posThreshold: 20, threshold: 5 }, ['tap']],
21
+ [Hammer.Press]
17
22
  ]
18
23
 
19
24
  initialize: (options) ->
@@ -35,7 +40,24 @@ class ELA.Views.AxisHandler extends Backbone.Poised.View
35
40
  @minValue ?= options.minValue
36
41
  @minValue ?= options.range?[1]
37
42
 
38
- @listenTo @model, "change:#{@attribute}", @renderText
43
+ @listenTo(@model, "change:#{@attribute}", @renderSpan)
44
+
45
+ @subviews = {}
46
+ @formSettings = @model.loadSettings("formFields")[@attribute]
47
+ @params = new Backbone.Model
48
+ showInput: false
49
+ @listenTo(@params, 'change:showInput', @renderSpan)
50
+
51
+ @lastFocusOutAt = undefined
52
+
53
+ handleTap: (e) =>
54
+ @updateValue(e) unless @hasRecentlyOpenInput()
55
+
56
+ handlePan: (e) =>
57
+ @updateValue(e) unless @params.get('showInput')
58
+
59
+ handleInputTap: (e) =>
60
+ e.stopPropagation()
39
61
 
40
62
  updateValue: (e) =>
41
63
  origin = @displayParams.get("#{@orientation}Origin")
@@ -57,16 +79,57 @@ class ELA.Views.AxisHandler extends Backbone.Poised.View
57
79
  point = Math.min(point, @maxValue) if isFinite(@maxValue)
58
80
  @model.set(@attribute, point)
59
81
 
60
- renderText: =>
61
- @$el.find('span').text(t(
82
+ showInputField: ->
83
+ @params.set(showInput: true)
84
+
85
+ focusInputField: =>
86
+ _.defer => @subviews.inputControl?.$('input').focus()
87
+
88
+ closeInputField: =>
89
+ @params.set(showInput: false)
90
+
91
+ hasRecentlyOpenInput: ->
92
+ # not (new Date - @lastFocusOutAt < 100) and (new Date - @lastFocusOutAt > 100)
93
+ # are not equal when @lastFocusOutAt is undefined!
94
+ @params.get('showInput') or (new Date - @lastFocusOutAt < 100)
95
+
96
+ handleFocusOut: =>
97
+ @lastFocusOutAt = new Date
98
+ @closeInputField()
99
+
100
+ text: (value) =>
101
+ t(
62
102
  "#{@model.name}.axisHandler.#{@attribute}.label"
63
103
  "#{@model.name}.axisHandler.label"
64
104
  'axisHandler.label'
65
- value: @model.get(@attribute).toFixed(@precision)
66
- ))
105
+ value: "<span></span>"
106
+ )
107
+
108
+ renderSpan: =>
109
+ if @params.get('showInput')
110
+ @$label.addClass('has-input')
111
+ control = new Backbone.Poised.Textfield(
112
+ _.defaults(
113
+ model: @model
114
+ attribute: @attribute
115
+ type: 'number'
116
+ ,
117
+ @formSettings
118
+ )
119
+ )
120
+ @subviews.inputControl = control
121
+ @listenToOnce(control, 'changeValue', @handleFocusOut)
122
+ @$label.find('span').html(control.render().el)
123
+ else
124
+ @$label.removeClass('has-input')
125
+ @$label.find('span').text(
126
+ @model.get(@attribute).toFixed(@precision) + ' ' + @formSettings.unit
127
+ )
67
128
 
68
129
  render: =>
69
- @$el.html('<span class="hint"></span>')
130
+ delete @subviews.inputField
131
+ @$label = $('<label>').html(@text())
132
+ @renderSpan()
133
+ @$el.html(@$label)
70
134
  @$el.addClass("axis-handler-#{@position}")
71
- @renderText()
72
135
  this
@@ -29,7 +29,8 @@ class ELA.Views.BaseApp extends Backbone.Poised.View
29
29
  'tap header .poised.subviews.select .option.subapp': 'openSubapp'
30
30
  'tap header .poised.subviews.select .option.layout': 'openLayout'
31
31
  'tap header .context.icon': 'toggleContextMenu'
32
- 'tap article.graph:has(~ aside.active)': 'hideAsides'
32
+ 'tap article.viewport:has(~ aside.active)': 'hideAsides'
33
+ 'tap article.viewport:has(~ .headup.active)': 'hideHeadup'
33
34
  'tap section:has(.subviews.select.view)': 'hideSubappOptions'
34
35
  'tap section:has(.menu.view)': 'hideMenus'
35
36
 
@@ -41,8 +42,8 @@ class ELA.Views.BaseApp extends Backbone.Poised.View
41
42
  initialize: ->
42
43
  @listenTo @model, 'change:currentAside', @toggleAside
43
44
  @listenTo @model, 'change:showHelp', @renderHelp
44
- @on 'controlLiveChangeStart', @liveChangeStart
45
- @on 'controlLiveChangeEnd', @liveChangeEnd
45
+ @on 'controlLiveChangeStart', @showHeadup
46
+ @on 'controlLiveChangeEnd', @hideHeadup
46
47
 
47
48
  for aside in @asides
48
49
  aside.link ?= 'icon'
@@ -150,15 +151,20 @@ class ELA.Views.BaseApp extends Backbone.Poised.View
150
151
  @$("header .#{value}.aside.icon").toggleClass('active', true)
151
152
  @$("aside.#{value}").toggleClass('active', true)
152
153
 
153
- liveChangeStart: (slider) =>
154
- if $(window).width() <= 768
155
- @$('aside.active').addClass('hidden')
156
- @subviews.headup.activate(slider)
154
+ showHeadup: (control, options = {}) =>
155
+ options.mobileOnly ?= true
156
+ isMobile = $(window).width() <= 768
157
+ if isMobile or not options.mobileOnly
158
+ if isMobile
159
+ @$('aside.active').addClass('hidden')
160
+ else
161
+ @model.set('currentAside', null)
157
162
 
158
- liveChangeEnd: =>
159
- if $(window).width() <= 768
160
- @$('aside.active').removeClass('hidden')
161
- @subviews.headup.deactivate()
163
+ @subviews.headup.activate(control)
164
+
165
+ hideHeadup: =>
166
+ @$('aside.active').removeClass('hidden')
167
+ @subviews.headup.deactivate()
162
168
 
163
169
  setActive: (active) =>
164
170
  @$el.toggleClass('active', active)
@@ -11,6 +11,7 @@ class ELA.Views.Canvas extends Backbone.Poised.View
11
11
  super
12
12
  fontWeight = if window.devicePixelRatio > 1 then 300 else 400
13
13
  @defaultFont = "#{fontWeight} 12px Roboto"
14
+ @largeBoldFont = "#{fontWeight * 2} 20px Roboto"
14
15
 
15
16
  initialize: (options = {}) ->
16
17
  # Make sure we got the parameters model for holding view specific
@@ -1,6 +1,8 @@
1
1
  ELA.Views ?= {}
2
2
 
3
3
  class ELA.Views.ChartView extends ELA.Views.ViewportView
4
+ className: 'view chart-view'
5
+
4
6
  initialize: (options = {}) ->
5
7
  unless options.name?
6
8
  throw 'ELA.Views.GraphView: option `name` is required'
@@ -1,6 +1,8 @@
1
1
  ELA.Views ?= {}
2
2
 
3
3
  class ELA.Views.GraphView extends ELA.Views.ViewportView
4
+ className: "#{ELA.Views.ViewportView::className} graph-view"
5
+
4
6
  initialize: (options = {}) ->
5
7
  unless options.name?
6
8
  throw 'ELA.Views.GraphView: option `name` is required'
@@ -55,11 +57,15 @@ class ELA.Views.GraphView extends ELA.Views.ViewportView
55
57
  xAxis: @xAxis
56
58
  yAxis: @yAxis
57
59
  app: @model
60
+ xOrigin: options.graph?.xOrigin
61
+ yOrigin: options.graph?.yOrigin
62
+ xOriginRatio: options.graph?.xOriginRatio
63
+ yOriginRatio: options.graph?.yOriginRatio
58
64
 
59
65
  @subviews = {}
60
66
 
61
67
  render: =>
62
- @$el.empty()
68
+ super
63
69
 
64
70
  if @LegendView?
65
71
  view = @subviews.legend ?= new @LegendView
@@ -90,7 +96,10 @@ class ELA.Views.GraphView extends ELA.Views.ViewportView
90
96
  localePrefix: @localePrefix
91
97
  $horizontalWrapper.append(view.render().el)
92
98
 
93
- $horizontalWrapper.append($('<div>', class: 'graph'))
99
+ $graph = $('<div>', class: 'graph')
100
+ $a = $('<a>', id: 'upstream', href: ELA.settings.upstream.url, target: '_blank')
101
+ $a.html($('<img>', src: 'images/logo.png'))
102
+ $horizontalWrapper.append($graph.html($a))
94
103
  @$el.append($horizontalWrapper)
95
104
 
96
105
  if @bottomAxisHandler?
@@ -104,7 +113,6 @@ class ELA.Views.GraphView extends ELA.Views.ViewportView
104
113
  @$el.append(view.render().el)
105
114
 
106
115
  delay =>
107
- $graph = @$('.graph')
108
116
  @subviews.graph?.remove()
109
117
  # Taken from ELA.Views.Canvas::readCanvasResolution
110
118
  @displayParams.set
@@ -116,9 +124,13 @@ class ELA.Views.GraphView extends ELA.Views.ViewportView
116
124
  params: @displayParams
117
125
  localePrefix: @localePrefix
118
126
  if @leftAxisHandler?
119
- view.$el.on('tap', @subviews.leftAxisHandler.updateValue)
127
+ view.$el.on 'tap', (e) =>
128
+ unless @subviews.bottomAxisHandler?.hasRecentlyOpenInput()
129
+ @subviews.leftAxisHandler.handleTap(e)
120
130
  if @bottomAxisHandler?
121
- view.$el.on('tap', @subviews.bottomAxisHandler.updateValue)
122
- $graph.html(view.render().el)
131
+ view.$el.on 'tap', (e) =>
132
+ unless @subviews.leftAxisHandler?.hasRecentlyOpenInput()
133
+ @subviews.bottomAxisHandler.handleTap(e)
134
+ $graph.append(view.render().el)
123
135
 
124
136
  this
@@ -8,7 +8,7 @@ class ELA.Views.Headup extends Backbone.Poised.View
8
8
 
9
9
  deactivate: =>
10
10
  @$el.removeClass('active')
11
- @subviews.control.remove()
11
+ @subviews.control?.remove()
12
12
 
13
13
  render: =>
14
14
  @$el.html(@subviews.control.render().el)
@@ -4,6 +4,7 @@ class Backbone.Poised.Textfield extends Backbone.View
4
4
  events:
5
5
  'focusin input': 'clearInputValue'
6
6
  'focusout input': 'readInput'
7
+ 'keyup input': 'handleKeyUp'
7
8
 
8
9
  initialize: (options = {}) =>
9
10
  throw new Error('Missing `model` option') unless options.model?
@@ -44,7 +45,7 @@ class Backbone.Poised.Textfield extends Backbone.View
44
45
  else
45
46
  value = @model.get(@attribute)
46
47
 
47
- if @options.precision
48
+ if @options.precision?
48
49
  valueString = value.toFixed(@options.precision)
49
50
 
50
51
  @$input.val(valueString or value)
@@ -59,8 +60,12 @@ class Backbone.Poised.Textfield extends Backbone.View
59
60
  return if @$input.is(':focus')
60
61
  @_updateValue(undefined, updateModel: false)
61
62
 
63
+ handleKeyUp: (e) =>
64
+ @readInput() if e.keyCode == 13
65
+
62
66
  readInput: =>
63
67
  @_updateValue(@$input.val())
68
+ @trigger('changeValue')
64
69
 
65
70
  clearInputValue: =>
66
71
  @$input.val('') if @options.clearOnFocus
@@ -19,6 +19,4 @@
19
19
  - if @hasHelpText
20
20
  %li.help= t('contextMenu.help')
21
21
  .viewport
22
- %a{ href: ELA.settings.upstream.url, target: '_blank' }
23
- %img.logo{ src: 'images/logo.png' }
24
22
  %aside.right.headup
@@ -1,3 +1,3 @@
1
1
  module ELA
2
- VERSION = '3.4.3'
2
+ VERSION = '4.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ela
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.3
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franz Kißig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-12 00:00:00.000000000 Z
11
+ date: 2018-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler