scrivito_advanced_editors 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +4 -0
- data/Rakefile +22 -0
- data/app/assets/javascripts/scrivito_advanced_editors/jquery.caret.min.js +2 -0
- data/app/assets/javascripts/scrivito_advanced_editors/jquery.tag-editor.min.js +3 -0
- data/app/assets/javascripts/scrivito_advanced_editors/scripts.js +2 -0
- data/app/assets/javascripts/scrivito_advanced_editors/scrivito_list_editor.js +41 -0
- data/app/assets/javascripts/scrivito_advanced_editors/scrivito_tabs.js +21 -0
- data/app/assets/javascripts/scrivito_advanced_editors/scrivito_toggle_button.js +34 -0
- data/app/assets/stylesheets/scrivito_advanced_editors/jquery.tag-editor.css +75 -0
- data/app/assets/stylesheets/scrivito_advanced_editors/scrivito_tabs.css +38 -0
- data/app/assets/stylesheets/scrivito_advanced_editors/scrivito_toggle_button.css +20 -0
- data/app/assets/stylesheets/scrivito_advanced_editors/styles.css +4 -0
- data/app/helpers/scrivito_advanced_editors/scrivito_advanced_tag_helper.rb +37 -0
- data/lib/scrivito_advanced_editors.rb +4 -0
- data/lib/scrivito_advanced_editors/engine.rb +9 -0
- data/lib/scrivito_advanced_editors/version.rb +3 -0
- data/lib/tasks/scrivito_advanced_editors_tasks.rake +4 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6e76149b824e06f476ffa18e9a7fa3440543dc3e
|
4
|
+
data.tar.gz: 4f06fb39e7609a6d38769c2874c2a53995b32320
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e3858d3bcaa3b6b5a9ca83c199ec4f7aeb037e5fcb29099529a95b7c9dfb61c648190dc39580305a927554064f03aa3c39a3765ba2bb1f1c6c79bc90d33e9cb
|
7
|
+
data.tar.gz: ed22e3a9013d87ac9930dbbac92bf295161bd02171e4bdc90bc7ee694f9f8fd5b2f76485aaac5ec7a2ddb1f9adddf104af8c70bb613a00adff3cb7e4b160f0a8
|
data/LICENSE
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'ScrivitoAdvancedEditors'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
Bundler::GemHelper.install_tasks
|
22
|
+
|
@@ -0,0 +1,2 @@
|
|
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);
|
@@ -0,0 +1,3 @@
|
|
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);
|
@@ -0,0 +1,41 @@
|
|
1
|
+
(function($, App) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
$(function() {
|
5
|
+
|
6
|
+
App.ScrivitoListEditor = {
|
7
|
+
// set selector for Editor
|
8
|
+
selector: "[data-editor='scrivito-list-editor']",
|
9
|
+
|
10
|
+
// Function that will be called on scrivito load
|
11
|
+
initFunction: function() { },
|
12
|
+
|
13
|
+
// set function triggert on click
|
14
|
+
clickFunction: function(scrivito_tag, text) {
|
15
|
+
return scrivito_tag.scrivito('save', text.join(','));
|
16
|
+
},
|
17
|
+
};
|
18
|
+
|
19
|
+
// Set click event
|
20
|
+
scrivito.on('content', function() {
|
21
|
+
if(scrivito.in_editable_view()) {
|
22
|
+
var elems = $(ScrivitoListEditor.selector);
|
23
|
+
|
24
|
+
$.each(elems, function(index, elem) {
|
25
|
+
var delimiter = $(elem).data('delimiter') || '|';
|
26
|
+
$(elem).tagEditor({
|
27
|
+
initialTags: $(elem).html().split(delimiter),
|
28
|
+
delimiter: delimiter,
|
29
|
+
forceLowercase: false,
|
30
|
+
maxLength: 1000,
|
31
|
+
placeholder: 'Enter new value ...',
|
32
|
+
onChange: function (field, editor, tags) {
|
33
|
+
ScrivitoListEditor.clickFunction(field, tags);
|
34
|
+
}
|
35
|
+
});
|
36
|
+
});
|
37
|
+
}
|
38
|
+
});
|
39
|
+
});
|
40
|
+
|
41
|
+
})(jQuery, this);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
(function($, App) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
$(function() {
|
5
|
+
scrivito.on('content', function() {
|
6
|
+
var tab_list = $('.tab-list');
|
7
|
+
var active = tab_list.find('.active');
|
8
|
+
|
9
|
+
$(active.data('panel-target')).addClass('active');
|
10
|
+
|
11
|
+
tab_list.on('click', 'li', function() {
|
12
|
+
var target = $(this).data('panel-target');
|
13
|
+
$(target).siblings('.active').removeClass('active');
|
14
|
+
$(this).siblings('.active').removeClass('active');
|
15
|
+
$(target).addClass('active');
|
16
|
+
$(this).addClass('active');
|
17
|
+
});
|
18
|
+
});
|
19
|
+
});
|
20
|
+
|
21
|
+
})(jQuery, this);
|
@@ -0,0 +1,34 @@
|
|
1
|
+
(function($, App) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
$(function() {
|
5
|
+
|
6
|
+
App.ScrivitoToggleButton = {
|
7
|
+
// set selector for Editor
|
8
|
+
selector: "[data-editor='scrivito-toggle-button']",
|
9
|
+
|
10
|
+
// Function that will be called on scrivito load
|
11
|
+
initFunction: function() {},
|
12
|
+
|
13
|
+
// set function triggert on click
|
14
|
+
clickFunction: function(scrivito_tag) {
|
15
|
+
var text = scrivito_tag.data('content');
|
16
|
+
|
17
|
+
scrivito_tag.addClass('active');
|
18
|
+
scrivito_tag.siblings().removeClass('active');
|
19
|
+
|
20
|
+
return scrivito_tag.scrivito('save', text);
|
21
|
+
},
|
22
|
+
};
|
23
|
+
|
24
|
+
// Set click event
|
25
|
+
scrivito.on('load', function() {
|
26
|
+
if(scrivito.in_editable_view()) {
|
27
|
+
return $('body').on('click', ScrivitoToggleButton.selector, function(event) {
|
28
|
+
ScrivitoToggleButton.clickFunction($(event.target));
|
29
|
+
});
|
30
|
+
}
|
31
|
+
});
|
32
|
+
});
|
33
|
+
|
34
|
+
})(jQuery, this);
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
/* surrounding tag container */
|
3
|
+
.tag-editor {
|
4
|
+
list-style-type: none;
|
5
|
+
padding: 0 5px;
|
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: 0 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: #46799b;
|
35
|
+
background: #e0eaf1;
|
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: #e0eaf1;
|
45
|
+
cursor: pointer;
|
46
|
+
padding: 3px 0;
|
47
|
+
border-radius: 0 2px 2px 0; }
|
48
|
+
.tag-editor .tag-editor-delete i {
|
49
|
+
display: inline-block;
|
50
|
+
width: 14px;
|
51
|
+
height: 14px;
|
52
|
+
vertical-align: middle;
|
53
|
+
position: relative;
|
54
|
+
top: -1px;
|
55
|
+
font: normal normal normal 14px/1 FontAwesome;
|
56
|
+
}
|
57
|
+
.tag-editor .tag-editor-delete i:before {
|
58
|
+
content: "\f00d";
|
59
|
+
}
|
60
|
+
.tag-editor .tag-editor-delete:hover i { background-position: 0 -14px; }
|
61
|
+
.tag-editor .tag-editor-tag.active+.tag-editor-delete,
|
62
|
+
.tag-editor .tag-editor-tag.active+.tag-editor-delete i { background: none; cursor: text; }
|
63
|
+
|
64
|
+
.tag-editor .tag-editor-tag.active { background: none !important; }
|
65
|
+
|
66
|
+
/* jQuery UI autocomplete - code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css */
|
67
|
+
.ui-autocomplete { position: absolute; top: 0; left: 0; cursor: default; font-size: 14px; }
|
68
|
+
.ui-front { z-index: 9999; }
|
69
|
+
.ui-menu { list-style: none; padding: 1px; margin: 0; display: block; outline: none; }
|
70
|
+
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.4; min-height: 0; /* support: IE7 */ }
|
71
|
+
.ui-widget-content { border: 1px solid #bbb; background: #fff; color: #555; }
|
72
|
+
.ui-widget-content a { color: #46799b; }
|
73
|
+
.ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus,
|
74
|
+
.ui-widget-header .ui-state-focus { background: #e0eaf1; }
|
75
|
+
.ui-helper-hidden-accessible { display: none; }
|
@@ -0,0 +1,38 @@
|
|
1
|
+
.tab-list {
|
2
|
+
overflow: hidden;
|
3
|
+
list-style: none;
|
4
|
+
margin-top: 0;
|
5
|
+
padding: 0;
|
6
|
+
}
|
7
|
+
|
8
|
+
.tab-list li {
|
9
|
+
float: left;
|
10
|
+
padding: 5px 10px;
|
11
|
+
cursor: pointer;
|
12
|
+
background: #ddd;
|
13
|
+
}
|
14
|
+
|
15
|
+
.tab-list li:hover {
|
16
|
+
background: #bbb;
|
17
|
+
}
|
18
|
+
|
19
|
+
.tab-list li.active {
|
20
|
+
background: #444;
|
21
|
+
color: #eee;
|
22
|
+
}
|
23
|
+
|
24
|
+
.tab-list li.active:hover {
|
25
|
+
background: #222;
|
26
|
+
}
|
27
|
+
|
28
|
+
.tab-panels {
|
29
|
+
overflow: hidden;
|
30
|
+
}
|
31
|
+
|
32
|
+
.tab-panels .tab-panel {
|
33
|
+
display: none;
|
34
|
+
}
|
35
|
+
|
36
|
+
.tab-panels .tab-panel.active {
|
37
|
+
display: block;
|
38
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
button[data-editor="scrivito-toggle-button"] {
|
2
|
+
margin: 4px;
|
3
|
+
min-width: 28px;
|
4
|
+
text-shadow: 0 0 2px #222;
|
5
|
+
background: #444;
|
6
|
+
color: #fff;
|
7
|
+
outline: none !important;
|
8
|
+
border: none;
|
9
|
+
border-radius: 5px;
|
10
|
+
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
|
11
|
+
}
|
12
|
+
|
13
|
+
button[data-editor='scrivito-toggle-button']:hover {
|
14
|
+
background: #888;
|
15
|
+
}
|
16
|
+
|
17
|
+
button[data-editor='scrivito-toggle-button'].active {
|
18
|
+
box-shadow: 0 0px 5px rgba(0,0,0,0.4) inset;
|
19
|
+
background: #888;
|
20
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ScrivitoAdvancedEditors
|
2
|
+
module ScrivitoAdvancedTagHelper
|
3
|
+
|
4
|
+
def scrivito_toggle_button_editor(obj, attribute, list=nil)
|
5
|
+
list = enum_list(obj, attribute) if list.nil?
|
6
|
+
buttons = if block_given?
|
7
|
+
list.map { |elem| yield(elem) }.join('').html_safe
|
8
|
+
else
|
9
|
+
list.map { |elem| fallback_toggle_button(obj, attribute, elem, obj.send(attribute)) }.join('').html_safe
|
10
|
+
end
|
11
|
+
|
12
|
+
content_tag :div, buttons, class: 'button_list'
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def fallback_toggle_button(obj, attribute, elem, active)
|
17
|
+
scrivito_tag(:button, obj, attribute, class: css_class(elem, active), data: data_attribute(elem)) do
|
18
|
+
elem.to_s
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def data_attribute(elem)
|
23
|
+
{
|
24
|
+
editor: 'scrivito-toggle-button',
|
25
|
+
content: elem,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def enum_list(obj, attribute)
|
30
|
+
Scrivito::ObjClass.find(obj.class.to_s).attributes[attribute].values
|
31
|
+
end
|
32
|
+
|
33
|
+
def css_class(elem, active)
|
34
|
+
elem.to_s == active ? 'active' : ''
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scrivito_advanced_editors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scrivito
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: scrivito_sdk
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: font-awesome-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Provides some advanced Editors and details view extensions for scrivito
|
70
|
+
email:
|
71
|
+
- support@scrivito.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- LICENSE
|
77
|
+
- Rakefile
|
78
|
+
- app/assets/javascripts/scrivito_advanced_editors/jquery.caret.min.js
|
79
|
+
- app/assets/javascripts/scrivito_advanced_editors/jquery.tag-editor.min.js
|
80
|
+
- app/assets/javascripts/scrivito_advanced_editors/scripts.js
|
81
|
+
- app/assets/javascripts/scrivito_advanced_editors/scrivito_list_editor.js
|
82
|
+
- app/assets/javascripts/scrivito_advanced_editors/scrivito_tabs.js
|
83
|
+
- app/assets/javascripts/scrivito_advanced_editors/scrivito_toggle_button.js
|
84
|
+
- app/assets/stylesheets/scrivito_advanced_editors/jquery.tag-editor.css
|
85
|
+
- app/assets/stylesheets/scrivito_advanced_editors/scrivito_tabs.css
|
86
|
+
- app/assets/stylesheets/scrivito_advanced_editors/scrivito_toggle_button.css
|
87
|
+
- app/assets/stylesheets/scrivito_advanced_editors/styles.css
|
88
|
+
- app/helpers/scrivito_advanced_editors/scrivito_advanced_tag_helper.rb
|
89
|
+
- lib/scrivito_advanced_editors.rb
|
90
|
+
- lib/scrivito_advanced_editors/engine.rb
|
91
|
+
- lib/scrivito_advanced_editors/version.rb
|
92
|
+
- lib/tasks/scrivito_advanced_editors_tasks.rake
|
93
|
+
homepage: https://www.scrivito.com
|
94
|
+
licenses:
|
95
|
+
- LGPL-3.0
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.2.2
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Advanced Editors and details view extensions for scrivito
|
117
|
+
test_files: []
|