scrivito_editors 0.0.15 → 0.0.16

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
  SHA1:
3
- metadata.gz: ab01a47f8d3930f53b531f531e876af4b2cdfcfb
4
- data.tar.gz: a763ce5cb7a1bb7cc08d3d982f14849f9871cf52
3
+ metadata.gz: efb1dd01d9b155f366520f9a2ff0c66b51e8ecd3
4
+ data.tar.gz: a44c9163f4144a844292e7abaf424748c8e8376c
5
5
  SHA512:
6
- metadata.gz: 7c893e87c20a703ad41b0b3700ea5c8ad0e81055bbbba85bc13e0200996870c2e83bba4998b2a4635986807892fecfd48365648791dacec6698a4919cdd6f2a4
7
- data.tar.gz: 6e9d5f21d7b3eef301331583cfea7875871b8ed556fdbfdee6698e6427a75983cfa8ef21ce864addd99d4cd765c268c37e85f2c24bfff52fb6625f7bd5ecc354
6
+ metadata.gz: 089a86e9d7cc05bb436f610d1d2d61f678c7bd3a20c6d812d88a3404ce1473d24b9c47473cce5dd0b0c5b0f773c3012b35c438c35b016ad680b2e09b2fbf3a09
7
+ data.tar.gz: 3b92cff37bfbe5308ff9b9d93991ce50d4650f01930b4a7aaf1945f3a7cd2ebf35e0a20eee4fe1e4fefe4c7461df497afbf9890e49b630e6f093b847d42dc648
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.0.16
2
+ * Bugfix: added a missing constant in text editor
3
+ * Introduced `ScrivitoTagHelper` for upcoming Scrivito SDK releases
4
+ (`CmsTagHelper` is still available for compatibility with older releases)
5
+
1
6
  # v0.0.15
2
7
  * Reduce unwanted `nbsp` in HTML editor
3
8
  * Resolved issues in string and text editor
@@ -1,9 +1,9 @@
1
1
  $ ->
2
2
  # Display a placeholder for empty CMS attributes. The placeholder can be overwritten by
3
- # defining a +data-placeholder+ HTML attribute on the DOM element generated by +cms_tag+.
3
+ # defining a +data-placeholder+ HTML attribute on the DOM element generated by +scrivito_tag+.
4
4
  #
5
5
  # For example:
6
- # cms_tag(:div, @obj, :my_attribute, data: { placeholder: 'My custom placeholder text.' })
6
+ # scrivito_tag(:div, @obj, :my_attribute, data: { placeholder: 'My custom placeholder text.' })
7
7
  addPlaceholder = ->
8
8
  cmsFields = $('[data-scrivito-field-type]')
9
9
 
@@ -56,6 +56,8 @@ $ ->
56
56
  else
57
57
  cmsField.siblings().addBack().not(siblingsBefore)
58
58
 
59
+ DOUBLE_CLICK_MS = 300
60
+
59
61
  initialize = ->
60
62
  $(':root').on 'mouseenter', '[data-scrivito-field-type="text"]:not([data-editor]), [data-editor~="text"]', (event) ->
61
63
  cmsField = $(@)
