pageflow 14.0.0 → 14.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pageflow might be problematic. Click here for more details.

Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -90
  3. data/admins/pageflow/accounts.rb +6 -2
  4. data/app/assets/javascripts/pageflow/dist/react-client.js +1 -1
  5. data/app/assets/javascripts/pageflow/dist/react-server.js +1 -1
  6. data/app/assets/javascripts/pageflow/editor/views/configuration_editors/groups/general.js +4 -1
  7. data/app/assets/javascripts/pageflow/editor/views/edit_meta_data_view.js +4 -0
  8. data/app/assets/javascripts/pageflow/page_types/mixins/default_page_content.js +1 -1
  9. data/app/assets/javascripts/pageflow/slideshow/page_split_layout.js +1 -1
  10. data/app/assets/javascripts/pageflow/slideshow/page_widget.js +4 -3
  11. data/app/assets/javascripts/pageflow/ui.js +1 -1
  12. data/app/assets/javascripts/pageflow/ui/templates/inputs/check_box_group_input.jst.ejs +5 -0
  13. data/app/assets/javascripts/pageflow/ui/templates/inputs/text_area_input.jst.ejs +45 -6
  14. data/app/assets/javascripts/pageflow/ui/views/inputs/check_box_group_input_view.js +75 -0
  15. data/app/assets/javascripts/pageflow/ui/views/inputs/text_area_input_view.js +131 -18
  16. data/app/assets/javascripts/pageflow/widgets/navigation.js +2 -2
  17. data/app/assets/javascripts/pageflow/widgets/share_menu.js +1 -1
  18. data/app/assets/stylesheets/pageflow/base.scss +7 -0
  19. data/app/assets/stylesheets/pageflow/editor/wysihtml5.scss +84 -5
  20. data/app/assets/stylesheets/pageflow/mixins/icons.scss +3 -1
  21. data/app/assets/stylesheets/pageflow/navigation_mobile.scss +13 -19
  22. data/app/assets/stylesheets/pageflow/subshare.scss +16 -14
  23. data/app/assets/stylesheets/pageflow/themes/default/base.scss +1 -0
  24. data/app/assets/stylesheets/pageflow/themes/default/mobile_navigation.scss +2 -2
  25. data/app/assets/stylesheets/pageflow/themes/default/navigation.scss +7 -1
  26. data/app/assets/stylesheets/pageflow/themes/default/navigation/dimensions.scss +34 -9
  27. data/app/assets/stylesheets/pageflow/themes/default/navigation/icons/icon_font.scss +1 -53
  28. data/app/assets/stylesheets/pageflow/themes/default/navigation/icons/sprite.scss +0 -12
  29. data/app/assets/stylesheets/pageflow/themes/default/navigation_share_box.scss +40 -0
  30. data/app/assets/stylesheets/pageflow/themes/default/navigation_share_box/icon_colors.scss +46 -0
  31. data/app/assets/stylesheets/pageflow/themes/default/overview/icons/icon_font.scss +1 -4
  32. data/app/assets/stylesheets/pageflow/themes/default/page.scss +7 -33
  33. data/app/assets/stylesheets/pageflow/themes/default/page/anchors.scss +10 -8
  34. data/app/assets/stylesheets/pageflow/themes/default/page/colors.scss +41 -0
  35. data/app/assets/stylesheets/pageflow/themes/default/page/content_text_margin.scss +1 -1
  36. data/app/assets/stylesheets/pageflow/themes/default/page/line_lengths.scss +3 -3
  37. data/app/assets/stylesheets/pageflow/ui.scss +1 -0
  38. data/app/assets/stylesheets/pageflow/ui/input/check_box_group_input.scss +15 -0
  39. data/app/controllers/pageflow/entries_controller.rb +2 -1
  40. data/app/helpers/pageflow/navigation_bar_helper.rb +7 -1
  41. data/app/helpers/pageflow/pages_helper.rb +1 -1
  42. data/app/helpers/pageflow/social_share_links_helper.rb +5 -1
  43. data/app/models/pageflow/draft_entry.rb +1 -0
  44. data/app/models/pageflow/published_entry.rb +1 -0
  45. data/app/models/pageflow/revision.rb +10 -0
  46. data/app/models/pageflow/theming.rb +19 -0
  47. data/app/views/admin/accounts/_form.html.erb +5 -0
  48. data/app/views/admin/accounts/_theming_details.html.arb +3 -0
  49. data/app/views/pageflow/config/_editor_seeds.json.jbuilder +2 -1
  50. data/app/views/pageflow/editor/entries/_entry.json.jbuilder +1 -1
  51. data/app/views/pageflow/entries/_mobile_navigation.html.erb +9 -11
  52. data/app/views/pageflow/entries/navigation/_bar_top.html.erb +1 -7
  53. data/app/views/pageflow/entries/navigation/_share_box_content.html.erb +9 -0
  54. data/app/views/pageflow/entries/share_menu/_email_link.html.erb +14 -0
  55. data/app/views/pageflow/entries/share_menu/_facebook_link.html.erb +11 -2
  56. data/app/views/pageflow/entries/share_menu/_linked_in_link.html.erb +18 -0
  57. data/app/views/pageflow/entries/share_menu/_telegram_link.html.erb +17 -0
  58. data/app/views/pageflow/entries/share_menu/_twitter_link.html.erb +16 -2
  59. data/app/views/pageflow/entries/share_menu/_whats_app_link.html.erb +21 -0
  60. data/config/initializers/paperclip.rb +0 -4
  61. data/config/locales/de.yml +22 -1
  62. data/config/locales/en.yml +22 -1
  63. data/db/migrate/20190408144136_add_default_share_providers_to_themings.rb +5 -0
  64. data/db/migrate/20190408161315_add_share_providers_to_revisions.rb +5 -0
  65. data/lib/generators/pageflow/initializer/templates/pageflow.rb +0 -14
  66. data/lib/pageflow/configuration.rb +27 -6
  67. data/lib/pageflow/engine.rb +1 -1
  68. data/lib/pageflow/version.rb +1 -1
  69. metadata +21 -11
  70. data/app/assets/images/pageflow/themes/default/mobile_navigation/sharing_icons_sprite.png +0 -0
  71. data/app/assets/stylesheets/pageflow/themes/default/navigation/share_box.scss +0 -28
  72. data/app/views/pageflow/entries/share_menu/_google_link.html.erb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53b1ec3afc77304b2749528b6c1bb9d40cfd60716f653fa46a5d9693e721cddb
