imperavi-rails 0.0.2.beta → 0.0.3.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/README.md +16 -4
  2. data/app/assets/javascripts/imperavi-rails/imperavi/dd_upload.js +100 -0
  3. data/app/assets/javascripts/imperavi-rails/imperavi/linkify.js +30 -0
  4. data/app/assets/javascripts/imperavi-rails/imperavi/redactor.js +104 -364
  5. data/app/assets/javascripts/imperavi-rails/imperavi/textselect.js +14 -0
  6. data/app/assets/javascripts/imperavi-rails/imperavi.js +4 -0
  7. data/app/helpers/imperavi_rails/imperavi_helper.rb +2 -2
  8. data/lib/imperavi-rails/version.rb +1 -1
  9. data/spec/dummy/app/assets/stylesheets/application.css.scss +1 -9
  10. data/spec/dummy/app/views/pages/index.html.erb +7 -17
  11. data/spec/dummy/db/development.sqlite3 +0 -0
  12. data/spec/dummy/log/development.log +1197 -0
  13. data/spec/dummy/public/system/dragonfly/development/2012/02/03/10_10_05_126_6.jpg +0 -0
  14. data/spec/dummy/public/system/dragonfly/development/2012/02/03/10_10_05_126_6.jpg.meta +4 -0
  15. data/spec/dummy/tmp/cache/assets/C41/5B0/sprockets%2F095415e1141a435237aa9464752d21fd +242 -0
  16. data/spec/dummy/tmp/cache/assets/CBE/FC0/sprockets%2Ff5431a64e341b062b7530132a5c1ea5a +1726 -0
  17. data/spec/dummy/tmp/cache/assets/CC0/310/sprockets%2Fb372e5f868e8a8801e126262f66c9c08 +16 -0
  18. data/spec/dummy/tmp/cache/assets/CC5/C10/sprockets%2F7c81f5c40dc9b87819488e127f487a04 +513 -0
  19. data/spec/dummy/tmp/cache/assets/CE5/650/sprockets%2F8ab512c9b33ac90e699b73469d71f061 +269 -0
  20. data/spec/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2 +81 -0
  21. data/spec/dummy/tmp/cache/assets/D02/F90/sprockets%2Ff029f33d65d53d13d3c0fd29e0c08133 +10 -0
  22. data/spec/dummy/tmp/cache/assets/D06/850/sprockets%2F9027c767fa3c09c1a605eae10b43d549 +9272 -0
  23. data/spec/dummy/tmp/cache/assets/D0C/0C0/sprockets%2F106b7f622fb804e4248c862abe73a4c8 +16 -0
  24. data/spec/dummy/{app/assets/stylesheets/scaffold.css → tmp/cache/assets/D11/D20/sprockets%2Fcac21eac42152981882bf9e489316af4} +6 -1
  25. data/spec/dummy/tmp/cache/assets/D24/8E0/sprockets%2F47f976dc55ebc7889e349067c9ba01b2 +16 -0
  26. data/spec/dummy/tmp/cache/assets/D2A/450/sprockets%2F58e369b37e5157ea746a485eea17e9f7 +28 -0
  27. data/spec/dummy/tmp/cache/assets/D34/D90/sprockets%2Fac3fb880b6bb140d16d5b4a6916e5067 +52 -0
  28. data/spec/dummy/tmp/cache/assets/D38/C80/sprockets%2Fb7152c93aa41253e9ed17d71a5c0eb88 +16 -0
  29. data/spec/dummy/tmp/cache/assets/D58/6D0/sprockets%2Fd2a3ab2b5401861dcd2e343ca6e4923e +37 -0
  30. data/spec/dummy/tmp/cache/assets/D59/260/sprockets%2Fd513a46ce8d83f003a733cb306dfe01a +1598 -0
  31. data/spec/dummy/tmp/cache/assets/D64/190/sprockets%2Ffdfa1bbf71247a2b9ef0b97732603e02 +0 -0
  32. data/spec/dummy/tmp/cache/assets/D6D/7C0/sprockets%2Fa4b9caa51f636e2b2db868c480e2a487 +8 -0
  33. data/spec/dummy/tmp/cache/assets/D73/170/sprockets%2Ffe70d93b5d3398dd8d0c6a3d701290ef +123 -0
  34. data/spec/dummy/tmp/cache/assets/D76/B30/sprockets%2Fce979145545abbfd4ca50fea3489554c +395 -0
  35. data/spec/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +9655 -0
  36. data/spec/dummy/tmp/cache/assets/D9B/E30/sprockets%2Fd87c8ca46743542cace533cfe91ae1d0 +495 -0
  37. data/spec/dummy/tmp/cache/assets/DA2/EA0/sprockets%2F9e95d2e1a4da7fafb60b9b782a53b753 +378 -0
  38. data/spec/dummy/tmp/cache/assets/DA8/F60/sprockets%2Fbb2cd57d63160c94d622ef9d91ccef68 +16 -0
  39. data/spec/dummy/tmp/cache/assets/DAC/DC0/sprockets%2Fe8cdb03f780ff87851dd459dc844ad1b +246 -0
  40. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +61 -0
  41. data/spec/dummy/tmp/cache/assets/E05/F10/sprockets%2Fb3d9b0e88cdded276ebdce333e338a85 +30 -0
  42. data/spec/dummy/tmp/cache/assets/E22/CE0/sprockets%2F6fe70d27fda81ea53c8bdaeb1b112dd7 +9289 -0
  43. data/spec/dummy/tmp/cache/assets/E26/210/sprockets%2Fbb3accabff7037e93dc9a3373f4a5b7a +1580 -0
  44. data/spec/dummy/tmp/cache/assets/E66/AE0/sprockets%2Ffcb98ed9ac3e15f6d9e59fd00cbb2d3d +16 -0
  45. data/spec/dummy/tmp/cache/sass/9bd7199bacdbfc23c47b913698aa7195d1e0f382/application.css.scssc +0 -0
  46. data/spec/dummy/tmp/cache/sass/bc54e898614d486bf9338d646e8cd056915d4779/imperavi-base.css.scssc +0 -0
  47. data/spec/dummy/tmp/cache/sass/bc54e898614d486bf9338d646e8cd056915d4779/redactor.css.scssc +0 -0
  48. data/spec/dummy/tmp/cache/sass/bc54e898614d486bf9338d646e8cd056915d4779/wym.css.scssc +0 -0
  49. data/spec/dummy/tmp/dragonfly/cache/body/00/4aecc0c59254723e83737f8928702ffd7bb98b +373 -0
  50. data/spec/dummy/tmp/dragonfly/cache/body/16/c5ea89574eb557096b3fefd758954e84a34381 +0 -0
  51. data/spec/dummy/tmp/dragonfly/cache/body/21/199c9bdb6c7f65200a15ca0934612bcae4204c +242 -0
  52. data/spec/dummy/tmp/dragonfly/cache/body/42/bb515c02767a37104eca97f75df3b4a49e1759 +242 -0
  53. data/spec/dummy/tmp/dragonfly/cache/body/48/cf4eb3ec838cdab2af24f4603e7954ab5012ee +0 -0
  54. data/spec/dummy/tmp/dragonfly/cache/body/4a/72b5c050f6e3702f880e19fcf37793c135cd3d +0 -0
  55. data/spec/dummy/tmp/dragonfly/cache/body/61/e9711fd55eccdf62882cb8d127b22664f7023f +3 -0
  56. data/spec/dummy/tmp/dragonfly/cache/body/74/98c8a3bb6ee03af2b6952e797e632938d84649 +237 -0
  57. data/spec/dummy/tmp/dragonfly/cache/body/77/78d2df49ed1274a18f2c479b5747a91417458f +490 -0
  58. data/spec/dummy/tmp/dragonfly/cache/body/8e/46450213e0599dab4f0033c16b21731ca5e19c +242 -0
  59. data/spec/dummy/tmp/dragonfly/cache/body/a4/2e62d48de5370a8402707dd02fcf64039923b4 +0 -0
  60. data/spec/dummy/tmp/dragonfly/cache/body/a8/85ba08a1465f458ec2e999aecc73ba6b885520 +1575 -0
  61. data/spec/dummy/tmp/dragonfly/cache/body/ab/c30526420462e4081de3dcbc7598a7930bbc51 +0 -0
  62. data/spec/dummy/tmp/dragonfly/cache/body/b2/f1d81a83ca37d428780d1d9deb87cf0312cb62 +0 -0
  63. data/spec/dummy/tmp/dragonfly/cache/body/bb/cf048304dee182fc21ba43f408d8623c2f65b1 +1721 -0
  64. data/{app/assets/javascripts/imperavi-rails/application.js → spec/dummy/tmp/dragonfly/cache/body/c2/d1fe276d6e527c155855e99dc19d239b6d71f3} +1 -3
  65. data/spec/dummy/tmp/dragonfly/cache/body/d6/1d64e39570cd647cee3d3a62efa17ab2290d1e +0 -0
  66. data/spec/dummy/tmp/dragonfly/cache/body/ef/f130cc312268f0864d651bb53d4f83189b925a +9267 -0
  67. data/spec/dummy/tmp/dragonfly/cache/body/fb/54a1604f6c72b35d8b9c3da9f3899d77db70dd +1834 -0
  68. data/spec/dummy/tmp/dragonfly/cache/meta/1d/f723c27427056dd58a506f1e4f15020442098e +0 -0
  69. data/spec/dummy/tmp/dragonfly/cache/meta/23/4f7740cb6118c7c530ce379339a99828a75ef3 +0 -0
  70. data/spec/dummy/tmp/dragonfly/cache/meta/2d/fe381b58b48b16278672bd61db736e4e920955 +0 -0
  71. data/spec/dummy/tmp/dragonfly/cache/meta/39/b52b68255f54efe8cb853fd153088f94a7661a +0 -0
  72. data/spec/dummy/tmp/dragonfly/cache/meta/55/32c60f25996b8e8a9fdf7125956c5204fa8792 +0 -0
  73. data/spec/dummy/tmp/dragonfly/cache/meta/66/b6e26427e56a9f9ade00d4cf5d615679f0f7a7 +0 -0
  74. data/spec/dummy/tmp/dragonfly/cache/meta/66/f44aba1428593600ff0e47ea6aa54362e39a59 +0 -0
  75. data/spec/dummy/tmp/dragonfly/cache/meta/78/d74c0cd05a77c0c06acb622761d30c9ea00bb3 +0 -0
  76. data/spec/dummy/tmp/dragonfly/cache/meta/80/5841ac20acdd8dd41460c8346294abc5c4dd8f +0 -0
  77. data/spec/dummy/tmp/dragonfly/cache/meta/e7/6d1dc2d45d19440e781f6c5d00f39d8aeb4da1 +0 -0
  78. data/spec/dummy/tmp/dragonfly/cache/meta/ee/fe74949a8c2a0bbc077385a12944d9f98a12e0 +0 -0
  79. data/spec/dummy/tmp/dragonfly/cache/meta/ef/d71b44567b90c7f85e9bd0576e4b7e55bd3565 +0 -0
  80. data/spec/dummy/tmp/dragonfly/cache/meta/f4/2f71b4755920b57e574c91123765511a8f0b25 +0 -0
  81. data/spec/dummy/tmp/dragonfly/cache/meta/f5/b1288f6769945a2de532e359e061896e1197df +0 -0
  82. data/spec/dummy/tmp/dragonfly/cache/meta/f9/67ac04386c59253bd80f4034d18af166cc5691 +0 -0
  83. data/spec/dummy/tmp/pids/server.pid +1 -0
  84. metadata +260 -122
  85. data/app/assets/stylesheets/imperavi-rails/imperavi/imperavi.css.scss +0 -150
  86. data/spec/dummy/app/assets/stylesheets/pages.css +0 -4
  87. data/spec/dummy/db/test.sqlite3 +0 -0
