scrivito_editors 1.13.0 → 1.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ddac99443feb82c41e2fbca3b617cdf3a0d33172a206ab702a2acb0c9735ebf
4
- data.tar.gz: fea0c9001e47b3cfeb126c729a31c4c944ca80d4dab1ca0d6d590bb92401ef5a
3
+ metadata.gz: edde882877616fa1eb7d8fcf7dc8b7c66857099c11a854e27b9d5fcb8389f864
4
+ data.tar.gz: aba07a37cf676ba3d547789bc817c238a6de2cf8a28b2a5d92b2cdbb1bcba04f
5
5
  SHA512:
6
- metadata.gz: 6d5ee0f3bd1fe4983405d14cde61a87d9e8b773d64e4c366c4445c693e6a13dec228eb08d67b7af573cf8f200b0b08971d93755cff82b53f7e06242218da565a
7
- data.tar.gz: 4fdf7ddc43c3b618baceb3e5691346a1bf80b60155cb8985204cb0eb6a1bb49415188649da4238743459598493c766f9f6fec058fc5a1f2081c6d0cf10d54e51
6
+ metadata.gz: f6e5604538b714ece7c86c3de8a8d2b0f20fcd2d1fe3e4500d4102dc2726fdaed31467272b6a4d0ac77f30fe83041c53e39f1851db17dc9994801d8eb6983e90
7
+ data.tar.gz: a6d44761c8a5eaa1831dae061c37a2a64004c55702f6cd9aed39448fdeeb7a27d7837ae82a5b132540e9f4ee326d5277ce4ce89bebab47344e691128290498cd
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 - 2014 Infopark AG (http://www.infopark.com)
1
+ Copyright (c) 2009 - 2018 Infopark AG (http://www.infopark.com)
2
2
 
3
3
  This software can be used and modified under the LGPL-3.0. Please refer to
4
4
  http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
data/README.md CHANGED
@@ -2,25 +2,17 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/scrivito_editors.svg)](https://badge.fury.io/rb/scrivito_editors)
4
4
 
5
- The [Scrivito](http://scrivito.com) Editors gem is a collection of useful standard
6
- JavaScript editors based on the Scrivito SDK. The editors allow to edit all CMS
7
- attributes in place and provide helper for the property view of pages and
8
- widgets. A content browser comes with the gem, to add, update and delete
9
- resources.
5
+ [Scrivito](http://scrivito.com/rails/documentation) Editors is a
6
+ collection of JavaScript editors based on the Scrivito SDK.
7
+ The editors let you edit CMS attributes in place and in property views of pages and widgets.
10
8
 
11
9
  ## Installation and Usage
12
10
 
13
- Please visit our Documentation to get the
14
- [latest installation and usage information](https://scrivito.com/editors).
15
-
16
-
17
- ## Changelog
18
-
19
- {include:file:CHANGELOG.md}
20
-
11
+ Please refer to the
12
+ [latest installation and usage instructions](https://scrivito.com/editors).
21
13
 
22
14
  ## License
23
- Copyright (c) 2009 - 2016 Infopark AG (http://www.infopark.com)
15
+ Copyright (c) 2009 - 2018 Infopark AG (http://www.infopark.com)
24
16
 
25
17
  This software can be used and modified under the LGPL-3.0. Please refer to
26
18
  http://www.gnu.org/licenses/lgpl-3.0.html for the license text.
@@ -1,165 +1,168 @@
1
- (function() {
2
- var DOUBLE_CLICK_MS, activate, cleanUp, cmsFieldAndPastedContent, finishEditing, fixSelectionForFirefox, getCurrentContent, isNewlineAllowed, onBlur, onClick, onFocus, onInput, onKey, prepareForEditing, save;
3
-
4
- onKey = function(event, proxy) {
5
- var cmsField, key;
6
- cmsField = proxy.jQueryElement();
7
- key = event.keyCode || event.which;
8
- switch (key) {
9
- case 13:
10
- if (!isNewlineAllowed(cmsField)) {
11
- event.preventDefault();
12
- return cmsField.blur();
13
- }
14
- break;
15
- case 27:
16
- event.stopPropagation();
17
- return cmsField.blur();
18
- }
19
- };
1
+ // This file integrates contenteditable for string attributes.
20
2
 
21
- onInput = function(proxy) {
22
- return save(proxy);
23
- };
3
+ 'use strict';
24
4
 
25
- onFocus = function(proxy) {
26
- return prepareForEditing(proxy.jQueryElement());
27
- };
5
+ function onKey(event, proxy) {
6
+ var cmsField = proxy.jQueryElement();
7
+ var key = event.keyCode || event.which;
28
8
 
29
- onClick = function(proxy) {
30
- return fixSelectionForFirefox(proxy.jQueryElement());
31
- };
9
+ switch (key) {
10
+ case 13:
11
+ // Enter
12
+ if (!isNewlineAllowed(cmsField)) {
13
+ event.preventDefault();
14
+ cmsField.blur();
15
+ }
16
+ break;
17
+ case 27:
18
+ // Esc
19
+ event.stopPropagation();
20
+ cmsField.blur();
21
+ }
22
+ }
23
+
24
+ function onInput(proxy) {
25
+ save(proxy);
26
+ }
27
+
28
+ function onFocus(proxy) {
29
+ prepareForEditing(proxy.jQueryElement());
30
+ }
31
+
32
+ function onClick(proxy) {
33
+ fixSelectionForFirefox(proxy.jQueryElement());
34
+ }
35
+
36
+ function onBlur(proxy) {
37
+ save(proxy).done(function () {
38
+ return proxy.trigger('scrivito_editors:blur');
39
+ });
32
40
 
33
- onBlur = function(proxy) {
34
- save(proxy).done(function() {
35
- return proxy.trigger('scrivito_editors:blur');
36
- });
37
- finishEditing(proxy);
38
- return prepareForEditing(proxy.jQueryElement());
39
- };
40
-
41
- save = function(proxy) {
42
- var content;
43
- content = getCurrentContent(proxy.jQueryElement());
44
- return proxy.save(content).done(function() {
45
- return proxy.trigger('scrivito_editors:save');
46
- });
47
- };
41
+ finishEditing(proxy);
42
+ prepareForEditing(proxy.jQueryElement());
43
+ }
48
44
 
49
- getCurrentContent = function(cmsField) {
50
- cleanUp(cmsField);
51
- return cmsField[0].innerText.replace(/\r\n/g, '\n').replace(/\n+$/, '');
52
- };
53
-
54
- cleanUp = function(cmsField) {
55
- var pasted, siblings;
56
- siblings = cmsFieldAndPastedContent(cmsField);
57
- pasted = siblings.not(cmsField);
58
- if (pasted.length > 0) {
59
- pasted.remove();
60
- return cmsField.text(siblings.text());
61
- }
62
- };
63
-
64
- cmsFieldAndPastedContent = function(cmsField) {
65
- var needsReset, siblings, siblingsBefore;
66
- siblingsBefore = cmsField.data('scrivito_editors_siblings_before_edit');
67
- siblings = cmsField.siblings();
68
- needsReset = !siblingsBefore || siblings.filter(siblingsBefore).length < siblingsBefore.length;
69
- if (needsReset) {
70
- return cmsField.data('scrivito_editors_siblings_before_edit', siblings);
71
- } else {
72
- return cmsField.siblings().addBack().not(siblingsBefore);
45
+ function save(proxy) {
46
+ var content = getCurrentContent(proxy.jQueryElement());
47
+ return proxy.save(content).done(function () {
48
+ return proxy.trigger('scrivito_editors:save');
49
+ });
50
+ }
51
+
52
+ function getCurrentContent(cmsField) {
53
+ cleanUp(cmsField);
54
+ return cmsField[0].innerText.replace(/\r\n/g, '\n').replace(/\n+$/, '');
55
+ }
56
+
57
+ function cleanUp(cmsField) {
58
+ var siblings = cmsFieldAndPastedContent(cmsField);
59
+ var pasted = siblings.not(cmsField);
60
+ if (pasted.length > 0) {
61
+ pasted.remove();
62
+ cmsField.text(siblings.text());
63
+ }
64
+ }
65
+
66
+ function cmsFieldAndPastedContent(cmsField) {
67
+ var siblingsBefore = cmsField.data('scrivito_editors_siblings_before_edit');
68
+ var siblings = cmsField.siblings();
69
+ var needsReset = !siblingsBefore || siblings.filter(siblingsBefore).length < siblingsBefore.length;
70
+ if (needsReset) {
71
+ return cmsField.data('scrivito_editors_siblings_before_edit', siblings);
72
+ }
73
+ return cmsField.siblings().addBack().not(siblingsBefore);
74
+ }
75
+
76
+ function isNewlineAllowed(cmsField) {
77
+ if (cmsField.data('scrivitoEditorsMultiline') === true) {
78
+ return true;
79
+ }
80
+ if (cmsField.data('scrivitoEditorsMultiline') === false) {
81
+ return false;
82
+ }
83
+ return cmsField.css('white-space').match(/pre/);
84
+ }
85
+
86
+ function prepareForEditing(cmsField) {
87
+ if (isNewlineAllowed(cmsField) && !cmsField.data('scrivito_editors_prepared_for_editing')) {
88
+ cmsField.data('scrivito_editors_prepared_for_editing', true);
89
+ var html = cmsField.html();
90
+ var htmlNl2Br = html.replace(/\r?\n/g, '<br />');
91
+ if (html !== htmlNl2Br) {
92
+ cmsField.html(htmlNl2Br);
73
93
  }
74
- };
94
+ }
95
+ }
96
+
97
+ function finishEditing(proxy) {
98
+ var cmsField = proxy.jQueryElement();
99
+ cmsField.data('scrivito_editors_prepared_for_editing', false);
100
+ cmsField.text(proxy.content());
101
+ }
102
+
103
+ var DOUBLE_CLICK_MS = 300;
104
+
105
+ function fixSelectionForFirefox(cmsField) {
106
+ // see https://bugzilla.mozilla.org/show_bug.cgi?id=389348
107
+ var sel = document.getSelection();
108
+ if (!sel.anchorNode || !sel.focusNode) {
109
+ return;
110
+ }
111
+
112
+ if (!cmsField.find(sel.anchorNode).addBack(sel.anchorNode).length || !cmsField.find(sel.focusNode).addBack(sel.focusNode).length) {
113
+ sel.selectAllChildren(cmsField[0]);
114
+ }
115
+ }
116
+
117
+ function _activate(proxy) {
118
+ var cmsField = proxy.jQueryElement();
119
+
120
+ scrivito.editors.applyPlaceholder(cmsField);
121
+
122
+ cmsField.attr('contenteditable', 'true').blur(function () {
123
+ return onBlur(proxy);
124
+ }).click(function () {
125
+ return onClick(proxy);
126
+ }).focus(function () {
127
+ return onFocus(proxy);
128
+ }).keypress(function (event) {
129
+ return onKey(event, proxy);
130
+ }).keyup(function (event) {
131
+ return onKey(event, proxy);
132
+ });
75
133
 
76
- isNewlineAllowed = function(cmsField) {
77
- if (cmsField.data('scrivitoEditorsMultiline') === true) {
78
- return true;
79
- }
80
- if (cmsField.data('scrivitoEditorsMultiline') === false) {
81
- return false;
82
- }
83
- return cmsField.css('white-space').match(/pre/);
84
- };
85
-
86
- prepareForEditing = function(cmsField) {
87
- var html, htmlNl2Br;
88
- if (isNewlineAllowed(cmsField) && !cmsField.data('scrivito_editors_prepared_for_editing')) {
89
- cmsField.data('scrivito_editors_prepared_for_editing', true);
90
- html = cmsField.html();
91
- htmlNl2Br = html.replace(/\r?\n/g, '<br />');
92
- if (html !== htmlNl2Br) {
93
- return cmsField.html(htmlNl2Br);
94
- }
95
- }
96
- };
97
-
98
- finishEditing = function(proxy) {
99
- var cmsField;
100
- cmsField = proxy.jQueryElement();
101
- cmsField.data('scrivito_editors_prepared_for_editing', false);
102
- return cmsField.text(proxy.content());
103
- };
104
-
105
- DOUBLE_CLICK_MS = 300;
106
-
107
- fixSelectionForFirefox = function(cmsField) {
108
- var sel;
109
- sel = document.getSelection();
110
- if (!sel.anchorNode || !sel.focusNode) {
111
- return;
112
- }
113
- if (!cmsField.find(sel.anchorNode).addBack(sel.anchorNode).length || !cmsField.find(sel.focusNode).addBack(sel.focusNode).length) {
114
- return sel.selectAllChildren(cmsField[0]);
115
- }
116
- };
117
-
118
- activate = function(proxy) {
119
- var cmsField;
120
- cmsField = proxy.jQueryElement();
121
- scrivito.editors.applyPlaceholder(cmsField);
122
- cmsField.attr('contenteditable', true).blur(function() {
123
- return onBlur(proxy);
124
- }).click(function() {
125
- return onClick(proxy);
126
- }).focus(function() {
127
- return onFocus(proxy);
128
- }).keypress(function(event) {
129
- return onKey(event, proxy);
130
- }).keyup(function(event) {
131
- return onKey(event, proxy);
132
- });
133
- if (cmsField.attr('data-scrivito-editors-autosave') !== 'false') {
134
- cmsField.on('cut input keypress keyup paste', function() {
135
- return onInput(proxy);
136
- });
137
- }
138
- prepareForEditing(cmsField);
139
- return cmsField.on('click', function(event) {
140
- cmsField.attr('contenteditable', true);
141
- cleanUp(cmsField);
142
- if (!(event.timeStamp - cmsField.data('scrivito_editors_last_click') < DOUBLE_CLICK_MS)) {
143
- event.preventDefault();
144
- }
145
- return cmsField.data('scrivito_editors_last_click', event.timeStamp);
134
+ if (cmsField.attr('data-scrivito-editors-autosave') !== 'false') {
135
+ cmsField.on('cut input keypress keyup paste', function () {
136
+ return onInput(proxy);
146
137
  });
147
- };
148
-
149
- scrivito.editors.string_editor = {
150
- can_edit: function(element) {
151
- return $(element).is('[data-scrivito-field-type=string]');
152
- },
153
- activate: function(element) {
154
- return activate(new scrivito.editors.DomContentProxy(element));
155
- },
156
- _activateWithProxy: function(proxy) {
157
- return activate(proxy);
158
- }
159
- };
138
+ }
160
139
 
161
- scrivito.on('load', function() {
162
- return scrivito.define_editor('string', scrivito.editors.string_editor);
163
- });
140
+ prepareForEditing(cmsField);
141
+
142
+ cmsField.on('click', function (event) {
143
+ cmsField.attr('contenteditable', 'true');
144
+ cleanUp(cmsField);
164
145
 
165
- }).call(this);
146
+ // Prevent editable link strings from being opened on click, but allow an enforcing double click
147
+ if (event.timeStamp - cmsField.data('scrivito_editors_last_click') >= DOUBLE_CLICK_MS) {
148
+ event.preventDefault();
149
+ }
150
+ cmsField.data('scrivito_editors_last_click', event.timeStamp);
151
+ });
152
+ }
153
+
154
+ scrivito.editors.string_editor = {
155
+ can_edit: function can_edit(element) {
156
+ return $(element).is('[data-scrivito-field-type=string]');
157
+ },
158
+ activate: function activate(element) {
159
+ _activate(new scrivito.editors.DomContentProxy(element));
160
+ },
161
+ _activateWithProxy: function _activateWithProxy(proxy) {
162
+ _activate(proxy);
163
+ }
164
+ };
165
+
166
+ scrivito.on('load', function () {
167
+ return scrivito.define_editor('string', scrivito.editors.string_editor);
168
+ });
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: 1.13.0
4
+ version: 1.14.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-13 00:00:00.000000000 Z
11
+ date: 2018-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-ui-rails
@@ -50,28 +50,28 @@ dependencies:
50
50
  requirements:
51
51
  - - '='
52
52
  - !ruby/object:Gem::Version
53
- version: 1.13.0
53
+ version: 1.14.0.rc1
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - '='
59
59
  - !ruby/object:Gem::Version
60
- version: 1.13.0
60
+ version: 1.14.0.rc1
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: scrivito_sdk
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - '='
66
66
  - !ruby/object:Gem::Version
67
- version: 1.13.0
67
+ version: 1.14.0.rc1
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - '='
73
73
  - !ruby/object:Gem::Version
74
- version: 1.13.0
74
+ version: 1.14.0.rc1
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: coffee-rails
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
331
  version: '1.8'
332
332
  requirements: []
333
333
  rubyforge_project:
334
- rubygems_version: 2.7.6
334
+ rubygems_version: 2.7.7
335
335
  signing_key:
336
336
  specification_version: 4
337
337
  summary: Scrivito Editors