scrivito_advanced_editors 0.90.0 → 1.0.0.rc1

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: 33b2bbdbfd168aa525e1bba4ecff5d77d032fc77
4
- data.tar.gz: b8fed4871888217730b24eacbd4446476a1bdabd
3
+ metadata.gz: 8d67ccd96d0f92203bc801001fbe9abda97740fd
4
+ data.tar.gz: 819ac1a7bcc835d3fb81f3668ce64c7cdc7d32e7
5
5
  SHA512:
6
- metadata.gz: 35bd327d93ff54040872e65207602304f00054560e7e7db8df34a2345885b0109fff7338adeac34f4e2e421a9be02620cc771dbfce7ca0f46b59dbee3bccec6d
7
- data.tar.gz: d20b84ae10243b65f7f5a532da64f765f24c39bc3caaaa77ed37f1e19b5d58b86e11c1a5377dcb1195525563c0b2a68f9bdb3fe752c288871a0c6c7d89ae7eb6
6
+ metadata.gz: e930f550a7d91f161a60e0766a80b6310736698568f00ab6f8e0dc5348dc75c86670edf5c9448e9ee73090dadd01fa197ec99a4da0c6adfa4ee5322c256c2905
7
+ data.tar.gz: 2dc9bffc5a11adfdf58aa1b2ee8696289c649a90cb1394d01df740022ef7421632a2fd706e74a80d447c7c76a65b0a23c2af8fe3d79e4ff32308d207a22edf18
@@ -6,12 +6,14 @@
6
6
  var content = $(scrivito_tag).scrivito('content');
7
7
  var values = $(scrivito_tag).data('colors-list');
8
8
 
9
- $(scrivito_tag).addClass('toggle_button_list').html('');
9
+ var with_text = $(scrivito_tag).data('scrivito-color-picker-show-text') == true;
10
+ if(with_text) $(scrivito_tag).addClass('with-text');
11
+
12
+ $(scrivito_tag).addClass('scrivito_color_picker').html('');
10
13
  return $.each(values, function(index, color) {
11
14
  var css_class = (color === content) ? 'active' : 'inactive'
12
15
  $('<button></button>')
13
- .addClass('scrivito-toggle-button')
14
- .addClass('color-select')
16
+ .addClass('scrivito-color-select')
15
17
  .addClass(color === "" ? "default" : color)
16
18
  .addClass(color !== "" ? '' : 'transparent_bg')
17
19
  .addClass(css_class)
@@ -39,7 +41,7 @@
39
41
  },
40
42
  activate: function(element) {
41
43
  ScrivitoColorPicker.init_function(element);
42
- $(element).on('click', '.scrivito-toggle-button', ScrivitoColorPicker.clickFunction);
44
+ $(element).on('click', '.scrivito-color-select', ScrivitoColorPicker.clickFunction);
43
45
  }
44
46
  });
45
47
  });
