pageflow-linkmap-page 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -0
  3. data/CHANGELOG.md +39 -1
  4. data/Gemfile +3 -7
  5. data/README.md +6 -2
  6. data/app/assets/javascript/pageflow/linkmap_page/editor/models/area.js +7 -2
  7. data/app/assets/javascript/pageflow/linkmap_page/editor/templates/scaled_on_phone_hint.jst.ejs +1 -0
  8. data/app/assets/javascript/pageflow/linkmap_page/editor/views/configuration_editor_view.js +4 -0
  9. data/app/assets/javascript/pageflow/linkmap_page/editor/views/edit_area_view.js +4 -1
  10. data/app/assets/javascript/pageflow/linkmap_page/editor/views/scaled_on_phone_hint_view.js +39 -0
  11. data/app/assets/javascript/pageflow/linkmap_page/page_type.js +20 -0
  12. data/app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_lookaround.js +8 -6
  13. data/app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_panorama.js +39 -70
  14. data/app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_panorama/get_panorama_size.js +60 -0
  15. data/app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_scroll_indicators.js +7 -3
  16. data/app/assets/stylesheets/pageflow/linkmap_page/themes/default/scroll_indicators.scss +45 -15
  17. data/app/views/pageflow/linkmap_page/{page.html → page.html.erb} +6 -0
  18. data/{exec → bin}/rspec +0 -3
  19. data/{exec → bin}/spring +0 -0
  20. data/config/locales/new/scaled_on_phone_hint.de.yml +11 -0
  21. data/config/locales/new/scaled_on_phone_hint.en.yml +11 -0
  22. data/config/locales/new/scroll_indicators_v.de.yml +6 -0
  23. data/config/locales/new/scroll_indicators_v.en.yml +6 -0
  24. data/config/locales/new/typo.en.yml +6 -0
  25. data/lib/generators/pageflow_linkmap_page/install/install_generator.rb +31 -0
  26. data/lib/pageflow/linkmap_page/engine.rb +2 -0
  27. data/lib/pageflow/linkmap_page/version.rb +1 -1
  28. data/pageflow-linkmap-page.gemspec +1 -2
  29. data/spec/helpers/pageflow/linkmap_page/areas_helper_spec.rb +23 -15
  30. data/spec/spec_helper.rb +7 -2
  31. data/spec/support/config/devise.rb +10 -0
  32. data/spec/support/config/factory_girl.rb +12 -0
  33. metadata +22 -10
  34. data/app/controllers/pageflow/external_links/sites_controller.rb +0 -40
  35. data/app/models/pageflow/linkmap_page/site.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b493ac7493f526d49f5805c713a211ba6447de0e
4
- data.tar.gz: 16e8273aa2955e2abec0d289a3aeb294d6ffb7c5
3
+ metadata.gz: 4be69c22ece16a9e318bb3566dc670fd6a1ca230
4
+ data.tar.gz: a7a90492548b93bbdc273717175616593c2dace0
5
5
  SHA512:
6
- metadata.gz: a1082d4931f516b774ccf34def7f6ac4bc8dd1e3f1a8a30f1676e70646f0ad55da29379cb76ea8074ca53720e2928ce95632fe83b42d510ea72c90a1687f68fa
7
- data.tar.gz: c42dd554b92d398453024079f6d0c826c0b1a5f77f847c7f1bab77b994da0346f6849069ffc5dd23a6562a55e20cd2e6aa92bf5be131099e9f8e28abe2501a40
6
+ metadata.gz: 2452e5b8dd93e30d517de81f8172decd7a716e787d45401e17cc037a62e1a5c5fb5351cb2c9c5c37fda452c3b98995fbfc4374e5e85f5cdc651b8bdcaab8dbfa
7
+ data.tar.gz: 3c2cbf1be66d085a038b1c2c666c6b93a5d27230efa64dcf2e3ef2dc183947fba95a673e424f8c6a9baea2b38f13488c3f4997dd4bcd85ebe4d861c4fe20a96a
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
4
+
5
+ # User container based travis infrastructure which allows caching
6
+ # features for open source projects.
7
+ sudo: false
8
+ cache: bundler
9
+
10
+ services:
11
+ - redis-server
12
+
13
+ script:
14
+ - bin/rspec
data/CHANGELOG.md CHANGED
@@ -1,8 +1,46 @@
1
1
  # CHANGELOG
2
2
 
