redactor2_rails 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +207 -0
  7. data/Rakefile +2 -0
  8. data/app/controller/redactor2_rails/files_controller.rb +28 -0
  9. data/app/controller/redactor2_rails/images_controller.rb +28 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +7 -0
  12. data/config/routes.rb +4 -0
  13. data/lib/generators/redactor2/config_generator.rb +18 -0
  14. data/lib/generators/redactor2/install_generator.rb +75 -0
  15. data/lib/generators/redactor2/templates/active_record/carrierwave/devise_migration.rb +28 -0
  16. data/lib/generators/redactor2/templates/active_record/carrierwave/migration.rb +25 -0
  17. data/lib/generators/redactor2/templates/active_record/carrierwave/redactor2/asset.rb +6 -0
  18. data/lib/generators/redactor2/templates/active_record/carrierwave/redactor2/file.rb +7 -0
  19. data/lib/generators/redactor2/templates/active_record/carrierwave/redactor2/image.rb +7 -0
  20. data/lib/generators/redactor2/templates/base/carrierwave/uploaders/redactor2_rails_file_uploader.rb +15 -0
  21. data/lib/generators/redactor2/templates/base/carrierwave/uploaders/redactor2_rails_image_uploader.rb +54 -0
  22. data/lib/generators/redactor2/templates/config.js +14 -0
  23. data/lib/generators/redactor2/templates/mongoid/carrierwave/redactor/asset.rb +9 -0
  24. data/lib/generators/redactor2/templates/mongoid/carrierwave/redactor/file.rb +7 -0
  25. data/lib/generators/redactor2/templates/mongoid/carrierwave/redactor/picture.rb +7 -0
  26. data/lib/redactor2_rails.rb +40 -0
  27. data/lib/redactor2_rails/backend/carrierwave.rb +64 -0
  28. data/lib/redactor2_rails/devise.rb +11 -0
  29. data/lib/redactor2_rails/engine.rb +9 -0
  30. data/lib/redactor2_rails/http.rb +89 -0
  31. data/lib/redactor2_rails/orm/active_record.rb +31 -0
  32. data/lib/redactor2_rails/orm/base.rb +38 -0
  33. data/lib/redactor2_rails/orm/mongoid.rb +37 -0
  34. data/lib/redactor2_rails/version.rb +3 -0
  35. data/redactor2_rails.gemspec +28 -0
  36. data/vendor/assets/javascripts/redactor2_rails/config.js +14 -0
  37. data/vendor/assets/javascripts/redactor2_rails/index.js +2 -0
  38. data/vendor/assets/javascripts/redactor2_rails/langs/ar.js +50 -0
  39. data/vendor/assets/javascripts/redactor2_rails/langs/de.js +50 -0
  40. data/vendor/assets/javascripts/redactor2_rails/langs/en.js +50 -0
  41. data/vendor/assets/javascripts/redactor2_rails/langs/es.js +50 -0
  42. data/vendor/assets/javascripts/redactor2_rails/langs/fa.js +50 -0
  43. data/vendor/assets/javascripts/redactor2_rails/langs/fi.js +50 -0
  44. data/vendor/assets/javascripts/redactor2_rails/langs/fr.js +50 -0
  45. data/vendor/assets/javascripts/redactor2_rails/langs/hu.js +50 -0
  46. data/vendor/assets/javascripts/redactor2_rails/langs/it.js +50 -0
  47. data/vendor/assets/javascripts/redactor2_rails/langs/ja.js +50 -0
  48. data/vendor/assets/javascripts/redactor2_rails/langs/ko.js +50 -0
  49. data/vendor/assets/javascripts/redactor2_rails/langs/nl.js +50 -0
  50. data/vendor/assets/javascripts/redactor2_rails/langs/pl.js +50 -0
  51. data/vendor/assets/javascripts/redactor2_rails/langs/pt_br.js +50 -0
  52. data/vendor/assets/javascripts/redactor2_rails/langs/ru.js +50 -0
  53. data/vendor/assets/javascripts/redactor2_rails/langs/sv.js +50 -0
  54. data/vendor/assets/javascripts/redactor2_rails/langs/tr.js +50 -0
  55. data/vendor/assets/javascripts/redactor2_rails/langs/zh_cn.js +52 -0
  56. data/vendor/assets/javascripts/redactor2_rails/langs/zh_tw.js +50 -0
  57. data/vendor/assets/javascripts/redactor2_rails/plugins.js +4 -0
  58. data/vendor/assets/javascripts/redactor2_rails/plugins/clips.js +60 -0
  59. data/vendor/assets/javascripts/redactor2_rails/plugins/fullscreen.js +159 -0
  60. data/vendor/assets/javascripts/redactor2_rails/plugins/source.js +195 -0
  61. data/vendor/assets/javascripts/redactor2_rails/plugins/textdirection.js +36 -0
  62. data/vendor/assets/javascripts/redactor2_rails/redactor.js +9989 -0
  63. data/vendor/assets/javascripts/redactor2_rails/redactor.min.js +13 -0
  64. data/vendor/assets/stylesheets/redactor2_rails/css/redactor.css +931 -0
  65. data/vendor/assets/stylesheets/redactor2_rails/index.css +1 -0
  66. data/vendor/assets/stylesheets/redactor2_rails/plugins.css +1 -0
  67. data/vendor/assets/stylesheets/redactor2_rails/plugins/clips.css +10 -0
  68. metadata +183 -0