@@ -0,0 +1,1721 @@
1
+ // Define: Linkify plugin from stackoverflow
2
+ (function($){
3
+ var url2 = /(^|<|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|>|$)/g;
4
+
5
+ linkifyThis = function ()
6
+ {
7
+ var childNodes = this.childNodes,
8
+ i = childNodes.length;
9
+ while(i--)
10
+ {
11
+ var n = childNodes[i];
12
+ if (n.nodeType == 3)
13
+ {
14
+ var html = n.nodeValue;
15
+ if (html)
16
+ {
17
+ html = html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(url2, '$1<a href="$2">$2</a>$5');
18
+ $(n).after(html).remove();
19
+ }
20
+ }
21
+ else if (n.nodeType == 1 && !/^(a|button|textarea)$/i.test(n.tagName)) linkifyThis.call(n);
22
+ }
23
+ };
24
+
25
+ $.fn.linkify = function ()
26
+ {
27
+ this.each(linkifyThis);
28
+ };
29
+
30
+ })(jQuery);
31
+ /* jQuery plugin textselect
32
+ * version: 0.9
33
+ * author: Josef Moravec, josef.moravec@gmail.com
34
+ * updated: Imperavi
35
+ *
36
+ */
37
+
38
+ (function($){$.event.special.textselect={setup:function(data,namespaces)
39
+ {$(this).data("textselected",false);$(this).data("ttt",data);$(this).bind('mouseup',$.event.special.textselect.handler);},teardown:function(data)
40
+ {$(this).unbind('mouseup',$.event.special.textselect.handler);},handler:function(event)
41
+ {var data=$(this).data("ttt");var text=$.event.special.textselect.getSelectedText(data).toString();if(text!='')
42
+ {$(this).data("textselected",true);event.type="textselect";event.text=text;$.event.handle.apply(this,arguments);}},getSelectedText:function(data)
43
+ {var text='';var frame=$('#imp_redactor_frame_'+data).get(0);if(frame.contentWindow.getSelection)text=frame.contentWindow.getSelection();else if(frame.contentWindow.document.getSelection) text=frame.contentWindow.document.getSelection();else if(frame.contentWindow.document.selection)text=frame.contentWindow.document.selection.createRange().text;return text;}}
44
+ $.event.special.textunselect={setup:function(data,namespaces){$(this).data("rttt",data);$(this).data("textselected",false);$(this).bind('mouseup',$.event.special.textunselect.handler);$(this).bind('keyup',$.event.special.textunselect.handlerKey)},teardown:function(data){$(this).unbind('mouseup',$.event.special.textunselect.handler);},handler:function(event){if($(this).data("textselected")){var data=$(this).data("rttt");var text=$.event.special.textselect.getSelectedText(data).toString();if(text==''){$(this).data("textselected",false);event.type="textunselect";$.event.handle.apply(this,arguments);}}},handlerKey:function(event){if($(this).data("textselected")){var data=$(this).data("rttt");var text=$.event.special.textselect.getSelectedText(data).toString();if((event.keyCode=27)&&(text=='')){$(this).data("textselected",false);event.type="textunselect";$.event.handle.apply(this,arguments);}}}}})(jQuery);
45
+
46
+ /*
47
+ Plugin Drag and drop Upload v1.0.0
48
+ http://imperavi.com/
49
+ Copyright 2011, Imperavi Ltd.
50
+ */
51
+
52
+ (function($){
53
+
54
+ // Initialization
55
+ $.fn.dragupload = function(options)
56
+ {
57
+ return this.each(function() {
58
+ var obj = new Construct(this, options);
59
+ obj.init();
60
+ });
61
+ };
62
+
63
+ // Options and variables
64
+ function Construct(el, options) {
65
+ this.opts = $.extend({
66
+ url: false,
67
+ success: false,
68
+ maxfilesize: 10485760, // 10MB
69
+ preview: false,
70
+ text: RLANG.drop_file_here,
71
+ atext: RLANG.or_choose
72
+ }, options);
73
+
74
+ this.$el = $(el);
75
+ };
76
+
77
+ // Functionality
78
+ Construct.prototype = {
79
+ init: function()
80
+ {
81
+ if (!$.browser.opera && !$.browser.msie)
82
+ {
83
+ this.droparea = $('<div class="redactor_droparea"></div>');
84
+ this.dropareabox = $('<div class="redactor_dropareabox">' + this.opts.text + '</div>');
85
+ this.dropalternative = $('<div class="redactor_dropalternative">' + this.opts.atext + '</div>');
86
+
87
+ this.droparea.append(this.dropareabox);
88
+
89
+ this.$el.before(this.droparea);
90
+ this.$el.before(this.dropalternative);
91
+
92
+
93
+ // drag over
94
+ this.dropareabox.bind('dragover', function() { return this.ondrag(); }.bind2(this));
95
+
96
+ // drag leave
97
+ this.dropareabox.bind('dragleave', function() { return this.ondragleave(); }.bind2(this));
98
+
99
+
100
+ // drop
101
+ this.dropareabox.get(0).ondrop = function(event) {
102
+ event.preventDefault();
103
+
104
+ this.dropareabox.removeClass('hover').addClass('drop');
105
+
106
+ var file = event.dataTransfer.files[0];
107
+ var fd = new FormData();
108
+
109
+ fd.append('file', file);
110
+
111
+ $.ajax({
112
+ url: this.opts.url,
113
+ data: fd,
114
+ //xhr: provider,
115
+ cache: false,
116
+ contentType: false,
117
+ processData: false,
118
+ type: 'POST',
119
+ success: function(data)
120
+ {
121
+ if (this.opts.success !== false) this.opts.success(data);
122
+
123
+ if (this.opts.preview === true) this.dropareabox.html(data);
124
+ //else this.dropareabox.text(this.opts.success_text);
125
+
126
+ }.bind2(this)
127
+ });
128
+
129
+
130
+ }.bind2(this);
131
+ }
132
+ },
133
+ ondrag: function()
134
+ {
135
+ this.dropareabox.addClass('hover');
136
+ return false;
137
+ },
138
+ ondragleave: function()
139
+ {
140
+ this.dropareabox.removeClass('hover');
141
+ return false;
142
+ }
143
+ };
144
+
145
+
146
+ })(jQuery);
147
+ /*
148
+ Redactor v7.2.0
149
+ Updated 20.11.2011
150
+
151
+ In English http://imperavi.com/
152
+ In Russian http://imperavi.ru/
153
+
154
+ Copyright (c) 2009-2012, Imperavi Ltd.
155
+ Dual licensed under the MIT or GPL Version 2 licenses.
156
+
157
+ Usage: $('#content').redactor();
158
+ */
159
+
160
+
161
+ var isCtrl = false;
162
+ var redactorActive = false;
163
+
164
+ var $table = false;
165
+ var $tbody = false;
166
+ var $thead = false;
167
+ var $current_tr = false;
168
+ var $current_td = false;
169
+
170
+ var deviceAndroid = "android";
171
+ var uagent = navigator.userAgent.toLowerCase();
172
+
173
+ // detect iOS and Android
174
+ function isiOS() {
175
+ return ((navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) || (navigator.platform.indexOf("iPad") != -1));
176
+ }
177
+
178
+ function detectAndroid() {
179
+ return uagent.search(deviceAndroid) > -1
180
+ }
181
+
182
+ function detectAndroidWebKit() {
183
+ if (detectAndroid()) {
184
+ return uagent.search('webkit') > -1
185
+ }
186
+
187
+ return false;
188
+ }
189
+
190
+ // redactor
191
+ (function($){
192
+ // Initialization
193
+ $.fn.redactor = function(options) {
194
+ if (isiOS() || detectAndroid() || detectAndroidWebKit()) return false;
195
+ var obj = new Construct(this, options);
196
+ obj.init();
197
+ return obj;
198
+ };
199
+
200
+ // Options and variables
201
+ function Construct(el, options) {
202
+ this.opts = $.extend({
203
+ air : false,
204
+ autosave : false, // false or url
205
+ interval : 20, // seconds
206
+ resize : true,
207
+ visual : true,
208
+ focus : false,
209
+ autoclear : true,
210
+ removeClasses : false,
211
+ removeStyles : true,
212
+ convertLinks : true,
213
+ autoformat : true,
214
+ clearOnInit : false,
215
+ overlay : true, // modal overlay
216
+ fileUploadCallback : false, // callback function
217
+ imageUploadCallback : false, // callback function
218
+
219
+ // Paths to various handlers
220
+ paths : {
221
+ // Editor css
222
+ stylesheets : ['/assets/imperavi-rails/imperavi/wym.css'],
223
+
224
+ // Toolbar
225
+ toolbar : '/imperavi/toolbar.js',
226
+
227
+ // Interface translations
228
+ language : '/imperavi/language.js',
229
+
230
+ // Typograf
231
+ typograf : '/imperavi/typograf',
232
+
233
+ // Dialogs
234
+ // TODO Add dialogs sizes
235
+ dialogs : {
236
+ file : '/imperavi/file?r',
237
+ fileEdit : '/imperavi/file_edit',
238
+ image : '/imperavi/image?r',
239
+ imageEdit : '/imperavi/image_edit',
240
+ link : '/imperavi/link',
241
+ table : '/imperavi/table',
242
+ video : '/imperavi/video'
243
+ },
244
+
245
+ // Images
246
+ images : {
247
+ upload : '/imperavi/images',
248
+ download : '/imperavi/images/777',
249
+ list : '/imperavi/images.json'
250
+ },
251
+
252
+ // Files
253
+ files : {
254
+ upload : '/imperavi/files',
255
+ download : '/imperavi/files/777', // /tests/file_download.php?file=
256
+ remove : '/imperavi/files/777' // /tests/file_delete.php?delete=
257
+ }
258
+ }
259
+ }, options);
260
+
261
+ this.$el = $(el);
262
+ };
263
+
264
+ // Functionality
265
+ Construct.prototype = {
266
+ init: function() {
267
+ if (this.opts.air) this.opts.toolbar = 'air';
268
+
269
+ // include lang and toolbar
270
+ this.include();
271
+
272
+ // sizes and id
273
+ this.frameID = this.$el.attr('id');
274
+ this.width = this.$el.css('width');
275
+ this.height = this.$el.css('height');
276
+
277
+ // modal overlay
278
+ if ($('#redactor_imp_modal_overlay').size() == 0) {
279
+ this.overlay = $('<div id="redactor_imp_modal_overlay" style="display: none;"></div>');
280
+ $('body').prepend(this.overlay);
281
+ }
282
+
283
+ // create container
284
+ this.box = $('<div id="imp_redactor_box_' + this.frameID + '" style="width: ' + this.width + ';" class="imp_redactor_box imp_redactor_box"></div>');
285
+
286
+ // air box
287
+ if (this.opts.air) {
288
+ this.air = $('<div id="imp_redactor_air_' + this.frameID + '" class="redactor_air" style="display: none;"></div>');
289
+ }
290
+
291
+ // create iframe
292
+ this.frame = $('<iframe frameborder="0" marginheight="0" marginwidth="0" vspace="0" hspace="0" scrolling="auto" id="imp_redactor_frame_' + this.frameID + '" style="height: ' + this.height + ';" class="imp_redactor_frame"></iframe>');
293
+
294
+ this.$el.hide();
295
+
296
+ // append box and frame
297
+ $(this.box).insertAfter(this.$el).append(this.frame).append(this.$el);
298
+
299
+ // toolbar
300
+ if (this.opts.toolbar !== false) this.buildToolbar();
301
+
302
+ // resizer
303
+ if (this.opts.resize) {
304
+ this.resizer = $('<div id="imp_redactor_resize' + this.frameID + '" class="imp_redactor_resize"><div></div></div>');
305
+ $(this.box).append(this.resizer);
306
+
307
+ $(this.resizer).mousedown(function(e) { this.initResize(e) }.bind2(this));
308
+ }
309
+
310
+ // enable
311
+ this.enable(this.$el.val());
312
+
313
+ $(this.doc).click(function() { this.hideAllDropDown() }.bind2(this));
314
+
315
+ if (this.opts.autoclear) {
316
+ $(this.doc).bind('paste', function(e) {
317
+ setTimeout(function () { this.clean(); }.bind2(this), 200);
318
+ }.bind2(this));
319
+ }
320
+
321
+ // air enable
322
+ this.enableAir();
323
+
324
+ // doc events
325
+ $(this.doc).keydown(function(e) {
326
+ if (e.ctrlKey || e.metaKey) isCtrl = true;
327
+ if (e.keyCode == 9) { this.execCommand('indent', false); return false; }
328
+ if (e.keyCode == 66 && isCtrl) { this.execCommand('bold', 'bold'); return false; }
329
+ if (e.keyCode == 73 && isCtrl) { this.execCommand('italic', 'italic'); return false; }
330
+
331
+ }.bind2(this)).keyup(function(e) {
332
+ isCtrl = false;
333
+
334
+ if (e.keyCode == 13) {
335
+ $(this.doc).linkify();
336
+ return true;
337
+ }
338
+
339
+ this.syncCode();
340
+ }.bind2(this));
341
+
342
+ // autosave
343
+ if (this.opts.autosave) {
344
+ setInterval(function() {
345
+ var html = this.getHtml();
346
+ $.post(this.opts.autosave, { data: html });
347
+ }.bind2(this), this.opts.interval*1000);
348
+ }
349
+
350
+ this.formSets();
351
+
352
+ // focus
353
+ if (this.opts.focus) this.focus();
354
+ },
355
+
356
+ /*
357
+ API
358
+ */
359
+ setHtml: function(html) {
360
+ this.doc.body.innerHTML = html;
361
+ this.docObserve();
362
+ },
363
+
364
+ getHtml: function() {
365
+ return this.doc.body.innerHTML;
366
+ },
367
+
368
+ getCode: function(clear) {
369
+ return this.$el.val();
370
+ },
371
+
372
+ focus: function() {
373
+ if ($.browser.msie) $(this.frame).load(function() { $(this).get(0).contentWindow.focus(); });
374
+ else this.frame.get(0).contentWindow.focus();
375
+ },
376
+
377
+ typo: function() {
378
+ var html = this.getHtml();
379
+
380
+ $.ajax({
381
+ url : this.opts.paths.typograf,
382
+ type : 'post',
383
+ data : 'redactor=' + escape(encodeURIComponent(html)),
384
+ success: function(data) {
385
+ this.setHtml(data);
386
+ }.bind2(this)
387
+ });
388
+ },
389
+
390
+ syncCode: function() {
391
+ var html = this.getHtml();
392
+
393
+ html = this.tidyUp(html);
394
+ html = html.replace(/\%7B/gi, '{');
395
+ html = html.replace(/\%7D/gi, '}');
396
+ html = html.replace(/<hr class="redactor_cut">/gi, '<!--more-->');
397
+ html = html.replace(/<hr class=redactor_cut>/gi, '<!--more-->');
398
+ this.$el.val(html);
399
+ },
400
+
401
+ destroy: function() {
402
+ var html = this.getCode();
403
+ $(this.box).after(this.$el)
404
+ this.box.remove();
405
+ this.$el.val(html).show();
406
+ },
407
+
408
+ // Include
409
+ include: function() {
410
+ // lang
411
+ $('head').append(
412
+ $('<script src="' + this.opts.paths.language + '"></script>')
413
+ );
414
+
415
+ // toolbar
416
+ // @tanraya
417
+ if (this.opts.toolbar !== false) {
418
+ $('head').append($('<script src="' + this.opts.paths.toolbar + '"></script>'));
419
+ }
420
+ },
421
+
422
+ // Enable
423
+ enable: function(html) {
424
+ this.doc = this.contentDocumentFrame(this.frame);
425
+
426
+ // flash replace
427
+ html = html.replace(/\<object([\w\W]*?)\<\/object\>/gi, '<p class="redactor_video_box"><object$1</object></p>');
428
+
429
+ if (html == '') {
430
+ if (this.opts.autoformat === true) {
431
+ html = $.browser.msie ? "<p></p>" : "<p>&nbsp;</p>";
432
+ }
433
+ }
434
+
435
+ this.redactorWrite(this.getRedactorDoc(html));
436
+ if (this.opts.clearOnInit) this.clean();
437
+ this.designMode();
438
+ },
439
+
440
+ enableAir: function() {
441
+ if (this.opts.air) {
442
+ $('#imp_redactor_air_' + this.frameID).hide();
443
+
444
+ $(this.doc).bind('textselect', this.frameID, function(e) {
445
+ var width = $('#imp_redactor_air_' + this.frameID).width();
446
+ var width_area = $(this.frame).width();
447
+ var diff = width_area - e.clientX;
448
+
449
+ if (diff < width) e.clientX = e.clientX - width;
450
+
451
+ $('#imp_redactor_air_' + this.frameID).css({ left: e.clientX + 'px', top: (e.clientY + 8) + 'px' }).show();
452
+
453
+ }.bind2(this));
454
+
455
+ $(this.doc).bind('textunselect', this.frameID, function() {
456
+ $('#imp_redactor_air_' + this.frameID).hide();
457
+ }.bind2(this));
458
+ }
459
+ },
460
+
461
+ redactorWrite: function(html) {
462
+ this.doc.open();
463
+ this.doc.write(html);
464
+ this.doc.close();
465
+ },
466
+
467
+ getRedactorDoc: function(html) {
468
+ css = '';
469
+
470
+ for (stylesheet in this.opts.paths.stylesheets) {
471
+ css += '<link media="all" href="' + this.opts.paths.stylesheets[stylesheet] + '" rel="stylesheet">';
472
+ }
473
+
474
+ var frameHtml = '<!DOCTYPE html>\n';
475
+ frameHtml += '<html><head>' + css + '</head><body>';
476
+ frameHtml += html;
477
+ frameHtml += '</body></html>';
478
+
479
+ return frameHtml;
480
+ },
481
+
482
+ contentDocumentFrame: function(frame) {
483
+ frame = frame.get(0);
484
+
485
+ if (frame.contentDocument) return frame.contentDocument;
486
+ else if (frame.contentWindow && frame.contentWindow.document) return frame.contentWindow.document;
487
+ else if (frame.document) return frame.document;
488
+ else return null;
489
+ },
490
+
491
+ designMode: function() {
492
+ if (this.doc) {
493
+ this.doc.designMode = 'on';
494
+ this.frame.load(function() {
495
+ this.enableObjects();
496
+ this.docObserve();
497
+ this.doc.designMode = 'on';
498
+ }.bind2(this));
499
+ }
500
+ },
501
+
502
+ enableObjects: function() {
503
+ if ($.browser.mozilla) {
504
+ this.doc.execCommand("enableObjectResizing", false, "false");
505
+ this.doc.execCommand("enableInlineTableEditing", false, "false");
506
+ }
507
+ },
508
+
509
+
510
+ // Observers
511
+ docObserve: function() {
512
+ var body = $(this.doc).find('body');
513
+
514
+ body.find('img').click(function(e) { this.imageEdit(e); }.bind2(this));
515
+ body.find('table').click(function(e) { this.tableObserver(e); }.bind2(this));
516
+ body.find('.redactor_file_link').click(function(e) { this.fileEdit(e); }.bind2(this));
517
+
518
+ },
519
+
520
+ // Format on submit form
521
+ formSets: function() {
522
+ var oldOnsubmit = null;
523
+ var theForm = $(this.box).parents('form');
524
+
525
+ if (theForm.length == 0) return false;
526
+
527
+ oldOnsubmit = theForm.get(0).onsubmit;
528
+
529
+ if (typeof theForm.get(0).onsubmit != "function") {
530
+ theForm.get(0).onsubmit = function() {
531
+ if (this.opts.visual) {
532
+ this.syncCode();
533
+ return true;
534
+ }
535
+ }.bind2(this)
536
+ } else {
537
+ theForm.get(0).onsubmit = function() {
538
+ if (this.opts.visual) {
539
+ this.syncCode();
540
+ return oldOnsubmit();
541
+ }
542
+ }.bind2(this)
543
+ }
544
+
545
+ return true;
546
+ },
547
+
548
+ // Exec
549
+ execCommand: function(cmd, param) {
550
+ if (this.opts.visual && this.doc) {
551
+ try {
552
+ this.frame.get(0).contentWindow.focus();
553
+
554
+ if (cmd == 'inserthtml' && $.browser.msie) {
555
+ this.doc.selection.createRange().pasteHTML(param);
556
+ } else {
557
+ this.doc.execCommand(cmd, false, param);
558
+
559
+ if (param == "blockquote" || param == 'pre')
560
+ this.doc.body.appendChild(this.doc.createElement("BR"));
561
+ }
562
+ } catch (e) { }
563
+
564
+ this.syncCode();
565
+ if (this.opts.air) $('#imp_redactor_air_' + this.frameID).hide();
566
+ }
567
+ },
568
+
569
+ // Format and clean
570
+ clean: function() {
571
+ var html = this.getHtml();
572
+
573
+ if ($.browser.mozilla) html = this.convertSpan(html);
574
+
575
+ // strip tags
576
+ html = html.replace(/<(?!\s*\/?(a|br|p|b|i|strong|em|table|tr|td|th|tbody|thead|tfoot|h2|h3|h4)\b)[^>]+>/ig,"");
577
+
578
+ if (this.opts.removeStyles) html = html.replace(/ style=".*?"/g, '');
579
+ if (this.opts.removeClasses) html = html.replace(/ class=".*?"/g, '');
580
+
581
+ html = this.tidyUp(html);
582
+
583
+ this.setHtml(html);
584
+ this.paragraphise();
585
+
586
+ return html;
587
+ },
588
+
589
+ tidyUp: function (html) {
590
+ // lowercase
591
+ if ($.browser.msie)
592
+ {
593
+ html = html.replace(/< *(\/ *)?(\w+)/g,function(w){return w.toLowerCase()});
594
+ html = html.replace(/ jQuery(.*?)=\"(.*?)\"/gi, '');
595
+ }
596
+
597
+ if (this.opts.convertLinks) html = this.convertLinks(html);
598
+
599
+ html = html.replace(/[\t]*/g, '');
600
+ html = html.replace(/[\r\n]*/g, '');
601
+ html = html.replace(/\n\s*\n/g, "\n");
602
+ html = html.replace(/^[\s\n]*/, '');
603
+ html = html.replace(/[\s\n]*$/, '');
604
+
605
+ var lb = '\r\n';
606
+ var btags = ["<html","</html>","</head>","<title","</title>","<meta","<link","<style","</style>","</body>","<body","<head","<div","<p","<form","<fieldset","<label","</label>","<legend","</legend>","<object","</object>","<embed","</embed>","<select","</select>","<option","<option","<input","<textarea","</textarea>","</form>","</fieldset>","<br>","<br />","<hr","<pre","</pre>","<blockquote","</blockquote>","<ul","</ul>","<ol","</ol>","<li","<dl","</dl>","<dt","</dt>","<dd","</dd>","<\!--","<table","</table>","</thead>","<tbody","</tbody>","<caption","</caption>","<th","</th>","<tr","</tr>","<td","<script","</script>","<noscript","</noscript>"];
607
+ for (i = 0; i < btags.length; ++i)
608
+ {
609
+ var bbb = btags[i];
610
+ html = html.replace(new RegExp(bbb,'gi'),lb+bbb);
611
+ }
612
+
613
+ // indenting
614
+ html = html.replace(/<li/g, "\t<li");
615
+ html = html.replace(/<tr/g, "\t<tr");
616
+ html = html.replace(/<td/g, "\t\t<td");
617
+ html = html.replace(/<\/tr>/g, "\t</tr>");
618
+
619
+ // empty tags
620
+ var btags = ["<pre></pre>","<blockquote></blockquote>","<ul></ul>","<ol></ol>","<li></li>","<table></table>","<tr></tr>","<span><span>", "<p>&nbsp;</p>", "<p></p>", "<p><br></p>", "<div></div>"];
621
+ for (i = 0; i < btags.length; ++i)
622
+ {
623
+ var bbb = btags[i];
624
+ html = html.replace(new RegExp(bbb,'gi'), "");
625
+ }
626
+
627
+ return html;
628
+ },
629
+
630
+ convertLinks: function(html)
631
+ {
632
+ html = html.replace(/\<a(.*?)href="http:\/\/(.*?)"(.*?)>([\w\W]*?)\<\/a\>/gi, "<a$1href=\"rttp://$2\"$3>$4</a>");
633
+ html = html.replace(/\<a(.*?)href="rttp:\/\/(.*?)"(.*?)>http:\/\/([\w\W]*?)\<\/a\>/gi, "<a$1href=\"rttp://$2\"$3>rttp:\/\/$4</a>");
634
+
635
+ //var url1 = /(^|>|\s)(www\..+?\..+?)(\s|<|$)/g;
636
+ var url2 = /(^|>|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|<|$)/g;
637
+
638
+ //html = html.replace(url1, '$1<a href="http://$2">$2</a>$3')
639
+ html = html.replace(url2, '$1<a href="$2">$2</a>$5');
640
+
641
+ html = html.replace(/\<a(.*?)href="rttp:\/\/(.*?)"(.*?)>([\w\W]*?)\<\/a\>/gi, "<a$1href=\"http://$2\"$3>$4</a>");
642
+ html = html.replace(/\<a(.*?)href="http:\/\/(.*?)"(.*?)>rttp:\/\/([\w\W]*?)\<\/a\>/gi, "<a$1href=\"http://$2\"$3>http://$4</a>");
643
+
644
+ return html;
645
+ },
646
+
647
+ convertSpan: function(html)
648
+ {
649
+ html = html.replace(/\<span(.*?)style="font-weight: bold;"\>([\w\W]*?)\<\/span\>/gi, "<strong>$2</strong>");
650
+ html = html.replace(/\<span(.*?)style="font-style: italic;"\>([\w\W]*?)\<\/span\>/gi, "<em>$2</em>");
651
+ html = html.replace(/\<span(.*?)style="font-weight: bold; font-style: italic;"\>([\w\W]*?)\<\/span\>/gi, "<em><strong>$2</strong></em>");
652
+ html = html.replace(/\<span(.*?)style="font-style: italic; font-weight: bold;"\>([\w\W]*?)\<\/span\>/gi, "<strong><em>$2</em></strong>");
653
+
654
+ return html;
655
+ },
656
+
657
+ /*
658
+ Paragraphise
659
+ */
660
+ paragraphise: function()
661
+ {
662
+
663
+ if (this.opts.autoformat === false) return true;
664
+ if (this.opts.visual)
665
+ {
666
+ var theBody = this.doc.body;
667
+
668
+ /* Remove all text nodes containing just whitespace */
669
+ for (var i = 0; i < theBody.childNodes.length; i++)
670
+ {
671
+ if (theBody.childNodes[i].nodeName.toLowerCase() == "#text" && theBody.childNodes[i].data.search(/^\s*$/) != -1)
672
+ {
673
+ theBody.removeChild(theBody.childNodes[i]);
674
+ i--;
675
+ }
676
+ }
677
+
678
+ var removedElements = new Array();
679
+ for (var i = 0; i < theBody.childNodes.length; i++)
680
+ {
681
+ if (theBody.childNodes[i].nodeName.isInlineName())
682
+ {
683
+ removedElements.push(theBody.childNodes[i].cloneNode(true));
684
+ theBody.removeChild(theBody.childNodes[i]);
685
+ i--;
686
+ }
687
+ else if (theBody.childNodes[i].nodeName.toLowerCase() == "br")
688
+ {
689
+ if (i + 1 < theBody.childNodes.length)
690
+ {
691
+ if (theBody.childNodes[i + 1].nodeName.toLowerCase() == "br")
692
+ {
693
+ while (i < theBody.childNodes.length && theBody.childNodes[i].nodeName.toLowerCase() == "br")
694
+ {
695
+ theBody.removeChild(theBody.childNodes[i]);
696
+ }
697
+
698
+ if (removedElements.length > 0)
699
+ {
700
+ this.insertNewParagraph(removedElements, theBody.childNodes[i]);
701
+ removedElements = new Array();
702
+ }
703
+ }
704
+ else if (!theBody.childNodes[i + 1].nodeName.isInlineName()) theBody.removeChild(theBody.childNodes[i]);
705
+ else if (removedElements.length > 0)
706
+ {
707
+ removedElements.push(theBody.childNodes[i].cloneNode(true));
708
+ theBody.removeChild(theBody.childNodes[i]);
709
+ }
710
+ else theBody.removeChild(theBody.childNodes[i]);
711
+ i--;
712
+ }
713
+ else theBody.removeChild(theBody.childNodes[i]);
714
+ }
715
+ else if (removedElements.length > 0)
716
+ {
717
+ this.insertNewParagraph(removedElements, theBody.childNodes[i]);
718
+ removedElements = new Array();
719
+ }
720
+ }
721
+
722
+ if (removedElements.length > 0) this.insertNewParagraph(removedElements);
723
+ }
724
+
725
+ return true;
726
+ },
727
+ insertNewParagraph: function(elementArray, succeedingElement)
728
+ {
729
+ var theBody = this.doc.getElementsByTagName("body")[0];
730
+ var theParagraph = this.doc.createElement("p");
731
+
732
+ for (var i = 0; i < elementArray.length; i++) theParagraph.appendChild(elementArray[i]);
733
+
734
+ if (typeof(succeedingElement) != "undefined") theBody.insertBefore(theParagraph, succeedingElement);
735
+ else theBody.appendChild(theParagraph);
736
+
737
+ return true;
738
+ },
739
+
740
+ /*
741
+ Selection
742
+ */
743
+ get_selection: function ()
744
+ {
745
+ if (this.frame.get(0).contentWindow.getSelection) return this.frame.get(0).contentWindow.getSelection();
746
+ else if (this.frame.get(0).contentWindow.document.selection) return this.frame.contentWindow.get(0).document.selection.createRange();
747
+ },
748
+
749
+ setCut: function()
750
+ {
751
+ this.execCommand('inserthtml', '<hr class="redactor_cut" />');
752
+ },
753
+
754
+ /*
755
+ Toggle
756
+ */
757
+ toggle: function()
758
+ {
759
+ if (this.opts.visual)
760
+ {
761
+ this.addSelButton('html');
762
+
763
+ var html = this.getHtml();
764
+
765
+ html = this.tidyUp(html);
766
+
767
+ html = html.replace(/\%7B/gi, '{');
768
+ html = html.replace(/\%7D/gi, '}');
769
+
770
+ // flash replace
771
+ html = html.replace(/<p(.*?)class="redactor_video_box"(.*?)>([\w\W]*?)\<\/p>/gi, "$3");
772
+
773
+ // files replace
774
+ html = html.replace(/<a(.*?)rel="(.*?)"(.*?)class="redactor_file_link(.*?)"(.*?)>([\w\W]*?)\<\/a>/gi, "<a href=\"" + this.opts.paths.files.download + "$2\" rel=\"$2\" class=\"redactor_file_link$4\">$6</a>");
775
+
776
+ // cut replace
777
+ html = html.replace(/<hr class="redactor_cut"\/>/gi, '<!--more-->');
778
+ html = html.replace(/<hr class=redactor_cut>/gi, '<!--more-->');
779
+
780
+
781
+ this.frame.hide();
782
+ this.$el.val(html);
783
+ this.$el.show().focus();
784
+
785
+ var height = this.$el.height();
786
+
787
+ this.opts.visual = false;
788
+ }
789
+ else
790
+ {
791
+ this.removeSelButton('html');
792
+ this.$el.hide();
793
+
794
+ var html = this.$el.val();
795
+
796
+ // cut replace
797
+ html = html.replace(/<!--more-->/gi, '<hr class="redactor_cut"/>');
798
+
799
+ // flash replace
800
+ html = html.replace(/\<object([\w\W]*?)\<\/object\>/gi, '<p class="redactor_video_box"><object$1</object></p>');
801
+
802
+ // files replace
803
+ html = html.replace(/<a(.*?)href="(.*?)"(.*?)rel="(.*?)"(.*?)class="redactor_file_link(.*?)">(.*?)<\/a>/gi, "<a href=\"javascript:void(null);\" rel=\"$4\" class=\"redactor_file_link$6\">$7</a>");
804
+
805
+
806
+ this.opts.visual = true;
807
+
808
+ this.setHtml(html);
809
+
810
+ this.frame.show();
811
+ this.focus();
812
+ }
813
+ },
814
+
815
+
816
+ /*
817
+ Video
818
+ */
819
+ showVideo: function()
820
+ {
821
+ redactorActive = this;
822
+ this.modalInit(RLANG.video, this.opts.paths.dialogs.video, 600, 360, function()
823
+ {
824
+ $('#redactor_insert_video_area').focus();
825
+ });
826
+ },
827
+ insertVideo: function()
828
+ {
829
+ var data = $('#redactor_insert_video_area').val();
830
+ if (redactorActive.opts.visual)
831
+ {
832
+ // iframe video
833
+ if (data.search('iframe')) {}
834
+ // flash
835
+ else data = '<p class="redactor_video_box">' + data + '</p>';
836
+ }
837
+
838
+ redactorActive.execCommand('inserthtml', data);
839
+ this.modalClose();
840
+
841
+ },
842
+
843
+
844
+
845
+ /*
846
+ File
847
+ */
848
+ showFile: function()
849
+ {
850
+ redactorActive = this;
851
+
852
+ var handler = function()
853
+ {
854
+ // upload params
855
+ var params = '';
856
+ if (this.opts.fileUploadCallback) params = this.opts.fileUploadCallback();
857
+
858
+ $('#redactor_file').dragupload(
859
+ {
860
+ url: this.opts.paths.files.upload + params,
861
+ success: function(data)
862
+ {
863
+ this.fileUploadCallback(data);
864
+
865
+ }.bind2(this)
866
+ });
867
+
868
+ this.uploadInit('redactor_file', { auto: true, url: this.opts.paths.files.upload + params, success: function(data) {
869
+
870
+ this.fileUploadCallback(data);
871
+
872
+ }.bind2(this) });
873
+
874
+
875
+ }.bind2(this);
876
+
877
+
878
+ redactorActive = this;
879
+ this.modalInit(RLANG.file, this.opts.paths.dialogs.file, 500, 400, handler);
880
+ },
881
+ fileUploadCallback: function(data)
882
+ {
883
+ redactorActive.frame.get(0).contentWindow.focus();
884
+ redactorActive.execCommand('inserthtml', data);
885
+ this.modalClose();
886
+ this.docObserve();
887
+ },
888
+ fileEdit: function(e)
889
+ {
890
+ var el = e.target;
891
+ var file_id = $(el).attr('rel');
892
+
893
+ var handler = function()
894
+ {
895
+ $('#file').val($(el).text());
896
+ $('#redactorFileDeleteBtn').click(function()
897
+ {
898
+ this.fileDelete(el, file_id);
899
+ }.bind2(this));
900
+
901
+ $('#redactorFileDownloadBtn').click(function()
902
+ {
903
+ this.fileDownload(el, file_id);
904
+ }.bind2(this));
905
+
906
+ }.bind2(this);
907
+
908
+ redactorActive = this;
909
+ this.modalInit(RLANG.file, this.opts.paths.dialogs.fileEdit, 400, 200, handler);
910
+ },
911
+ fileDelete: function(el, file_id)
912
+ {
913
+ $(el).remove();
914
+ $.get(this.opts.paths.files.remove + file_id);
915
+ redactorActive.frame.get(0).contentWindow.focus();
916
+ this.modalClose();
917
+ },
918
+ fileDownload: function(el, file_id)
919
+ {
920
+ top.location.href = this.opts.paths.files.download + file_id;
921
+ },
922
+
923
+ /*
924
+ Table
925
+ */
926
+ showTable: function()
927
+ {
928
+ redactorActive = this;
929
+ this.modalInit(RLANG.table, this.opts.paths.dialogs.table, 360, 200);
930
+ },
931
+ insertTable: function()
932
+ {
933
+ var rows = $('#redactor_table_rows').val();
934
+ var columns = $('#redactor_table_columns').val();
935
+
936
+ var table_box = $('<div></div>');
937
+
938
+ var tableid = Math.floor(Math.random() * 99999);
939
+ var table = $('<table id="table' + tableid + '"><tbody></tbody></table>');
940
+
941
+ for (i = 0; i < rows; i++)
942
+ {
943
+ var row = $('<tr></tr>')
944
+ for (z = 0; z < columns; z++)
945
+ {
946
+ var column = $('<td>&nbsp;</td>');
947
+ $(row).append(column);
948
+ }
949
+ $(table).append(row);
950
+ }
951
+
952
+ $(table_box).append(table);
953
+ var html = $(table_box).html();
954
+ if ($.browser.msie) html += '<p></p>';
955
+ else html += '<p>&nbsp;</p>';
956
+
957
+ redactorActive.execCommand('inserthtml', html);
958
+ this.enableObjects();
959
+ this.docObserve();
960
+ this.modalClose();
961
+
962
+ $table = $(this.doc).find('body').find('#table' + tableid);
963
+
964
+
965
+ },
966
+ tableObserver: function(e)
967
+ {
968
+ $table = $(e.target).parents('table');
969
+
970
+ $tbody = $(e.target).parents('tbody');
971
+ $thead = $($table).find('thead');
972
+
973
+ $current_td = $(e.target);
974
+ $current_tr = $(e.target).parents('tr');
975
+ },
976
+ deleteTable: function()
977
+ {
978
+ $($table).remove();
979
+ $table = false;
980
+ },
981
+ deleteRow: function()
982
+ {
983
+ $($current_tr).remove();
984
+ },
985
+ deleteColumn: function()
986
+ {
987
+ var index = $($current_td).attr('cellIndex');
988
+
989
+ $($table).find('tr').each(function()
990
+ {
991
+ $(this).find('td').eq(index).remove();
992
+ });
993
+ },
994
+ addHead: function()
995
+ {
996
+ if ($($table).find('thead').size() != 0) this.deleteHead();
997
+ else
998
+ {
999
+ var tr = $($table).find('tr').first().clone();
1000
+ tr.find('td').html('&nbsp;');
1001
+ $thead = $('<thead></thead>');
1002
+ $thead.append(tr);
1003
+ $($table).prepend($thead);
1004
+ }
1005
+ },
1006
+ deleteHead: function()
1007
+ {
1008
+ $($thead).remove();
1009
+ $thead = false;
1010
+ },
1011
+ insertRowAbove: function()
1012
+ {
1013
+ this.insertRow('before');
1014
+ },
1015
+ insertRowBelow: function()
1016
+ {
1017
+ this.insertRow('after');
1018
+ },
1019
+ insertColumnLeft: function()
1020
+ {
1021
+ this.insertColumn('before');
1022
+ },
1023
+ insertColumnRight: function()
1024
+ {
1025
+ this.insertColumn('after');
1026
+ },
1027
+ insertRow: function(type)
1028
+ {
1029
+ var new_tr = $($current_tr).clone();
1030
+ new_tr.find('td').html('&nbsp;');
1031
+ if (type == 'after') $($current_tr).after(new_tr);
1032
+ else $($current_tr).before(new_tr);
1033
+ },
1034
+ insertColumn: function(type)
1035
+ {
1036
+ var index = $($current_td).attr('cellIndex');
1037
+
1038
+ $($table).find('tr').each(function(i,s)
1039
+ {
1040
+ var current = $(s).find('td').eq(index);
1041
+ var td = current.clone();
1042
+ td.html('&nbsp;');
1043
+ if (type == 'after') $(current).after(td);
1044
+ else $(current).before(td);
1045
+ });
1046
+ },
1047
+
1048
+ /*
1049
+ Image
1050
+ */
1051
+ imageEdit: function(e)
1052
+ {
1053
+ var handler = function()
1054
+ {
1055
+ var $el = $(e.target);
1056
+ var src = $el.attr('src');
1057
+ $('#redactor_image_edit_src').attr('href', src);
1058
+ $('#redactor_image_edit_delete').click(function() { this.deleteImage(e.target); }.bind2(this));
1059
+ $('#redactorSaveBtn').click(function() { this.imageSave(e.target); }.bind2(this));
1060
+
1061
+ $('#redactor_file_alt').val($el.attr('alt'));
1062
+
1063
+ var float = $el.css('float');
1064
+ if (float == 'none') float = 0;
1065
+
1066
+ $('#redactor_form_image_align').val(float);
1067
+
1068
+ }.bind2(this);
1069
+
1070
+ redactorActive = this;
1071
+ this.modalInit(RLANG.image, this.opts.paths.dialogs.imageEdit, 380, 290, handler);
1072
+ },
1073
+ imageSave: function(el)
1074
+ {
1075
+ $(el).attr('alt', $('#redactor_file_alt').val());
1076
+
1077
+ var style = '';
1078
+ if ($('#redactor_form_image_align') != 0)
1079
+ {
1080
+ var float = $('#redactor_form_image_align').val();
1081
+
1082
+ // @tanraya AddedClasses
1083
+ $(el).removeClass('img_left').removeClass('img_right')
1084
+
1085
+ if (float == 'left')
1086
+ $(el).addClass('img_left');
1087
+ else if (float == 'right')
1088
+ $(el).addClass('img_right')
1089
+ }
1090
+ else $(el).css({ float: 'none', margin: '0' });
1091
+
1092
+ this.modalClose();
1093
+ },
1094
+ deleteImage: function(el)
1095
+ {
1096
+ $(el).remove();
1097
+ this.modalClose();
1098
+ },
1099
+ showImage: function()
1100
+ {
1101
+ this.spanid = Math.floor(Math.random() * 99999);
1102
+ if (jQuery.browser.msie)
1103
+ {
1104
+ this.execCommand('inserthtml', '<span id="span' + this.spanid + '"></span>');
1105
+ }
1106
+
1107
+ var handler = function() {
1108
+ if (this.opts.paths.images.list !== false) {
1109
+ $.getJSON(this.opts.paths.images.list, function(data) {
1110
+ $.each(data, function(key, val) {
1111
+ var img = $('<img src="' + val.thumb + '" rel="' + val.image + '">');
1112
+ img.click(function() { redactorActive.imageSetThumb($(this).attr('rel')); });
1113
+ $('#redactor_image_box').append(img);
1114
+ });
1115
+ });
1116
+ } else {
1117
+ $('#redactor_tabs li').eq(0).remove();
1118
+ $('#redactor_tabs a').eq(1).addClass('redactor_tabs_act');
1119
+ $('#redactor_tabs1').hide();
1120
+ $('#redactor_tabs2').show();
1121
+ }
1122
+
1123
+ // upload params
1124
+ var params = '';
1125
+ if (this.opts.imageUploadCallback) var params = this.opts.imageUploadCallback();
1126
+
1127
+ $('#redactor_file').dragupload({
1128
+ url : this.opts.paths.images.upload + params,
1129
+ success : function(data) {
1130
+ this.imageUploadCallback(data);
1131
+ }.bind2(this)
1132
+ });
1133
+
1134
+ this.uploadInit('redactor_file', {
1135
+ auto : true,
1136
+ url : this.opts.paths.images.upload + params,
1137
+ trigger : 'redactorUploadBtn',
1138
+ success : function(data) {
1139
+ this.imageUploadCallback(data);
1140
+ }.bind2(this)});
1141
+ }.bind2(this);
1142
+
1143
+ redactorActive = this;
1144
+ this.modalInit(RLANG.image, this.opts.paths.dialogs.image, 570, 450, handler);
1145
+
1146
+ },
1147
+ imageSetThumb: function(data)
1148
+ {
1149
+ this._imageSet('<img alt="" src="' + data + '" />');
1150
+ },
1151
+ imageUploadCallback: function(data)
1152
+ {
1153
+ if ($('#redactor_file_link').val() != '') data = $('#redactor_file_link').val();
1154
+
1155
+ this._imageSet(data);
1156
+
1157
+ },
1158
+ _imageSet: function(html)
1159
+ {
1160
+ redactorActive.frame.get(0).contentWindow.focus();
1161
+
1162
+ if ($.browser.msie)
1163
+ {
1164
+ $(redactorActive.doc.getElementById('span' + redactorActive.spanid)).after(html);
1165
+ $(redactorActive.doc.getElementById('span' + redactorActive.spanid)).remove();
1166
+ }
1167
+ else
1168
+ {
1169
+ redactorActive.execCommand('inserthtml', html);
1170
+ }
1171
+
1172
+ this.modalClose();
1173
+ this.docObserve();
1174
+ },
1175
+
1176
+
1177
+ /*
1178
+ Link
1179
+ */
1180
+ showLink: function()
1181
+ {
1182
+ redactorActive = this;
1183
+
1184
+ var handler = function()
1185
+ {
1186
+ var sel = this.get_selection();
1187
+ if ($.browser.msie)
1188
+ {
1189
+ var temp = sel.htmlText.match(/href="(.*?)"/gi);
1190
+ if (temp != null)
1191
+ {
1192
+ temp = new String(temp);
1193
+ temp = temp.replace(/href="(.*?)"/gi, '$1');
1194
+ }
1195
+
1196
+ var text = sel.text;
1197
+ if (temp != null) var url = temp;
1198
+ else var url = '';
1199
+ var title = '';
1200
+ }
1201
+ else
1202
+ {
1203
+ if (sel.anchorNode.parentNode.tagName == 'A')
1204
+ {
1205
+ var url = sel.anchorNode.parentNode.href;
1206
+ var text = sel.anchorNode.parentNode.text;
1207
+ var title = sel.anchorNode.parentNode.title;
1208
+ if (sel.toString() == '') this.insert_link_node = sel.anchorNode.parentNode
1209
+
1210
+ }
1211
+ else
1212
+ {
1213
+ var text = sel.toString();
1214
+ var url = '';
1215
+ var title = '';
1216
+ }
1217
+ }
1218
+
1219
+ $('#redactor_link_url').val(url).focus();
1220
+ $('#redactor_link_text').val(text);
1221
+ $('#redactor_link_title').val(title);
1222
+
1223
+ }.bind2(this);
1224
+
1225
+ this.modalInit(RLANG.link, this.opts.paths.dialogs.link, 400, 300, handler);
1226
+
1227
+ },
1228
+ insertLink: function()
1229
+ {
1230
+ var value = $('#redactor_link_text').val();
1231
+ if (value == '') return true;
1232
+
1233
+ var title = $('#redactor_link_title').val();
1234
+ if (title != '') title = ' title="' + $('#redactor_link_title').val() + '"';
1235
+
1236
+ if ($('#redactor_link_id_url').get(0).checked) var mailto = '';
1237
+ else var mailto = 'mailto:';
1238
+
1239
+ var a = '<a href="' + mailto + $('#redactor_link_url').val() + '"' + title +'>' + value + '</a> ';
1240
+
1241
+ if (a)
1242
+ {
1243
+ if (this.insert_link_node)
1244
+ {
1245
+ $(this.insert_link_node).text(value);
1246
+ $(this.insert_link_node).attr('href', $('#redactor_link_url').val());
1247
+
1248
+ var title = $('#redactor_link_title').val();
1249
+ if (title != '') $(this.insert_link_node).attr('title', title);
1250
+
1251
+ this.modalClose();
1252
+ }
1253
+ else
1254
+ {
1255
+ redactorActive.frame.get(0).contentWindow.focus();
1256
+ redactorActive.execCommand('inserthtml', a);
1257
+ }
1258
+ }
1259
+
1260
+ this.modalClose();
1261
+ },
1262
+
1263
+
1264
+ /*
1265
+ Modal
1266
+ */
1267
+ modalInit: function(title, url, width, height, handler, scroll)
1268
+ {
1269
+ if (this.opts.overlay)
1270
+ {
1271
+ $('#redactor_imp_modal_overlay').show();
1272
+ $('#redactor_imp_modal_overlay').click(function() { this.modalClose(); }.bind2(this));
1273
+ }
1274
+
1275
+ if ($('#redactor_imp_modal').size() == 0)
1276
+ {
1277
+ this.modal = $('<div id="redactor_imp_modal" style="display: none;"><div id="redactor_imp_modal_close"></div><div id="redactor_imp_modal_header"></div><div id="redactor_imp_modal_inner"></div></div>');
1278
+ $('body').append(this.modal);
1279
+ }
1280
+
1281
+ $('#redactor_imp_modal_close').click(function() { this.modalClose(); }.bind2(this));
1282
+ $(document).keyup(function(e) { if( e.keyCode == 27) this.modalClose(); }.bind2(this));
1283
+ $(this.doc).keyup(function(e) { if( e.keyCode == 27) this.modalClose(); }.bind2(this));
1284
+
1285
+ $.ajax({
1286
+ url: url,
1287
+ success: function(data)
1288
+ {
1289
+ // parse lang
1290
+ $.each(RLANG, function(i,s)
1291
+ {
1292
+ var re = new RegExp("%RLANG\." + i + "%","gi");
1293
+ data = data.replace(re, s);
1294
+ });
1295
+
1296
+ $('#redactor_imp_modal_inner').html(data);
1297
+ $('#redactor_imp_modal_header').html(title);
1298
+
1299
+ if (height === false) theight = 'auto';
1300
+ else theight = height + 'px';
1301
+
1302
+ $('#redactor_imp_modal').css({ width: width + 'px', height: theight, marginTop: '-' + height/2 + 'px', marginLeft: '-' + width/2 + 'px' }).fadeIn('fast');
1303
+
1304
+ if (scroll === true)
1305
+ {
1306
+ $('#imp_redactor_table_box').height(height-$('#redactor_imp_modal_header').outerHeight()-130).css('overflow', 'auto');
1307
+ }
1308
+
1309
+ if (typeof(handler) == 'function') handler();
1310
+
1311
+
1312
+ }.bind2(this)
1313
+ });
1314
+ },
1315
+ modalClose: function()
1316
+ {
1317
+
1318
+ $('#redactor_imp_modal_close').unbind('click', function() { this.modalClose(); }.bind2(this));
1319
+ $('#redactor_imp_modal').fadeOut('fast', function()
1320
+ {
1321
+ $('#redactor_imp_modal_inner').html('');
1322
+
1323
+ if (this.opts.overlay)
1324
+ {
1325
+ $('#redactor_imp_modal_overlay').hide();
1326
+ $('#redactor_imp_modal_overlay').unbind('click', function() { this.modalClose(); }.bind2(this));
1327
+ }
1328
+
1329
+ $(document).unbind('keyup', function(e) { if( e.keyCode == 27) this.modalClose(); }.bind2(this));
1330
+ $(this.doc).unbind('keyup', function(e) { if( e.keyCode == 27) this.modalClose(); }.bind2(this));
1331
+
1332
+ }.bind2(this));
1333
+
1334
+ },
1335
+
1336
+ /*
1337
+ Upload
1338
+ */
1339
+ uploadInit: function(element, options)
1340
+ {
1341
+ /*
1342
+ Options
1343
+ */
1344
+ this.uploadOptions = {
1345
+ url: false,
1346
+ success: false,
1347
+ start: false,
1348
+ trigger: false,
1349
+ auto: false,
1350
+ input: false
1351
+ };
1352
+
1353
+ $.extend(this.uploadOptions, options);
1354
+
1355
+
1356
+ // Test input or form
1357
+ if ($('#' + element).get(0).tagName == 'INPUT')
1358
+ {
1359
+ this.uploadOptions.input = $('#' + element);
1360
+ this.element = $($('#' + element).get(0).form);
1361
+ }
1362
+ else
1363
+ {
1364
+ this.element = $('#' + element);
1365
+ }
1366
+
1367
+
1368
+ this.element_action = this.element.attr('action');
1369
+
1370
+ // Auto or trigger
1371
+ if (this.uploadOptions.auto)
1372
+ {
1373
+ $(this.uploadOptions.input).change(function()
1374
+ {
1375
+ this.element.submit(function(e) { return false; });
1376
+ this.uploadSubmit();
1377
+ }.bind2(this));
1378
+
1379
+ }
1380
+ else if (this.uploadOptions.trigger)
1381
+ {
1382
+ $('#' + this.uploadOptions.trigger).click(function() { this.uploadSubmit(); }.bind2(this));
1383
+ }
1384
+ },
1385
+ uploadSubmit : function()
1386
+ {
1387
+ this.uploadForm(this.element, this.uploadFrame());
1388
+ },
1389
+ uploadFrame : function()
1390
+ {
1391
+ this.id = 'f' + Math.floor(Math.random() * 99999);
1392
+
1393
+ var d = document.createElement('div');
1394
+ var iframe = '<iframe style="display:none" src="about:blank" id="'+this.id+'" name="'+this.id+'"></iframe>';
1395
+ d.innerHTML = iframe;
1396
+ document.body.appendChild(d);
1397
+
1398
+ // Start
1399
+ if (this.uploadOptions.start) this.uploadOptions.start();
1400
+
1401
+ $('#' + this.id).load(function () { this.uploadLoaded() }.bind2(this));
1402
+
1403
+ return this.id;
1404
+ },
1405
+ uploadForm : function(f, name)
1406
+ {
1407
+ if (this.uploadOptions.input)
1408
+ {
1409
+ var formId = 'redactorUploadForm' + this.id;
1410
+ var fileId = 'redactorUploadFile' + this.id;
1411
+ this.form = $('<form action="' + this.uploadOptions.url + '" method="POST" target="' + name + '" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
1412
+
1413
+ var oldElement = this.uploadOptions.input;
1414
+ var newElement = $(oldElement).clone();
1415
+ $(oldElement).attr('id', fileId);
1416
+ $(oldElement).before(newElement);
1417
+ $(oldElement).appendTo(this.form);
1418
+ $(this.form).css('position', 'absolute');
1419
+ $(this.form).css('top', '-2000px');
1420
+ $(this.form).css('left', '-2000px');
1421
+ $(this.form).appendTo('body');
1422
+
1423
+ this.form.submit();
1424
+ }
1425
+ else
1426
+ {
1427
+ f.attr('target', name);
1428
+ f.attr('method', 'POST');
1429
+ f.attr('enctype', 'multipart/form-data');
1430
+ f.attr('action', this.uploadOptions.url);
1431
+
1432
+ this.element.submit();
1433
+ }
1434
+
1435
+ },
1436
+ uploadLoaded : function()
1437
+ {
1438
+ var i = $('#' + this.id);
1439
+
1440
+ if (i.contentDocument) var d = i.contentDocument;
1441
+ else if (i.contentWindow) var d = i.contentWindow.document;
1442
+ else var d = window.frames[this.id].document;
1443
+
1444
+ if (d.location.href == "about:blank") return true;
1445
+
1446
+ // Success
1447
+ if (this.uploadOptions.success) this.uploadOptions.success(d.body.innerHTML);
1448
+
1449
+ this.element.attr('action', this.element_action);
1450
+ this.element.attr('target', '');
1451
+ //this.element.unbind('submit');
1452
+ //if (this.uploadOptions.input) $(this.form).remove();
1453
+ },
1454
+
1455
+ /*
1456
+ Toolbar
1457
+ */
1458
+ buildToolbar: function()
1459
+ {
1460
+ this.toolbar = $('<ul id="imp_redactor_toolbar_' + this.frameID + '" class="imp_redactor_toolbar"></ul>');
1461
+
1462
+ if (this.opts.air)
1463
+ {
1464
+ $(this.air).append(this.toolbar);
1465
+ this.box.prepend(this.air);
1466
+ }
1467
+ else $(this.box).prepend(this.toolbar);
1468
+
1469
+
1470
+ $.each(RTOOLBAR,
1471
+ function (i, s)
1472
+ {
1473
+ if (s.name == 'separator')
1474
+ {
1475
+ var li = $('<li class="separator"></li>');
1476
+ $(this.toolbar).append(li);
1477
+ }
1478
+ else
1479
+ {
1480
+
1481
+ var a = $('<a href="javascript:void(null);" class="imp_btn imp_btn_' + s.name + '" title="' + s.title + '"></a>');
1482
+
1483
+ if (typeof(s.func) == 'undefined') a.click(function() { this.execCommand(s.exec, s.name); }.bind2(this));
1484
+ else if (s.func != 'show') a.click(function(e) { this[s.func](e); }.bind2(this));
1485
+
1486
+ var li = $('<li class="imp_li_btn imp_li_btn_' + s.name + '"></li>');
1487
+ $(li).append(a);
1488
+ $(this.toolbar).append(li);
1489
+
1490
+ // build dropdown box
1491
+ if (s.name == 'backcolor' || s.name == 'fontcolor' || typeof(s.dropdown) != 'undefined')
1492
+ {
1493
+ var ul = $('<ul class="imp_redactor_drop_down imp_redactor_drop_down' + this.frameID + '" id="imp_redactor_drop_down' + this.frameID + '_' + s.name + '" style="display: none;"></ul>');
1494
+ if ($.browser.msie) ul.css({ borderLeft: '1px solid #ddd', borderRight: '1px solid #ddd', borderBottom: '1px solid #ddd' });
1495
+ }
1496
+
1497
+ // build dropdown
1498
+ if (typeof(s.dropdown) != 'undefined')
1499
+ {
1500
+
1501
+ $.each(s.dropdown,
1502
+ function (x, d)
1503
+ {
1504
+ if (typeof(d.style) == 'undefined') d.style = '';
1505
+
1506
+ if (d.name == 'separator')
1507
+ {
1508
+ var ul_li = $('<li class="separator_drop"></li>');
1509
+ $(ul).append(ul_li);
1510
+ }
1511
+ else
1512
+ {
1513
+
1514
+ var ul_li = $('<li></li>');
1515
+ var ul_li_a = $('<a href="javascript:void(null);" style="' + d.style + '">' + d.title + '</a>');
1516
+ $(ul_li).append(ul_li_a);
1517
+ $(ul).append(ul_li);
1518
+
1519
+ if (typeof(d.func) == 'undefined') $(ul_li_a).click(function() { this.execCommand(d.exec, d.name); }.bind2(this));
1520
+ else $(ul_li_a).click(function(e) { this[d.func](e); }.bind2(this));
1521
+ }
1522
+
1523
+
1524
+
1525
+ }.bind2(this)
1526
+ );
1527
+ }
1528
+ else a.mouseover(function() { this.hideAllDropDown() }.bind2(this));
1529
+
1530
+ // observing dropdown
1531
+ if (s.name == 'backcolor' || s.name == 'fontcolor' || typeof(s.dropdown) != 'undefined')
1532
+ {
1533
+ $('#imp_redactor_toolbar_' + this.frameID).after(ul);
1534
+
1535
+ this.hdlHideDropDown = function(e) { this.hideDropDown(e, ul, s.name) }.bind2(this);
1536
+ this.hdlShowDropDown = function(e) { this.showDropDown(e, ul, s.name) }.bind2(this);
1537
+ this.hdlShowerDropDown = function(e) { this.showerDropDown(e, ul, s.name) }.bind2(this);
1538
+
1539
+ a.click(this.hdlShowDropDown).mouseover(this.hdlShowerDropDown);
1540
+
1541
+ $(document).click(this.hdlHideDropDown);
1542
+ }
1543
+
1544
+
1545
+ }
1546
+ }.bind2(this)
1547
+ );
1548
+ },
1549
+
1550
+ /*
1551
+ DropDown
1552
+ */
1553
+ showedDropDown: false,
1554
+ showDropDown: function(e, ul, name)
1555
+ {
1556
+
1557
+ if (this.showedDropDown) this.hideAllDropDown();
1558
+ else
1559
+ {
1560
+ this.showedDropDown = true;
1561
+ this.showingDropDown(e, ul, name);
1562
+ }
1563
+
1564
+ },
1565
+ showingDropDown: function(e, ul, name)
1566
+ {
1567
+ this.hideAllDropDown();
1568
+ this.addSelButton(name);
1569
+
1570
+ var left = $('#imp_redactor_toolbar_' + this.frameID + ' li.imp_li_btn_' + name).position().left;
1571
+ $(ul).css('left', left + 'px').show();
1572
+ },
1573
+ showerDropDown: function(e, ul, name)
1574
+ {
1575
+ if (this.showedDropDown) this.showingDropDown(e, ul, name);
1576
+ },
1577
+ hideAllDropDown: function()
1578
+ {
1579
+ $('#imp_redactor_toolbar_' + this.frameID + ' li.imp_li_btn').removeClass('act');
1580
+ $('ul.imp_redactor_drop_down' + this.frameID).hide();
1581
+ },
1582
+ hideDropDown: function(e, ul, name)
1583
+ {
1584
+ if (!$(e.target).parent().hasClass('act'))
1585
+ {
1586
+ this.showedDropDown = false;
1587
+ this.hideAllDropDown();
1588
+ }
1589
+
1590
+ $(document).unbind('click', this.hdlHideDropDown);
1591
+ $(this.doc).unbind('click', this.hdlHideDropDown);
1592
+
1593
+ },
1594
+ addSelButton: function(name)
1595
+ {
1596
+ var element = $('#imp_redactor_toolbar_' + this.frameID + ' li.imp_li_btn_' + name);
1597
+ element.addClass('act');
1598
+ },
1599
+ removeSelButton: function(name)
1600
+ {
1601
+ var element = $('#imp_redactor_toolbar_' + this.frameID + ' li.imp_li_btn_' + name);
1602
+ element.removeClass('act');
1603
+ },
1604
+ toggleSelButton: function(name)
1605
+ {
1606
+ $('#imp_redactor_toolbar_' + this.frameID + ' li.imp_li_btn_' + name).toggleClass('act');
1607
+ },
1608
+
1609
+
1610
+ /*
1611
+ Resizer
1612
+ */
1613
+ initResize: function(e)
1614
+ {
1615
+ if (e.preventDefault) e.preventDefault();
1616
+ else e.returnValue = false;
1617
+
1618
+ this.splitter = e.target;
1619
+
1620
+ if (this.opts.visual)
1621
+ {
1622
+ this.element_resize = this.frame;
1623
+ this.element_resize.get(0).style.visibility = 'hidden';
1624
+ this.element_resize_parent = this.$el;
1625
+ }
1626
+ else
1627
+ {
1628
+ this.element_resize = this.$el;
1629
+ this.element_resize_parent = this.frame;
1630
+ }
1631
+
1632
+ this.stopResizeHdl = function (e) { this.stopResize(e) }.bind2(this);
1633
+ this.startResizeHdl = function (e) { this.startResize(e) }.bind2(this);
1634
+ this.resizeHdl = function (e) { this.resize(e) }.bind2(this);
1635
+
1636
+ $(document).mousedown(this.startResizeHdl);
1637
+ $(document).mouseup(this.stopResizeHdl);
1638
+ $(this.splitter).mouseup(this.stopResizeHdl);
1639
+
1640
+ this.null_point = false;
1641
+ this.h_new = false;
1642
+ this.h = this.element_resize.height();
1643
+ },
1644
+ startResize: function()
1645
+ {
1646
+ $(document).mousemove(this.resizeHdl);
1647
+ },
1648
+ resize: function(e)
1649
+ {
1650
+ if (e.preventDefault) e.preventDefault();
1651
+ else e.returnValue = false;
1652
+
1653
+ var y = e.pageY;
1654
+ if (this.null_point == false) this.null_point = y;
1655
+ if (this.h_new == false) this.h_new = this.element_resize.height();
1656
+
1657
+ var s_new = (this.h_new + y - this.null_point) - 10;
1658
+
1659
+ if (s_new <= 30) return true;
1660
+
1661
+ if (s_new >= 0)
1662
+ {
1663
+ this.element_resize.get(0).style.height = s_new + 'px';
1664
+ this.element_resize_parent.get(0).style.height = s_new + 'px';
1665
+ }
1666
+ },
1667
+ stopResize: function(e)
1668
+ {
1669
+ $(document).unbind('mousemove', this.resizeHdl);
1670
+ $(document).unbind('mousedown', this.startResizeHdl);
1671
+ $(document).unbind('mouseup', this.stopResizeHdl);
1672
+ $(this.splitter).unbind('mouseup', this.stopResizeHdl);
1673
+
1674
+ this.element_resize.get(0).style.visibility = 'visible';
1675
+ }
1676
+
1677
+ };
1678
+
1679
+
1680
+ String.prototype.isInlineName = function()
1681
+ {
1682
+ var inlineList = new Array("#text", "a", "em", "font", "span", "strong", "u");
1683
+ var theName = this.toLowerCase();
1684
+
1685
+ for (var i = 0; i < inlineList.length; i++)
1686
+ {
1687
+ if (theName == inlineList[i])
1688
+ {
1689
+ return true;
1690
+ }
1691
+ }
1692
+
1693
+ return false;
1694
+ };
1695
+
1696
+
1697
+ // bind2
1698
+ Function.prototype.bind2 = function(object)
1699
+ {
1700
+ var method = this; var oldArguments = $.makeArray(arguments).slice(1);
1701
+ return function (argument)
1702
+ {
1703
+ if (argument == new Object) { method = null; oldArguments = null; }
1704
+ else if (method == null) throw "Attempt to invoke destructed method reference.";
1705
+ else { var newArguments = $.makeArray(arguments); return method.apply(object, oldArguments.concat(newArguments)); }
1706
+ };
1707
+ };
1708
+
1709
+
1710
+ })(jQuery);
1711
+
1712
+ // redactor_tabs
1713
+ function showRedactorTabs(el, index)
1714
+ {
1715
+ $('#redactor_tabs a').removeClass('redactor_tabs_act');
1716
+ $(el).addClass('redactor_tabs_act');
1717
+
1718
+ $('.redactor_tabs').hide();
1719
+ $('#redactor_tabs' + index).show();
1720
+ }
1721
+ ;