redactor-rails 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b682b1c7c9c12bcda1b2619337c55114ffa79fb1
4
- data.tar.gz: b3be1e362676e20f93d105d807113351012d8d8c
3
+ metadata.gz: 472bf4ed25c75361f5e496b0f9112ea424fa3ad4
4
+ data.tar.gz: fa090720d7f4c96fabc646e7a45e10dca2258c78
5
5
  SHA512:
6
- metadata.gz: ae43769622c4035642e52b27182951de8bf7b428db280e1e6d10817014d2ec420e21986af9a09a8a9cc9a6afea5b6ed64ee4b27f98378ac9211cab61b85ec4d6
7
- data.tar.gz: 34968fc5bfce52c121d8611cdd919f76ce56a4cd199f068b52d4f621c35b3a290819b62ee778407dc61fbce9c15abb88349dbcd1fe497f699c9100bcabcec8ff
6
+ metadata.gz: 294f26b31600e64a626c403c96cfe3b13c9e1f55b9bfb3978b289c9083f5b8cbd803338e4e39272dbf5053b10a296c5fadf94e3dce5892ecf6678f425376e1af
7
+ data.tar.gz: 0470184ffab5856e78966dcf86a057e9e1229b19b3706b893224bfe633595581b5657b892043ed9d18b745d3bf6c297cf87e1111a089b791abe5bac16aa76f60
data/README.md CHANGED
@@ -70,7 +70,7 @@ If you need change some config in redactor, you can
70
70
 
71
71
  Then generate `app\assets\redactor-rails\config.js`.
72
72
 