@@ -0,0 +1,50 @@
1
+ (function ($)
2
+ {
3
+ $.Redactor.opts.langs['tr'] = {
4
+ "format": "Format",
5
+ "image": "Görsel",
6
+ "file": "Dosya",
7
+ "link": "Link",
8
+ "bold": "Kalın",
9
+ "italic": "İtalik",
10
+ "deleted": "Üzeri çizgili",
11
+ "underline": "Altı çizgili",
12
+ "bold-abbr": "B",
13
+ "italic-abbr": "I",
14
+ "deleted-abbr": "S",
15
+ "underline-abbr": "U",
16
+ "lists": "Listeleme",
17
+ "link-insert": "Link ekle",
18
+ "link-edit": "Linki düzenle",
19
+ "link-in-new-tab": "Yeni bir pencerede aç",
20
+ "unlink": "Linki Kaldır",
21
+ "cancel": "Vazgeç",
22
+ "close": "Kapat",
23
+ "insert": "Ekle",
24
+ "save": "Kaydet",
25
+ "delete": "Sil",
26
+ "text": "Metin",
27
+ "edit": "Düzenle",
28
+ "title": "Başlık",
29
+ "paragraph": "Normal yazı",
30
+ "quote": "Alıntı",
31
+ "code": "Kod",
32
+ "heading1": "Başlık 1",
33
+ "heading2": "Başlık 2",
34
+ "heading3": "Başlık 3",
35
+ "heading4": "Başlık 4",
36
+ "heading5": "Başlık 5",
37
+ "heading6": "Başlık 6",
38
+ "filename": "İsim",
39
+ "optional": "opsiyonel",
40
+ "unorderedlist": "Sırasız Liste",
41
+ "orderedlist": "Sıralı Liste",
42
+ "outdent": "Dışarı Doğru",
43
+ "indent": "İçeri Doğru",
44
+ "horizontalrule": "Çizgi",
45
+ "upload-label": "Dosyayı buraya sürukle veya ",
46
+ "accessibility-help-label": "Zenginleştirilmiş yazı editorü",
47
+ "caption": "Caption"
48
+ };
49
+
50
+ })(jQuery);
@@ -0,0 +1,52 @@
1
+ (function ($)
2
+ {
3
+ $.Redactor.opts.langs['zh_cn'] = {
4
+ "format": "格式",
5
+ "image": "图片",
6
+ "file": "文件",
7
+ "link": "链接",
8
+ "bold": "加粗",
9
+ "italic": "斜体",
10
+ "deleted": "删除线",
11
+ "underline": "底线",
12
+ "bold-abbr": "B",
13
+ "italic-abbr": "I",
14
+ "deleted-abbr": "S",
15
+ "underline-abbr": "U",
16
+ "lists": "列表",
17
+ "link-insert": "插入链接",
18
+ "link-edit": "编辑链接",
19
+ "link-in-new-tab": "在新页面中打开",
20
+ "unlink": "取消链接",
21
+ "cancel": "取消",
22
+ "close": "关闭",
23
+ "insert": "插入",
24
+ "save": "保存",
25
+ "delete": "删除",
26
+ "text": "文本",
27
+ "edit": "编辑",
28
+ "title": "标题",
29
+ "paragraph": "段落",
30
+ "quote": "引用",
31
+ "code": "代码",
32
+ "heading1": "标题 1",
33
+ "heading2": "标题 2",
34
+ "heading3": "标题 3",
35
+ "heading4": "标题 4",
36
+ "heading5": "标题 5",
37
+ "heading6": "标题 6",
38
+ "filename": "文件名",
39
+ "optional": "optional",
40
+ "unorderedlist": "无序列表",
41
+ "orderedlist": "有序列表",
42
+ "outdent": "向左缩进",
43
+ "indent": "向右缩进",
44
+ "horizontalrule": "水平分隔线",
45
+ "upload-label": "上传文件",
46
+ "table": "表格",
47
+ "video": "视频",
48
+ "accessibility-help-label": "富文本编辑器",
49
+ "caption": "Caption"
50
+ };
51
+
52
+ })(jQuery);
@@ -0,0 +1,50 @@
1
+ (function ($)
2
+ {
3
+ $.Redactor.opts.langs['zh_tw'] = {
4
+ "format": "樣式",
5
+ "image": "插入圖片",
6
+ "file": "插入文件",
7
+ "link": "連結",
8
+ "bold": "將文字變成粗體",
9
+ "italic": "將文字變成斜體",
10
+ "deleted": "刪除線",
11
+ "underline": "底線",
12
+ "bold-abbr": "B",
13
+ "italic-abbr": "I",
14
+ "deleted-abbr": "S",
15
+ "underline-abbr": "U",
16
+ "lists": "列表",
17
+ "link-insert": "插入連結",
18
+ "link-edit": "編輯連結",
19
+ "link-in-new-tab": "開啟新分頁",
20
+ "unlink": "移除連結",
21
+ "cancel": "取消",
22
+ "close": "關閉",
23
+ "insert": "插入",
24
+ "save": "儲存",
25
+ "delete": "刪除",
26
+ "text": "內文",
27
+ "edit": "編輯",
28
+ "title": "標題",
29
+ "paragraph": "段落",
30
+ "quote": "引用",
31
+ "code": "原始碼",
32
+ "heading1": "標題 1",
33
+ "heading2": "標題 2",
34
+ "heading3": "標題 3",
35
+ "heading4": "標題 4",
36
+ "heading5": "標題 5",
37
+ "heading6": "標題 6",
38
+ "filename": "檔案名稱",
39
+ "optional": "optional",
40
+ "unorderedlist": "項目列表",
41
+ "orderedlist": "編號列表",
42
+ "outdent": "減少縮排",
43
+ "indent": "增加縮排",
44
+ "horizontalrule": "插入水平線",
45
+ "upload-label": "拖曳檔案",
46
+ "accessibility-help-label": "Rich text editor",
47
+ "caption": "Caption"
48
+ };
49
+
50
+ })(jQuery);
@@ -0,0 +1,4 @@
1
+ //= require ./plugins/clips
2
+ //= require ./plugins/fullscreen
3
+ //= require ./plugins/source
4
+ //= require ./plugins/textdirection
@@ -0,0 +1,60 @@
1
+ (function($)
2
+ {
3
+ $.Redactor.prototype.clips = function()
4
+ {
5
+ return {
6
+ init: function()
7
+ {
8
+ var items = [
9
+ ['Lorem ipsum...', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'],
10
+ ['Red label', '<b class="label-red">Label</b>']
11
+ ];
12
+
13
+ this.clips.template = $('<ul id="redactor-modal-list">');
14
+
15
+ for (var i = 0; i < items.length; i++)
16
+ {
17
+ var li = $('<li>');
18
+ var a = $('<a href="#" class="redactor-clips-link">').text(items[i][0]);
19
+ var div = $('<div class="redactor-clips">').hide().html(items[i][1]);
20
+
21
+ li.append(a);
22
+ li.append(div);
23
+ this.clips.template.append(li);
24
+ }
25
+
26
+ this.modal.addTemplate('clips', '<div class="modal-section">' + this.utils.getOuterHtml(this.clips.template) + '</div>');
27
+
28
+ var button = this.button.add('clips', 'Clips');
29
+
30
+ this.button.addCallback(button, this.clips.show);
31
+
32
+ },
33
+ show: function()
34
+ {
35
+ this.modal.load('clips', 'Insert Clips', 500);
36
+
37
+ $('#redactor-modal-list').find('.redactor-clips-link').each($.proxy(this.clips.load, this));
38
+
39
+ this.modal.show();
40
+ },
41
+ load: function(i,s)
42
+ {
43
+ $(s).on('click', $.proxy(function(e)
44
+ {
45
+ e.preventDefault();
46
+ this.clips.insert($(s).next().html());
47
+
48
+ }, this));
49
+ },
50
+ insert: function(html)
51
+ {
52
+ this.buffer.set();
53
+ this.air.collapsedEnd();
54
+ this.insert.html(html);
55
+ this.modal.close();
56
+ }
57
+ };
58
+ };
59
+ })(jQuery);
60
+
@@ -0,0 +1,159 @@
1
+ (function($)
2
+ {
3
+ $.Redactor.prototype.fullscreen = function()
4
+ {
5
+ return {
6
+ langs: {
7
+ en: {
8
+ "fullscreen": "Fullscreen"
9
+ }
10
+ },
11
+ init: function()
12
+ {
13
+ this.fullscreen.isOpen = false;
14
+
15
+ var button = this.button.add('fullscreen', this.lang.get('fullscreen'));
16
+ this.button.addCallback(button, this.fullscreen.toggle);
17
+
18
+ if (this.opts.fullscreen)
19
+ {
20
+ this.fullscreen.toggle();
21
+ }
22
+
23
+ },
24
+ enable: function()
25
+ {
26
+ this.fullscreen.isOpened = false;
27
+ this.button.setActive('fullscreen');
28
+ this.fullscreen.isOpen = true;
29
+
30
+ if (!this.opts.fullscreen)
31
+ {
32
+ this.selection.save();
33
+ }
34
+
35
+ if (this.opts.toolbarExternal)
36
+ {
37
+ this.fullscreen.toolcss = {};
38
+ this.fullscreen.boxcss = {};
39
+ this.fullscreen.toolcss.width = this.$toolbar.css('width');
40
+ this.fullscreen.toolcss.top = this.$toolbar.css('top');
41
+ this.fullscreen.toolcss.position = this.$toolbar.css('position');
42
+ this.fullscreen.boxcss.top = this.$box.css('top');
43
+ }
44
+
45
+ this.fullscreen.height = this.core.editor().height();
46
+
47
+ if (this.opts.maxHeight)
48
+ {
49
+ this.core.editor().css('max-height', '');
50
+ }
51
+
52
+ if (this.opts.minHeight)
53
+ {
54
+ this.core.editor().css('min-height', '');
55
+ }
56
+
57
+ if (!this.$fullscreenPlaceholder)
58
+ {
59
+ this.$fullscreenPlaceholder = $('<div/>');
60
+ }
61
+
62
+ this.$fullscreenPlaceholder.insertAfter(this.$box);
63
+
64
+ this.core.box().appendTo(document.body);
65
+ this.core.box().addClass('redactor-box-fullscreen');
66
+
67
+ $('body').addClass('redactor-body-fullscreen');
68
+ $('body, html').css('overflow', 'hidden');
69
+
70
+ this.fullscreen.resize();
71
+
72
+ if (!this.opts.fullscreen)
73
+ {
74
+ this.selection.restore();
75
+ }
76
+
77
+ this.toolbar.observeScrollDisable();
78
+ $(window).on('resize.redactor-plugin-fullscreen', $.proxy(this.fullscreen.resize, this));
79
+ $(document).scrollTop(0, 0);
80
+
81
+ var self = this;
82
+ setTimeout(function()
83
+ {
84
+ self.fullscreen.isOpened = true;
85
+ }, 10);
86
+
87
+ },
88
+ disable: function()
89
+ {
90
+ this.button.setInactive('fullscreen');
91
+ this.fullscreen.isOpened = undefined;
92
+ this.fullscreen.isOpen = false;
93
+ this.selection.save();
94
+
95
+ $(window).off('resize.redactor-plugin-fullscreen');
96
+ $('body, html').css('overflow', '');
97
+
98
+ this.core.box().insertBefore(this.$fullscreenPlaceholder);
99
+ this.$fullscreenPlaceholder.remove();
100
+
101
+ this.core.box().removeClass('redactor-box-fullscreen').css({ width: 'auto', height: 'auto' });
102
+ this.core.box().removeClass('redactor-box-fullscreen');
103
+
104
+ if (this.opts.toolbarExternal)
105
+ {
106
+ this.core.box().css('top', this.fullscreen.boxcss.top);
107
+ this.core.toolbar().css({
108
+ 'width': this.fullscreen.toolcss.width,
109
+ 'top': this.fullscreen.toolcss.top,
110
+ 'position': this.fullscreen.toolcss.position
111
+ });
112
+ }
113
+
114
+ if (this.opts.minHeight)
115
+ {
116
+ this.core.editor().css('minHeight', this.opts.minHeight);
117
+ }
118
+
119
+ if (this.opts.maxHeight)
120
+ {
121
+ this.core.editor().css('maxHeight', this.opts.maxHeight);
122
+ }
123
+
124
+ this.core.editor().css('height', 'auto');
125
+ this.selection.restore();
126
+ },
127
+ toggle: function()
128
+ {
129
+ return (this.fullscreen.isOpen) ? this.fullscreen.disable() : this.fullscreen.enable();
130
+ },
131
+ resize: function()
132
+ {
133
+ if (!this.fullscreen.isOpen)
134
+ {
135
+ return;
136
+ }
137
+
138
+ var toolbarHeight = this.button.toolbar().height();
139
+ var padding = parseInt(this.core.editor().css('padding-top')) + parseInt(this.core.editor().css('padding-bottom'));
140
+ var height = $(window).height() - toolbarHeight - padding;
141
+
142
+ this.core.box().width($(window).width()).height(height);
143
+
144
+ if (this.opts.toolbarExternal)
145
+ {
146
+ this.core.toolbar().css({
147
+ 'top': '0px',
148
+ 'position': 'absolute',
149
+ 'width': '100%'
150
+ });
151
+
152
+ this.core.box().css('top', toolbarHeight + 'px');
153
+ }
154
+
155
+ this.core.editor().height(height);
156
+ }
157
+ };
158
+ };
159
+ })(jQuery);
@@ -0,0 +1,195 @@
1
+ (function($)
2
+ {
3
+ $.Redactor.prototype.source = function()
4
+ {
5
+ return {
6
+ init: function()
7
+ {
8
+ var button = this.button.addFirst('html', 'HTML');
9
+ this.button.addCallback(button, this.source.toggle);
10
+
11
+ var style = {
12
+ 'width': '100%',
13
+ 'margin': '0',
14
+ 'background': '#111',
15
+ 'box-sizing': 'border-box',
16
+ 'color': 'rgba(255, 255, 255, .8)',
17
+ 'font-size': '14px',
18
+ 'outline': 'none',
19
+ 'padding': '16px',
20
+ 'line-height': '22px',
21
+ 'font-family': 'Menlo, Monaco, Consolas, "Courier New", monospace'
22
+ };
23
+
24
+ this.source.$textarea = $('<textarea />');
25
+ this.source.$textarea.css(style).hide();
26
+
27
+ if (this.opts.type === 'textarea')
28
+ {
29
+ this.core.box().append(this.source.$textarea);
30
+ }
31
+ else
32
+ {
33
+ this.core.box().after(this.source.$textarea);
34
+ }
35
+
36
+ this.core.element().on('destroy.callback.redactor', $.proxy(function()
37
+ {
38
+ this.source.$textarea.remove();
39
+
40
+ }, this));
41
+
42
+ },
43
+ toggle: function()
44
+ {
45
+ return (this.source.$textarea.hasClass('open')) ? this.source.hide() : this.source.show();
46
+ },
47
+ setCaretOnShow: function()
48
+ {
49
+ this.source.offset = this.offset.get();
50
+ var scroll = $(window).scrollTop();
51
+
52
+ var width = this.core.editor().innerWidth();
53
+ var height = this.core.editor().innerHeight();
54
+
55
+ // caret position sync
56
+ this.source.start = 0;
57
+ this.source.end = 0;
58
+ var $editorDiv = $("<div/>").append($.parseHTML(this.core.editor().html(), document, true));
59
+ var $selectionMarkers = $editorDiv.find("span.redactor-selection-marker");
60
+
61
+ if ($selectionMarkers.length > 0)
62
+ {
63
+ var editorHtml = $editorDiv.html().replace(/&amp;/g, '&');
64
+
65
+ if ($selectionMarkers.length === 1)
66
+ {
67
+ this.source.start = this.utils.strpos(editorHtml, $editorDiv.find("#selection-marker-1").prop("outerHTML"));
68
+ this.source.end = this.source.start;
69
+ }
70
+ else if ($selectionMarkers.length === 2)
71
+ {
72
+ this.source.start = this.utils.strpos(editorHtml, $editorDiv.find("#selection-marker-1").prop("outerHTML"));
73
+ this.source.end = this.utils.strpos(editorHtml, $editorDiv.find("#selection-marker-2").prop("outerHTML")) - $editorDiv.find("#selection-marker-1").prop("outerHTML").toString().length;
74
+ }
75
+ }
76
+
77
+ },
78
+ setCaretOnHide: function(html)
79
+ {
80
+ this.source.start = this.source.$textarea.get(0).selectionStart;
81
+ this.source.end = this.source.$textarea.get(0).selectionEnd;
82
+
83
+ // if selection starts from end
84
+ if (this.source.start > this.source.end && this.source.end > 0)
85
+ {
86
+ var tempStart = this.source.end;
87
+ var tempEnd = this.source.start;
88
+
89
+ this.source.start = tempStart;
90
+ this.source.end = tempEnd;
91
+ }
92
+
93
+ this.source.start = this.source.enlargeOffset(html, this.source.start);
94
+ this.source.end = this.source.enlargeOffset(html, this.source.end);
95
+
96
+ html = html.substr(0, this.source.start) + this.marker.html(1) + html.substr(this.source.start);
97
+
98
+ if (this.source.end > this.source.start)
99
+ {
100
+ var markerLength = this.marker.html(1).toString().length;
101
+
102
+ html = html.substr(0, this.source.end + markerLength) + this.marker.html(2) + html.substr(this.source.end + markerLength);
103
+ }
104
+
105
+ return html;
106
+
107
+ },
108
+ hide: function()
109
+ {
110
+ this.source.$textarea.removeClass('open').hide();
111
+ this.source.$textarea.off('.redactor-source');
112
+
113
+ var code = this.source.$textarea.val();
114
+
115
+ code = this.paragraphize.load(code);
116
+ code = this.source.setCaretOnHide(code);
117
+
118
+ this.code.start(code);
119
+ this.button.enableAll();
120
+ this.core.editor().show().focus();
121
+ this.selection.restore();
122
+ this.code.sync();
123
+ },
124
+ show: function()
125
+ {
126
+ this.selection.save();
127
+ this.source.setCaretOnShow();
128
+
129
+ var height = this.core.editor().innerHeight();
130
+ var code = this.code.get();
131
+
132
+ code = code.replace(/\n\n\n/g, "\n");
133
+ code = code.replace(/\n\n/g, "\n");
134
+
135
+ this.core.editor().hide();
136
+ this.button.disableAll('html');
137
+ this.source.$textarea.val(code).height(height).addClass('open').show();
138
+ this.source.$textarea.on('keyup.redactor-source', $.proxy(function()
139
+ {
140
+ if (this.opts.type === 'textarea')
141
+ {
142
+ this.core.textarea().val(this.source.$textarea.val());
143
+ }
144
+
145
+ }, this));
146
+
147
+ this.marker.remove();
148
+
149
+ $(window).scrollTop(scroll);
150
+
151
+ if (this.source.$textarea[0].setSelectionRange)
152
+ {
153
+ this.source.$textarea[0].setSelectionRange(this.source.start, this.source.end);
154
+ }
155
+
156
+ this.source.$textarea[0].scrollTop = 0;
157
+
158
+ setTimeout($.proxy(function()
159
+ {
160
+ this.source.$textarea.focus();
161
+
162
+ }, this), 0);
163
+ },
164
+ enlargeOffset: function(html, offset)
165
+ {
166
+ var htmlLength = html.length;
167
+ var c = 0;
168
+
169
+ if (html[offset] === '>')
170
+ {
171
+ c++;
172
+ }
173
+ else
174
+ {
175
+ for(var i = offset; i <= htmlLength; i++)
176
+ {
177
+ c++;
178
+
179
+ if (html[i] === '>')
180
+ {
181
+ break;
182
+ }
183
+ else if (html[i] === '<' || i === htmlLength)
184
+ {
185
+ c = 0;
186
+ break;
187
+ }
188
+ }
189
+ }
190
+
191
+ return offset + c;
192
+ }
193
+ };
194
+ };
195
+ })(jQuery);