4
- data.tar.gz: ccb398e3bb105e3315dac05230f55b693e3514bb3a94258a78bf4e59dc124310
3
+ metadata.gz: 26efef4a8054a381429f740caba05bcd9478e6051c513d122169851841f8075a
4
+ data.tar.gz: ad96598509d90638857b6434bff2f31cb83563a2291aba9adc40537415d86202
5
5
  SHA512:
6
- metadata.gz: b242b3b3c2325e4285b8ef20463ff847ade31f42a53dd3b5c6b68894fd3d690780df0eaa662ed17bb60a8160f907c9042f28e4c524e8f577b097f91eb44fe0b3
7
- data.tar.gz: d899b10166573a330b7568ce9a61fa784937677c74b96ab7e55cf25454bfd76fda71da56fd4ab28793406bd855f748cf3343b7b6c3b02e561b650aed5e679fb2
6
+ metadata.gz: e98f4d0a5071282045e89bc9ac92d4654d6868b974237e755d6b1206048791c30f5768830ba54aeafcb7c3991b7ae328ce4fe9fadf2495d6bc515c16cb357553
7
+ data.tar.gz: f3322825d98421689c84aba34d8a40113768f8bba6bacad5728b9748e48ae86689c56a73faadbee19d4017c4ce20c16a29dc002f74583e3eebb63032efbd02dc
data/CHANGELOG.md CHANGED
@@ -1,98 +1,67 @@
1
1
  # CHANGELOG
2
2
 
3
- ### Version 14.0.0
3
+
4
+ ### Version 14.1.0
4
5
 
5
- 2019-04-08
6
+ 2019-05-20
6
7
 