73
- See the [Redactor Documentation](http://redactorjs.com/docs/settings/) for a full list of configuration options.
73
+ See the [Redactor Documentation](http://imperavi.com/redactor/docs/settings/) for a full list of configuration options.
74
74
 
75
75
 
76
76
  If You Want To setup a new language in Redactor you should do two things:
@@ -94,6 +94,37 @@ Add to your `application.js`:
94
94
 
95
95
  //= require redactor-rails/langs/zh_tw
96
96
 
97
+ ### Using plugins
98
+
99
+ This gem comes bundled with several Redactor plugins:
100
+
101
+ - Fullscreen
102
+ - Clips
103
+ - FontColor
104
+ - FontSize
105
+ - FontFamily
106
+ - Text direction
107
+
108
+ Full details of these can be found at [Redactor Plugins](http://imperavi.com/redactor/docs/plugins/)
109
+
110
+ To include all the plugins just add to your `application.js`:
111
+
112
+ //= require redactor-rails/plugins
113
+
114
+ and add to your `application.css`:
115
+
116
+ *= redactor-rails/plugins
117
+
118
+ If you would prefer to pick and choose which plugins to include you can
119
+ add for example:
120
+
121
+ //= require redactor-rails/plugins/fontsize
122
+ //= require redactor-rails/plugins/fontfamily
123
+
124
+ After including the desired plugins they can be configured in the
125
+ redactor config file as normal.
126
+
127
+
97
128
  ### Defining a Devise User Model
98
129
 
99
130
  By default redactor-rails uses the `User` model.
@@ -121,7 +152,7 @@ You may use a different model by:
121
152
  ```
122
153
 
123
154
  ```
124
- # config/redactor.rb
155
+ # config/initializers/redactor.rb
125
156
  # Overrides the user class
126
157
 
127
158
  module RedactorRails
@@ -1,3 +1,3 @@
1
1
  module RedactorRails
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -1,5 +1,4 @@
1
- $(document).ready(
2
- function(){
1
+ window.init_redactor = function(){
3
2
  var csrf_token = $('meta[name=csrf-token]').attr('content');
4
3
  var csrf_param = $('meta[name=csrf-param]').attr('content');
5
4
  var params;
@@ -12,4 +11,7 @@ $(document).ready(
12
11
  "path":"/assets/redactor-rails",
13
12
  "css":"style.css"}
14
13
  );
15
- });
14
+ }
15
+
16
+ $(document).ready( window.init_redactor );
17
+ $(window).bind('page:change', window.init_redactor);
@@ -7,6 +7,7 @@ $.Redactor.opts.langs['zh_cn'] = {
7
7
  table: '表格',
8
8
  link: '链接',
9
9
  link_insert: '插入链接',
10
+ link_edit: '编辑链接',
10
11
  unlink: '取消链接',
11
12
  formatting: '样式',
12
13
  paragraph: '段落',
@@ -16,6 +17,7 @@ $.Redactor.opts.langs['zh_cn'] = {
16
17
  header2: '二级标题',
17
18
  header3: '三级标题',
18
19
  header4: '四级标题',
20
+ header5: '五级标题'
19
21
  bold: '粗体',
20
22
  italic: '斜体',
21
23
  fontcolor: '字体颜色',
@@ -66,6 +68,8 @@ $.Redactor.opts.langs['zh_cn'] = {
66
68
  anchor: '锚点',
67
69
  link_new_tab: '在新窗口打开',
68
70
  underline: '下划线',
69
- alignment: '对齐方式'
71
+ alignment: '对齐方式',
72
+ filename: '文件名 (可选)',
73
+ edit: '编辑'
70
74
  };
71
- })( jQuery );
75
+ })( jQuery );
@@ -0,0 +1,6 @@
1
+ //= require redactor-rails/plugins/clips
2
+ //= require redactor-rails/plugins/fontcolor
3
+ //= require redactor-rails/plugins/fontfamily
4
+ //= require redactor-rails/plugins/fontsize
5
+ //= require redactor-rails/plugins/fullscreen
6
+ //= require redactor-rails/plugins/textdirection
@@ -0,0 +1,35 @@
1
+ if (!RedactorPlugins) var RedactorPlugins = {};
2
+
3
+ RedactorPlugins.clips = {
4
+ init: function()
5
+ {
6
+ var callback = $.proxy(function()
7
+ {
8
+ $('#redactor_modal').find('.redactor_clip_link').each($.proxy(function(i, s)
9
+ {
10
+ $(s).click($.proxy(function()
11
+ {
12
+ this.insertClip($(s).next().html());
13
+ return false;
14
+
15
+ }, this));
16
+ }, this));
17
+
18
+ this.selectionSave();
19
+ this.bufferSet();
20
+
21
+ }, this );
22
+
23
+ this.buttonAdd('clips', 'Clips', function(e)
24
+ {
25
+ this.modalInit('Clips', '#clipsmodal', 500, callback);
26
+ });
27
+ },
28
+ insertClip: function(html)
29
+ {
30
+ this.selectionRestore();
31
+ this.insertHtml($.trim(html));
32
+ this.modalClose();
33
+ }
34
+ };
35
+
@@ -0,0 +1,73 @@
1
+ if (!RedactorPlugins) var RedactorPlugins = {};
2
+
3
+ RedactorPlugins.fontcolor = {
4
+ init: function()
5
+ {
6
+ var colors = ['#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00', '#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca', '#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694', '#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314', '#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100', '#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000'];
7
+ var buttons = ['fontcolor', 'backcolor'];
8
+
9
+ this.buttonAddSeparator();
10
+
11
+ for (var i = 0; i < 2; i++)
12
+ {
13
+ var name = buttons[i];
14
+
15
+ var $dropdown = $('<div class="redactor_dropdown redactor_dropdown_box_' + name + '" style="display: none; width: 210px;">');
16
+
17
+ this.pickerBuild($dropdown, name, colors);
18
+ $(this.$toolbar).append($dropdown);
19
+
20
+ this.buttonAdd(name, this.opts.curLang[name], $.proxy(function(btnName, $button, btnObject, e)
21
+ {
22
+ this.dropdownShow(e, btnName);
23
+
24
+ }, this));
25
+ }
26
+ },
27
+ pickerBuild: function($dropdown, name, colors)
28
+ {
29
+ var rule = 'color';
30
+ if (name === 'backcolor') rule = 'background-color';
31
+
32
+ var _self = this;
33
+ var onSwatch = function(e)
34
+ {
35
+ e.preventDefault();
36
+
37
+ var $this = $(this);
38
+ _self.pickerSet($this.data('rule'), $this.attr('rel'));
39
+
40
+ }
41
+
42
+ var len = colors.length;
43
+ for (var z = 0; z < len; z++)
44
+ {
45
+ var color = colors[z];
46
+
47
+ var $swatch = $('<a rel="' + color + '" data-rule="' + rule +'" href="#" style="float: left; font-size: 0; border: 2px solid #fff; padding: 0; margin: 0; width: 15px; height: 15px;"></a>');
48
+ $swatch.css('background-color', color);
49
+ $dropdown.append($swatch);
50
+ $swatch.on('click', onSwatch);
51
+ }
52
+
53
+ var $elNone = $('<a href="#" style="display: block; clear: both; padding: 4px 0; font-size: 11px; line-height: 1;"></a>')
54
+ .html(this.opts.curLang.none)
55
+ .on('click', function(e)
56
+ {
57
+ e.preventDefault();
58
+ _self.pickerSet(rule, false);
59
+ });
60
+
61
+ $dropdown.append($elNone);
62
+ },
63
+ pickerSet: function(rule, type)
64
+ {
65
+ this.bufferSet();
66
+
67
+ this.$editor.focus();
68
+ this.inlineRemoveStyle(rule);
69
+ if (type !== false) this.inlineSetStyle(rule, type);
70
+ if (this.opts.air) this.$air.fadeOut(100);
71
+ this.sync();
72
+ }
73
+ };
@@ -0,0 +1,27 @@
1
+ if (!RedactorPlugins) var RedactorPlugins = {};
2
+
3
+ RedactorPlugins.fontfamily = {
4
+ init: function ()
5
+ {
6
+ var fonts = [ 'Arial', 'Helvetica', 'Georgia', 'Times New Roman', 'Monospace' ];
7
+ var that = this;
8
+ var dropdown = {};
9
+
10
+ $.each(fonts, function(i, s)
11
+ {
12
+ dropdown['s' + i] = { title: s, callback: function() { that.setFontfamily(s); }};
13
+ });
14
+
15
+ dropdown['remove'] = { title: 'Remove font', callback: function() { that.resetFontfamily(); }};
16
+
17
+ this.buttonAdd('fontfamily', 'Change font family', false, dropdown);
18
+ },
19
+ setFontfamily: function (value)
20
+ {
21
+ this.inlineSetStyle('font-family', value);
22
+ },
23
+ resetFontfamily: function()
24
+ {
25
+ this.inlineRemoveStyle('font-family');
26
+ }
27
+ };
@@ -0,0 +1,27 @@
1
+ if (!RedactorPlugins) var RedactorPlugins = {};
2
+
3
+ RedactorPlugins.fontsize = {
4
+ init: function()
5
+ {
6
+ var fonts = [10, 11, 12, 14, 16, 18, 20, 24, 28, 30];
7
+ var that = this;
8
+ var dropdown = {};
9
+
10
+ $.each(fonts, function(i, s)
11
+ {
12
+ dropdown['s' + i] = { title: s + 'px', callback: function() { that.setFontsize(s); } };
13
+ });
14
+
15
+ dropdown['remove'] = { title: 'Remove font size', callback: function() { that.resetFontsize(); } };
16
+
17
+ this.buttonAdd( 'fontsize', 'Change font size', false, dropdown);
18
+ },
19
+ setFontsize: function(size)
20
+ {
21
+ this.inlineSetStyle('font-size', size + 'px');
22
+ },
23
+ resetFontsize: function()
24
+ {
25
+ this.inlineRemoveStyle('font-size');
26
+ }
27
+ };
@@ -0,0 +1,146 @@
1
+ if (!RedactorPlugins) var RedactorPlugins = {};
2
+
3
+ RedactorPlugins.fullscreen = {
4
+ init: function()
5
+ {
6
+ this.fullscreen = false;
7
+
8
+ this.buttonAdd('fullscreen', 'Fullscreen', $.proxy(this.toggleFullscreen, this));
9
+ this.buttonSetRight('fullscreen');
10
+
11
+ if (this.opts.fullscreen) this.toggleFullscreen();
12
+ },
13
+ toggleFullscreen: function()
14
+ {
15
+ var html;
16
+
17
+ if (!this.fullscreen)
18
+ {
19
+ this.buttonChangeIcon('fullscreen', 'normalscreen');
20
+ this.buttonActive('fullscreen');
21
+ this.fullscreen = true;
22
+
23
+ if (this.opts.toolbarExternal)
24
+ {
25
+ this.toolcss = {};
26
+ this.boxcss = {};
27
+ this.toolcss.width = this.$toolbar.css('width');
28
+ this.toolcss.top = this.$toolbar.css('top');
29
+ this.toolcss.position = this.$toolbar.css('position');
30
+ this.boxcss.top = this.$box.css('top');
31
+ }
32
+
33
+ this.fsheight = this.$editor.height();
34
+
35
+ if (this.opts.iframe) html = this.get();
36
+
37
+ this.tmpspan = $('<span></span>');
38
+ this.$box.addClass('redactor_box_fullscreen').after(this.tmpspan);
39
+
40
+ $('body, html').css('overflow', 'hidden');
41
+ $('body').prepend(this.$box);
42
+
43
+ if (this.opts.iframe) this.fullscreenIframe(html);
44
+
45
+ this.fullScreenResize();
46
+ $(window).resize($.proxy(this.fullScreenResize, this));
47
+ $(document).scrollTop(0, 0);
48
+
49
+ this.focus();
50
+ this.observeStart();
51
+
52
+ }
53
+ else
54
+ {
55
+ this.buttonRemoveIcon('fullscreen', 'normalscreen');
56
+ this.buttonInactive('fullscreen');
57
+ this.fullscreen = false;
58
+
59
+ $(window).off('resize', $.proxy(this.fullScreenResize, this));
60
+ $('body, html').css('overflow', '');
61
+
62
+ this.$box.removeClass('redactor_box_fullscreen').css({ width: 'auto', height: 'auto' });
63
+
64
+ if (this.opts.iframe) html = this.$editor.html();
65
+ this.tmpspan.after(this.$box).remove();
66
+
67
+ if (this.opts.iframe) this.fullscreenIframe(html);
68
+ else this.sync();
69
+
70
+ var height = this.fsheight;
71
+ if (this.opts.autoresize) height = 'auto';
72
+
73
+ if (this.opts.toolbarExternal)
74
+ {
75
+ this.$box.css('top', this.boxcss.top);
76
+ this.$toolbar.css({
77
+ 'width': this.toolcss.width,
78
+ 'top': this.toolcss.top,
79
+ 'position': this.toolcss.position
80
+ });
81
+ }
82
+
83
+ if (!this.opts.iframe) this.$editor.css('height', height);
84
+ else this.$frame.css('height', height);
85
+
86
+ this.$editor.css('height', height);
87
+ this.focus();
88
+ this.observeStart();
89
+ }
90
+ },
91
+ fullscreenIframe: function(html)
92
+ {
93
+ this.$editor = this.$frame.contents().find('body').attr({
94
+ 'contenteditable': true,
95
+ 'dir': this.opts.direction
96
+ });
97
+
98
+ // set document & window
99
+ if (this.$editor[0])
100
+ {
101
+ this.document = this.$editor[0].ownerDocument;
102
+ this.window = this.document.defaultView || window;
103
+ }
104
+
105
+ // iframe css
106
+ this.iframeAddCss();
107
+
108
+ if (this.opts.fullpage) this.setFullpageOnInit(html);
109
+ else this.set(html);
110
+
111
+ if (this.opts.wym) this.$editor.addClass('redactor_editor_wym');
112
+ },
113
+ fullScreenResize: function()
114
+ {
115
+ if (!this.fullscreen) return false;
116
+
117
+ var toolbarHeight = this.$toolbar.height();
118
+
119
+ var pad = this.$editor.css('padding-top').replace('px', '');
120
+ var height = $(window).height() - toolbarHeight;
121
+ this.$box.width($(window).width() - 2).height(height + toolbarHeight);
122
+
123
+ if (this.opts.toolbarExternal)
124
+ {
125
+ this.$toolbar.css({
126
+ 'top': '0px',
127
+ 'position': 'absolute',
128
+ 'width': '100%'
129
+ });
130
+
131
+ this.$box.css('top', toolbarHeight + 'px');
132
+ }
133
+
134
+ if (!this.opts.iframe) this.$editor.height(height - (pad * 2));
135
+ else
136
+ {
137
+ setTimeout($.proxy(function()
138
+ {
139
+ this.$frame.height(height);
140
+
141
+ }, this), 1);
142
+ }
143
+
144
+ this.$editor.height(height);
145
+ }
146
+ };
@@ -0,0 +1,24 @@
1
+ if (!RedactorPlugins) var RedactorPlugins = {};
2
+
3
+ RedactorPlugins.textdirection = {
4
+ init: function()
5
+ {
6
+ var that = this;
7
+ var dropdown = {};
8
+
9
+ dropdown['ltr'] = { title: 'Left to right', callback: function () { that.ltrTextDirection(); } };
10
+ dropdown['rtl'] = { title: 'Right to left', callback: function () { that.rtlTextDirection(); } };
11
+
12
+ this.buttonAdd('direction', 'Change direction', false, dropdown);
13
+ },
14
+ rtlTextDirection: function()
15
+ {
16
+ this.bufferSet();
17
+ this.blockSetAttr('dir', 'rtl');
18
+ },
19
+ ltrTextDirection: function()
20
+ {
21
+ this.bufferSet();
22
+ this.blockRemoveAttr('dir');
23
+ }
24
+ };
@@ -105,7 +105,7 @@ body .redactor_box_fullscreen {
105
105
  .redactor_editor blockquote,
106
106
  .redactor_editor pre {
107
107
  font-size: 15px;
108
- line-height: 1.5rem;
108
+ line-height: 1.5em;
109
109
  }
110
110
 
111
111
  .redactor_editor,
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require redactor-rails/plugins/clips
3
+ */
@@ -0,0 +1,34 @@
1
+ .label-red {
2
+ color: #fff;
3
+ background: #c92020;
4
+ padding: 0 7px;
5
+ border-radius: 4px;
6
+ }
7
+
8
+ .redactor_clips_box {
9
+ margin-left: 0;
10
+ padding-left: 0;
11
+ list-style: none;
12
+ max-height: 250px;
13
+ overflow-x: scroll;
14
+ }
15
+ .redactor_clips_box li {
16
+ border-top: 1px solid #fff;
17
+ border-bottom: 1px solid #ddd;
18
+ }
19
+ .redactor_clips_box li:first-child {
20
+ border-top: none;
21
+ }
22
+ .redactor_clips_box li:last-child {
23
+ border-bottom: none;
24
+ }
25
+ .redactor_clips_box li a {
26
+ padding: 10px 5px;
27
+ color: #000;
28
+ text-decoration: none;
29
+ font-size: 13px;
30
+ display: block;
31
+ }
32
+ .redactor_clips_box li a:hover {
33
+ background-color: #fff;
34
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redactor-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sammy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -131,12 +131,21 @@ files:
131
131
  - vendor/assets/javascripts/redactor-rails/langs/vi.js
132
132
  - vendor/assets/javascripts/redactor-rails/langs/zh_cn.js
133
133
  - vendor/assets/javascripts/redactor-rails/langs/zh_tw.js
134
+ - vendor/assets/javascripts/redactor-rails/plugins.js
135
+ - vendor/assets/javascripts/redactor-rails/plugins/clips.js
136
+ - vendor/assets/javascripts/redactor-rails/plugins/fontcolor.js
137
+ - vendor/assets/javascripts/redactor-rails/plugins/fontfamily.js
138
+ - vendor/assets/javascripts/redactor-rails/plugins/fontsize.js
139
+ - vendor/assets/javascripts/redactor-rails/plugins/fullscreen.js
140
+ - vendor/assets/javascripts/redactor-rails/plugins/textdirection.js
134
141
  - vendor/assets/javascripts/redactor-rails/redactor.js
135
142
  - vendor/assets/javascripts/redactor-rails/redactor.min.js
136
143
  - vendor/assets/stylesheets/redactor-rails/css/redactor-iframe.css
137
144
  - vendor/assets/stylesheets/redactor-rails/css/redactor.css
138
145
  - vendor/assets/stylesheets/redactor-rails/css/style.css
139
146
  - vendor/assets/stylesheets/redactor-rails/index.css
147
+ - vendor/assets/stylesheets/redactor-rails/plugins.css
148
+ - vendor/assets/stylesheets/redactor-rails/plugins/clips.css
140
149
  homepage: https://github.com/SammyLin/redactor-rails
141
150
  licenses: []
142
151
  metadata: {}