godmin-redactor 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +27 -7
- data/app/assets/javascripts/godmin-redactor/index.js +5 -2
- data/lib/godmin/redactor/helper.rb +5 -2
- data/lib/godmin/redactor/version.rb +1 -1
- data/vendor/assets/javascripts/langs/sv.js +74 -0
- data/vendor/assets/javascripts/plugins/fullscreen.js +123 -0
- data/vendor/assets/javascripts/plugins/table.js +337 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1eff63e39537b1cd7977ca3bce56050cc6cb82c
|
4
|
+
data.tar.gz: b31dd14a36f9323828e1e9be1259e7124f129e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06a59abc01ac8b337fb86cabdc84ba552342311f6c4d80deb08620e7a44ab654a58b1318ed72534ec27f78d3351aa6b1e23dedbeba3ae186d78eff9eedc74684
|
7
|
+
data.tar.gz: 3102e537f33bf7e7c23871de1c1c84cf41a9a10ed4c0902f844ca53fd2c4e9fbd4bb013958c0f8c726b5f8105b3bb983654bb607e0dc3c748c96205209ec7898
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
### 0.1.1 - 2015-03-12
|
4
|
+
Features
|
5
|
+
- Adds possibility to pass Redactor options
|
6
|
+
- Bundles Swedish [translations](http://imperavi.com/redactor/docs/languages/)
|
7
|
+
- Bundles [Table plugin](http://imperavi.com/redactor/plugins/table/)
|
8
|
+
- Bundles [Fullscreen plugin](http://imperavi.com/redactor/plugins/fullscreen/)
|
9
|
+
|
10
|
+
### 0.1.0 - 2015-02-23
|
11
|
+
Initial release
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](http://img.shields.io/gem/v/godmin-redactor.svg)](https://rubygems.org/gems/godmin-redactor)
|
4
4
|
|
5
|
-
Godmin Redactor is a redactor component for [Godmin](https://github.com/varvet/godmin) that adds an `f.redactor_area` to forms.
|
5
|
+
Godmin Redactor is a [Redactor](http://imperavi.com/redactor/) component for [Godmin](https://github.com/varvet/godmin) that adds an `f.redactor_area` to forms.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -16,21 +16,41 @@ Or to the admin engine's `gemspec`:
|
|
16
16
|
s.add_dependency "godmin-redactor", "~> 0.1.0"
|
17
17
|
```
|
18
18
|
|
19
|
+
Require it in your `app/assets/javascripts/application.js`, just after the `require godmin` line:
|
20
|
+
|
21
|
+
```js
|
22
|
+
//= require godmin
|
23
|
+
//= require godmin-redactor
|
24
|
+
```
|
25
|
+
|
26
|
+
And finally, do the same with your `app/assets/stylesheets/application.css`:
|
27
|
+
```scss
|
28
|
+
*= require godmin
|
29
|
+
*= require godmin-redactor
|
30
|
+
```
|
31
|
+
|
19
32
|
## Usage
|
20
33
|
|
21
|
-
Use the redactor
|
34
|
+
Use the redactor area in your form like so:
|
22
35
|
|
23
36
|
```erb
|
24
|
-
<%= form_for
|
25
|
-
<%= f.
|
26
|
-
<%= f.redactor_area :body
|
37
|
+
<%= form_for @resource do |f| %>
|
38
|
+
<%= f.text_field :title %>
|
39
|
+
<%= f.redactor_area :body, {
|
40
|
+
buttons: ['formatting', 'bold', 'italic'],
|
41
|
+
plugins: ['fullscreen']
|
42
|
+
} %>
|
43
|
+
<%= f.submit %>
|
27
44
|
<% end %>
|
28
45
|
```
|
29
46
|
|
30
47
|
## Contributors
|
31
48
|
|
32
|
-
https://github.com/varvet/godmin-
|
49
|
+
https://github.com/varvet/godmin-redactor/graphs/contributors
|
33
50
|
|
34
51
|
## License
|
35
52
|
|
36
|
-
|
53
|
+
Godmin Redactor is licensed under the MIT license. See the separate MIT-LICENSE file.
|
54
|
+
|
55
|
+
[Redactor](http://imperavi.com/redactor/) has [3 different licenses](http://imperavi.com/redactor/download/).
|
56
|
+
For details please see [License Agreement](http://imperavi.com/redactor/license/).
|
@@ -11,6 +11,9 @@
|
|
11
11
|
// about supported directives.
|
12
12
|
//
|
13
13
|
//= require redactor
|
14
|
+
//= require langs/sv
|
15
|
+
//= require plugins/fullscreen
|
16
|
+
//= require plugins/table
|
14
17
|
|
15
18
|
window.Godmin = window.Godmin || {};
|
16
19
|
|
@@ -23,8 +26,8 @@ Godmin.Redactor = (function() {
|
|
23
26
|
initializeRedactor($('[data-behavior~=redactor]'));
|
24
27
|
}
|
25
28
|
|
26
|
-
function initializeRedactor($el
|
27
|
-
$el.redactor(options);
|
29
|
+
function initializeRedactor($el) {
|
30
|
+
$el.redactor($el.data("options"));
|
28
31
|
}
|
29
32
|
|
30
33
|
return {
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module Godmin
|
2
2
|
module Redactor
|
3
3
|
module Helper
|
4
|
-
def redactor_area(attribute, options = {})
|
5
|
-
text_area(attribute,
|
4
|
+
def redactor_area(attribute, options = {}, html_options = {})
|
5
|
+
text_area(attribute, html_options.deep_merge(data: {
|
6
|
+
behavior: "redactor",
|
7
|
+
options: options
|
8
|
+
}))
|
6
9
|
end
|
7
10
|
end
|
8
11
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
(function ($) {
|
2
|
+
$.Redactor.opts.langs['sv'] = {
|
3
|
+
_delete: 'Ta bort',
|
4
|
+
add_head: 'Lägg till tabellhuvud',
|
5
|
+
align_center: 'Centerjustera',
|
6
|
+
align_justify: 'Marginaljustering',
|
7
|
+
align_left: 'Vänsterjustera',
|
8
|
+
align_right: 'Högerjustera',
|
9
|
+
alignment: 'Justering',
|
10
|
+
anchor: 'Ankare',
|
11
|
+
backcolor: 'Bakgrundsfärg',
|
12
|
+
bold: 'Fet',
|
13
|
+
cancel: 'Ångra',
|
14
|
+
center: 'Center',
|
15
|
+
choose: 'Välj',
|
16
|
+
code: 'Kod',
|
17
|
+
columns: 'Kolumner',
|
18
|
+
delete_column: 'Ta bort kolumn',
|
19
|
+
delete_head: 'Ta bort tabellhuvud',
|
20
|
+
delete_row: 'Ta bort rad',
|
21
|
+
delete_table: 'Ta bort tabell',
|
22
|
+
deleted: 'Överstruken',
|
23
|
+
download: 'Nedladdning',
|
24
|
+
drop_file_here: 'Släpp fil här',
|
25
|
+
edit: 'Ändra',
|
26
|
+
file: 'Infoga fil',
|
27
|
+
filename: 'Namn (valfritt)',
|
28
|
+
fontcolor: 'Typsnittsfärg',
|
29
|
+
formatting: 'Formatering',
|
30
|
+
header1: 'Rubrik 1',
|
31
|
+
header2: 'Rubrik 2',
|
32
|
+
header3: 'Rubrik 3',
|
33
|
+
header4: 'Rubrik 4',
|
34
|
+
header5: 'Rubrik 5',
|
35
|
+
horizontalrule: 'Infoga horisontell linje',
|
36
|
+
html: 'HTML',
|
37
|
+
image: 'Infoga bild',
|
38
|
+
image_position: 'Position',
|
39
|
+
image_web_link: 'Bildlänk',
|
40
|
+
indent: 'Öka indentering',
|
41
|
+
insert: 'Infoga',
|
42
|
+
insert_column_left: 'Lägg till vänsterkolumn',
|
43
|
+
insert_column_right: 'Lägg till högerkolumn',
|
44
|
+
insert_row_above: 'Lägg till rad ovanför',
|
45
|
+
insert_row_below: 'Lägg till rad under',
|
46
|
+
insert_table: 'Infoga tabell',
|
47
|
+
italic: 'Kursiv',
|
48
|
+
left: 'Vänster',
|
49
|
+
link: 'Länk',
|
50
|
+
link_edit: 'Ändra länk',
|
51
|
+
link_insert: 'Infoga länk',
|
52
|
+
link_new_tab: 'Öppna länk i ny flik',
|
53
|
+
mailto: 'E-post',
|
54
|
+
none: 'Ingen',
|
55
|
+
or_choose: 'Eller välj',
|
56
|
+
orderedlist: 'Ordnad lista',
|
57
|
+
outdent: 'Minska indentering',
|
58
|
+
paragraph: 'Paragraf',
|
59
|
+
quote: 'Citat',
|
60
|
+
right: 'Höger',
|
61
|
+
rows: 'Rader',
|
62
|
+
save: 'Spara',
|
63
|
+
table: 'Tabell',
|
64
|
+
text: 'Text',
|
65
|
+
title: 'Alt-text',
|
66
|
+
underline: 'Understryk',
|
67
|
+
unlink: 'Ta bort länk',
|
68
|
+
unorderedlist: 'Oordnad lista',
|
69
|
+
upload: 'Uppladdning',
|
70
|
+
video: 'Infoga video',
|
71
|
+
video_html_code: 'Kod för inbäddad video eller Youtube-/Vimeolänk',
|
72
|
+
web: 'Webbadress'
|
73
|
+
};
|
74
|
+
})( jQuery );
|
@@ -0,0 +1,123 @@
|
|
1
|
+
if (!RedactorPlugins) var RedactorPlugins = {};
|
2
|
+
|
3
|
+
(function($)
|
4
|
+
{
|
5
|
+
RedactorPlugins.fullscreen = function()
|
6
|
+
{
|
7
|
+
return {
|
8
|
+
init: function()
|
9
|
+
{
|
10
|
+
this.fullscreen.isOpen = false;
|
11
|
+
|
12
|
+
var button = this.button.add('fullscreen', 'Fullscreen');
|
13
|
+
this.button.addCallback(button, this.fullscreen.toggle);
|
14
|
+
|
15
|
+
if (this.opts.fullscreen) this.fullscreen.toggle();
|
16
|
+
},
|
17
|
+
enable: function()
|
18
|
+
{
|
19
|
+
this.button.changeIcon('fullscreen', 'normalscreen');
|
20
|
+
this.button.setActive('fullscreen');
|
21
|
+
this.fullscreen.isOpen = true;
|
22
|
+
|
23
|
+
if (this.opts.toolbarExternal)
|
24
|
+
{
|
25
|
+
this.fullscreen.toolcss = {};
|
26
|
+
this.fullscreen.boxcss = {};
|
27
|
+
this.fullscreen.toolcss.width = this.$toolbar.css('width');
|
28
|
+
this.fullscreen.toolcss.top = this.$toolbar.css('top');
|
29
|
+
this.fullscreen.toolcss.position = this.$toolbar.css('position');
|
30
|
+
this.fullscreen.boxcss.top = this.$box.css('top');
|
31
|
+
}
|
32
|
+
|
33
|
+
this.fullscreen.height = this.$editor.height();
|
34
|
+
|
35
|
+
if (this.opts.maxHeight) this.$editor.css('max-height', '');
|
36
|
+
if (this.opts.minHeight) this.$editor.css('min-height', '');
|
37
|
+
|
38
|
+
if (!this.$fullscreenPlaceholder) this.$fullscreenPlaceholder = $('<div/>');
|
39
|
+
this.$fullscreenPlaceholder.insertAfter(this.$box);
|
40
|
+
|
41
|
+
this.$box.appendTo(document.body);
|
42
|
+
|
43
|
+
this.$box.addClass('redactor-box-fullscreen');
|
44
|
+
$('body, html').css('overflow', 'hidden');
|
45
|
+
|
46
|
+
this.fullscreen.resize();
|
47
|
+
$(window).on('resize.redactor.fullscreen', $.proxy(this.fullscreen.resize, this));
|
48
|
+
$(document).scrollTop(0, 0);
|
49
|
+
|
50
|
+
$('.redactor-toolbar-tooltip').hide();
|
51
|
+
this.$editor.focus();
|
52
|
+
this.observe.load();
|
53
|
+
},
|
54
|
+
disable: function()
|
55
|
+
{
|
56
|
+
this.button.removeIcon('fullscreen', 'normalscreen');
|
57
|
+
this.button.setInactive('fullscreen');
|
58
|
+
this.fullscreen.isOpen = false;
|
59
|
+
|
60
|
+
$(window).off('resize.redactor.fullscreen');
|
61
|
+
$('body, html').css('overflow', '');
|
62
|
+
|
63
|
+
this.$box.insertBefore(this.$fullscreenPlaceholder);
|
64
|
+
this.$fullscreenPlaceholder.remove();
|
65
|
+
|
66
|
+
this.$box.removeClass('redactor-box-fullscreen').css({ width: 'auto', height: 'auto' });
|
67
|
+
|
68
|
+
this.code.sync();
|
69
|
+
|
70
|
+
if (this.opts.toolbarExternal)
|
71
|
+
{
|
72
|
+
this.$box.css('top', this.fullscreen.boxcss.top);
|
73
|
+
this.$toolbar.css({
|
74
|
+
'width': this.fullscreen.toolcss.width,
|
75
|
+
'top': this.fullscreen.toolcss.top,
|
76
|
+
'position': this.fullscreen.toolcss.position
|
77
|
+
});
|
78
|
+
}
|
79
|
+
|
80
|
+
if (this.opts.minHeight) this.$editor.css('minHeight', this.opts.minHeight);
|
81
|
+
if (this.opts.maxHeight) this.$editor.css('maxHeight', this.opts.maxHeight);
|
82
|
+
|
83
|
+
$('.redactor-toolbar-tooltip').hide();
|
84
|
+
this.$editor.css('height', 'auto');
|
85
|
+
this.$editor.focus();
|
86
|
+
this.observe.load();
|
87
|
+
},
|
88
|
+
toggle: function()
|
89
|
+
{
|
90
|
+
if (this.fullscreen.isOpen)
|
91
|
+
{
|
92
|
+
this.fullscreen.disable();
|
93
|
+
}
|
94
|
+
else
|
95
|
+
{
|
96
|
+
this.fullscreen.enable();
|
97
|
+
}
|
98
|
+
},
|
99
|
+
resize: function()
|
100
|
+
{
|
101
|
+
if (!this.fullscreen.isOpen) return;
|
102
|
+
|
103
|
+
var toolbarHeight = this.$toolbar.height();
|
104
|
+
|
105
|
+
var height = $(window).height() - toolbarHeight - this.utils.normalize(this.$editor.css('padding-top')) - this.utils.normalize(this.$editor.css('padding-bottom'));
|
106
|
+
this.$box.width($(window).width()).height(height);
|
107
|
+
|
108
|
+
if (this.opts.toolbarExternal)
|
109
|
+
{
|
110
|
+
this.$toolbar.css({
|
111
|
+
'top': '0px',
|
112
|
+
'position': 'absolute',
|
113
|
+
'width': '100%'
|
114
|
+
});
|
115
|
+
|
116
|
+
this.$box.css('top', toolbarHeight + 'px');
|
117
|
+
}
|
118
|
+
|
119
|
+
this.$editor.height(height);
|
120
|
+
}
|
121
|
+
};
|
122
|
+
};
|
123
|
+
})(jQuery);
|
@@ -0,0 +1,337 @@
|
|
1
|
+
if (!RedactorPlugins) var RedactorPlugins = {};
|
2
|
+
|
3
|
+
(function($)
|
4
|
+
{
|
5
|
+
RedactorPlugins.table = function()
|
6
|
+
{
|
7
|
+
return {
|
8
|
+
getTemplate: function()
|
9
|
+
{
|
10
|
+
return String()
|
11
|
+
+ '<section id="redactor-modal-table-insert">'
|
12
|
+
+ '<label>' + this.lang.get('rows') + '</label>'
|
13
|
+
+ '<input type="text" size="5" value="2" id="redactor-table-rows" />'
|
14
|
+
+ '<label>' + this.lang.get('columns') + '</label>'
|
15
|
+
+ '<input type="text" size="5" value="3" id="redactor-table-columns" />'
|
16
|
+
+ '</section>';
|
17
|
+
},
|
18
|
+
init: function()
|
19
|
+
{
|
20
|
+
|
21
|
+
var dropdown = {};
|
22
|
+
|
23
|
+
dropdown.insert_table = { title: this.lang.get('insert_table'), func: this.table.show };
|
24
|
+
dropdown.insert_row_above = { title: this.lang.get('insert_row_above'), func: this.table.addRowAbove };
|
25
|
+
dropdown.insert_row_below = { title: this.lang.get('insert_row_below'), func: this.table.addRowBelow };
|
26
|
+
dropdown.insert_column_left = { title: this.lang.get('insert_column_left'), func: this.table.addColumnLeft };
|
27
|
+
dropdown.insert_column_right = { title: this.lang.get('insert_column_right'), func: this.table.addColumnRight };
|
28
|
+
dropdown.add_head = { title: this.lang.get('add_head'), func: this.table.addHead };
|
29
|
+
dropdown.delete_head = { title: this.lang.get('delete_head'), func: this.table.deleteHead };
|
30
|
+
dropdown.delete_column = { title: this.lang.get('delete_column'), func: this.table.deleteColumn };
|
31
|
+
dropdown.delete_row = { title: this.lang.get('delete_row'), func: this.table.deleteRow };
|
32
|
+
dropdown.delete_table = { title: this.lang.get('delete_table'), func: this.table.deleteTable };
|
33
|
+
|
34
|
+
this.observe.addButton('td', 'table');
|
35
|
+
this.observe.addButton('th', 'table');
|
36
|
+
|
37
|
+
var button = this.button.addBefore('link', 'table', this.lang.get('table'));
|
38
|
+
this.button.addDropdown(button, dropdown);
|
39
|
+
},
|
40
|
+
show: function()
|
41
|
+
{
|
42
|
+
this.modal.addTemplate('table', this.table.getTemplate());
|
43
|
+
|
44
|
+
this.modal.load('table', this.lang.get('insert_table'), 300);
|
45
|
+
this.modal.createCancelButton();
|
46
|
+
|
47
|
+
var button = this.modal.createActionButton(this.lang.get('insert'));
|
48
|
+
button.on('click', this.table.insert);
|
49
|
+
|
50
|
+
this.selection.save();
|
51
|
+
this.modal.show();
|
52
|
+
|
53
|
+
$('#redactor-table-rows').focus();
|
54
|
+
|
55
|
+
},
|
56
|
+
insert: function()
|
57
|
+
{
|
58
|
+
|
59
|
+
var rows = $('#redactor-table-rows').val(),
|
60
|
+
columns = $('#redactor-table-columns').val(),
|
61
|
+
$tableBox = $('<div>'),
|
62
|
+
tableId = Math.floor(Math.random() * 99999),
|
63
|
+
$table = $('<table id="table' + tableId + '"><tbody></tbody></table>'),
|
64
|
+
i, $row, z, $column;
|
65
|
+
|
66
|
+
for (i = 0; i < rows; i++)
|
67
|
+
{
|
68
|
+
$row = $('<tr>');
|
69
|
+
|
70
|
+
for (z = 0; z < columns; z++)
|
71
|
+
{
|
72
|
+
$column = $('<td>' + this.opts.invisibleSpace + '</td>');
|
73
|
+
|
74
|
+
// set the focus to the first td
|
75
|
+
if (i === 0 && z === 0)
|
76
|
+
{
|
77
|
+
$column.append(this.selection.getMarker());
|
78
|
+
}
|
79
|
+
|
80
|
+
$($row).append($column);
|
81
|
+
}
|
82
|
+
|
83
|
+
$table.append($row);
|
84
|
+
}
|
85
|
+
|
86
|
+
$tableBox.append($table);
|
87
|
+
var html = $tableBox.html();
|
88
|
+
|
89
|
+
|
90
|
+
this.modal.close();
|
91
|
+
this.selection.restore();
|
92
|
+
|
93
|
+
if (this.table.getTable()) return;
|
94
|
+
|
95
|
+
this.buffer.set();
|
96
|
+
|
97
|
+
var current = this.selection.getBlock() || this.selection.getCurrent();
|
98
|
+
if (current && current.tagName != 'BODY')
|
99
|
+
{
|
100
|
+
if (current.tagName == 'LI') current = $(current).closest('ul, ol');
|
101
|
+
$(current).after(html);
|
102
|
+
}
|
103
|
+
else
|
104
|
+
{
|
105
|
+
this.insert.html(html);
|
106
|
+
}
|
107
|
+
|
108
|
+
this.selection.restore();
|
109
|
+
|
110
|
+
var table = this.$editor.find('#table' + tableId);
|
111
|
+
|
112
|
+
if (!this.opts.linebreaks && (this.utils.browser('mozilla') || this.utils.browser('msie')))
|
113
|
+
{
|
114
|
+
var $next = table.next();
|
115
|
+
if ($next.length === 0)
|
116
|
+
{
|
117
|
+
table.after(this.opts.emptyHtml);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
this.observe.buttons();
|
122
|
+
|
123
|
+
table.find('span.redactor-selection-marker').remove();
|
124
|
+
table.removeAttr('id');
|
125
|
+
|
126
|
+
this.code.sync();
|
127
|
+
this.core.setCallback('insertedTable', table);
|
128
|
+
},
|
129
|
+
getTable: function()
|
130
|
+
{
|
131
|
+
var $table = $(this.selection.getParent()).closest('table');
|
132
|
+
|
133
|
+
if (!this.utils.isRedactorParent($table)) return false;
|
134
|
+
if ($table.size() === 0) return false;
|
135
|
+
|
136
|
+
return $table;
|
137
|
+
},
|
138
|
+
restoreAfterDelete: function($table)
|
139
|
+
{
|
140
|
+
this.selection.restore();
|
141
|
+
$table.find('span.redactor-selection-marker').remove();
|
142
|
+
this.code.sync();
|
143
|
+
},
|
144
|
+
deleteTable: function()
|
145
|
+
{
|
146
|
+
var $table = this.table.getTable();
|
147
|
+
if (!$table) return;
|
148
|
+
|
149
|
+
this.buffer.set();
|
150
|
+
|
151
|
+
|
152
|
+
var $next = $table.next();
|
153
|
+
if (!this.opts.linebreaks && $next.length !== 0)
|
154
|
+
{
|
155
|
+
this.caret.setStart($next);
|
156
|
+
}
|
157
|
+
else
|
158
|
+
{
|
159
|
+
this.caret.setAfter($table);
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
$table.remove();
|
164
|
+
|
165
|
+
this.code.sync();
|
166
|
+
},
|
167
|
+
deleteRow: function()
|
168
|
+
{
|
169
|
+
var $table = this.table.getTable();
|
170
|
+
if (!$table) return;
|
171
|
+
|
172
|
+
var $current = $(this.selection.getCurrent());
|
173
|
+
|
174
|
+
this.buffer.set();
|
175
|
+
|
176
|
+
var $current_tr = $current.closest('tr');
|
177
|
+
var $focus_tr = $current_tr.prev().length ? $current_tr.prev() : $current_tr.next();
|
178
|
+
if ($focus_tr.length)
|
179
|
+
{
|
180
|
+
var $focus_td = $focus_tr.children('td, th').first();
|
181
|
+
if ($focus_td.length) $focus_td.prepend(this.selection.getMarker());
|
182
|
+
}
|
183
|
+
|
184
|
+
$current_tr.remove();
|
185
|
+
this.table.restoreAfterDelete($table);
|
186
|
+
},
|
187
|
+
deleteColumn: function()
|
188
|
+
{
|
189
|
+
var $table = this.table.getTable();
|
190
|
+
if (!$table) return;
|
191
|
+
|
192
|
+
this.buffer.set();
|
193
|
+
|
194
|
+
var $current = $(this.selection.getCurrent());
|
195
|
+
var $current_td = $current.closest('td, th');
|
196
|
+
var index = $current_td[0].cellIndex;
|
197
|
+
|
198
|
+
$table.find('tr').each($.proxy(function(i, elem)
|
199
|
+
{
|
200
|
+
var $elem = $(elem);
|
201
|
+
var focusIndex = index - 1 < 0 ? index + 1 : index - 1;
|
202
|
+
if (i === 0) $elem.find('td, th').eq(focusIndex).prepend(this.selection.getMarker());
|
203
|
+
|
204
|
+
$elem.find('td, th').eq(index).remove();
|
205
|
+
|
206
|
+
}, this));
|
207
|
+
|
208
|
+
this.table.restoreAfterDelete($table);
|
209
|
+
},
|
210
|
+
addHead: function()
|
211
|
+
{
|
212
|
+
var $table = this.table.getTable();
|
213
|
+
if (!$table) return;
|
214
|
+
|
215
|
+
this.buffer.set();
|
216
|
+
|
217
|
+
if ($table.find('thead').size() !== 0)
|
218
|
+
{
|
219
|
+
this.table.deleteHead();
|
220
|
+
return;
|
221
|
+
}
|
222
|
+
|
223
|
+
var tr = $table.find('tr').first().clone();
|
224
|
+
tr.find('td').replaceWith($.proxy(function()
|
225
|
+
{
|
226
|
+
return $('<th>').html(this.opts.invisibleSpace);
|
227
|
+
}, this));
|
228
|
+
|
229
|
+
$thead = $('<thead></thead>').append(tr);
|
230
|
+
$table.prepend($thead);
|
231
|
+
|
232
|
+
this.code.sync();
|
233
|
+
|
234
|
+
},
|
235
|
+
deleteHead: function()
|
236
|
+
{
|
237
|
+
var $table = this.table.getTable();
|
238
|
+
if (!$table) return;
|
239
|
+
|
240
|
+
var $thead = $table.find('thead');
|
241
|
+
if ($thead.size() === 0) return;
|
242
|
+
|
243
|
+
this.buffer.set();
|
244
|
+
|
245
|
+
$thead.remove();
|
246
|
+
this.code.sync();
|
247
|
+
},
|
248
|
+
addRowAbove: function()
|
249
|
+
{
|
250
|
+
this.table.addRow('before');
|
251
|
+
},
|
252
|
+
addRowBelow: function()
|
253
|
+
{
|
254
|
+
this.table.addRow('after');
|
255
|
+
},
|
256
|
+
addColumnLeft: function()
|
257
|
+
{
|
258
|
+
this.table.addColumn('before');
|
259
|
+
},
|
260
|
+
addColumnRight: function()
|
261
|
+
{
|
262
|
+
this.table.addColumn('after');
|
263
|
+
},
|
264
|
+
addRow: function(type)
|
265
|
+
{
|
266
|
+
var $table = this.table.getTable();
|
267
|
+
if (!$table) return;
|
268
|
+
|
269
|
+
this.buffer.set();
|
270
|
+
|
271
|
+
var $current = $(this.selection.getCurrent());
|
272
|
+
var $current_tr = $current.closest('tr');
|
273
|
+
var new_tr = $current_tr.clone();
|
274
|
+
|
275
|
+
new_tr.find('th').replaceWith(function()
|
276
|
+
{
|
277
|
+
var $td = $('<td>');
|
278
|
+
$td[0].attributes = this.attributes;
|
279
|
+
|
280
|
+
return $td.append($(this).contents());
|
281
|
+
});
|
282
|
+
|
283
|
+
new_tr.find('td').html(this.opts.invisibleSpace);
|
284
|
+
|
285
|
+
if (type == 'after')
|
286
|
+
{
|
287
|
+
$current_tr.after(new_tr);
|
288
|
+
}
|
289
|
+
else
|
290
|
+
{
|
291
|
+
$current_tr.before(new_tr);
|
292
|
+
}
|
293
|
+
|
294
|
+
this.code.sync();
|
295
|
+
},
|
296
|
+
addColumn: function (type)
|
297
|
+
{
|
298
|
+
var $table = this.table.getTable();
|
299
|
+
if (!$table) return;
|
300
|
+
|
301
|
+
var index = 0;
|
302
|
+
var current = $(this.selection.getCurrent());
|
303
|
+
|
304
|
+
this.buffer.set();
|
305
|
+
|
306
|
+
var $current_tr = current.closest('tr');
|
307
|
+
var $current_td = current.closest('td, th');
|
308
|
+
|
309
|
+
$current_tr.find('td, th').each($.proxy(function(i, elem)
|
310
|
+
{
|
311
|
+
if ($(elem)[0] === $current_td[0]) index = i;
|
312
|
+
|
313
|
+
}, this));
|
314
|
+
|
315
|
+
$table.find('tr').each($.proxy(function(i, elem)
|
316
|
+
{
|
317
|
+
var $current = $(elem).find('td, th').eq(index);
|
318
|
+
|
319
|
+
var td = $current.clone();
|
320
|
+
td.html(this.opts.invisibleSpace);
|
321
|
+
|
322
|
+
if (type == 'after')
|
323
|
+
{
|
324
|
+
$current.after(td);
|
325
|
+
}
|
326
|
+
else
|
327
|
+
{
|
328
|
+
$current.before(td);
|
329
|
+
}
|
330
|
+
|
331
|
+
}, this));
|
332
|
+
|
333
|
+
this.code.sync();
|
334
|
+
}
|
335
|
+
};
|
336
|
+
};
|
337
|
+
})(jQuery);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: godmin-redactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Varvet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: godmin
|
@@ -66,6 +66,7 @@ extensions: []
|
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
68
|
- ".gitignore"
|
69
|
+
- CHANGELOG.md
|
69
70
|
- Gemfile
|
70
71
|
- Gemfile.lock
|
71
72
|
- MIT-LICENSE
|
@@ -78,6 +79,9 @@ files:
|
|
78
79
|
- lib/godmin/redactor/engine.rb
|
79
80
|
- lib/godmin/redactor/helper.rb
|
80
81
|
- lib/godmin/redactor/version.rb
|
82
|
+
- vendor/assets/javascripts/langs/sv.js
|
83
|
+
- vendor/assets/javascripts/plugins/fullscreen.js
|
84
|
+
- vendor/assets/javascripts/plugins/table.js
|
81
85
|
- vendor/assets/javascripts/redactor.js
|
82
86
|
- vendor/assets/stylesheets/redactor-font.eot
|
83
87
|
- vendor/assets/stylesheets/redactor.css
|