3
+ ### Version 0.2.0
4
+
5
+ 2017-04-21
6
+
7
+ [Compare changes](http://github.com/codevise/pageflow-linkmap-page/compare/v0.1.0...v0.2.0)
8
+
9
+ - Add vertical scroll indicators
10
+ ([#7](https://github.com/codevise/pageflow-linkmap-page/pull/7))
11
+ - Prevent scrolling via mousemove on mobile platform
12
+ ([#21](https://github.com/codevise/pageflow-linkmap-page/pull/21))
13
+ - Improve panorama scaling
14
+ ([#20](https://github.com/codevise/pageflow-linkmap-page/pull/20))
15
+ - Ensure viewport is covered when scroll area restricted
16
+ ([#19](https://github.com/codevise/pageflow-linkmap-page/pull/19))
17
+ - Disable links in overlay boxes
18
+ ([#18](https://github.com/codevise/pageflow-linkmap-page/pull/18))
19
+ - Prevent overlays to be displayed behind editor bar
20
+ ([#8](https://github.com/codevise/pageflow-linkmap-page/pull/8))
21
+ - Use info box title as title for text only areas
22
+ ([#16](https://github.com/codevise/pageflow-linkmap-page/pull/16))
23
+ - Fix translation typo
24
+ ([#13](https://github.com/codevise/pageflow-linkmap-page/pull/13))
25
+
26
+ Internals:
27
+
28
+ - Fix test suite and run on travis
29
+ ([#15](https://github.com/codevise/pageflow-linkmap-page/pull/15))
30
+ - Add .erb extension
31
+ ([#11](https://github.com/codevise/pageflow-linkmap-page/pull/11))
32
+ - Remove unused files
33
+ ([#17](https://github.com/codevise/pageflow-linkmap-page/pull/17))
34
+
35
+ Documentation:
36
+
37
+ - Add instructions to migrate external links migrations
38
+ ([#3](https://github.com/codevise/pageflow-linkmap-page/pull/3))
39
+ - Explicitly note to enable the feature
40
+ ([#12](https://github.com/codevise/pageflow-linkmap-page/pull/12))
41
+
3
42
  ### Version 0.1.0
4
43
 
5
44
  2016-06-09
6
45
 
7
46
  - Initial release
8
-
data/Gemfile CHANGED
@@ -3,14 +3,10 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in chart.gemspec
4
4
  gemspec
5
5
 
6
- # Rails 4 compat
7
- gem 'activeadmin', :git => 'https://github.com/codevise/active_admin.git', :branch => 'rails4'
8
- gem 'ransack'
9
- gem 'inherited_resources', '1.4.1'
10
- gem 'formtastic', '2.3.0.rc2'
6
+ gem 'state_machine', git: 'https://github.com/codevise/state_machine.git'
11
7
 
12
- gem 'pageflow', path: '.bundle/linked/pageflow'
13
- gem 'pageflow-support', path: '.bundle/linked/pageflow/spec/support'
8
+ gem 'pageflow', '0.11.3'
9
+ gem 'pageflow-support', '0.11.3'
14
10
 
15
11
  gem 'teaspoon', git: 'https://github.com/modeset/teaspoon'
16
12
 
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Pageflow Linkmap Page
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/pageflow-linkmap-page.svg)](http://badge.fury.io/rb/pageflowlinkmap-page)
3
+ [![Gem Version](https://badge.fury.io/rb/pageflow-linkmap-page.svg)](http://badge.fury.io/rb/pageflow-linkmap-page)
4
+ [![Build Status](https://travis-ci.org/codevise/pageflow-linkmap-page.svg?branch=master)](https://travis-ci.org/codevise/pageflow-linkmap-page)
4
5
 
5
6
  Page type to display customizable link areas to internal/external
6
7
  pages and inline audio players.
@@ -10,6 +11,7 @@ pages and inline audio players.
10
11
  Add this line to your application's `Gemfile`:
11
12
 
12
13
  gem 'pageflow-linkmap-page'
14
+ gem 'pageflow-external-links' # needed to copy the migration contained within
13
15
 
14
16
  Register the page type inside the configure block in `config/initializers/pageflow.rb`
15
17
 
@@ -44,8 +46,10 @@ Install dependencies:
44
46
 
45
47
  bundle install
46
48
 
49
+ Then follow the installation instructions for the [pageflow-external-links](https://github.com/codevise/pageflow-external-links) gem.
50
+
47
51
  Restart the application server and enable the corresponding page type
48
- feature.
52
+ feature for entries in the tab *features*.
49
53
 
50
54
  ## Troubleshooting
51
55
 
@@ -26,8 +26,13 @@ pageflow.linkmapPage.Area = Backbone.Model.extend({
26
26
  },
27
27
 
28
28
  title: function() {
29
- var target = this.target();
30
- return target ? target.title() : null;
29
+ if (this.get('target_type') === 'text_only') {
30
+ return this.get('link_title');
31
+ }
32
+ else {
33
+ var target = this.target();
34
+ return target ? target.title() : null;
35
+ }
31
36
  },
32
37
 
33
38
  thumbnailFile: function() {
@@ -71,6 +71,10 @@ pageflow.linkmapPage.ConfigurationEditorView = pageflow.ConfigurationEditorView.
71
71
  });
72
72
 
73
73
  this.tab('areas', function() {
74
+ this.view(pageflow.linkmapPage.ScaledOnPhoneHintView, {
75
+ model: this.model.page
76
+ });
77
+
74
78
  this.view(pageflow.linkmapPage.AreasListView, {
75
79
  model: this.model
76
80
  });
@@ -76,7 +76,10 @@ pageflow.linkmapPage.EditAreaView = Backbone.Marionette.Layout.extend({
76
76
  });
77
77
 
78
78
  this.input('link_title', pageflow.TextInputView);
79
- this.input('link_description', pageflow.TextAreaInputView, {size: 'short'});
79
+ this.input('link_description', pageflow.TextAreaInputView, {
80
+ size: 'short',
81
+ disableLinks: true
82
+ });
80
83
  });
81
84
 
82
85
  configurationEditor.tab('appearance', function() {
@@ -0,0 +1,39 @@
1
+ pageflow.linkmapPage.ScaledOnPhoneHintView = Backbone.Marionette.ItemView.extend({
2
+ template: 'pageflow/linkmap_page/editor/templates/scaled_on_phone_hint',
3
+ className: 'scaled_on_phone_hint',
4
+
5
+ modelEvents: {
6
+ 'change:scaled_on_portrait_phone change:scaled_on_landscape_phone': 'update'
7
+ },
8
+
9
+ ui: {
10
+ hint: 'p'
11
+ },
12
+
13
+ onRender: function() {
14
+ this.update();
15
+ },
16
+
17
+ update: function() {
18
+ this.$el.toggle(this.model.get('scaled_on_portrait_phone') ||
19
+ this.model.get('scaled_on_landscape_phone'));
20
+
21
+ if (this.model.get('scaled_on_portrait_phone') &&
22
+ this.model.get('scaled_on_landscape_phone')) {
23
+ this.ui.hint.text(this.hintText('both'));
24
+ }
25
+ else if (this.model.get('scaled_on_portrait_phone')) {
26
+ this.ui.hint.text(this.hintText('portrait'));
27
+ }
28
+ else if (this.model.get('scaled_on_landscape_phone')) {
29
+ this.ui.hint.text(this.hintText('landscape'));
30
+ }
31
+ },
32
+
33
+ hintText: function(orientation) {
34
+ var prefix = 'pageflow.linkmap_page.editor.views.scaled_on_phone_hint';
35
+ return I18n.t(prefix + '.text', {
36
+ orientation: I18n.t(prefix + '.orientations.' + orientation)
37
+ });
38
+ }
39
+ });
@@ -23,6 +23,7 @@ pageflow.pageType.register('linkmap_page', _.extend({
23
23
  scroller: this.scroller,
24
24
  activeAreasSelector: '.linkmap_areas > *',
25
25
  limitScrolling: configuration.limit_scrolling,
26
+ minScaling: pageflow.browser.has('mobile platform'),
26
27
  addEnvironment: configuration.add_environment,
27
28
  marginScrollingDisabled: configuration.margin_scrolling_disabled,
28
29
  startScrollPosition: this.getPanoramaStartScrollPosition(configuration)
@@ -219,6 +220,9 @@ pageflow.pageType.register('linkmap_page', _.extend({
219
220
  this.getPanoramaStartScrollPosition(configuration.attributes),
220
221
  minScaling);
221
222
 
223
+ this.updateScaledOnPhoneFlags(configuration.page,
224
+ this.content.linkmapPanorama('instance'));
225
+
222
226
  this.content.linkmapLookaround('update',
223
227
  configuration.get('margin_scrolling_disabled'));
224
228
  this.setupHoverImages(pageElement, configuration.attributes);
@@ -229,6 +233,22 @@ pageflow.pageType.register('linkmap_page', _.extend({
229
233
  });
230
234
  },
231
235
 
236
+ updateScaledOnPhoneFlags: function(page, panorama) {
237
+ page.set('scaled_on_portrait_phone',
238
+ panorama.getPanoramaSize({
239
+ pageWidth: 360,
240
+ pageHeight: 640,
241
+ minScaling: true
242
+ }).scaled);
243
+
244
+ page.set('scaled_on_landscape_phone',
245
+ panorama.getPanoramaSize({
246
+ pageWidth: 640,
247
+ pageHeight: 360,
248
+ minScaling: true
249
+ }).scaled);
250
+ },
251
+
232
252
  updateVideoPlayState: function(configuration) {
233
253
  if (configuration.hasChanged('background_type')) {
234
254
  if (this.isVideoEnabled(configuration.attributes)) {
@@ -61,13 +61,15 @@
61
61
  that.initialGamma = null;
62
62
  });
63
63
 
64
- this.element.on('mousemove', function(e) {
65
- var containerWidth = that.element.width();
66
- var containerHeight = that.element.height();
64
+ if (!pageflow.browser.has('mobile platform')) {
65
+ this.element.on('mousemove', function(e) {
66
+ var containerWidth = that.element.width();
67
+ var containerHeight = that.element.height();
67
68
 
68
- that.scrollStrategyX.updateMouse(e.pageX / containerWidth);
69
- that.scrollStrategyY.updateMouse(e.pageY / containerHeight);
70
- });
69
+ that.scrollStrategyX.updateMouse(e.pageX / containerWidth);
70
+ that.scrollStrategyY.updateMouse(e.pageY / containerHeight);
71
+ });
72
+ }
71
73
  },
72
74
 
73
75
  enable: function() {
@@ -2,8 +2,6 @@
2
2
  $.widget('pageflow.linkmapPanorama', {
3
3
  scrollHoverMargin : 0.2,
4
4
  environmentMargin : 0.2,
5
- minScaling: true,
6
- minScalingSize: 80,
7
5
  lastMouseMoveEvent: null,
8
6
 
9
7
  _create: function() {
@@ -13,6 +11,7 @@
13
11
  this.addEnvironment = this.options.addEnvironment;
14
12
  this.panorama = this.options.panorama();
15
13
  this.limitScrolling = this.options.limitScrolling;
14
+ this.minScaling = this.options.minScaling;
16
15
  this.scroller = this.options.scroller;
17
16
 
18
17
  this.activeAreas = pageElement.find(this.options.activeAreasSelector);
@@ -93,15 +92,13 @@
93
92
 
94
93
  that.overlayBox.addClass('active');
95
94
 
96
-
97
-
98
95
  if(that.panorama.width() - (area.position().left + area.outerWidth()) < that.overlayBox.outerWidth()) {
99
96
  var overlayAlignmentDirection = "left";
100
97
  that.overlayBox.addClass('left_aligned');
101
98
  }
102
99
  else {
103
100
  var spaceLeftOfArea = area.offset().left;
104
- var spaceRightOfArea = $(window).width() - area.offset().left - area.outerWidth();
101
+ var spaceRightOfArea = $(pageElement).width() - area.offset().left - area.outerWidth();
105
102
 
106
103
  if(spaceLeftOfArea < spaceRightOfArea || spaceLeftOfArea < that.overlayBox.outerWidth()) {
107
104
  var overlayAlignmentDirection = "right";
@@ -131,8 +128,8 @@
131
128
  }
132
129
 
133
130
  var spaceToBottom = that.panorama.height() - area.position().top;
134
- var spaceToViewportBottom = $(window).height() - area.offset().top - area.height() / 2;
135
- var spaceToViewportTop = $(window).height() - 50;
131
+ var spaceToViewportBottom = $(pageElement).height() - area.offset().top - area.height() / 2;
132
+ var spaceToViewportTop = $(pageElement).height() - 50;
136
133
  var minMargin = 40;
137
134
 
138
135
  if(that.overlayBox.outerHeight() > spaceToBottom) {
@@ -241,33 +238,6 @@
241
238
  }
242
239
 
243
240
  return scrollArea;
244
-
245
- },
246
-
247
- getMinScale: function(activeAreas) {
248
- var smallestScale;
249
- var that = this;
250
- var minimumSize = this.minScalingSize;
251
- var smallestSize = Math.min(this.panorama.attr('data-width'), this.panorama.attr('data-height'));
252
-
253
- if(this.minScaling) {
254
-
255
- for (var i = 0; i < activeAreas.length; i++) {
256
- var el = $(activeAreas[i]);
257
-
258
- if(el.attr('data-height') / 100 * that.panorama.attr('data-height') < smallestSize) {
259
- smallestSize = el.attr('data-height') / 100 * that.panorama.attr('data-height');
260
- }
261
- if(el.attr('data-width') / 100 * that.panorama.attr('data-width') < smallestSize) {
262
- smallestSize = el.attr('data-width') / 100 * that.panorama.attr('data-width');
263
- }
264
- smallestScale = minimumSize / smallestSize;
265
- }
266
- } else {
267
- smallestScale = 0;
268
- }
269
-
270
- return smallestScale;
271
241
  },
272
242
 
273
243
  update: function(addEnvironment, limitScrolling, startScrollPosition, minScaling) {
@@ -285,10 +255,19 @@
285
255
 
286
256
  this.panorama = this.options.panorama();
287
257
 
288
- this.panoramaSize = this.getPanoramaSize(pageElement);
258
+ this.panoramaSize = this.getPanoramaSize({
259
+ pageWidth: pageElement.width(),
260
+ pageHeight: pageElement.height(),
261
+
262
+ minScaling: this.minScaling
263
+ });
264
+
289
265
  this.panorama.width(this.panoramaSize.width);
290
266
  this.panorama.height(this.panoramaSize.height);
291
267
 
268
+ pageElement.toggleClass('linkmap_panorama_h', this.panoramaSize.orientation === 'h');
269
+ pageElement.toggleClass('linkmap_panorama_v', this.panoramaSize.orientation === 'v');
270
+
292
271
  this.activeAreas = pageElement.find(this.options.activeAreasSelector);
293
272
  this.scrollArea = this.getScrollArea(this.activeAreas);
294
273
 
@@ -297,54 +276,44 @@
297
276
  this.innerScrollerElement.width(this.scrollArea.right - this.scrollArea.left);
298
277
  this.innerScrollerElement.height(this.scrollArea.bottom - this.scrollArea.top);
299
278
 
279
+ var centerX = Math.max(0, (pageElement.width() - (this.scrollArea.right - this.scrollArea.left)) / 2);
280
+ var centerY = Math.max(0, (pageElement.height() - (this.scrollArea.bottom - this.scrollArea.top)) / 2);
281
+
282
+ var translateX = this.scrollArea.left - centerX;
283
+ var translateY = this.scrollArea.top - centerY;
284
+
300
285
  var maxTranslateX = this.panoramaSize.width - pageElement.width();
301
286
  var maxTranslateY = this.panoramaSize.height - pageElement.height();
302
287
 
303
288
  this.panoramaWrapper.css({
304
- left: -Math.min(maxTranslateX, this.scrollArea.left) +'px',
305
- top: -Math.min(maxTranslateY, this.scrollArea.top) + 'px'
289
+ left: -Math.min(maxTranslateX, Math.max(0, translateX)) +'px',
290
+ top: -Math.min(maxTranslateY, Math.max(0, translateY)) + 'px'
306
291
  });
307
292
 
308
293
  this.innerScrollerElement.removeClass('measuring');
309
294
  this.scroller.refresh();
310
-
311
- var leftToCenterInnerScroller = (pageElement.width() - (this.scrollArea.right - this.scrollArea.left)) / 2;
312
- var topToCenterInnerScroller = (pageElement.height() - (this.scrollArea.bottom - this.scrollArea.top)) / 2;
313
-
314
- this.innerScrollerElement.css('left', (this.scroller.maxX() == 0 && this.panoramaSize.width > this.scrollArea.right - this.scrollArea.left ? Math.min(leftToCenterInnerScroller, this.scrollArea.left) : 0) + "px");
315
- this.innerScrollerElement.css('top', (this.scroller.maxY() == 0 && this.panoramaSize.height > pageElement.height() ? Math.min(topToCenterInnerScroller, this.scrollArea.top) : 0) + "px");
316
295
  });
317
296
  },
318
297
 
319
- getPanoramaSize: function(pageElement) {
320
- var result = {};
321
- var windowRatio = pageElement.width() / pageElement.height();
322
- var environmentMargin = this.addEnvironment ? (1 + this.environmentMargin) : 1;
323
- var smallestScale = this.getMinScale(this.activeAreas);
324
- var imageRatio;
325
-
326
- if (this.panorama.attr('data-height') > 0) {
327
- imageRatio = this.panorama.attr('data-width') / this.panorama.attr('data-height');
328
- }
329
- else {
330
- imageRatio = 1;
331
- }
332
-
333
- if(imageRatio > windowRatio) {
334
- result.height = pageElement.height() * environmentMargin;
335
- result.width = result.height * imageRatio;
336
- }
337
- else {
338
- result.width = pageElement.width() * environmentMargin;
339
- result.height = result.width / imageRatio;
340
- }
298
+ getPanoramaSize: function(options) {
299
+ return pageflow.linkmapPage.getPanoramaSize({
300
+ pageWidth: options.pageWidth,
301
+ pageHeight: options.pageHeight,
341
302
 
342
- if (result.width < this.panorama.attr('data-width') * smallestScale) {
343
- result.width = this.panorama.attr('data-width') * smallestScale;
344
- result.height = this.panorama.attr('data-height') * smallestScale;
345
- }
303
+ panoramaWidth: this.panorama.attr('data-width'),
304
+ panoramaHeight: this.panorama.attr('data-height'),
346
305
 
347
- return result;
306
+ areaDimensions: this.activeAreas.map(function() {
307
+ var el = $(this);
308
+ return {
309
+ width: el.attr('data-width'),
310
+ height: el.attr('data-height')
311
+ };
312
+ }).get(),
313
+
314
+ minScaling: options.minScaling,
315
+ addEnvironment: this.addEnvironment
316
+ });
348
317
  },
349
318
 
350
319
  resetScrollPosition: function() {
@@ -0,0 +1,60 @@
1
+ pageflow.linkmapPage.getPanoramaSize = (function() {
2
+ var MIN_SCALING_SIZE = 80;
3
+ var ENVIRONMENT_MARGIN = 1.2;
4
+
5
+ return function getPanoramaSize(options) {
6
+ var result = {
7
+ scaled: false
8
+ };
9
+
10
+ var environmentMargin = options.addEnvironment ? ENVIRONMENT_MARGIN : 1;
11
+
12
+ var windowRatio = options.pageWidth / options.pageHeight;
13
+ var imageRatio;
14
+
15
+ if (options.panoramaHeight > 0) {
16
+ imageRatio = options.panoramaWidth / options.panoramaHeight;
17
+ }
18
+ else {
19
+ imageRatio = 1;
20
+ }
21
+
22
+ if (imageRatio > windowRatio) {
23
+ result.height = options.pageHeight * environmentMargin;
24
+ result.width = result.height * imageRatio;
25
+ result.orientation = 'h';
26
+ }
27
+ else {
28
+ result.width = options.pageWidth * environmentMargin;
29
+ result.height = result.width / imageRatio;
30
+ result.orientation = 'v';
31
+ }
32
+
33
+ if (options.minScaling) {
34
+ var minScale = getMinScale(options);
35
+
36
+ if (result.width < options.panoramaWidth * minScale) {
37
+ result.width = options.panoramaWidth * minScale;
38
+ result.height = options.panoramaHeight * minScale;
39
+ result.scaled = true;
40
+ }
41
+ }
42
+
43
+ return result;
44
+ };
45
+
46
+ function getMinScale(options) {
47
+ var that = this;
48
+
49
+ var smallestSize = Math.min(options.panoramaWidth, options.panoramaHeight);
50
+
51
+ _(options.areaDimensions).each(function(dimensions) {
52
+ var width = dimensions.width / 100 * options.panoramaWidth;
53
+ var height = dimensions.height / 100 * options.panoramaHeight;
54
+
55
+ smallestSize = Math.min(smallestSize, Math.min(width, height));
56
+ });
57
+
58
+ return MIN_SCALING_SIZE / smallestSize;
59
+ }
60
+ }());
@@ -1,4 +1,6 @@
1
1
  (function($) {
2
+ var margin = 40;
3
+
2
4
  $.widget('pageflow.linkmapScrollIndicators', {
3
5
  _create: function() {
4
6
  var element = this.element;
@@ -9,9 +11,11 @@
9
11
  toggle();
10
12
 
11
13
  function toggle() {
12
- element.toggleClass('can_scroll_left', Math.ceil(scroller.positionX()) < 0);
13
- element.toggleClass('can_scroll_right', Math.floor(scroller.positionX()) > scroller.maxX());
14
+ element.toggleClass('can_scroll_left', Math.ceil(scroller.positionX()) < - margin);
15
+ element.toggleClass('can_scroll_right', Math.floor(scroller.positionX()) > scroller.maxX() + margin);
16
+ element.toggleClass('can_scroll_up', Math.ceil(scroller.positionY()) < - margin);
17
+ element.toggleClass('can_scroll_down', Math.floor(scroller.positionY()) > scroller.maxY() + margin);
14
18
  }
15
19
  }
16
20
  });
17
- }(jQuery))
21
+ }(jQuery));
@@ -4,10 +4,10 @@
4
4
  $arrow-margin-mobile: 10px;
5
5
 
6
6
  .arrow_left,
7
- .arrow_right {
7
+ .arrow_right,
8
+ .arrow_up,
9
+ .arrow_down {
8
10
  position: absolute;
9
- top: 50%;
10
- margin-top: -40px;
11
11
  width: 80px;
12
12
  height: 80px;
13
13
  text-decoration: none;
@@ -15,6 +15,10 @@
15
15
  z-index: 10;
16
16
  display: block;
17
17
 
18
+ @include phone {
19
+ @include transform(scale(0.5))
20
+ }
21
+
18
22
  &:before {
19
23
  color: #fff;
20
24
  width: 100%;
@@ -42,41 +46,67 @@
42
46
  }
43
47
  }
44
48
 
49
+ .arrow_left,
50
+ .arrow_right {
51
+ margin-top: -40px;
52
+ top: 50%;
53
+ }
54
+
55
+ .arrow_up,
56
+ .arrow_down {
57
+ left: 50%;
58
+ }
59
+
45
60
  .arrow_left {
46
61
  @include fa-angle-left-icon;
47
62
  left: 10px;
48
63
 
49
64
  @include phone {
50
65
  left: $arrow-margin-mobile;
51
- @include transform(scale(0.5))
52
66
  }
53
67
  }
54
68
 
55
69
  .arrow_right {
56
70
  @include fa-angle-right-icon;
57
71
  right: $arrow-margin;
72
+ @extend %pageflow_widget_margin_right !optional;
58
73
 
59
74
  @include phone {
60
75
  right: $arrow-margin-mobile;
61
- @include transform(scale(0.5))
62
76
  }
77
+ }
63
78
 
64
- .widget_default_navigation_present & {
65
- @include desktop {
66
- right: $arrow-margin-with-default-navigation;
67
- }
79
+ .arrow_up {
80
+ @include fa-angle-up-icon;
81
+ top: $arrow-margin;
68
82
 
69
- @include pad_portrait {
70
- right: $arrow-margin-mobile;
71
- }
83
+ @include phone {
84
+ top: 0;
85
+ }
86
+ }
87
+
88
+ .arrow_down {
89
+ @include fa-angle-down-icon;
90
+ bottom: $arrow-margin;
91
+
92
+ @include phone {
93
+ bottom: 0;
72
94
  }
73
95
  }
74
96
 
75
- &.can_scroll_left .arrow_left:before {
97
+ .linkmap_panorama_h &.can_scroll_left .arrow_left:before {
98
+ opacity: 1;
99
+ }
100
+
101
+ .linkmap_panorama_h &.can_scroll_right .arrow_right:before {
102
+ opacity: 1;
103
+ }
104
+
105
+ .linkmap_panorama_v &.can_scroll_up .arrow_up:before {
76
106
  opacity: 1;
77
107
  }
78
108
 
79
- &.can_scroll_right .arrow_right:before {
109
+ .linkmap_panorama_v &.can_scroll_down .arrow_down:before {
80
110
  opacity: 1;
81
111
  }
82
- }
112
+ }
@@ -41,11 +41,17 @@
41
41
  </div>
42
42
  </div>
43
43
 
44
+ <div class="arrow_up">
45
+ <span class="hint"><%= t('.scroll_up') %></span>
46
+ </div>
44
47
  <div class="arrow_left">
45
48
  <span class="hint"><%= t('.scroll_left') %></span>
46
49
  </div>
47
50
  <div class="arrow_right">
48
51
  <span class="hint"><%= t('.scroll_right') %></span>
49
52
  </div>
53
+ <div class="arrow_down">
54
+ <span class="hint"><%= t('.scroll_down') %></span>
55
+ </div>
50
56
  </div>
51
57
  </div>
data/{exec → bin}/rspec RENAMED
@@ -9,7 +9,4 @@ rescue LoadError
9
9
  end
10
10
  require 'bundler/setup'
11
11
 
12
- require 'pageflow/support'
13
- Pageflow::Dummy.setup
14
-
15
12
  load Gem.bin_path('rspec-core', 'rspec')
File without changes
@@ -0,0 +1,11 @@
1
+ de:
2
+ pageflow:
3
+ linkmap_page:
4
+ editor:
5
+ views:
6
+ scaled_on_phone_hint:
7
+ text: "Das Panorama wird im %{orientation} skaliert, um eine Mindestgröße der Hotspots für die Touch-Eingabe zu gewährleisten. Hotspots vergrößern, um Skalierung zu vermeiden."
8
+ orientations:
9
+ both: "Phone Layout"
10
+ landscape: "Landscape Phone Layout"
11
+ portrait: "Portrait Phone Layout"
@@ -0,0 +1,11 @@
1
+ en:
2
+ pageflow:
3
+ linkmap_page:
4
+ editor:
5
+ views:
6
+ scaled_on_phone_hint:
7
+ text: "The panorama will be scaled on %{orientation} to ensure minimum hotspot size for touch interaction. Increase hotspot size to prevent scaling."
8
+ orientations:
9
+ both: "phones"
10
+ landscape: "phones in landscape orientation"
11
+ portrait: "phones in portrait orientation"
@@ -0,0 +1,6 @@
1
+ de:
2
+ pageflow:
3
+ linkmap_page:
4
+ page:
5
+ scroll_up: Nach oben scrollen
6
+ scroll_down: Nach unten scrollen
@@ -0,0 +1,6 @@
1
+ en:
2
+ pageflow:
3
+ linkmap_page:
4
+ page:
5
+ scroll_up: Scroll up
6
+ scroll_down: Scroll down
@@ -0,0 +1,6 @@
1
+ en:
2
+ pageflow:
3
+ linkmap_page:
4
+ page_attributes:
5
+ limit_scrolling:
6
+ label: Restrict to hotspot areas
@@ -0,0 +1,31 @@
1
+ module PageflowLinkmapPage
2
+ class InstallGenerator < Rails::Generators::Base
3
+ desc 'Install the Pageflow plugin and the necessary migrations.'
4
+
5
+ def register_plugin
6
+ inject_into_file('config/initializers/pageflow.rb',
7
+ after: "Pageflow.configure do |config|\n") do
8
+
9
+ " config.plugin(Pageflow::#{engine_name_suffix.camelize}.plugin)\n"
10
+ end
11
+ end
12
+
13
+ def mount_engine
14
+ route("mount #{engine.name}, at: '/#{engine_name_suffix}'\n")
15
+ end
16
+
17
+ def install_migrations
18
+ rake 'pageflow_external_links:install:migrations'
19
+ end
20
+
21
+ private
22
+
23
+ def engine_name_suffix
24
+ engine.engine_name.gsub(/^pageflow_/, '')
25
+ end
26
+
27
+ def engine
28
+ Pageflow::LinkmapPage::Engine
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,5 @@
1
+ require 'pageflow-external-links'
2
+
1
3
  module Pageflow
2
4
  module LinkmapPage
3
5
  class Engine < Rails::Engine
@@ -1,5 +1,5 @@
1
1
  module Pageflow
2
2
  module LinkmapPage
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
@@ -13,7 +13,6 @@ Gem::Specification.new do |spec|
13
13
  spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
17
  spec.require_paths = ['lib']
19
18
 
@@ -25,7 +24,7 @@ Gem::Specification.new do |spec|
25
24
 
26
25
  spec.add_development_dependency 'bundler'
27
26
  spec.add_development_dependency 'rake'
28
- spec.add_development_dependency 'rspec-rails', '~> 2.0'
27
+ spec.add_development_dependency 'rspec-rails', '~> 3.0'
29
28
  spec.add_development_dependency 'factory_girl_rails'
30
29
  spec.add_development_dependency 'sqlite3'
31
30
 
@@ -5,25 +5,28 @@ module Pageflow
5
5
  describe AreasHelper do
6
6
  describe '#linkmap_area_divs' do
7
7
  it 'renders div with attribute name as class' do
8
+ entry = create(:entry)
8
9
  configuration = {}
9
10
 
10
- html = helper.linkmap_areas_div(configuration, 'linkmap_page_link_areas')
11
+ html = helper.linkmap_areas_div(entry, configuration)
11
12
 
12
- expect(html).to have_selector('div.linkmap_areas.linkmap_page_link_areas')
13
+ expect(html).to have_selector('div.linkmap_areas')
13
14
  end
14
15
 
15
16
  it 'renders linkmap areas' do
16
- configuration = {'linkmap_page_link_areas' => [{}]}
17
+ entry = create(:entry)
18
+ configuration = {'linkmap_areas' => [{}]}
17
19
 
18
- html = helper.linkmap_areas_div(configuration, 'linkmap_page_link_areas')
20
+ html = helper.linkmap_areas_div(entry, configuration)
19
21
 
20
22
  expect(html).to have_selector('div a[href]')
21
23
  end
22
24
 
23
- it 'renders hover image divs inside linkmap areas' do
24
- configuration = {'linkmap_page_link_areas' => [{}], 'hover_image_id' => 5}
25
+ it 'renders hover image inside linkmap areas' do
26
+ entry = create(:entry)
27
+ configuration = {'linkmap_areas' => [{}], 'hover_image_id' => 5}
25
28
 
26
- html = helper.linkmap_areas_div(configuration, 'linkmap_page_link_areas')
29
+ html = helper.linkmap_areas_div(entry, configuration)
27
30
 
28
31
  expect(html).to have_selector('a div[class~="image_panorama_5"]')
29
32
  end
@@ -31,15 +34,18 @@ module Pageflow
31
34
 
32
35
  describe '#linkmap_area' do
33
36
  it 'renders link tag' do
34
- html = helper.linkmap_area({}, 0)
37
+ entry = create(:entry)
38
+
39
+ html = helper.linkmap_area(entry, {}, 0)
35
40
 
36
41
  expect(html).to have_selector('a[href]')
37
42
  end
38
43
 
39
44
  it 'sets inline styles for position and size' do
45
+ entry = create(:entry)
40
46
  attributes = {top: 20, left: 30, width: 40, height: 50}
41
47
 
42
- html = helper.linkmap_area(attributes, 0)
48
+ html = helper.linkmap_area(entry, attributes, 0)
43
49
 
44
50
  expect(html).to include('top: 20%;')
45
51
  expect(html).to include('left: 30%;')
@@ -48,19 +54,21 @@ module Pageflow
48
54
  end
49
55
 
50
56
  it 'sets data attribute for audio file' do
51
- attributes = {audio_file_id: 25}
57
+ entry = create(:entry)
58
+ attributes = {target_type: 'audio_file', target_id: 25}
52
59
 
53
- html = helper.linkmap_area(attributes, 5)
60
+ html = helper.linkmap_area(entry, attributes, 5)
54
61
 
55
62
  expect(html).to have_selector('a[data-audio-file="25.area_5"]')
56
63
  end
57
64
 
58
- it 'sets data attribute for audio file' do
59
- attributes = {target_page_id: 10}
65
+ it 'sets data attribute for page link' do
66
+ entry = create(:entry)
67
+ attributes = {target_type: 'page', target_id: 10}
60
68
 
61
- html = helper.linkmap_area(attributes, 0)
69
+ html = helper.linkmap_area(entry, attributes, 0)
62
70
 
63
- expect(html).to have_selector('a[data-page="10"]')
71
+ expect(html).to have_selector('a[data-target-id="10"]')
64
72
  end
65
73
  end
66
74
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,12 @@
1
1
  ENV['RAILS_ENV'] ||= 'test'
2
- # ENV['PAGEFLOW_PLUGIN_ENGINE'] = 'pageflow_linkmap_page'
2
+ ENV['PAGEFLOW_PLUGIN_ENGINE'] = 'pageflow_linkmap_page'
3
3
 
4
- require 'pageflow'
4
+ require 'factory_girl_rails'
5
+
6
+ require 'pageflow/support'
7
+ Pageflow::Dummy.setup
8
+
9
+ require 'pageflow-linkmap-page'
5
10
  require 'rspec/rails'
6
11
 
7
12
  engine_root = File.join(File.dirname(__FILE__), '..')
@@ -0,0 +1,10 @@
1
+ RSpec.configure do |config|
2
+ module DeviseTestHelpersWithScope
3
+ def sign_in(user)
4
+ super(:user, user)
5
+ end
6
+ end
7
+
8
+ config.include Devise::TestHelpers, type: :controller
9
+ config.include DeviseTestHelpersWithScope, type: :controller
10
+ end
@@ -0,0 +1,12 @@
1
+ RSpec.configure do |config|
2
+ # Allow to use build and create methods without FactoryGirl prefix.
3
+ config.include FactoryGirl::Syntax::Methods
4
+
5
+ # Make sure factories are up to date when using spring. Skip in CI
6
+ # since reloading causes factories to be excluded in test coverage.
7
+ unless ENV['CI']
8
+ config.before(:all) do
9
+ FactoryGirl.reload
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pageflow-linkmap-page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codevise Solutions Ltd.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pageflow
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.0'
89
+ version: '3.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '2.0'
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: factory_girl_rails
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -160,6 +160,7 @@ files:
160
160
  - ".gitignore"
161
161
  - ".jshintignore"
162
162
  - ".jshintrc"
163
+ - ".travis.yml"
163
164
  - CHANGELOG.md
164
165
  - Gemfile
165
166
  - README.md
@@ -186,6 +187,7 @@ files:
186
187
  - app/assets/javascript/pageflow/linkmap_page/editor/routers/side_bar_router.js
187
188
  - app/assets/javascript/pageflow/linkmap_page/editor/templates/edit_area.jst.ejs
188
189
  - app/assets/javascript/pageflow/linkmap_page/editor/templates/embedded/area_item.jst.ejs
190
+ - app/assets/javascript/pageflow/linkmap_page/editor/templates/scaled_on_phone_hint.jst.ejs
189
191
  - app/assets/javascript/pageflow/linkmap_page/editor/views/areas_list_view.js
190
192
  - app/assets/javascript/pageflow/linkmap_page/editor/views/configuration_editor_view.js
191
193
  - app/assets/javascript/pageflow/linkmap_page/editor/views/edit_area_view.js
@@ -193,6 +195,7 @@ files:
193
195
  - app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/area_item_embedded_view.js
194
196
  - app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/areas_embedded_view.js
195
197
  - app/assets/javascript/pageflow/linkmap_page/editor/views/embedded/panorama_embedded_view.js
198
+ - app/assets/javascript/pageflow/linkmap_page/editor/views/scaled_on_phone_hint_view.js
196
199
  - app/assets/javascript/pageflow/linkmap_page/features.js
197
200
  - app/assets/javascript/pageflow/linkmap_page/page_type.js
198
201
  - app/assets/javascript/pageflow/linkmap_page/vendor/gyro.js
@@ -203,6 +206,7 @@ files:
203
206
  - app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_lookaround.js
204
207
  - app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_lookaround_strategies/target_speed.js
205
208
  - app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_panorama.js
209
+ - app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_panorama/get_panorama_size.js
206
210
  - app/assets/javascript/pageflow/linkmap_page/widgets/linkmap_scroll_indicators.js
207
211
  - app/assets/stylesheets/pageflow/linkmap_page.css.scss
208
212
  - app/assets/stylesheets/pageflow/linkmap_page/animations/rotate.css.scss
@@ -213,21 +217,25 @@ files:
213
217
  - app/assets/stylesheets/pageflow/linkmap_page/editor/resizable.css.scss
214
218
  - app/assets/stylesheets/pageflow/linkmap_page/themes/default.css.scss
215
219
  - app/assets/stylesheets/pageflow/linkmap_page/themes/default/scroll_indicators.scss
216
- - app/controllers/pageflow/external_links/sites_controller.rb
217
220
  - app/helpers/pageflow/linkmap_page/areas_helper.rb
218
- - app/models/pageflow/linkmap_page/site.rb
219
221
  - app/views/pageflow/linkmap_page/areas/_div.html.erb
220
- - app/views/pageflow/linkmap_page/page.html
222
+ - app/views/pageflow/linkmap_page/page.html.erb
223
+ - bin/rspec
224
+ - bin/spring
221
225
  - config/locales/de.yml
222
226
  - config/locales/en.yml
223
227
  - config/locales/new/inverted.de.yml
224
228
  - config/locales/new/inverted.en.yml
229
+ - config/locales/new/scaled_on_phone_hint.de.yml
230
+ - config/locales/new/scaled_on_phone_hint.en.yml
231
+ - config/locales/new/scroll_indicators_v.de.yml
232
+ - config/locales/new/scroll_indicators_v.en.yml
225
233
  - config/locales/new/text_only_area_type.de.yml
226
234
  - config/locales/new/text_only_area_type.en.yml
235
+ - config/locales/new/typo.en.yml
227
236
  - config/routes.rb
228
237
  - config/spring.rb
229
- - exec/rspec
230
- - exec/spring
238
+ - lib/generators/pageflow_linkmap_page/install/install_generator.rb
231
239
  - lib/pageflow-linkmap-page.rb
232
240
  - lib/pageflow/linkmap_page/engine.rb
233
241
  - lib/pageflow/linkmap_page/page_type.rb
@@ -236,6 +244,8 @@ files:
236
244
  - pageflow-linkmap-page.gemspec
237
245
  - spec/helpers/pageflow/linkmap_page/areas_helper_spec.rb
238
246
  - spec/spec_helper.rb
247
+ - spec/support/config/devise.rb
248
+ - spec/support/config/factory_girl.rb
239
249
  homepage: http://github.com/codevise/pageflow-linkmap-page
240
250
  licenses:
241
251
  - MIT
@@ -256,10 +266,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
266
  version: '0'
257
267
  requirements: []
258
268
  rubyforge_project:
259
- rubygems_version: 2.2.5
269
+ rubygems_version: 2.6.8
260
270
  signing_key:
261
271
  specification_version: 4
262
272
  summary: Pageflow page type for a page that contains customizable link areas
263
273
  test_files:
264
274
  - spec/helpers/pageflow/linkmap_page/areas_helper_spec.rb
265
275
  - spec/spec_helper.rb
276
+ - spec/support/config/devise.rb
277
+ - spec/support/config/factory_girl.rb
@@ -1,40 +0,0 @@
1
- module Pageflow
2
- module ExternalLinks
3
- class SitesController < ActionController::Base
4
- respond_to :json
5
-
6
- def index
7
- @entry = Entry.find(params[:entry_id])
8
-
9
- respond_with(Site.all_for_revision(@entry.draft))
10
- end
11
-
12
- def create
13
- @entry = Entry.find(params[:entry_id])
14
- site = Site.all_for_revision(@entry.draft).create!(site_params)
15
-
16
- respond_with(site)
17
- end
18
-
19
- def update
20
- site = Site.find(params[:id])
21
- site.update(site_params)
22
-
23
- respond_with(site)
24
- end
25
-
26
- def destroy
27
- site = Site.find(params[:id])
28
- site.destroy
29
-
30
- respond_with(site)
31
- end
32
-
33
- protected
34
-
35
- def site_params
36
- params.require(:site).permit(:url, :thumbnail, :title, :description, :open_in_new_tab)
37
- end
38
- end
39
- end
40
- end
@@ -1,11 +0,0 @@
1
- module Pageflow
2
- module ExternalLinks
3
- class Site < ActiveRecord::Base
4
- include RevisionComponent
5
-
6
- def thumbnail_file
7
- ImageFile.find_by_id(thumbnail)
8
- end
9
- end
10
- end
11
- end