@@ -0,0 +1,140 @@
1
+ module ScrivitoEditors
2
+ # This module includes helpers that render the HTML for specfic CMS
3
+ # attributes and their JS editors. These special methods are needed
4
+ # because the editors need additional information that is not provided
5
+ # by the Scrivito SDK's ++scrivito_tag++ method.
6
+ module ScrivitoTagHelper
7
+
8
+ # Allows you to edit a CMS ++enum++ attribute using a dropdown
9
+ #
10
+ # @param [Obj, Widgegt] object
11
+ # @param [String, Symbol] attribute_name
12
+ # @param [Hash] options passed to the ++scrivito_tag++ helper
13
+ def scrivito_edit_enum(object, attribute_name, options = {})
14
+ values = object.obj_class.attributes[attribute_name].values
15
+ values |= [object[attribute_name].to_s]
16
+
17
+ options.reverse_merge!({
18
+ data: {
19
+ values: values,
20
+ min: values.min,
21
+ max: values.max,
22
+ }
23
+ })
24
+
25
+ scrivito_tag(:div, object, attribute_name, options)
26
+ end
27
+
28
+ # Allows you to edit a CMS ++multienum++ attribute using a multi-select.
29
+ #
30
+ # @param [Obj, Widget] object
31
+ # @param [String, Symbol] attribute_name
32
+ # @param [Hash] options passed to the ++scrivito_tag++ helper
33
+ def scrivito_edit_multienum(object, attribute_name, options = {})
34
+ values = object.obj_class.attributes[attribute_name].values
35
+
36
+ options.reverse_merge!({
37
+ multiple: true,
38
+ data: {
39
+ values: values,
40
+ }
41
+ })
42
+
43
+ scrivito_tag(:div, object, attribute_name, options) do |tag|
44
+ (object[attribute_name] || []).join(', ')
45
+ end
46
+ end
47
+
48
+ # Allows you to edit a CMS ++reference++ attribute using the resource
49
+ # browser.
50
+ #
51
+ # @param [Obj, Widget] object
52
+ # @param [String, Symbol] attribute_name
53
+ # @param [Hash] options passed to the ++scrivito_tag++ helper
54
+ def scrivito_edit_reference(object, attribute_name, options = {})
55
+ reference = object[attribute_name]
56
+
57
+ scrivito_tag(:div, object, attribute_name, options) do
58
+ if reference
59
+ reference.description_for_editor
60
+ end
61
+ end
62
+ end
63
+
64
+ # Allows you to edit a CMS ++referencelist++ attribute using the resource
65
+ # browser.
66
+ #
67
+ # @param [Obj, Widget] object
68
+ # @param [String, Symbol] attribute_name
69
+ # @param [Hash] options passed to the ++scrivito_tag++ helper
70
+ def scrivito_edit_referencelist(object, attribute_name, options = {})
71
+ reference_list = object[attribute_name]
72
+
73
+ scrivito_tag(:div, object, attribute_name, options) do
74
+ if reference_list.present?
75
+ content_tag(:ul) do
76
+ html = ''.html_safe
77
+
78
+ reference_list.each do |reference|
79
+ html << content_tag(:li, data: { name: reference.name, id: reference.id }) do
80
+ content_tag(:span, reference.description_for_editor, class: 'list-content')
81
+ end
82
+ end
83
+
84
+ html
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ # Allows you to edit a CMS ++linklist++ attribute
91
+ #
92
+ # @param [Obj, Widget] object
93
+ # @param [String, Symbol] attribute_name
94
+ # @param [Hash] options passed to the ++scrivito_tag++ helper
95
+ def scrivito_edit_linklist(object, attribute_name, options = {})
96
+ linklist = object[attribute_name]
97
+
98
+ scrivito_tag(:div, object, attribute_name, options) do
99
+ if linklist
100
+ content_tag(:ul) do
101
+ html = ''.html_safe
102
+
103
+ linklist.each do |link|
104
+ html << _edit_link_li(link)
105
+ end
106
+
107
+ html
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ # Allows you to edit a CMS ++link++ attribute
114
+ #
115
+ # @param [Obj, Widget] object
116
+ # @param [String, Symbol] attribute_name
117
+ # @param [Hash] options passed to the ++scrivito_tag++ helper
118
+ def scrivito_edit_link(object, attribute_name, options = {})
119
+ link = object[attribute_name]
120
+
121
+ scrivito_tag(:div, object, attribute_name, options) do
122
+ content_tag(:ul) { _edit_link_li(link) } if link
123
+ end
124
+ end
125
+
126
+ private
127
+
128
+ def _edit_link_li(link)
129
+ query = link.query.present? ? "?#{link.query}" : ""
130
+ url = link.internal? ? scrivito_path(link).sub(/\?.*/, query) : link.url
131
+ description = link.internal? ? link.obj.description_for_editor : link.url
132
+
133
+ content_tag(:li, data: { title: link.title, url: url }) do
134
+ content_tag(:span, class: 'list-content') do
135
+ "#{link.title} #{link_to(description, url, target: :_blank)}".html_safe
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
@@ -1,3 +1,3 @@
1
1
  module ScrivitoEditors
2
- VERSION = '0.0.15'
2
+ VERSION = '0.0.16'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_editors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-23 00:00:00.000000000 Z
11
+ date: 2014-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -168,6 +168,7 @@ files:
168
168
  - app/assets/stylesheets/scrivito_editors/placeholder.css
169
169
  - app/assets/stylesheets/scrivito_editors/widget_preview.css
170
170
  - app/helpers/scrivito_editors/cms_tag_helper.rb
171
+ - app/helpers/scrivito_editors/scrivito_tag_helper.rb
171
172
  - lib/scrivito_editors.rb
172
173
  - lib/scrivito_editors/engine.rb
173
174
  - lib/scrivito_editors/version.rb