7
- [Compare changes](https://github.com/codevise/pageflow/compare/13-x-stable...v14.0.0)
8
-
9
- See
10
- [changes grouped by pre releases](https://github.com/codevise/pageflow/blob/v14.0.0.rc2/CHANGELOG.md).
8
+ [Compare changes](https://github.com/codevise/pageflow/compare/14-0-stable...v14.1.0)
11
9
 
12
10
  #### Manual Update Steps
13
-
14
- - Direct upload to S3
15
- ([#1076](https://github.com/codevise/pageflow/pull/1076))
16
-
17
- Files are now uploaded directly to S3 from the browser. The
18
- following steps need to be performed:
19
-
20
- * Update CORS-config for S3 bucket as described in
21
- [`doc/setting_up_external_services.md`](https://github.com/codevise/pageflow/blob/14-0-stable/doc/setting_up_external_services.md).
22
-
23
- * `nginx-upload-module` is no longer supported since the requests to
24
- create files no longer contain uploads. Corresponding Nginx
25
- configuration for Pageflow endpoints needs to be removed. Check
26
- whether the `paperclip-nginx-upload` io adapter is still needed.
27
-
28
- #### Breaking Changes for Pageflow Plugins
29
-
30
- - Page DOM layout change
31
- ([#1135](https://github.com/codevise/pageflow/pull/1135),
32
- [#1149](https://github.com/codevise/pageflow/pull/1149),
33
- [#1148](https://github.com/codevise/pageflow/pull/1148))
34
-
35
- Page headers are now have level 3 instead of level 2. There is a new
36
- helper which is recommended to render the default page header and
37
- content text.
38
-
39
- ERB template based page types need to make the following changes to
40
- CSS class names in their page templates:
41
-
42
- * `blackLayer` -> `black_layer`
43
- * `backgroundArea` -> `page_background`
44
- * `contentWrapper` -> `content_wrapper`
45
- * `videoWrapper` -> `uncropped_media_wrapper`
46
-
47
- The default header and content snippet
48
-
49
- <div class="page_header">
50
- <h2>
51
- <span class="tagline"><%= configuration['tagline'] %></span>
52
- <span class="title"><%= configuration['title'] %></span>
53
- <span class="subtitle"><%= configuration['subtitle'] %></span>
54
- </h2>
55
- <%= background_image_tag(configuration['background_image_id'], {class: "print_image"}) %>
56
- </div>
57
- <div class="contentText">
58
- <p><%= raw configuration['text'] %></p>
59
- </div>
60
-
61
- should be replaced with the following helper call:
62
-
63
- <%= page_default_content(page) %>
64
-
65
- - Direct upload to S3
66
- ([#1132](https://github.com/codevise/pageflow/pull/1132),
67
- [#1147](https://github.com/codevise/pageflow/pull/1147))
68
-
69
- Files are now uploaded directly to S3 from the browser. The state
70
- machine defined by `HostedFile` therefore no longer includes states
71
- like `uploading_to_s3`. Files which are be in state
72
- `uploading_to_s3_failed` have to be migrated to the
73
- `uploading_failed` state. See the migrations inside the PR for
74
- examples.
75
-
76
- #### Minor Changes
77
-
78
- - Structured data for videos, audios and background images
79
- ([#1145](https://github.com/codevise/pageflow/pull/1145))
80
- - Change header structure to improve document outline
81
- ([#1139](https://github.com/codevise/pageflow/pull/1139))
82
- - Allow passing custom query params for collection.create
83
- ([#1136](https://github.com/codevise/pageflow/pull/1136))
84
- - Bug fix: Setup visited pages before resolving ready
85
- ([#1144](https://github.com/codevise/pageflow/pull/1144))
86
- - Add shared specs to pageflow-support to lint page types
87
- ([#1133](https://github.com/codevise/pageflow/pull/1133),
88
- [#1146](https://github.com/codevise/pageflow/pull/1146))
89
- - Increase max length for page tagline, title and subtitles
90
- ([#1131](https://github.com/codevise/pageflow/pull/1131))
91
- - Include text in navigation bar links
92
- ([#1129](https://github.com/codevise/pageflow/pull/1129))
93
- - Update chromedriver-helper to fix travis build
94
- ([#1140](https://github.com/codevise/pageflow/pull/1140))
95
-
11
+ - Configurable sharing providers
12
+ ([#1142](https://github.com/codevise/pageflow/pull/1142))
13
+
14
+ You can now configure which sharing providers should be enabled for your stories.
15
+ Default providers for new and existing stories can be set via the pageflow initializer:
16
+ ```
17
+ config.default_share_providers = [:facebook, :twitter, :email]
18
+ ```
19
+
20
+ To restrict the set of sharing providers you can also specify which ones should
21
+ be available to editors:
22
+ ```
23
+ config.available_share_providers = [:email, :facebook, :linked_in, :twitter, :telegram, :whats_app]
24
+ ```
25
+ By default all available providers are enabled.
26
+
27
+ For custom themes the share icons can be styled via newly introduced SCSS-variables:
28
+
29
+ ```
30
+ $share-icon-color: #7D7D7D;
31
+ $share-icon-hover-color: #909090;
32
+ $share-icon-active-color: #FFC001;
33
+ ```
34
+
35
+ - Remove paperclip_filesystem_root config
36
+ ([#1150](https://github.com/codevise/pageflow/pull/1150))
37
+
38
+ Since uploads go directly to S3 via direct upload (signed post request)
39
+ the `paperclip_filesystem_root` configuration is now deprecated and can be removed
40
+ from the pageflow initializer.
41
+
42
+ #### Editor
43
+ - Add lists to WYSIHTML editor
44
+ ([#1156](https://github.com/codevise/pageflow/pull/1156))
45
+ - Add option to link to other pages from page text
46
+ ([#1154](https://github.com/codevise/pageflow/pull/1154))
47
+ - Bug fix: Prevent page styles from applying to editor elements
48
+ ([#1153](https://github.com/codevise/pageflow/pull/1153))
49
+
50
+ #### Published Entries
51
+ - Reset background color in fullscreen Safari
52
+ ([#1159](https://github.com/codevise/pageflow/pull/1159))
53
+
54
+ #### Custom Themes
55
+ - Add theme variable for title color
56
+ ([#1157](https://github.com/codevise/pageflow/pull/1157))
57
+
58
+ #### Internals
59
+ - Add build-edge script
60
+ ([#1152](https://github.com/codevise/pageflow/pull/1152))
61
+ - Fix spec for jbuilder 2.9
62
+ ([#1158](https://github.com/codevise/pageflow/pull/1158))
63
+
64
+
96
65
  See
97
- [13-x-stable branch](https://github.com/codevise/pageflow/blob/13-x-stable/CHANGELOG.md)
66
+ [14-0-stable branch](https://github.com/codevise/pageflow/blob/14-0-stable/CHANGELOG.md)
98
67
  for previous changes.
@@ -80,7 +80,10 @@ module Pageflow
80
80
 
81
81
  def new
82
82
  @account = Account.new
83
- @account.build_default_theming(default_locale: current_user.locale)
83
+ @account.build_default_theming(
84
+ default_locale: current_user.locale,
85
+ share_providers: Pageflow.config.default_share_providers
86
+ )
84
87
  end
85
88
 
86
89
  def create
@@ -147,7 +150,8 @@ module Pageflow
147
150
  :default_author,
148
151
  :default_publisher,
149
152
  :default_keywords,
150
- :default_locale
153
+ :default_locale,
154
+ share_providers: []
151
155
  ] +
152
156
  permitted_attributes_for(:theming)
153
157
  end
@@ -17823,7 +17823,7 @@ pageflow = typeof pageflow === "object" ? pageflow : {}; pageflow["react"] =
17823
17823
  return _react2.default.createElement(
17824
17824
  'div',
17825
17825
  { className: className(props) },
17826
- _react2.default.createElement('p', { dangerouslySetInnerHTML: text(props) }),
17826
+ _react2.default.createElement('div', { className: 'paragraph', dangerouslySetInnerHTML: text(props) }),
17827
17827
  props.children
17828
17828
  );
17829
17829
  }
@@ -17817,7 +17817,7 @@ pageflow = typeof pageflow === "object" ? pageflow : {}; pageflow["react"] =
17817
17817
  return _react2.default.createElement(
17818
17818
  'div',
17819
17819
  { className: className(props) },
17820
- _react2.default.createElement('p', { dangerouslySetInnerHTML: text(props) }),
17820
+ _react2.default.createElement('div', { className: 'paragraph', dangerouslySetInnerHTML: text(props) }),
17821
17821
  props.children
17822
17822
  );
17823
17823
  }
@@ -3,7 +3,10 @@ pageflow.ConfigurationEditorTabView.groups.define('general', function() {
3
3
  this.input('hide_title', pageflow.CheckBoxInputView);
4
4
  this.input('tagline', pageflow.TextInputView, {maxLength: 5000});
5
5
  this.input('subtitle', pageflow.TextInputView, {maxLength: 5000});
6
- this.input('text', pageflow.TextAreaInputView);
6
+ this.input('text', pageflow.TextAreaInputView, {
7
+ fragmentLinkInputView: pageflow.PageLinkInputView,
8
+ enableLists: true
9
+ });
7
10
  this.input('text_position', pageflow.SelectInputView, {values: pageflow.Page.textPositions});
8
11
  this.input('gradient_opacity', pageflow.SliderInputView);
9
12
  this.input('invert', pageflow.CheckBoxInputView);
@@ -91,6 +91,10 @@ pageflow.EditMetaDataView = Backbone.Marionette.Layout.extend({
91
91
  this.input('share_url', pageflow.TextInputView, {
92
92
  placeholder: pageflow.entry.get('pretty_url')
93
93
  });
94
+ this.input('share_providers', pageflow.CheckBoxGroupInputView, {
95
+ values: pageflow.config.availableShareProviders,
96
+ translationKeyPrefix: 'activerecord.values.pageflow/entry.share_providers'
97
+ });
94
98
  });
95
99
 
96
100
  this.listenTo(entry.configuration, 'change:theme_name', function() {
@@ -3,6 +3,6 @@ pageflow.defaultPageContent = {
3
3
  pageElement.find('.page_header-tagline').text(configuration.get('tagline') || '');
4
4
  pageElement.find('.page_header-title').text(configuration.get('title') || '');
5
5
  pageElement.find('.page_header-subtitle').text(configuration.get('subtitle') || '');
6
- pageElement.find('.page_text p').html(configuration.get('text') || '');
6
+ pageElement.find('.page_text .paragraph').html(configuration.get('text') || '');
7
7
  }
8
8
  };
@@ -32,7 +32,7 @@ pageflow.pageSplitLayout = (function() {
32
32
 
33
33
  function getContentClientRect(pageElement, pageClientRect) {
34
34
  var pageTitle = pageElement.find('.page_header-title');
35
- var pageText = pageElement.find('.page_text p');
35
+ var pageText = pageElement.find('.page_text .paragraph');
36
36
 
37
37
  var pageTitleClientRect = pageTitle[0].getBoundingClientRect();
38
38
  var pageTextClientRect = pageText[0].getBoundingClientRect();
@@ -214,8 +214,9 @@
214
214
 
215
215
  _setupContentLinkTargetHandling: function() {
216
216
  this._on({
217
- 'click .page_text p a': function(event) {
217
+ 'click .page_text .paragraph a': function(event) {
218
218
  var href = $(event.currentTarget).attr('href');
219
+ var target = PAGEFLOW_EDITOR ? '_blank' : $(event.currentTarget).attr('target');
219
220
 
220
221
  if (href[0] === '#') {
221
222
  pageflow.slides.goToByPermaId(href.substr(1));
@@ -224,8 +225,8 @@
224
225
  // There was a time when the rich text editor did not add
225
226
  // target attributes to inline links even though it should
226
227
  // have. Ensure all content links to external urls open in
227
- // new tab.
228
- window.open(href, '_blank');
228
+ // new tab, except explicitly specified otherwise by editor.
229
+ window.open(href, target || '_blank');
229
230
  }
230
231
 
231
232
  event.preventDefault();
@@ -1,6 +1,6 @@
1
1
  //= require_self
2
2
 
3
- //= require wysihtml5x-toolbar
3
+ //= require wysihtml-toolbar
4
4
  //= require jquery.minicolors
5
5
 
6
6
  //= require i18n
@@ -0,0 +1,5 @@
1
+ <label>
2
+ <span class="name"></span>
3
+ <span class="inline_help"></span>
4
+ </label>
5
+ <div class="check_boxes_container" />
@@ -11,13 +11,52 @@
11
11
  <a data-wysihtml5-command="italic" title="<%= I18n.t('pageflow.ui.templates.inputs.text_area_input.italic') %>"></a>
12
12
  <a data-wysihtml5-command="underline" title="<%= I18n.t('pageflow.ui.templates.inputs.text_area_input.underline') %>"></a>
13
13
  <a data-wysihtml5-command="createLink" title="<%= I18n.t('pageflow.ui.templates.inputs.text_area_input.create_link') %>"></a>
14
+ <a data-wysihtml5-command="insertOrderedList" title="<%= I18n.t('pageflow.ui.templates.inputs.text_area_input.insert_ordered_list') %>"></a>
15
+ <a data-wysihtml5-command="insertUnorderedList" title="<%= I18n.t('pageflow.ui.templates.inputs.text_area_input.insert_unordered_list') %>"></a>
14
16
 
15
17
  <div data-wysihtml5-dialog="createLink" class="dialog" style="display: none;">
16
- <label>
17
- <%= I18n.t('pageflow.ui.templates.inputs.text_area_input.url') %>:
18
- <input data-wysihtml5-dialog-field="href" value="http://">
19
- </label>
20
- <a data-wysihtml5-dialog-action="save"><%= I18n.t('pageflow.ui.templates.inputs.text_area_input.ok') %></a>
21
- <a data-wysihtml5-dialog-action="cancel"><%= I18n.t('pageflow.ui.templates.inputs.text_area_input.cancel') %></a>
18
+ <div class="link_type_select">
19
+ <label>
20
+ <input type="radio" name="link_type" class="url_link_radio_button">
21
+ <%= I18n.t('pageflow.ui.templates.inputs.text_area_input.link_type.url') %>
22
+ </label>
23
+ <label>
24
+ <input type="radio" name="link_type" class="fragment_link_radio_button">
25
+ <%= I18n.t('pageflow.ui.templates.inputs.text_area_input.link_type.page_link') %>
26
+ </label>
27
+ </div>
28
+ <div class="url_link_panel">
29
+ <label>
30
+ <%= I18n.t('pageflow.ui.templates.inputs.text_area_input.target') %>
31
+ </label>
32
+ <input type="text" class="display_url">
33
+ <div class="open_in_new_tab_section">
34
+ <label>
35
+ <input type="checkbox" class="open_in_new_tab">
36
+ <%= I18n.t('pageflow.ui.templates.inputs.text_area_input.open_in_new_tab') %>
37
+ </label>
38
+ <span class="inline_help">
39
+ <%= I18n.t('pageflow.ui.templates.inputs.text_area_input.open_in_new_tab_help') %>
40
+ </span>
41
+ </div>
42
+ </div>
43
+ <div class="fragment_link_panel">
44
+ <!-- LinkInputView is inserted here -->
45
+ </div>
46
+
47
+ <!-- wysihtml5 does not handle hidden fields correctly -->
48
+ <div class="internal">
49
+ <input type="text" data-wysihtml5-dialog-field="href" class="current_url" value="http://">
50
+ <input type="text" data-wysihtml5-dialog-field="target" class="current_target" value="_blank">
51
+ </div>
52
+
53
+ <a class="button" data-wysihtml5-dialog-action="save">
54
+ <%= I18n.t('pageflow.ui.templates.inputs.text_area_input.save') %>
55
+ </a>
56
+ <a class="button" data-wysihtml5-dialog-action="cancel">
57
+ <%= I18n.t('pageflow.ui.templates.inputs.text_area_input.cancel') %>
58
+ </a>
59
+
60
+ <a data-wysihtml5-command="removeLink"><%= I18n.t('pageflow.ui.templates.inputs.text_area_input.remove_link') %></a>
22
61
  </div>
23
62
  </div>
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Input view for attributes storing configuration hashes with boolean values.
3
+ *
4
+ * @see {@link module:pageflow/ui.pageflow.inputView pageflow.inputView} for further options
5
+ * @class
6
+ * @memberof module:pageflow/ui
7
+ */
8
+ pageflow.CheckBoxGroupInputView = Backbone.Marionette.ItemView.extend({
9
+ mixins: [pageflow.inputView],
10
+
11
+ template: 'pageflow/ui/templates/inputs/check_box_group_input',
12
+ className: 'check_box_group_input',
13
+
14
+ events: {
15
+ 'change': 'save'
16
+ },
17
+
18
+ ui: {
19
+ label: 'label',
20
+ container: '.check_boxes_container'
21
+ },
22
+
23
+ initialize: function() {
24
+ if (!this.options.texts) {
25
+ if (!this.options.translationKeys) {
26
+ var translationKeyPrefix = this.options.translationKeyPrefix ||
27
+ pageflow.i18nUtils.findKeyWithTranslation(this.attributeTranslationKeys('values', {
28
+ fallbackPrefix: 'activerecord.values'
29
+ }));
30
+
31
+ this.options.translationKeys = _.map(this.options.values, function(value) {
32
+ return translationKeyPrefix + '.' + value;
33
+ }, this);
34
+ }
35
+
36
+ this.options.texts = _.map(this.options.translationKeys, function(key) {
37
+ return I18n.t(key);
38
+ });
39
+ }
40
+ },
41
+
42
+ onRender: function() {
43
+ this.ui.label.attr('for', this.cid);
44
+ this.appendOptions();
45
+ this.load();
46
+ this.listenTo(this.model, 'change:' + this.options.propertyName, this.load);
47
+ },
48
+
49
+ appendOptions: function () {
50
+ _.each(this.options.values, function(value, index) {
51
+ var option = '<div class="check_box">'+
52
+ '<label><input type="checkbox" name="'+value+'" />'+
53
+ this.options.texts[index]+'</label></div>';
54
+ this.ui.container.append($(option));
55
+ }, this);
56
+ },
57
+
58
+ save: function() {
59
+ var configured = {};
60
+ _.each(this.ui.container.find('input'), function(input) {
61
+ configured[$(input).attr('name')] = $(input).prop('checked');
62
+ });
63
+ this.model.set(this.options.propertyName, configured);
64
+ },
65
+
66
+ load: function() {
67
+ if (!this.isClosed) {
68
+ _.each(this.options.values, function(value) {
69
+ this.ui.container
70
+ .find('input[name="'+value+'"]')
71
+ .prop('checked', this.model.get(this.options.propertyName)[value]);
72
+ }, this);
73
+ }
74
+ }
75
+ });
@@ -12,6 +12,11 @@
12
12
  * @param {boolean} [options.disableRichtext=false]
13
13
  * Do not provide text formatting options.
14
14
  *
15
+ * @param {Backbone.View} [options.fragmentLinkInputView]
16
+ * A view to select an id to use in links which only consist
17
+ * of a url fragment. Will receive a model with a `linkId`
18
+ * attribute.
19
+ *
15
20
  * @see
16
21
  * {@link module:pageflow/ui.pageflow.inputWithPlaceholderText pageflow.inputWithPlaceholderText}
17
22
  * for placeholder related options
@@ -27,11 +32,30 @@ pageflow.TextAreaInputView = Backbone.Marionette.ItemView.extend({
27
32
 
28
33
  ui: {
29
34
  input: 'textarea',
30
- toolbar: '.toolbar'
35
+ toolbar: '.toolbar',
36
+
37
+ urlInput: '.current_url',
38
+ targetInput: '.current_target',
39
+
40
+ linkTypeSelection: '.link_type_select',
41
+ urlLinkRadioButton: '.url_link_radio_button',
42
+ fragmentLinkRadioButton: '.fragment_link_radio_button',
43
+
44
+ urlLinkPanel: '.url_link_panel',
45
+ displayUrlInput: '.display_url',
46
+ openInNewTabCheckBox: '.open_in_new_tab',
47
+
48
+ fragmentLinkPanel: '.fragment_link_panel',
31
49
  },
32
50
 
33
51
  events: {
34
- 'change': 'save'
52
+ 'change textarea': 'save',
53
+
54
+ 'click .url_link_radio_button': 'showUrlLinkPanel',
55
+ 'click .fragment_link_radio_button': 'showFragmentLinkPanel',
56
+
57
+ 'change .open_in_new_tab': 'setTargetFromOpenInNewTabCheckBox',
58
+ 'change .display_url': 'setUrlFromDisplayUrl'
35
59
  },
36
60
 
37
61
  onRender: function() {
@@ -49,15 +73,18 @@ pageflow.TextAreaInputView = Backbone.Marionette.ItemView.extend({
49
73
  u: {unwrap: this.options.disableRichtext ? 1 : 0},
50
74
  b: {unwrap: this.options.disableRichtext ? 1 : 0},
51
75
  i: {unwrap: this.options.disableRichtext ? 1 : 0},
76
+ ol: {unwrap: this.options.enableLists ? 0 : 1},
77
+ ul: {unwrap: this.options.enableLists ? 0 : 1},
78
+ li: {unwrap: this.options.enableLists ? 0 : 1},
52
79
  br: {},
53
80
  a: {
54
81
  unwrap: this.options.disableLinks ? 1 : 0,
55
82
  check_attributes: {
56
- href: "href"
83
+ href: 'href',
84
+ target: 'any'
57
85
  },
58
86
  set_attributes: {
59
- rel: "nofollow",
60
- target: "_blank"
87
+ rel: 'nofollow'
61
88
  }
62
89
  }
63
90
  }
@@ -68,33 +95,119 @@ pageflow.TextAreaInputView = Backbone.Marionette.ItemView.extend({
68
95
  this.ui.toolbar.find('a[data-wysihtml5-command="bold"]').hide();
69
96
  this.ui.toolbar.find('a[data-wysihtml5-command="italic"]').hide();
70
97
  this.ui.toolbar.find('a[data-wysihtml5-command="underline"]').hide();
98
+ this.ui.toolbar.find('a[data-wysihtml5-command="insertOrderedList"]').hide();
99
+ this.ui.toolbar.find('a[data-wysihtml5-command="insertUnorderedList"]').hide();
100
+ }
101
+
102
+ if (!this.options.enableLists) {
103
+ this.ui.toolbar.find('a[data-wysihtml5-command="insertOrderedList"]').hide();
104
+ this.ui.toolbar.find('a[data-wysihtml5-command="insertUnorderedList"]').hide();
71
105
  }
106
+
72
107
  if (this.options.disableLinks) {
73
108
  this.ui.toolbar.find('a[data-wysihtml5-command="createLink"]').hide();
74
109
  }
110
+ else {
111
+ this.setupUrlLinkPanel();
112
+ this.setupFragmentLinkPanel();
113
+ }
75
114
 
76
115
  this.editor.on('change', _.bind(this.save, this));
77
116
  this.editor.on('aftercommand:composer', _.bind(this.save, this));
78
117
  },
79
118
 
119
+ onClose: function() {
120
+ this.editor.fire('destroy:composer');
121
+ },
122
+
80
123
  save: function() {
81
124
  this.model.set(this.options.propertyName, this.editor.getValue());
82
125
  },
83
126
 
84
127
  load: function() {
85
128
  this.ui.input.val(this.model.get(this.options.propertyName));
129
+ },
130
+
131
+ setupUrlLinkPanel: function() {
132
+ this.editor.on('show:dialog', _.bind(function() {
133
+ var currentUrl = this.ui.urlInput.val();
134
+
135
+ if (currentUrl.startsWith('#')) {
136
+ this.ui.displayUrlInput.val('http://');
137
+ this.ui.openInNewTabCheckBox.prop('checked', true);
138
+ }
139
+ else {
140
+ this.ui.displayUrlInput.val(currentUrl);
141
+ this.ui.openInNewTabCheckBox.prop('checked', this.ui.targetInput.val() !== '_self');
142
+ }
143
+ }, this));
144
+ },
145
+
146
+ setupFragmentLinkPanel: function() {
147
+ if (this.options.fragmentLinkInputView) {
148
+ this.fragmentLinkModel = new Backbone.Model();
149
+
150
+ this.listenTo(this.fragmentLinkModel, 'change', function(model, options) {
151
+ if (!options.skipCurrentUrlUpdate) {
152
+ this.setInputsFromFragmentLinkModel();
153
+ }
154
+ });
155
+
156
+ this.editor.on('show:dialog', _.bind(function() {
157
+ var currentUrl = this.ui.urlInput.val();
158
+ var id = currentUrl.startsWith('#') ? currentUrl.substr(1) : null;
159
+
160
+ this.fragmentLinkModel.set('linkId', id, {skipCurrentUrlUpdate: true});
161
+ this.initLinkTypePanels(!id);
162
+ }, this));
163
+
164
+ var fragmentLinkInput = new this.options.fragmentLinkInputView({
165
+ model: this.fragmentLinkModel,
166
+ propertyName: 'linkId',
167
+ label: I18n.t('pageflow.ui.templates.inputs.text_area_input.target'),
168
+ hideUnsetButton: true
169
+ });
170
+
171
+ this.ui.fragmentLinkPanel.append(fragmentLinkInput.render().el);
172
+ }
173
+ else {
174
+ this.ui.linkTypeSelection.hide();
175
+ this.ui.fragmentLinkPanel.hide();
176
+ }
177
+ },
178
+
179
+ initLinkTypePanels: function(isUrlLink) {
180
+ if (isUrlLink) {
181
+ this.ui.urlLinkRadioButton.prop('checked', true);
182
+ }
183
+ else {
184
+ this.ui.fragmentLinkRadioButton.prop('checked', true);
185
+ }
186
+
187
+ this.ui.toolbar.toggleClass('fragment_link_panel_active', !isUrlLink);
188
+ },
189
+
190
+ showUrlLinkPanel: function() {
191
+ this.ui.toolbar.removeClass('fragment_link_panel_active');
192
+ this.setUrlFromDisplayUrl();
193
+ this.setTargetFromOpenInNewTabCheckBox();
194
+ },
195
+
196
+ showFragmentLinkPanel: function() {
197
+ this.ui.toolbar.addClass('fragment_link_panel_active');
198
+ this.setInputsFromFragmentLinkModel();
199
+ },
200
+
201
+ setInputsFromFragmentLinkModel: function() {
202
+ this.ui.urlInput.val('#' + (this.fragmentLinkModel.get('linkId') || ''));
203
+ this.ui.targetInput.val('_self');
204
+ },
205
+
206
+ setUrlFromDisplayUrl: function() {
207
+ this.ui.urlInput.val(this.ui.displayUrlInput.val());
208
+ },
209
+
210
+ setTargetFromOpenInNewTabCheckBox: function() {
211
+ this.ui.targetInput.val(this.ui.openInNewTabCheckBox.is(':checked') ? '_blank' : '_self');
86
212
  }
87
213
  });
88
-
89
- (function() {
90
- var isIE11 = navigator.userAgent.indexOf("Trident") !== -1;
91
- // This browser detections is copied from wysihtml5.
92
- var isGecko = navigator.userAgent.indexOf("Gecko") !== -1 && navigator.userAgent.indexOf("KHTML") === -1;
93
-
94
- wysihtml5.browser.insertsLineBreaksOnReturn = function() {
95
- // Used to be only isGecko. Unfortunately IE 11 is detected as
96
- // Gecko since it says "like Gecko" in its user agent. Make sure
97
- // we really are not IE 11.
98
- return isGecko && !isIE11;
99
- };
100
- }());