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