pageflow-external-links 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +5 -0
  3. data/app/assets/javascripts/pageflow/external_links/editor.js +4 -0
  4. data/app/assets/javascripts/pageflow/external_links/editor/config.js +1 -0
  5. data/app/assets/javascripts/pageflow/external_links/editor/models/site.js +5 -1
  6. data/app/assets/javascripts/pageflow/external_links/editor/templates/site_selection.jst.ejs +12 -0
  7. data/app/assets/javascripts/pageflow/external_links/editor/views/configuration_editor.js +1 -1
  8. data/app/assets/javascripts/pageflow/external_links/editor/views/embedded/list_item_embedded_view.js +1 -1
  9. data/app/assets/javascripts/pageflow/external_links/editor/views/inputs/site_reference_input_view.js +6 -28
  10. data/app/assets/javascripts/pageflow/external_links/editor/views/inputs/site_references_input_view.js +31 -0
  11. data/app/assets/javascripts/pageflow/external_links/editor/views/site_item_view.js +7 -2
  12. data/app/assets/javascripts/pageflow/external_links/editor/views/site_reference_item_view.js +1 -1
  13. data/app/assets/javascripts/pageflow/external_links/editor/views/site_selection_view.js +45 -0
  14. data/app/assets/javascripts/pageflow/external_links/editor/views/sites_view.js +2 -1
  15. data/app/assets/stylesheets/pageflow/external_links/editor.css.scss +11 -47
  16. data/app/assets/stylesheets/pageflow/external_links/editor/external_sites.css.scss +47 -0
  17. data/app/assets/stylesheets/pageflow/external_links/editor/site_selection.css.scss +34 -0
  18. data/config/locales/de.yml +3 -0
  19. data/config/locales/en.yml +3 -0
  20. data/lib/pageflow/external_links/engine.rb +1 -0
  21. data/pageflow-external-links.gemspec +3 -3
  22. metadata +10 -5
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2I3YWE2NmUxYTE0NTgzMjUxOWFjM2RlYjVhMWNmM2RiM2IyM2I3OQ==
4
+ Y2NiNWQwYjY3MjQzNzAxNGM3NjdiMTdmM2UwMTYzMjZiODIy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5
+ - Site reference input and site selection api.
6
+ ([#15](https://github.com/codevise/pageflow-external-links/pull/15))
7
+
3
8
  ### 0.2.0
4
9
 
5
10
  2015-02-03
@@ -10,3 +10,7 @@
10
10
  //= require ./editor/config
11
11
 
12
12
  pageflow.externalLinks = pageflow.externalLinks || {};
13
+
14
+ pageflow.externalLinks.selectSite = function() {
15
+ return pageflow.externalLinks.SiteSelectionView.selectSite();
16
+ };
@@ -14,4 +14,5 @@ pageflow.editor.registerMainMenuItem({
14
14
 
15
15
  pageflow.editor.addInitializer(function() {
16
16
  pageflow.externalLinks.sites = new pageflow.externalLinks.SitesCollection();
17
+ pageflow.externalLinks.sites.ensureFetched();
17
18
  });
@@ -19,7 +19,11 @@ pageflow.externalLinks.Site = Backbone.Model.extend({
19
19
  return this.isNew() ? this.collection.url() : '/external_links/sites';
20
20
  },
21
21
 
22
- getThumbnail: function() {
22
+ thumbnailFile: function() {
23
23
  return this.getReference('thumbnail', pageflow.imageFiles);
24
+ },
25
+
26
+ title: function() {
27
+ return this.get('title');
24
28
  }
25
29
  });
@@ -0,0 +1,12 @@
1
+ <div class="box">
2
+ <h2><%= I18n.t('pageflow.external_links.editor.templates.site_selection.title') %></h2>
3
+
4
+ <div class="wrapper editor">
5
+ <ul class="external_sites">
6
+ </ul>
7
+ </div>
8
+
9
+ <div class="footer">
10
+ <a href="" class="close"><%= I18n.t('pageflow.external_links.editor.templates.site_selection.cancel') %></a>
11
+ </div>
12
+ </div>
@@ -13,7 +13,7 @@ pageflow.ConfigurationEditorView.register('external_links', {
13
13
  });
14
14
 
15
15
  this.tab('links', function() {
16
- this.input('linked_external_site_perma_ids', pageflow.externalLinks.SiteReferenceInputView);
16
+ this.input('linked_external_site_perma_ids', pageflow.externalLinks.SiteReferencesInputView);
17
17
  });
18
18
 
19
19
  this.tab('options', function() {
@@ -58,7 +58,7 @@ pageflow.externalLinks.ListItemEmbeddedView = Backbone.Marionette.ItemView.exten
58
58
  },
59
59
 
60
60
  updateThumbnailView: function(site) {
61
- var thumbnail = site.getThumbnail();
61
+ var thumbnail = site.thumbnailFile();
62
62
 
63
63
  if (this.currentThumbnail !== thumbnail) {
64
64
  this.currentThumbnail = thumbnail;
@@ -1,31 +1,9 @@
1
- pageflow.externalLinks.SiteReferenceInputView = Backbone.Marionette.ItemView.extend({
2
- mixins: [pageflow.inputView],
3
-
4
- template: 'pageflow/external_links/editor/templates/inputs/site_reference',
5
- className: 'external_links_site_reference_input',
6
-
7
- ui: {
8
- sites: 'ul.sites'
9
- },
10
-
11
- events: {
12
- 'click .add_reference': function() {
13
- pageflow.editor.navigate(
14
- '/external_links/sites?page=' + this.model.page.id,
15
- {trigger: true}
16
- );
17
- return false;
18
- }
1
+ pageflow.externalLinks.SiteReferenceInputView = pageflow.ReferenceInputView.extend({
2
+ choose: function() {
3
+ return pageflow.externalLinks.selectSite();
19
4
  },
20
5
 
21
- onRender: function() {
22
- this.subview(new pageflow.SortableCollectionView({
23
- el: this.ui.sites,
24
- collection: this.model.externalSiteReferences(),
25
- itemViewConstructor: pageflow.externalLinks.SiteReferenceItemView,
26
- itemViewOptions: {
27
- page: this.model.page
28
- }
29
- }));
6
+ getTarget: function(permaId) {
7
+ return pageflow.externalLinks.sites.getByPermaId(permaId);
30
8
  }
31
- });
9
+ });
@@ -0,0 +1,31 @@
1
+ pageflow.externalLinks.SiteReferencesInputView = Backbone.Marionette.ItemView.extend({
2
+ mixins: [pageflow.inputView],
3
+
4
+ template: 'pageflow/external_links/editor/templates/inputs/site_reference',
5
+ className: 'external_links_site_references_input',
6
+
7
+ ui: {
8
+ sites: 'ul.sites'
9
+ },
10
+
11
+ events: {
12
+ 'click .add_reference': function() {
13
+ pageflow.editor.navigate(
14
+ '/external_links/sites?page=' + this.model.page.id,
15
+ {trigger: true}
16
+ );
17
+ return false;
18
+ }
19
+ },
20
+
21
+ onRender: function() {
22
+ this.subview(new pageflow.SortableCollectionView({
23
+ el: this.ui.sites,
24
+ collection: this.model.externalSiteReferences(),
25
+ itemViewConstructor: pageflow.externalLinks.SiteReferenceItemView,
26
+ itemViewOptions: {
27
+ page: this.model.page
28
+ }
29
+ }));
30
+ }
31
+ });
@@ -12,7 +12,7 @@ pageflow.externalLinks.SiteItemView = Backbone.Marionette.ItemView.extend({
12
12
 
13
13
  events: {
14
14
  'click': function() {
15
- if (!this.model.isNew()) {
15
+ if (!this.model.isNew() && this.options.navigatable) {
16
16
  var query = this.options.page ? '/?page=' + this.options.page.id + '&return_to=sites' : '';
17
17
  pageflow.editor.navigate('/external_links/sites/' + this.model.get('id') + query, {trigger: true});
18
18
  }
@@ -22,7 +22,10 @@ pageflow.externalLinks.SiteItemView = Backbone.Marionette.ItemView.extend({
22
22
  'click .select': function() {
23
23
  if (this.options.selectionHandler) {
24
24
  this.options.selectionHandler.call(this.model);
25
- pageflow.editor.navigate(this.options.referer, {trigger: true});
25
+
26
+ if (this.options.referer) {
27
+ pageflow.editor.navigate(this.options.referer, {trigger: true});
28
+ }
26
29
  }
27
30
  return false;
28
31
  }
@@ -38,6 +41,8 @@ pageflow.externalLinks.SiteItemView = Backbone.Marionette.ItemView.extend({
38
41
  },
39
42
 
40
43
  update: function() {
44
+ this.$el.toggleClass('navigatable', !!this.options.navigatable);
45
+
41
46
  this.ui.title.text(this.model.get('title') || I18n.t('pageflow.external_links.editor.views.site_item_view.unknown'));
42
47
  this.ui.selectButton.toggle(!!this.options.selectionHandler);
43
48
  }
@@ -24,7 +24,7 @@ pageflow.externalLinks.SiteReferenceItemView = Backbone.Marionette.ItemView.exte
24
24
  onRender: function() {
25
25
  this.subview(new pageflow.FileThumbnailView({
26
26
  el: this.ui.thumbnail,
27
- model: this.model.get('site').getThumbnail()
27
+ model: this.model.get('site').thumbnailFile()
28
28
  }));
29
29
 
30
30
  this.ui.title.text(this.model.get('site').get('title') || I18n.t('pageflow.external_links.editor.views.site_item_reference_view.unknown'));
@@ -0,0 +1,45 @@
1
+ pageflow.externalLinks.SiteSelectionView = Backbone.Marionette.ItemView.extend({
2
+ className: 'external_site_selection dialog',
3
+ template: 'pageflow/external_links/editor/templates/site_selection',
4
+
5
+ mixins: [pageflow.dialogView],
6
+
7
+ ui: {
8
+ items: 'ul'
9
+ },
10
+
11
+ onRender: function() {
12
+ var view = this;
13
+
14
+ pageflow.externalLinks.sites.ensureFetched();
15
+
16
+ this.subview(new pageflow.CollectionView({
17
+ el: this.ui.items,
18
+ collection: pageflow.externalLinks.sites,
19
+ itemViewConstructor: pageflow.externalLinks.SiteItemView,
20
+ itemViewOptions: {
21
+ selectionHandler: function() {
22
+ view.options.onSelect(this);
23
+ view.close();
24
+ }
25
+ },
26
+ blankSlateViewConstructor: Backbone.Marionette.ItemView.extend({
27
+ template: 'pageflow/external_links/editor/templates/sites_blank_slate'
28
+ })
29
+ }));
30
+ }
31
+ });
32
+
33
+ pageflow.externalLinks.SiteSelectionView.selectSite = function() {
34
+ return $.Deferred(function(deferred) {
35
+ var view = new pageflow.externalLinks.SiteSelectionView({
36
+ onSelect: deferred.resolve
37
+ });
38
+
39
+ view.on('close', function() {
40
+ deferred.reject();
41
+ });
42
+
43
+ pageflow.app.dialogRegion.show(view.render());
44
+ }).promise();
45
+ };
@@ -19,10 +19,11 @@ pageflow.externalLinks.SitesView = Backbone.Marionette.ItemView.extend({
19
19
 
20
20
  this.$el.append(this.subview(new pageflow.CollectionView({
21
21
  tagName: 'ul',
22
- className: 'sites',
22
+ className: 'external_sites',
23
23
  collection: pageflow.externalLinks.sites,
24
24
  itemViewConstructor: pageflow.externalLinks.SiteItemView,
25
25
  itemViewOptions: {
26
+ navigatable: true,
26
27
  selectionHandler: this.options.selectionHandler,
27
28
  referer: this.options.referer,
28
29
  page: this.options.page
@@ -1,56 +1,20 @@
1
1
  @import "./editor/embedded";
2
+ @import "./editor/site_selection";
2
3
 
3
4
  .editor {
4
- .manage_external_sites {
5
- a.add {
6
- @include plus-circled-icon;
7
- @include icon-button;
8
- position: absolute;
9
- top: 0;
10
- right: 0;
11
- }
12
-
13
- ul.sites {
14
- margin-top: 10px;
15
- }
16
-
17
- ul.sites > li {
18
- @include right-open-icon;
19
- @include background-icon-right($color: #888, $top: 20px);
20
-
21
- background-color: #fff;
22
- margin-bottom: 2px;
23
- padding: 37px 10px 0 70px;
24
- white-space: nowrap;
25
- overflow: hidden;
26
- height: 23px;
27
- }
5
+ @import "./editor/external_sites";
28
6
 
29
- .thumbnail {
30
- position: absolute;
31
- top: 0;
32
- left: 0;
33
- height: 60px;
34
- width: 60px;
35
- vertical-align: middle;
36
- background-size: cover;
37
- background-color: #444;
38
- }
39
-
40
- a.select {
41
- @include button(#590);
42
-
43
- padding-left: 5px;
44
- padding-right: 5px;
45
- vertical-align: middle;
46
-
47
- position: absolute;
48
- top: 3px;
49
- left: 70px;
7
+ .manage_external_sites {
8
+ a.add {
9
+ @include plus-circled-icon;
10
+ @include icon-button;
11
+ position: absolute;
12
+ top: 0;
13
+ right: 0;
14
+ }
50
15
  }
51
- }
52
16
 
53
- .external_links_site_reference_input {
17
+ .external_links_site_references_input {
54
18
  .add_reference {
55
19
  @include plus-circled-icon;
56
20
  @include icon-button;
@@ -0,0 +1,47 @@
1
+ ul.external_sites {
2
+ margin-top: 10px;
3
+
4
+ > li {
5
+ position: relative;
6
+ background-color: #eee;
7
+ margin-bottom: 2px;
8
+ padding: 37px 10px 0 70px;
9
+ white-space: nowrap;
10
+ overflow: hidden;
11
+ height: 23px;
12
+
13
+ &.navigatable {
14
+ background-color: #fff;
15
+ @include right-open-icon;
16
+ @include background-icon-right($color: #888, $top: 20px);
17
+ }
18
+ }
19
+
20
+ .thumbnail {
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ height: 60px;
25
+ width: 60px;
26
+ vertical-align: middle;
27
+ background-size: cover;
28
+ background-color: #444;
29
+ }
30
+
31
+ a.select {
32
+ @include button(#590);
33
+
34
+ padding-left: 5px;
35
+ padding-right: 5px;
36
+ vertical-align: middle;
37
+
38
+ position: absolute;
39
+ top: 3px;
40
+ right: 5px;
41
+ }
42
+
43
+ .navigatable .select {
44
+ left: 70px;
45
+ right: auto;
46
+ }
47
+ }
@@ -0,0 +1,34 @@
1
+ .external_site_selection {
2
+ .box {
3
+ top: 5%;
4
+ width: 90%;
5
+ max-width: 400px;
6
+ max-height: 745px;
7
+ padding-bottom: 20px;
8
+ height: 80%;
9
+ }
10
+
11
+ .wrapper {
12
+ background-color: #fff;
13
+ padding-right: 10px;
14
+
15
+ overflow: hidden;
16
+ overflow-y: scroll;
17
+
18
+ position: absolute;
19
+ top: 70px;
20
+ bottom: 70px;
21
+ left: 10px;
22
+ right: 10px;
23
+ }
24
+
25
+ ul.external_sites {
26
+ margin-top: 0;
27
+ }
28
+
29
+ .footer {
30
+ position: absolute;
31
+ bottom: 20px;
32
+ right: 10px;
33
+ }
34
+ }
@@ -31,6 +31,9 @@ de:
31
31
  site_reference_item:
32
32
  edit: Bearbeiten
33
33
  remove: Löschen
34
+ site_selection:
35
+ cancel: Abbrechen
36
+ title: Externe Seite auswählen
34
37
  sites:
35
38
  add: Hinzufügen
36
39
  sites_blank_slate:
@@ -31,6 +31,9 @@ en:
31
31
  site_reference_item:
32
32
  edit: Edit
33
33
  remove: Remove
34
+ site_selection:
35
+ cancel: Cancel
36
+ title: Select external site
34
37
  sites:
35
38
  add: Add
36
39
  sites_blank_slate:
@@ -4,6 +4,7 @@ module Pageflow
4
4
  isolate_namespace Pageflow::ExternalLinks
5
5
 
6
6
  config.autoload_paths << File.join(config.root, 'lib')
7
+ config.i18n.load_path += Dir[config.root.join('config', 'locales', '**', '*.yml').to_s]
7
8
 
8
9
  config.generators do |g|
9
10
  g.test_framework :rspec,:fixture => false
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "pageflow-external-links"
5
- spec.version = "0.2.0"
5
+ spec.version = "0.3.0"
6
6
  spec.authors = ["Tim Fischbach"]
7
7
  spec.email = ["tfischbach@codevise.de"]
8
8
  spec.summary = "Pageflow Page Type for links to external sites"
9
- spec.homepage = ""
9
+ spec.homepage = "https://github.com/codevise/pageflow-external-links"
10
10
  spec.license = "MIT"
11
11
 
12
12
  spec.files = `git ls-files`.split($/)
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
15
  spec.require_paths = ["lib"]
16
16
 
17
- spec.add_runtime_dependency 'pageflow', '~> 0.7'
17
+ spec.add_runtime_dependency 'pageflow', '~> 0.9'
18
18
 
19
19
  # Using translations from rails locales in javascript code.
20
20
  spec.add_runtime_dependency 'i18n-js'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pageflow-external-links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Fischbach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pageflow
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0.7'
19
+ version: '0.9'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0.7'
26
+ version: '0.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n-js
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +143,7 @@ files:
143
143
  - app/assets/javascripts/pageflow/external_links/editor/templates/inputs/site_reference.jst.ejs
144
144
  - app/assets/javascripts/pageflow/external_links/editor/templates/site_item.jst.ejs
145
145
  - app/assets/javascripts/pageflow/external_links/editor/templates/site_reference_item.jst.ejs
146
+ - app/assets/javascripts/pageflow/external_links/editor/templates/site_selection.jst.ejs
146
147
  - app/assets/javascripts/pageflow/external_links/editor/templates/sites.jst.ejs
147
148
  - app/assets/javascripts/pageflow/external_links/editor/templates/sites_blank_slate.jst.ejs
148
149
  - app/assets/javascripts/pageflow/external_links/editor/views/configuration_editor.js
@@ -150,13 +151,17 @@ files:
150
151
  - app/assets/javascripts/pageflow/external_links/editor/views/embedded/list_embedded_view.js
151
152
  - app/assets/javascripts/pageflow/external_links/editor/views/embedded/list_item_embedded_view.js
152
153
  - app/assets/javascripts/pageflow/external_links/editor/views/inputs/site_reference_input_view.js
154
+ - app/assets/javascripts/pageflow/external_links/editor/views/inputs/site_references_input_view.js
153
155
  - app/assets/javascripts/pageflow/external_links/editor/views/site_item_view.js
154
156
  - app/assets/javascripts/pageflow/external_links/editor/views/site_reference_item_view.js
157
+ - app/assets/javascripts/pageflow/external_links/editor/views/site_selection_view.js
155
158
  - app/assets/javascripts/pageflow/external_links/editor/views/sites_view.js
156
159
  - app/assets/javascripts/pageflow/external_links/page_type.js
157
160
  - app/assets/stylesheets/pageflow/external_links.css.scss
158
161
  - app/assets/stylesheets/pageflow/external_links/editor.css.scss
159
162
  - app/assets/stylesheets/pageflow/external_links/editor/embedded.css.scss
163
+ - app/assets/stylesheets/pageflow/external_links/editor/external_sites.css.scss
164
+ - app/assets/stylesheets/pageflow/external_links/editor/site_selection.css.scss
160
165
  - app/controllers/pageflow/external_links/sites_controller.rb
161
166
  - app/helpers/pageflow/external_links/sites_helper.rb
162
167
  - app/models/pageflow/external_links/site.rb
@@ -173,7 +178,7 @@ files:
173
178
  - lib/pageflow/external_links/page_type.rb
174
179
  - lib/pageflow/external_links/plugin.rb
175
180
  - pageflow-external-links.gemspec
176
- homepage: ''
181
+ homepage: https://github.com/codevise/pageflow-external-links
177
182
  licenses:
178
183
  - MIT
179
184
  metadata: {}