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