scrivito_advanced_editors 0.0.19 → 0.90.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/scripts/color_picker.js +48 -0
- data/app/assets/javascripts/scripts/scrivito_multi_select_button.js +45 -29
- data/app/assets/javascripts/scripts/scrivito_toggle_button.js +36 -21
- data/app/assets/stylesheets/scrivito_advanced_editors/color_picker.css.scss +1 -1
- data/app/assets/stylesheets/scrivito_advanced_editors/scrivito_dialog.css.scss +5 -2
- data/app/assets/stylesheets/scrivito_advanced_editors/scrivito_mutli_select_button.css.scss +12 -10
- data/app/assets/stylesheets/scrivito_advanced_editors/scrivito_toggle_button.css +21 -13
- data/app/assets/stylesheets/scrivito_advanced_editors/transparent_bg.css.scss +2 -2
- data/app/helpers/scrivito_advanced_editors/scrivito_advanced_tag_helper.rb +10 -57
- data/lib/scrivito_advanced_editors/version.rb +1 -1
- metadata +5 -9
- data/app/assets/javascripts/scripts/jquery.caret.min.js +0 -2
- data/app/assets/javascripts/scripts/jquery.tag-editor.min.js +0 -3
- data/app/assets/javascripts/scripts/scrivito_list_editor.js +0 -42
- data/app/assets/stylesheets/scrivito_advanced_editors/jquery.tag-editor.css +0 -76
- data/app/views/scrivito_advanced_editors/_color_picker.html.erb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38dbbfe68c25c0d405f26124f3079314af575f88
|
4
|
+
data.tar.gz: 0e9c6885568f5b264f1b843c58ce06065225f53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95607a4fb909790d6e66d1c50b9ff7d193fdc3e5c4a1b98fd9528d49625f2b9a08db90807b59ffba57b5f82d614b22682ec3893bc7b69631348b87df97950e66
|
7
|
+
data.tar.gz: 5ed8a2f4d95f6fa43719c0045f07bb403ff8be0e1ec5c7942eb1877712f28757c373a58b24923fe133aa084ec2ecbdfbb165c42a22808b59741dbd145d5cf6c4
|
@@ -0,0 +1,48 @@
|
|
1
|
+
(function($, App) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
$(function() {
|
5
|
+
App.ScrivitoColorPicker = {
|
6
|
+
init_function: function(scrivito_tag) {
|
7
|
+
var content = $(scrivito_tag).scrivito('content');
|
8
|
+
var values = $(scrivito_tag).data('colors-list');
|
9
|
+
|
10
|
+
$(scrivito_tag).addClass('button_list').html('');
|
11
|
+
return $.each(values, function(index, color) {
|
12
|
+
var css_class = (color === content) ? 'active' : 'inactive'
|
13
|
+
$('<button></button>')
|
14
|
+
.addClass('scrivito-toggle-button')
|
15
|
+
.addClass('color-select')
|
16
|
+
.addClass(color === "" ? "default" : color)
|
17
|
+
.addClass(color !== "" ? '' : 'transparent_bg')
|
18
|
+
.addClass(css_class)
|
19
|
+
.data('content', color)
|
20
|
+
.html('')
|
21
|
+
.appendTo($(scrivito_tag));
|
22
|
+
});
|
23
|
+
},
|
24
|
+
|
25
|
+
clickFunction: function(event) {
|
26
|
+
var text = $(event.currentTarget).data('content');
|
27
|
+
var scrivito_tag = $(event.currentTarget).parent();
|
28
|
+
|
29
|
+
scrivito_tag.find('.active').removeClass('active');
|
30
|
+
$(event.currentTarget).addClass('active');
|
31
|
+
|
32
|
+
scrivito_tag.scrivito('save', text);
|
33
|
+
},
|
34
|
+
};
|
35
|
+
|
36
|
+
scrivito.on('load', function() {
|
37
|
+
scrivito.define_editor("color_picker", {
|
38
|
+
can_edit: function(element) {
|
39
|
+
return $(element).is('[data-colors-list]');
|
40
|
+
},
|
41
|
+
activate: function(element) {
|
42
|
+
ScrivitoColorPicker.init_function(element);
|
43
|
+
$(element).on('click', '.scrivito-toggle-button', ScrivitoColorPicker.clickFunction);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
});
|
47
|
+
});
|
48
|
+
})(jQuery, this);
|
@@ -2,46 +2,62 @@
|
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
$(function() {
|
5
|
-
|
6
5
|
App.ScrivitoMultiSelectButton = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
6
|
+
init_function: function(scrivito_tag) {
|
7
|
+
var content = $(scrivito_tag).scrivito('content');
|
8
|
+
var is_enum = $(scrivito_tag).is('[data-scrivito-field-type=multienum]');
|
9
|
+
var values = is_enum ? $(scrivito_tag).scrivito('allowed_values') : $(scrivito_tag).data('multi-select-list');
|
10
|
+
var captions = $(scrivito_tag).data('multi-select-caption');
|
11
|
+
|
12
|
+
$(scrivito_tag).addClass('button_list').addClass('select').html('');
|
13
|
+
return $.each(values, function(index, value) {
|
14
|
+
var css_class = ($.inArray(value, content) >= 0) ? 'active' : 'inactive'
|
15
|
+
|
16
|
+
if(!is_enum) css_class = (content.indexOf(value) > -1) ? 'active' : 'inactive'
|
17
|
+
|
18
|
+
var caption = (captions && captions[value]) ? captions[value] : value
|
19
|
+
$('<button></button>')
|
20
|
+
.addClass('scrivito-multi-select-button')
|
21
|
+
.addClass(css_class)
|
22
|
+
.data('content', value)
|
23
|
+
.html(caption)
|
24
|
+
.appendTo($(scrivito_tag));
|
23
25
|
});
|
26
|
+
},
|
24
27
|
|
25
|
-
|
26
|
-
|
28
|
+
clickFunction: function(event) {
|
29
|
+
var newValue = $(event.currentTarget).data('content');
|
30
|
+
var scrivito_tag = $(event.currentTarget).parent();
|
31
|
+
var content = $(scrivito_tag).scrivito('content');
|
32
|
+
var array_content = Array.isArray(content) ? content : content.split('%|%')
|
33
|
+
if(content === "") array_content = []
|
34
|
+
|
35
|
+
if($.inArray(newValue, content) >= 0) {
|
36
|
+
array_content.splice( content.indexOf(newValue), 1 );
|
27
37
|
} else {
|
28
|
-
|
38
|
+
array_content.push(newValue);
|
29
39
|
}
|
30
40
|
|
31
|
-
|
41
|
+
$(event.currentTarget).toggleClass('active');
|
42
|
+
|
43
|
+
var to_save = $(scrivito_tag).is('[data-scrivito-field-type=multienum]') ? array_content : array_content.join('%|%');
|
32
44
|
|
33
|
-
|
45
|
+
scrivito_tag.scrivito('save', to_save);
|
34
46
|
},
|
35
47
|
};
|
36
48
|
|
37
|
-
// Set click event
|
38
49
|
scrivito.on('load', function() {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
50
|
+
scrivito.define_editor("toggle_multi_select_editor", {
|
51
|
+
can_edit: function(element) {
|
52
|
+
var is_enum = $(element).is('[data-scrivito-field-type=multienum]')
|
53
|
+
var has_list = $(element).is('[data-multi-select-list]')
|
54
|
+
return is_enum || has_list;
|
55
|
+
},
|
56
|
+
activate: function(element) {
|
57
|
+
ScrivitoMultiSelectButton.init_function(element);
|
58
|
+
$(element).on('click', '.scrivito-multi-select-button', ScrivitoMultiSelectButton.clickFunction);
|
59
|
+
}
|
60
|
+
});
|
44
61
|
});
|
45
62
|
});
|
46
|
-
|
47
63
|
})(jQuery, this);
|
@@ -2,33 +2,48 @@
|
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
$(function() {
|
5
|
-
|
6
5
|
App.ScrivitoToggleButton = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
init_function: function(scrivito_tag) {
|
7
|
+
var content = $(scrivito_tag).scrivito('content');
|
8
|
+
var values = $(scrivito_tag).is('[data-scrivito-field-type=enum]') ? $(scrivito_tag).scrivito('allowed_values') : $(scrivito_tag).data('toggle-button-list');
|
9
|
+
var captions = $(scrivito_tag).data('toggle-button-caption');
|
10
|
+
|
11
|
+
$(scrivito_tag).addClass('button_list').html('');
|
12
|
+
return $.each(values, function(index, value) {
|
13
|
+
var css_class = (value === content) ? 'active' : 'inactive'
|
14
|
+
var caption = (captions && captions[value]) ? captions[value] : value
|
15
|
+
$('<button></button>')
|
16
|
+
.addClass('scrivito-toggle-button')
|
17
|
+
.addClass(css_class)
|
18
|
+
.data('content', value)
|
19
|
+
.html(caption)
|
20
|
+
.appendTo($(scrivito_tag));
|
21
|
+
});
|
22
|
+
},
|
16
23
|
|
17
|
-
|
18
|
-
|
24
|
+
clickFunction: function(event) {
|
25
|
+
var text = $(event.currentTarget).data('content');
|
26
|
+
var scrivito_tag = $(event.currentTarget).parent();
|
19
27
|
|
20
|
-
|
28
|
+
scrivito_tag.find('.active').removeClass('active');
|
29
|
+
$(event.currentTarget).addClass('active');
|
30
|
+
|
31
|
+
scrivito_tag.scrivito('save', text);
|
21
32
|
},
|
22
33
|
};
|
23
34
|
|
24
|
-
// Set click event
|
25
35
|
scrivito.on('load', function() {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
36
|
+
scrivito.define_editor("toggle_button_editor", {
|
37
|
+
can_edit: function(element) {
|
38
|
+
var is_enum = $(element).is('[data-scrivito-field-type=enum]')
|
39
|
+
var has_list = $(element).is('[data-toggle-button-list]')
|
40
|
+
return is_enum || has_list;
|
41
|
+
},
|
42
|
+
activate: function(element) {
|
43
|
+
ScrivitoToggleButton.init_function(element);
|
44
|
+
$(element).on('click', '.scrivito-toggle-button', ScrivitoToggleButton.clickFunction);
|
45
|
+
}
|
46
|
+
});
|
31
47
|
});
|
32
48
|
});
|
33
|
-
|
34
|
-
})(jQuery, this);
|
49
|
+
})(jQuery, this);
|
@@ -6,27 +6,29 @@
|
|
6
6
|
box-shadow: 0 0 5px #888 inset;
|
7
7
|
}
|
8
8
|
|
9
|
-
.scrivito_dialog .button_list button
|
9
|
+
.scrivito_dialog .button_list button.scrivito-multi-select-button {
|
10
10
|
margin: 1px;
|
11
11
|
min-width: 28px;
|
12
|
-
|
13
|
-
|
14
|
-
color: #fff;
|
12
|
+
background: #ddd;
|
13
|
+
color: #888;
|
15
14
|
outline: none !important;
|
16
15
|
border: none;
|
17
|
-
|
16
|
+
cursor: pointer;
|
17
|
+
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
18
18
|
font-size: 15px;
|
19
19
|
border-radius: 5px;
|
20
20
|
line-height: 15px;
|
21
21
|
width: initial;
|
22
22
|
float: left;
|
23
|
+
padding: 5px 15px;
|
23
24
|
}
|
24
25
|
|
25
|
-
.scrivito_dialog .button_list button
|
26
|
-
background: #
|
26
|
+
.scrivito_dialog .button_list button.scrivito-multi-select-button:hover {
|
27
|
+
background: #ccc;
|
27
28
|
}
|
28
29
|
|
29
|
-
.scrivito_dialog .button_list button
|
30
|
-
box-shadow: 0 0px 5px rgba(0,0,0,0.
|
31
|
-
|
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;
|
32
34
|
}
|
@@ -1,34 +1,42 @@
|
|
1
|
-
.button_list {
|
1
|
+
.scrivito_dialog .button_list {
|
2
2
|
overflow: hidden;
|
3
3
|
position: relative;
|
4
4
|
}
|
5
5
|
|
6
|
-
.scrivito_dialog
|
6
|
+
.scrivito_dialog [data-scrivito-field-type="enum"].button_list {
|
7
|
+
background: transparent;
|
8
|
+
border: none;
|
9
|
+
padding: 0;
|
10
|
+
}
|
11
|
+
|
12
|
+
.scrivito_dialog .button_list .scrivito-toggle-button {
|
7
13
|
margin: 4px;
|
8
14
|
min-width: 28px;
|
9
|
-
|
10
|
-
|
11
|
-
color: #fff;
|
15
|
+
background: #ddd;
|
16
|
+
color: #888;
|
12
17
|
outline: none !important;
|
13
18
|
border: none;
|
14
19
|
border-radius: 5px;
|
15
|
-
|
20
|
+
cursor: pointer;
|
21
|
+
box-shadow: 0 0 5px rgba(0,0,0,0.1);
|
16
22
|
font-size: 15px;
|
17
23
|
line-height: 15px;
|
18
24
|
width: initial;
|
19
25
|
float: left;
|
26
|
+
padding: 5px 15px;
|
20
27
|
}
|
21
28
|
|
22
|
-
.scrivito_dialog .button_list
|
23
|
-
background: #
|
29
|
+
.scrivito_dialog .button_list .scrivito-toggle-button:hover {
|
30
|
+
background: #ccc;
|
24
31
|
}
|
25
32
|
|
26
|
-
.scrivito_dialog .button_list
|
27
|
-
box-shadow: 0 0px 5px rgba(0,0,0,0.
|
28
|
-
|
33
|
+
.scrivito_dialog .button_list .scrivito-toggle-button.active {
|
34
|
+
box-shadow: 0 0px 5px rgba(0,0,0,0.2);
|
35
|
+
color: white;
|
36
|
+
background: #658b51;
|
29
37
|
}
|
30
38
|
|
31
|
-
.scrivito_dialog .button_list
|
39
|
+
.scrivito_dialog .button_list .scrivito-toggle-button.color-select {
|
32
40
|
background: transparent;
|
33
41
|
transition: width 0.3s, height 0.3s, margin 0.3s;
|
34
42
|
position: relative;
|
@@ -36,7 +44,7 @@
|
|
36
44
|
margin: 7px 4px;
|
37
45
|
}
|
38
46
|
|
39
|
-
.scrivito_dialog .button_list
|
47
|
+
.scrivito_dialog .button_list .scrivito-toggle-button.color-select.active {
|
40
48
|
background: transparent;
|
41
49
|
height: 51px;
|
42
50
|
width: 51px;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
.scrivito_dialog .button_list
|
1
|
+
.scrivito_dialog .button_list .scrivito-toggle-button.color-select:before {
|
2
2
|
content: '';
|
3
3
|
background-color: #fff;
|
4
4
|
background-image:
|
@@ -14,7 +14,7 @@
|
|
14
14
|
bottom: 0;
|
15
15
|
}
|
16
16
|
|
17
|
-
.scrivito_dialog .button_list
|
17
|
+
.scrivito_dialog .button_list .scrivito-toggle-button.color-select:after {
|
18
18
|
content: '';
|
19
19
|
background-color: inherit;
|
20
20
|
position: absolute;
|
@@ -2,23 +2,19 @@ module ScrivitoAdvancedEditors
|
|
2
2
|
module ScrivitoAdvancedTagHelper
|
3
3
|
|
4
4
|
def scrivito_multi_select_button_editor(obj, attribute, list=nil)
|
5
|
-
|
5
|
+
if list
|
6
|
+
scrivito_tag(:div, obj, attribute, data: {multi_select_list: list})
|
7
|
+
else
|
8
|
+
scrivito_tag(:div, obj, attribute)
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
def scrivito_toggle_button_editor(obj, attribute, list=nil)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def scrivito_button_editor(obj, attribute, type, list=nil)
|
13
|
-
list = enum_list(obj, attribute) if list.nil?
|
14
|
-
|
15
|
-
buttons = if block_given?
|
16
|
-
list.map { |elem| yield(elem) }.join('').html_safe
|
13
|
+
if list
|
14
|
+
scrivito_tag(:div, obj, attribute, data: {toggle_list: list})
|
17
15
|
else
|
18
|
-
|
16
|
+
scrivito_tag(:div, obj, attribute)
|
19
17
|
end
|
20
|
-
|
21
|
-
content_tag :div, buttons, class: "button_list #{type}"
|
22
18
|
end
|
23
19
|
|
24
20
|
def scrivito_selectable_color_classes(class_name, attribute)
|
@@ -28,56 +24,13 @@ module ScrivitoAdvancedEditors
|
|
28
24
|
fallback_colors
|
29
25
|
end
|
30
26
|
|
31
|
-
colors
|
27
|
+
colors
|
32
28
|
end
|
33
29
|
|
34
30
|
private
|
35
31
|
|
36
32
|
def fallback_colors
|
37
|
-
['',
|
38
|
-
end
|
39
|
-
|
40
|
-
def fallback_toggle_button(obj, attribute, elem, active, type)
|
41
|
-
content = elem.is_a?(Hash) ? elem : content_hash(elem)
|
42
|
-
scrivito_tag(:button, obj, attribute, class: (content[:css] + " " + css_class(elem, active)), style: content[:style], data: data_attribute(content, type)) do
|
43
|
-
content[:caption]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def content_hash(elem)
|
48
|
-
{
|
49
|
-
content: elem,
|
50
|
-
caption: (elem.present? ? elem.to_s : 'default'),
|
51
|
-
style: '',
|
52
|
-
css: ''
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
|
-
def color_hash(color)
|
57
|
-
{
|
58
|
-
content: color,
|
59
|
-
caption: (color.present? ? color : 'default'),
|
60
|
-
style: '',
|
61
|
-
css: "color-select #{color == "" ? "default" : color} #{ color.present? ? '' : 'transparent_bg' }",
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
def data_attribute(elem, type)
|
66
|
-
{
|
67
|
-
editor: (type == 'toggle' ? 'scrivito-toggle-button' : 'scrivito-multi-select-button'),
|
68
|
-
content: elem[:content],
|
69
|
-
}
|
70
|
-
end
|
71
|
-
|
72
|
-
def enum_list(obj, attribute)
|
73
|
-
obj.attribute_definitions[attribute].values
|
74
|
-
end
|
75
|
-
|
76
|
-
def css_class(elem, active)
|
77
|
-
return '' if active.nil?
|
78
|
-
return active == elem[:content] ? 'active' : '' if elem.is_a? Hash
|
79
|
-
return active == elem.to_s ? 'active' : '' if (active.is_a?(String) || active.is_a?(Fixnum))
|
80
|
-
active.include?(elem) ? 'active' : ''
|
33
|
+
['', 'black', 'gray', 'light-gray', 'red', 'green', 'blue', 'yellow']
|
81
34
|
end
|
82
35
|
end
|
83
36
|
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.0.
|
4
|
+
version: 0.90.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-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,11 +75,9 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- LICENSE
|
77
77
|
- Rakefile
|
78
|
+
- app/assets/javascripts/scripts/color_picker.js
|
78
79
|
- app/assets/javascripts/scripts/create_obj.js
|
79
|
-
- app/assets/javascripts/scripts/jquery.caret.min.js
|
80
|
-
- app/assets/javascripts/scripts/jquery.tag-editor.min.js
|
81
80
|
- app/assets/javascripts/scripts/scrivito_dialog.js
|
82
|
-
- app/assets/javascripts/scripts/scrivito_list_editor.js
|
83
81
|
- app/assets/javascripts/scripts/scrivito_multi_select_button.js
|
84
82
|
- app/assets/javascripts/scripts/scrivito_tabs.js
|
85
83
|
- app/assets/javascripts/scripts/scrivito_textarea_editor.js
|
@@ -88,7 +86,6 @@ files:
|
|
88
86
|
- app/assets/stylesheets/scrivito_advanced_editors.css
|
89
87
|
- app/assets/stylesheets/scrivito_advanced_editors/color_picker.css.scss
|
90
88
|
- app/assets/stylesheets/scrivito_advanced_editors/create_obj.css
|
91
|
-
- app/assets/stylesheets/scrivito_advanced_editors/jquery.tag-editor.css
|
92
89
|
- app/assets/stylesheets/scrivito_advanced_editors/scrivito_dialog.css.scss
|
93
90
|
- app/assets/stylesheets/scrivito_advanced_editors/scrivito_mutli_select_button.css.scss
|
94
91
|
- app/assets/stylesheets/scrivito_advanced_editors/scrivito_tabs.css
|
@@ -96,7 +93,6 @@ files:
|
|
96
93
|
- app/assets/stylesheets/scrivito_advanced_editors/textarea_editor.css.scss
|
97
94
|
- app/assets/stylesheets/scrivito_advanced_editors/transparent_bg.css.scss
|
98
95
|
- app/helpers/scrivito_advanced_editors/scrivito_advanced_tag_helper.rb
|
99
|
-
- app/views/scrivito_advanced_editors/_color_picker.html.erb
|
100
96
|
- app/views/scrivito_advanced_editors/_create_obj.html.erb
|
101
97
|
- lib/scrivito_advanced_editors.rb
|
102
98
|
- lib/scrivito_advanced_editors/engine.rb
|
@@ -117,9 +113,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
113
|
version: '0'
|
118
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
115
|
requirements:
|
120
|
-
- - "
|
116
|
+
- - ">"
|
121
117
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
118
|
+
version: 1.3.1
|
123
119
|
requirements: []
|
124
120
|
rubyforge_project:
|
125
121
|
rubygems_version: 2.4.5
|
@@ -1,2 +0,0 @@
|
|
1
|
-
// http://code.accursoft.com/caret - 1.3.3
|
2
|
-
!function(e){e.fn.caret=function(e){var t=this[0],n="true"===t.contentEditable;if(0==arguments.length){if(window.getSelection){if(n){t.focus();var o=window.getSelection().getRangeAt(0),r=o.cloneRange();return r.selectNodeContents(t),r.setEnd(o.endContainer,o.endOffset),r.toString().length}return t.selectionStart}if(document.selection){if(t.focus(),n){var o=document.selection.createRange(),r=document.body.createTextRange();return r.moveToElementText(t),r.setEndPoint("EndToEnd",o),r.text.length}var e=0,c=t.createTextRange(),r=document.selection.createRange().duplicate(),a=r.getBookmark();for(c.moveToBookmark(a);0!==c.moveStart("character",-1);)e++;return e}return t.selectionStart?t.selectionStart:0}if(-1==e&&(e=this[n?"text":"val"]().length),window.getSelection)n?(t.focus(),window.getSelection().collapse(t.firstChild,e)):t.setSelectionRange(e,e);else if(document.body.createTextRange)if(n){var c=document.body.createTextRange();c.moveToElementText(t),c.moveStart("character",e),c.collapse(!0),c.select()}else{var c=t.createTextRange();c.move("character",e),c.select()}return n||t.focus(),e}}(jQuery);
|
@@ -1,3 +0,0 @@
|
|
1
|
-
// jQuery tagEditor v1.0.13
|
2
|
-
// https://github.com/Pixabay/jQuery-tagEditor
|
3
|
-
!function(t){t.fn.tagEditorInput=function(){var e=" ",i=t(this),a=parseInt(i.css("fontSize")),r=t("<span/>").css({position:"absolute",top:-9999,left:-9999,width:"auto",fontSize:i.css("fontSize"),fontFamily:i.css("fontFamily"),fontWeight:i.css("fontWeight"),letterSpacing:i.css("letterSpacing"),whiteSpace:"nowrap"}),l=function(){if(e!==(e=i.val())){r.html(e.replace(/&/g,"&").replace(/\s/g," ").replace(/</g,"<").replace(/>/g,">"));var t=r.width()+a;20>t&&(t=20),t!=i.width()&&i.width(t)}};return r.insertAfter(i),i.bind("keyup keydown focus",l)},t.fn.tagEditor=function(e,a,r){function l(e){if(8==e.which||46==e.which||e.ctrlKey&&88==e.which){try{var a=getSelection(),r=t(a.getRangeAt(0).commonAncestorContainer)}catch(e){r=0}if(r&&r.hasClass("tag-editor")){var l=[],n=a.toString().split(r.prev().data("options").dregex);for(i=0;i<n.length;i++){var o=t.trim(n[i]);o&&l.push(o)}t(".tag-editor-tag",r).each(function(){~t.inArray(t(this).html(),l)&&t(this).closest("li").find(".tag-editor-delete").click()})}}}var n,o=t.extend({},t.fn.tagEditor.defaults,e),c=this;if(o.dregex=new RegExp("["+o.delimiter.replace("-","-")+"]","g"),"string"==typeof e){var s=[];return c.each(function(){var i=t(this),l=i.data("options"),n=i.next(".tag-editor");"getTags"==e?s.push({field:i[0],editor:n,tags:n.data("tags")}):"addTag"==e?(t('<li><div class="tag-editor-spacer"> '+l.delimiter[0]+'</div><div class="tag-editor-tag"></div><div class="tag-editor-delete"><i></i></div></li>').appendTo(n).find(".tag-editor-tag").html('<input type="text" maxlength="'+l.maxLength+'">').addClass("active").find("input").val(a).blur(),r?t(".placeholder",n).remove():n.click()):"removeTag"==e?(t(".tag-editor-tag",n).filter(function(){return t(this).html()==a}).closest("li").find(".tag-editor-delete").click(),r||n.click()):"destroy"==e&&i.removeClass("tag-editor-hidden-src").removeData("options").off("focus.tag-editor").next(".tag-editor").remove()}),"getTags"==e?s:this}return window.getSelection&&t(document).off("keydown.tag-editor").on("keydown.tag-editor",l),c.each(function(){function e(){!o.placeholder||c.length||t(".deleted, .placeholder, input",s).length||s.append('<li class="placeholder"><div>'+o.placeholder+"</div></li>")}function a(i){var a=c.toString();c=t(".tag-editor-tag:not(.deleted)",s).map(function(e,i){var a=t.trim(t(this).hasClass("active")?t(this).find("input").val():t(i).text());return a?a:void 0}).get(),s.data("tags",c),l.val(c.join(o.delimiter[0])),i||a!=c.toString()&&o.onChange(l,s,c),e()}function r(e){var r=e.closest("li"),n=e.val().replace(/ +/," ").split(o.dregex),d=e.data("old_tag"),g=c.slice(0);for(i=0;i<n.length;i++)u=t.trim(n[i]).slice(0,o.maxLength),u&&(o.forceLowercase&&(u=u.toLowerCase()),u=o.beforeTagSave(l,s,g,d,u)||u,~t.inArray(u,g)&&t(".tag-editor-tag",s).each(function(){t(this).html()==u&&t(this).closest("li").remove()}),g.push(u),r.before('<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag">'+u+'</div><div class="tag-editor-delete"><i></i></div></li>'));e.attr("maxlength",o.maxLength).removeData("old_tag").val("").focus(),a()}var l=t(this),c=[],s=t("<ul "+(o.clickDelete?'oncontextmenu="return false;" ':"")+'class="tag-editor"></ul>').insertAfter(l);l.addClass("tag-editor-hidden-src").data("options",o).on("focus.tag-editor",function(){s.click()}),s.append('<li style="width:1px"> </li>');var d='<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag"></div><div class="tag-editor-delete"><i></i></div></li>';s.click(function(e,i){var a,r,l=99999;if(!window.getSelection||""==getSelection())return n=!0,t("input:focus",s).blur(),n?(n=!0,t(".placeholder",s).remove(),i&&i.length?r="before":t(".tag-editor-tag",s).each(function(){var n=t(this),o=n.offset(),c=o.left,s=o.top;e.pageY>=s&&e.pageY<=s+n.height()&&(e.pageX<c?(r="before",a=c-e.pageX):(r="after",a=e.pageX-c-n.width()),l>a&&(l=a,i=n))}),"before"==r?t(d).insertBefore(i.closest("li")).find(".tag-editor-tag").click():"after"==r?t(d).insertAfter(i.closest("li")).find(".tag-editor-tag").click():t(d).appendTo(s).find(".tag-editor-tag").click(),!1):!1}),s.on("click",".tag-editor-delete",function(){if(t(this).prev().hasClass("active"))return t(this).closest("li").find("input").caret(-1),!1;var i=t(this).closest("li"),r=i.find(".tag-editor-tag");return o.beforeTagDelete(l,s,c,r.html())===!1?!1:(r.addClass("deleted").animate({width:0},175,function(){i.remove(),e()}),a(),!1)}),o.clickDelete&&s.on("mousedown",".tag-editor-tag",function(i){if(i.ctrlKey||i.which>1){var r=t(this).closest("li"),n=r.find(".tag-editor-tag");return o.beforeTagDelete(l,s,c,n.html())===!1?!1:(n.addClass("deleted").animate({width:0},175,function(){r.remove(),e()}),a(),!1)}}),s.on("click",".tag-editor-tag",function(e){if(o.clickDelete&&(e.ctrlKey||e.which>1))return!1;if(!t(this).hasClass("active")){var i=t(this).html(),a=Math.abs((t(this).offset().left-e.pageX)/t(this).width()),r=parseInt(i.length*a),l=t(this).html('<input type="text" maxlength="'+o.maxLength+'" value="'+i+'">').addClass("active").find("input");if(l.data("old_tag",i).tagEditorInput().focus().caret(r),o.autocomplete){var n=t.extend({},o.autocomplete),c="select"in n?o.autocomplete.select:"";n.select=function(){c&&c(),setTimeout(function(){t(".active",s).find("input").focus()},20)},l.autocomplete(n)}}return!1}),s.on("blur","input",function(){var i=t(this),d=i.data("old_tag"),g=t.trim(i.val().replace(/ +/," ").replace(o.dregex,o.delimiter[0]));if(g){if(g.indexOf(o.delimiter[0])>=0)return void r(i);g!=d&&(o.forceLowercase&&(g=g.toLowerCase()),g=o.beforeTagSave(l,s,c,d,g)||g,t(".tag-editor-tag:not(.active)",s).each(function(){t(this).html()==g&&t(this).closest("li").remove()}))}else{if(d&&o.beforeTagDelete(l,s,c,d)===!1)return i.val(d).focus(),n=!1,void a();try{i.closest("li").remove()}catch(f){}d&&a()}i.parent().html(g).removeClass("active"),g!=d&&a(),e()});var g;s.on("paste","input",function(){t(this).removeAttr("maxlength"),g=t(this),setTimeout(function(){r(g)},30)});var f;s.on("keypress","input",function(e){o.delimiter.indexOf(String.fromCharCode(e.which))>=0&&(f=t(this),setTimeout(function(){r(f)},20))}),s.on("keydown","input",function(e){var i=t(this);if((37==e.which||!o.autocomplete&&38==e.which)&&!i.caret()||8==e.which&&!i.val()){var a=i.closest("li").prev("li").find(".tag-editor-tag");return a.length?a.click().find("input").caret(-1):i.val()&&t(d).insertBefore(i.closest("li")).find(".tag-editor-tag").click(),!1}if((39==e.which||!o.autocomplete&&40==e.which)&&i.caret()==i.val().length){var r=i.closest("li").next("li").find(".tag-editor-tag");return r.length?r.click().find("input").caret(0):i.val()&&s.click(),!1}if(9==e.which){if(e.shiftKey){var a=i.closest("li").prev("li").find(".tag-editor-tag");if(a.length)a.click().find("input").caret(0);else{if(!i.val())return l.attr("disabled","disabled"),void setTimeout(function(){l.removeAttr("disabled")},30);t(d).insertBefore(i.closest("li")).find(".tag-editor-tag").click()}return!1}var r=i.closest("li").next("li").find(".tag-editor-tag");if(r.length)r.click().find("input").caret(0);else{if(!i.val())return;s.click()}return!1}if(!(46!=e.which||t.trim(i.val())&&i.caret()!=i.val().length)){var r=i.closest("li").next("li").find(".tag-editor-tag");return r.length?r.click().find("input").caret(0):i.val()&&s.click(),!1}if(13==e.which)return s.trigger("click",[i.closest("li").next("li").find(".tag-editor-tag")]),!1;if(36!=e.which||i.caret()){if(35==e.which&&i.caret()==i.val().length)s.find(".tag-editor-tag").last().click();else if(27==e.which)return i.val(i.data("old_tag")?i.data("old_tag"):"").blur(),!1}else s.find(".tag-editor-tag").first().click()});var h=o.initialTags.length?o.initialTags:l.val().split(o.dregex);for(i=0;i<h.length;i++){var u=t.trim(h[i].replace(/ +/," "));u&&(o.forceLowercase&&(u=u.toLowerCase()),c.push(u),s.append('<li><div class="tag-editor-spacer"> '+o.delimiter[0]+'</div><div class="tag-editor-tag">'+u+'</div><div class="tag-editor-delete"><i></i></div></li>'))}a(!0),o.sortable&&t.fn.sortable&&s.sortable({distance:5,cancel:".tag-editor-spacer, input",helper:"clone",update:function(){a()}})})},t.fn.tagEditor.defaults={initialTags:[],maxLength:50,delimiter:",;",placeholder:"",forceLowercase:!0,clickDelete:!1,sortable:!0,autocomplete:null,onChange:function(){},beforeTagSave:function(){},beforeTagDelete:function(){}}}(jQuery);
|
@@ -1,42 +0,0 @@
|
|
1
|
-
(function($, App) {
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
$(function() {
|
5
|
-
App.ScrivitoListEditor = {
|
6
|
-
// set selector for Editor
|
7
|
-
selector: "[data-editor='scrivito-list-editor']",
|
8
|
-
|
9
|
-
// Function that will be called on scrivito load
|
10
|
-
initFunction: function() { },
|
11
|
-
|
12
|
-
// set function triggert on click
|
13
|
-
clickFunction: function(scrivito_tag, text, delimiter) {
|
14
|
-
var delimiter = $(scrivito_tag).data('delimiter') || '|';
|
15
|
-
var content = scrivito_tag.data('scrivito-field-type') == 'string' ? text.join(delimiter) : text;
|
16
|
-
return scrivito_tag.scrivito('save', content);
|
17
|
-
},
|
18
|
-
};
|
19
|
-
|
20
|
-
// Set click event
|
21
|
-
scrivito.on('content', function() {
|
22
|
-
if(scrivito.in_editable_view()) {
|
23
|
-
var elems = $(ScrivitoListEditor.selector);
|
24
|
-
$.each(elems, function(index, elem) {
|
25
|
-
var delimiter = $(elem).data('delimiter') || '|';
|
26
|
-
var content = $(elem).data('scrivito-field-type') == 'string' ? $(elem).html().split(delimiter) : $(elem).scrivito('content');
|
27
|
-
$(elem).tagEditor({
|
28
|
-
initialTags: content,
|
29
|
-
delimiter: delimiter,
|
30
|
-
forceLowercase: false,
|
31
|
-
maxLength: 1000,
|
32
|
-
placeholder: 'Enter new value ...',
|
33
|
-
onChange: function (field, editor, tags) {
|
34
|
-
ScrivitoListEditor.clickFunction(field, tags);
|
35
|
-
}
|
36
|
-
});
|
37
|
-
});
|
38
|
-
}
|
39
|
-
});
|
40
|
-
});
|
41
|
-
|
42
|
-
})(jQuery, this);
|
@@ -1,76 +0,0 @@
|
|
1
|
-
|
2
|
-
/* surrounding tag container */
|
3
|
-
.tag-editor {
|
4
|
-
list-style-type: none;
|
5
|
-
padding: 5px 0;
|
6
|
-
margin: 0 3px 3px;
|
7
|
-
overflow: hidden;
|
8
|
-
cursor: text;
|
9
|
-
font: normal 14px sans-serif;
|
10
|
-
color: #555;
|
11
|
-
background: #fff;
|
12
|
-
box-shadow: 0 0 3px rgba(0,0,0,0.5);
|
13
|
-
border-radius: 5px;
|
14
|
-
}
|
15
|
-
|
16
|
-
/* core styles usually need no change */
|
17
|
-
.tag-editor li { display: block; float: left; overflow: hidden; margin: 3px 0; line-height: 1.5; }
|
18
|
-
.tag-editor div { float: left; padding: 0 4px; }
|
19
|
-
.tag-editor .placeholder { padding: 3px 8px; color: #bbb; }
|
20
|
-
.tag-editor .tag-editor-spacer { padding: 0; width: 8px; overflow: hidden; color: transparent; background: none; }
|
21
|
-
.tag-editor input {
|
22
|
-
vertical-align: inherit; border: 0; outline: none; padding: 0; margin: 0; cursor: text;
|
23
|
-
font-family: inherit; font-weight: inherit; font-size: inherit; font-style: inherit;
|
24
|
-
box-shadow: none; background: none;
|
25
|
-
}
|
26
|
-
/* hide original input field or textarea visually to allow tab navigation */
|
27
|
-
.tag-editor-hidden-src { position: absolute !important; left: -99999px; }
|
28
|
-
/* hide IE10 "clear field" X */
|
29
|
-
.tag-editor ::-ms-clear { display: none; }
|
30
|
-
|
31
|
-
/* tag style */
|
32
|
-
.tag-editor .tag-editor-tag {
|
33
|
-
padding: 3px 5px;
|
34
|
-
color: #fff;
|
35
|
-
background: #444;
|
36
|
-
white-space: nowrap;
|
37
|
-
overflow: hidden;
|
38
|
-
cursor: pointer;
|
39
|
-
border-radius: 2px 0 0 2px;
|
40
|
-
}
|
41
|
-
|
42
|
-
/* delete icon */
|
43
|
-
.tag-editor .tag-editor-delete {
|
44
|
-
background: #444;
|
45
|
-
color: #fff;
|
46
|
-
cursor: pointer;
|
47
|
-
padding: 3px 0;
|
48
|
-
border-radius: 0 2px 2px 0; }
|
49
|
-
.tag-editor .tag-editor-delete i {
|
50
|
-
display: inline-block;
|
51
|
-
width: 14px;
|
52
|
-
height: 14px;
|
53
|
-
vertical-align: middle;
|
54
|
-
position: relative;
|
55
|
-
top: -1px;
|
56
|
-
font: normal normal normal 14px/1 FontAwesome;
|
57
|
-
}
|
58
|
-
.tag-editor .tag-editor-delete i:before {
|
59
|
-
content: "\f00d";
|
60
|
-
}
|
61
|
-
.tag-editor .tag-editor-delete:hover i { background-position: 0 -14px; }
|
62
|
-
.tag-editor .tag-editor-tag.active+.tag-editor-delete,
|
63
|
-
.tag-editor .tag-editor-tag.active+.tag-editor-delete i { background: none; cursor: text; }
|
64
|
-
|
65
|
-
.tag-editor .tag-editor-tag.active { background: #eee; color: #000; }
|
66
|
-
|
67
|
-
/* jQuery UI autocomplete - code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css */
|
68
|
-
.ui-autocomplete { position: absolute; top: 0; left: 0; cursor: default; font-size: 14px; }
|
69
|
-
.ui-front { z-index: 9999; }
|
70
|
-
.ui-menu { list-style: none; padding: 1px; margin: 0; display: block; outline: none; }
|
71
|
-
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.4; min-height: 0; /* support: IE7 */ }
|
72
|
-
.ui-widget-content { border: 1px solid #bbb; background: #fff; color: #555; }
|
73
|
-
.ui-widget-content a { color: #46799b; }
|
74
|
-
.ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus,
|
75
|
-
.ui-widget-header .ui-state-focus { background: #e0eaf1; }
|
76
|
-
.ui-helper-hidden-accessible { display: none; }
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= scrivito_toggle_button_editor(widget, attribute, scrivito_selectable_color_classes(widget.class.to_s, attribute)) %>
|