@@ -1,62 +1,61 @@
1
1
  (function($, App) {
2
2
  'use strict';
3
3
 
4
- var ScrivitoMultiSelectButton = {
5
- init_function: function(scrivito_tag) {
6
- var content = $(scrivito_tag).scrivito('content');
7
- var is_enum = $(scrivito_tag).is('[data-scrivito-field-type=multienum]');
8
- var values = is_enum ? $(scrivito_tag).scrivito('allowed_values') : $(scrivito_tag).data('multi-select-list');
9
- var captions = $(scrivito_tag).data('multi-select-caption');
10
-
11
- $(scrivito_tag).addClass('button_list').addClass('select').html('');
12
- return $.each(values, function(index, value) {
13
- var css_class = ($.inArray(value, content) >= 0) ? 'active' : 'inactive'
14
-
15
- if(!is_enum) css_class = (content.indexOf(value) > -1) ? 'active' : 'inactive'
16
-
17
- var caption = (captions && captions[value]) ? captions[value] : value
18
- $('<button></button>')
19
- .addClass('scrivito-multi-select-button')
20
- .addClass(css_class)
21
- .data('content', value)
22
- .html(caption)
23
- .appendTo($(scrivito_tag));
24
- });
4
+ var activate, handleClick, renderTemplate,
5
+ indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
6
+
7
+ scrivito.editors.multienum_editor = {
8
+ can_edit: function(element) {
9
+ var is_multienum = $(element).is('[data-scrivito-field-type=multienum]')
10
+ var has_list = $(element).is('[data-multi-select-list]');
11
+ return is_multienum || has_list;
25
12
  },
13
+ activate: function(element) {
14
+ return activate($(element));
15
+ }
16
+ };
26
17
 
27
- clickFunction: function(event) {
28
- var newValue = $(event.currentTarget).data('content');
29
- var scrivito_tag = $(event.currentTarget).parent();
30
- var content = $(scrivito_tag).scrivito('content');
31
- var array_content = Array.isArray(content) ? content : content.split('%|%')
32
- if(content === "") array_content = []
33
-
34
- if($.inArray(newValue, array_content) >= 0) {
35
- array_content.splice( array_content.indexOf(newValue), 1 );
36
- } else {
37
- array_content.push(newValue);
38
- }
39
-
40
- var to_save = $(scrivito_tag).is('[data-scrivito-field-type=multienum]') ? array_content : array_content.join('%|%');
18
+ scrivito.on('load', function() {
19
+ return scrivito.define_editor('multienum', scrivito.editors.enum_editor);
20
+ });
41
21
 
42
- scrivito_tag.scrivito('save', to_save).then(function() {
43
- $(event.currentTarget).toggleClass('active');
44
- });
45
- },
22
+ activate = function(cmsField) {
23
+ var validValues = cmsField.data('multi-select-list') || cmsField.scrivito('valid_values');
24
+ var captions = cmsField.data('multi-select-caption');
25
+ cmsField.html(renderTemplate(cmsField.scrivito('content'), validValues, captions));
26
+ return cmsField.find('.scrivito_enum_editor li').on('click', function() {
27
+ return handleClick(cmsField, $(this));
28
+ });
46
29
  };
47
30
 
48
- scrivito.on('load', function() {
49
- scrivito.define_editor("toggle_multi_select_editor", {
50
- can_edit: function(element) {
51
- var is_enum = $(element).is('[data-scrivito-field-type=multienum]')
52
- var has_list = $(element).is('[data-multi-select-list]')
53
- return is_enum || has_list;
54
- },
55
- activate: function(element) {
56
- ScrivitoMultiSelectButton.init_function(element);
57
- $(element).on('click', '.scrivito-multi-select-button', ScrivitoMultiSelectButton.clickFunction);
31
+ renderTemplate = function(values, validValues, captions) {
32
+ var i, len, li, ul, validValue, caption;
33
+ ul = $('<ul class="scrivito_enum_editor scrivito_multi"></ul>');
34
+ for (i = 0, len = validValues.length; i < len; i++) {
35
+ validValue = validValues[i];
36
+ caption = (captions && captions[validValue]) ? captions[validValue] : validValue;
37
+ li = $('<li></li>');
38
+ li.text(caption);
39
+ li.data('scrivito-select-value', validValue);
40
+ if (indexOf.call(values, validValue) >= 0) {
41
+ li.addClass('scrivito_enum_active');
58
42
  }
43
+ ul.append(li);
44
+ }
45
+ return ul;
46
+ };
47
+
48
+ handleClick = function(cmsField, clickedItem) {
49
+ var values;
50
+ clickedItem.toggleClass('scrivito_enum_active');
51
+ values = $.map(cmsField.find('li.scrivito_enum_active'), function(item) {
52
+ return $(item).data('scrivito-select-value');
59
53
  });
60
- });
54
+ cmsField.scrivito('save', values).done(function() {
55
+ cmsField.trigger('scrivito_editors:save');
56
+ return cmsField.trigger('scrivito_editors:blur');
57
+ });
58
+ return false;
59
+ };
61
60
 
62
- })(jQuery, this);
61
+ })(jQuery, this);
@@ -1,48 +1,66 @@
1
1
  (function($, App) {
2
2
  'use strict';
3
3
 
4
- var ScrivitoToggleButton = {
5
- init_function: function($scrivito_tag) {
6
- var content = $scrivito_tag.scrivito('content');
7
- var values = $scrivito_tag.is('[data-scrivito-field-type=enum]') ? $scrivito_tag.scrivito('allowed_values') : $scrivito_tag.data('toggle-button-list');
8
- var captions = $scrivito_tag.data('toggle-button-caption');
9
-
10
- $scrivito_tag.addClass('toggle_button_list').html('');
11
- return $.each(values, function(index, value) {
12
- var css_class = (value.toString() === content) ? 'active' : 'inactive'
13
- var caption = (captions && captions[value]) ? captions[value] : value
14
- $('<button></button>')
15
- .addClass('scrivito-toggle-button')
16
- .addClass(css_class)
17
- .data('content', value)
18
- .html(caption)
19
- .appendTo($scrivito_tag);
20
- });
21
- },
22
-
23
- clickFunction: function(event) {
24
- var text = $(event.currentTarget).data('content');
25
- var scrivito_tag = $(event.currentTarget).parent();
4
+ var activate, handleClick, renderTemplate, save;
26
5
 
27
- scrivito_tag.scrivito('save', text).then(function() {
28
- scrivito_tag.find('.active').removeClass('active');
29
- $(event.currentTarget).addClass('active');
30
- });
6
+ scrivito.editors.enum_editor = {
7
+ can_edit: function(element) {
8
+ var is_enum = $(element).is('[data-scrivito-field-type=enum]');
9
+ var has_list = $(element).is('[data-toggle-button-list]');
10
+ return is_enum || has_list;
31
11
  },
12
+ activate: function(element) {
13
+ return activate($(element));
14
+ }
32
15
  };
33
16
 
34
17
  scrivito.on('load', function() {
35
- scrivito.define_editor("toggle_button_editor", {
36
- can_edit: function(element) {
37
- var is_enum = $(element).is('[data-scrivito-field-type=enum]')
38
- var has_list = $(element).is('[data-toggle-button-list]')
39
- return is_enum || has_list;
40
- },
41
- activate: function(element) {
42
- ScrivitoToggleButton.init_function($(element));
43
- $(element).on('click', '.scrivito-toggle-button', ScrivitoToggleButton.clickFunction);
44
- }
45
- });
18
+ return scrivito.define_editor('enum', scrivito.editors.enum_editor);
46
19
  });
47
20
 
21
+ activate = function(cmsField) {
22
+ var validValues = cmsField.data('toggle-button-list') || cmsField.scrivito('valid_values');
23
+ var captions = cmsField.data('toggle-button-caption');
24
+ cmsField.html(renderTemplate(cmsField.scrivito('content'), validValues, captions));
25
+ return cmsField.find('.scrivito_enum_editor li').on('click', function() {
26
+ return handleClick(cmsField, $(this));
27
+ });
28
+ };
29
+
30
+ renderTemplate = function(value, validValues, captions) {
31
+ var i, len, li, ul, validValue, caption;
32
+
33
+ ul = $('<ul class="scrivito_enum_editor"></ul>');
34
+ for (i = 0, len = validValues.length; i < len; i++) {
35
+ validValue = validValues[i];
36
+ caption = (captions && captions[validValue]) ? captions[validValue] : validValue;
37
+ li = $('<li></li>');
38
+ li.text(caption);
39
+ li.data('scrivito-toggle-value', validValue);
40
+ if (validValue === value) {
41
+ li.addClass('scrivito_enum_active');
42
+ }
43
+ ul.append(li);
44
+ }
45
+ return ul;
46
+ };
47
+
48
+ handleClick = function(cmsField, clickedItem) {
49
+ if (clickedItem.hasClass('scrivito_enum_active')) {
50
+ clickedItem.removeClass('scrivito_enum_active');
51
+ save(cmsField, null);
52
+ } else {
53
+ cmsField.find('li').removeClass('scrivito_enum_active');
54
+ clickedItem.addClass('scrivito_enum_active');
55
+ save(cmsField, clickedItem.data('scrivito-toggle-value'));
56
+ }
57
+ return false;
58
+ };
59
+
60
+ save = function(cmsField, value) {
61
+ return cmsField.scrivito('save', value).done(function() {
62
+ cmsField.trigger('scrivito_editors:save');
63
+ return cmsField.trigger('scrivito_editors:blur');
64
+ });
65
+ };
48
66
  })(jQuery, this);
@@ -1,11 +1,78 @@
1
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button.color-select {
1
+ .scrivito_dialog [data-colors-list] {
2
+ background: #fff;
3
+ border: 1px solid #ddd;
4
+ border-radius: 5px;
5
+ color: #555;
6
+ display: block;
7
+ font-size: 14px;
8
+ min-height: 71px;
9
+ margin: 0;
10
+ padding: 6px 12px;
11
+ width: 100%;
12
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
13
+ font-weight: normal;
14
+ }
15
+ .scrivito_dialog [data-colors-list] .scrivito-color-select {
2
16
  padding: 3px;
3
17
  font-size: 0px;
4
18
  line-height: 10px;
5
19
  width: 45px;
6
20
  height: 45px;
21
+ overflow: hidden;
22
+ position: relative;
23
+ border: 0;
24
+ margin: 0 5px 0 0;
25
+ box-shadow: 0 0 4px 1px rgba(0,0,0,0.1);
26
+ border-radius: 3px;
27
+ background: transparent;
28
+ top: -5px;
29
+ outline: none;
30
+ }
31
+
32
+ .scrivito_dialog [data-colors-list] .scrivito-color-select.active {
33
+ width: 55px;
34
+ height: 55px;
35
+ top: 0;
7
36
  }
8
37
 
9
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button.color-select.none {
38
+ .scrivito_dialog [data-colors-list] .scrivito-color-select.none {
10
39
  font-size: 10px;
40
+ }
41
+
42
+ .scrivito_dialog [data-colors-list].with-text .scrivito-color-select:after {
43
+ content: 'Lorem Ipsum dolor';
44
+ font-size: 11px;
45
+ line-height: 13px;
46
+ padding-top: 3px;
47
+ }
48
+
49
+ .scrivito_dialog [data-colors-list].with-text .scrivito-color-select.active:after {
50
+ padding-top: 8px;
51
+ }
52
+
53
+ .scrivito_dialog [data-colors-list] .scrivito-color-select:before {
54
+ content: '';
55
+ background-color: #fff;
56
+ background-image:
57
+ linear-gradient(45deg, #33312d 25%, transparent 25%, transparent 75%, #33312d 75%, #33312d),
58
+ linear-gradient(45deg, #33312d 25%, transparent 25%, transparent 75%, #33312d 75%, #33312d);
59
+
60
+ background-size: 20px 20px;
61
+ background-position:0 0, 30px 30px;
62
+ position: absolute;
63
+ top: 0;
64
+ left: 0;
65
+ right: 0;
66
+ bottom: 0;
67
+ }
68
+
69
+ .scrivito_dialog [data-colors-list] .scrivito-color-select:after {
70
+ content: '';
71
+ background: inherit;
72
+ background-size: cover;
73
+ position: absolute;
74
+ top: 0;
75
+ left: 0;
76
+ right: 0;
77
+ bottom: 0;
11
78
  }
@@ -1,52 +1,15 @@
1
- .scrivito_dialog .toggle_button_list {
2
- overflow: hidden;
3
- position: relative;
4
- }
5
-
6
- .scrivito_dialog [data-scrivito-field-type="enum"].toggle_button_list {
7
- background: transparent;
8
- border: none;
9
- padding: 0;
10
- }
11
-
12
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button {
13
- margin: 4px;
14
- min-width: 28px;
15
- background: #ddd;
16
- color: #888;
17
- outline: none !important;
18
- border: none;
1
+ .scrivito_dialog [data-toggle-button-list],
2
+ .scrivito_dialog [data-multi-select-list] {
3
+ background: #fff;
4
+ border: 1px solid #ddd;
19
5
  border-radius: 5px;
20
- cursor: pointer;
21
- box-shadow: 0 0 5px rgba(0,0,0,0.1);
22
- font-size: 15px;
23
- line-height: 15px;
24
- width: initial;
25
- float: left;
26
- padding: 5px 15px;
27
- }
28
-
29
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button:hover {
30
- background: #ccc;
31
- }
32
-
33
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button.active {
34
- box-shadow: 0 0px 5px rgba(0,0,0,0.2);
35
- color: white;
36
- background: #658b51;
37
- }
38
-
39
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button.color-select {
40
- background: transparent;
41
- transition: width 0.3s, height 0.3s, margin 0.3s;
42
- position: relative;
43
- overflow: hidden;
44
- margin: 7px 4px;
45
- }
46
-
47
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button.color-select.active {
48
- background: transparent;
49
- height: 51px;
50
- width: 51px;
51
- margin: 4px;
6
+ color: #555;
7
+ display: block;
8
+ font-size: 14px;
9
+ min-height: 31px;
10
+ margin: 0;
11
+ padding: 6px 12px;
12
+ width: 100%;
13
+ font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
14
+ font-weight: normal;
52
15
  }
@@ -1,3 +1,3 @@
1
1
  module ScrivitoAdvancedEditors
2
- VERSION = "0.90.0"
2
+ VERSION = "1.0.0.rc1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_advanced_editors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.90.0
4
+ version: 1.0.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: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,11 +87,9 @@ files:
87
87
  - app/assets/stylesheets/scrivito_advanced_editors/color_picker.css
88
88
  - app/assets/stylesheets/scrivito_advanced_editors/create_obj.css
89
89
  - app/assets/stylesheets/scrivito_advanced_editors/scrivito_dialog.css
90
- - app/assets/stylesheets/scrivito_advanced_editors/scrivito_mutli_select_button.css.scss
91
90
  - app/assets/stylesheets/scrivito_advanced_editors/scrivito_tabs.css
92
91
  - app/assets/stylesheets/scrivito_advanced_editors/scrivito_toggle_button.css
93
92
  - app/assets/stylesheets/scrivito_advanced_editors/textarea_editor.css
94
- - app/assets/stylesheets/scrivito_advanced_editors/transparent_bg.css
95
93
  - app/helpers/scrivito_advanced_editors/scrivito_advanced_tag_helper.rb
96
94
  - app/views/scrivito_advanced_editors/_create_obj.html.erb
97
95
  - lib/scrivito_advanced_editors.rb
@@ -113,9 +111,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
111
  version: '0'
114
112
  required_rubygems_version: !ruby/object:Gem::Requirement
115
113
  requirements:
116
- - - ">="
114
+ - - ">"
117
115
  - !ruby/object:Gem::Version
118
- version: '0'
116
+ version: 1.3.1
119
117
  requirements: []
120
118
  rubyforge_project:
121
119
  rubygems_version: 2.4.5
@@ -1,34 +0,0 @@
1
- .button_list.select {
2
- overflow: hidden;
3
- padding: 5px;
4
- background-color: white;
5
- border-radius: 5px;
6
- box-shadow: 0 0 5px #888 inset;
7
- }
8
-
9
- .scrivito_dialog .button_list button.scrivito-multi-select-button {
10
- margin: 1px;
11
- min-width: 28px;
12
- background: #ddd;
13
- color: #888;
14
- outline: none !important;
15
- border: none;
16
- cursor: pointer;
17
- box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
18
- font-size: 15px;
19
- border-radius: 5px;
20
- line-height: 15px;
21
- width: initial;
22
- float: left;
23
- padding: 5px 15px;
24
- }
25
-
26
- .scrivito_dialog .button_list button.scrivito-multi-select-button:hover {
27
- background: #ccc;
28
- }
29
-
30
- .scrivito_dialog .button_list button.scrivito-multi-select-button.active {
31
- box-shadow: 0 0px 5px rgba(0,0,0,0.2);
32
- color: white;
33
- background: #658b51;
34
- }
@@ -1,25 +0,0 @@
1
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button.color-select:before {
2
- content: '';
3
- background-color: #fff;
4
- background-image:
5
- linear-gradient(45deg, #33312d 25%, transparent 25%, transparent 75%, #33312d 75%, #33312d),
6
- linear-gradient(45deg, #33312d 25%, transparent 25%, transparent 75%, #33312d 75%, #33312d);
7
-
8
- background-size: 20px 20px;
9
- background-position:0 0, 30px 30px;
10
- position: absolute;
11
- top: 0;
12
- left: 0;
13
- right: 0;
14
- bottom: 0;
15
- }
16
-
17
- .scrivito_dialog .toggle_button_list .scrivito-toggle-button.color-select:after {
18
- content: '';
19
- background-color: inherit;
20
- position: absolute;
21
- top: 0;
22
- left: 0;
23
- right: 0;
24
- bottom: 0;
25
- }