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
@@ -24,39 +24,29 @@ var deviceAndroid = "android";
24
24
  var uagent = navigator.userAgent.toLowerCase();
25
25
 
26
26
  // detect iOS and Android
27
- function isiOS()
28
- {
27
+ function isiOS() {
29
28
  return ((navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) || (navigator.platform.indexOf("iPad") != -1));
30
29
  }
31
30
 
32
- function detectAndroid()
33
- {
34
- if (uagent.search(deviceAndroid) > -1) return true;
35
- else return false;
31
+ function detectAndroid() {
32
+ return uagent.search(deviceAndroid) > -1
36
33
  }
37
34
 
38
- function detectAndroidWebKit()
39
- {
40
- if (detectAndroid())
41
- {
42
- if (uagent.search('webkit') > -1) return true;
43
- else return false;
35
+ function detectAndroidWebKit() {
36
+ if (detectAndroid()) {
37
+ return uagent.search('webkit') > -1
44
38
  }
45
- else return false;
39
+
40
+ return false;
46
41
  }
47
42
 
48
43
  // redactor
49
44
  (function($){
50
-
51
45
  // Initialization
52
- $.fn.redactor = function(options)
53
- {
46
+ $.fn.redactor = function(options) {
54
47
  if (isiOS() || detectAndroid() || detectAndroidWebKit()) return false;
55
-
56
48
  var obj = new Construct(this, options);
57
-
58
49
  obj.init();
59
-
60
50
  return obj;
61
51
  };
62
52
 
@@ -126,9 +116,7 @@ function detectAndroidWebKit()
126
116
 
127
117
  // Functionality
128
118
  Construct.prototype = {
129
-
130
- init: function()
131
- {
119
+ init: function() {
132
120
  if (this.opts.air) this.opts.toolbar = 'air';
133
121
 
134
122
  // include lang and toolbar
@@ -136,13 +124,11 @@ function detectAndroidWebKit()
136
124
 
137
125
  // sizes and id
138
126
  this.frameID = this.$el.attr('id');
139
- this.width = this.$el.css('width');
140
- this.height = this.$el.css('height');
141
-
127
+ this.width = this.$el.css('width');
128
+ this.height = this.$el.css('height');
142
129
 
143
130
  // modal overlay
144
- if ($('#redactor_imp_modal_overlay').size() == 0)
145
- {
131
+ if ($('#redactor_imp_modal_overlay').size() == 0) {
146
132
  this.overlay = $('<div id="redactor_imp_modal_overlay" style="display: none;"></div>');
147
133
  $('body').prepend(this.overlay);
148
134
  }
@@ -151,8 +137,7 @@ function detectAndroidWebKit()
151
137
  this.box = $('<div id="imp_redactor_box_' + this.frameID + '" style="width: ' + this.width + ';" class="imp_redactor_box imp_redactor_box"></div>');
152
138
 
153
139
  // air box
154
- if (this.opts.air)
155
- {
140
+ if (this.opts.air) {
156
141
  this.air = $('<div id="imp_redactor_air_' + this.frameID + '" class="redactor_air" style="display: none;"></div>');
157
142
  }
158
143
 
@@ -168,12 +153,11 @@ function detectAndroidWebKit()
168
153
  if (this.opts.toolbar !== false) this.buildToolbar();
169
154
 
170
155
  // resizer
171
- if (this.opts.resize)
172
- {
156
+ if (this.opts.resize) {
173
157
  this.resizer = $('<div id="imp_redactor_resize' + this.frameID + '" class="imp_redactor_resize"><div></div></div>');
174
158
  $(this.box).append(this.resizer);
175
159
 
176
- $(this.resizer).mousedown(function(e) { this.initResize(e) }.bind2(this));
160
+ $(this.resizer).mousedown(function(e) { this.initResize(e) }.bind2(this));
177
161
  }
178
162
 
179
163
  // enable
@@ -181,10 +165,8 @@ function detectAndroidWebKit()
181
165
 
182
166
  $(this.doc).click(function() { this.hideAllDropDown() }.bind2(this));
183
167
 
184
- if (this.opts.autoclear)
185
- {
186
- $(this.doc).bind('paste', function(e)
187
- {
168
+ if (this.opts.autoclear) {
169
+ $(this.doc).bind('paste', function(e) {
188
170
  setTimeout(function () { this.clean(); }.bind2(this), 200);
189
171
  }.bind2(this));
190
172
  }
@@ -193,40 +175,30 @@ function detectAndroidWebKit()
193
175
  this.enableAir();
194
176
 
195
177
  // doc events
196
- $(this.doc).keydown(function(e)
197
- {
178
+ $(this.doc).keydown(function(e) {
198
179
  if (e.ctrlKey || e.metaKey) isCtrl = true;
199
-
200
180
  if (e.keyCode == 9) { this.execCommand('indent', false); return false; }
201
181
  if (e.keyCode == 66 && isCtrl) { this.execCommand('bold', 'bold'); return false; }
202
182
  if (e.keyCode == 73 && isCtrl) { this.execCommand('italic', 'italic'); return false; }
203
183
 
204
- }.bind2(this)).keyup(function(e)
205
- {
184
+ }.bind2(this)).keyup(function(e) {
206
185
  isCtrl = false;
207
186
 
208
- if (e.keyCode == 13)
209
- {
187
+ if (e.keyCode == 13) {
210
188
  $(this.doc).linkify();
211
189
  return true;
212
190
  }
213
191
 
214
- this.syncCode();
215
-
192
+ this.syncCode();
216
193
  }.bind2(this));
217
-
218
194
 
219
195
  // autosave
220
- if (this.opts.autosave)
221
- {
222
- setInterval(function()
223
- {
196
+ if (this.opts.autosave) {
197
+ setInterval(function() {
224
198
  var html = this.getHtml();
225
199
  $.post(this.opts.autosave, { data: html });
226
-
227
200
  }.bind2(this), this.opts.interval*1000);
228
-
229
- }
201
+ }
230
202
 
231
203
  this.formSets();
232
204
 
@@ -237,64 +209,57 @@ function detectAndroidWebKit()
237
209
  /*
238
210
  API
239
211
  */
240
- setHtml: function(html)
241
- {
212
+ setHtml: function(html) {
242
213
  this.doc.body.innerHTML = html;
243
214
  this.docObserve();
244
215
  },
245
- getHtml: function()
246
- {
216
+
217
+ getHtml: function() {
247
218
  return this.doc.body.innerHTML;
248
219
  },
249
- getCode: function(clear)
250
- {
220
+
221
+ getCode: function(clear) {
251
222
  return this.$el.val();
252
- },
253
- focus: function()
254
- {
223
+ },
224
+
225
+ focus: function() {
255
226
  if ($.browser.msie) $(this.frame).load(function() { $(this).get(0).contentWindow.focus(); });
256
227
  else this.frame.get(0).contentWindow.focus();
257
- },
258
- typo: function()
259
- {
228
+ },
229
+
230
+ typo: function() {
260
231
  var html = this.getHtml();
232
+
261
233
  $.ajax({
262
- url: this.opts.paths.typograf,
263
- type: 'post',
264
- data: 'redactor=' + escape(encodeURIComponent(html)),
265
- success: function(data)
266
- {
234
+ url : this.opts.paths.typograf,
235
+ type : 'post',
236
+ data : 'redactor=' + escape(encodeURIComponent(html)),
237
+ success: function(data) {
267
238
  this.setHtml(data);
268
239
  }.bind2(this)
269
240
  });
270
- },
271
- syncCode: function()
272
- {
241
+ },
242
+
243
+ syncCode: function() {
273
244
  var html = this.getHtml();
274
245
 
275
246
  html = this.tidyUp(html);
276
-
277
247
  html = html.replace(/\%7B/gi, '{');
278
248
  html = html.replace(/\%7D/gi, '}');
279
-
280
249
  html = html.replace(/<hr class="redactor_cut">/gi, '<!--more-->');
281
250
  html = html.replace(/<hr class=redactor_cut>/gi, '<!--more-->');
282
-
283
251
  this.$el.val(html);
284
252
  },
285
- destroy: function()
286
- {
253
+
254
+ destroy: function() {
287
255
  var html = this.getCode();
288
256
  $(this.box).after(this.$el)
289
257
  this.box.remove();
290
258
  this.$el.val(html).show();
291
259
  },
292
260
 
293
- /*
294
- Include
295
- */
296
- include: function()
297
- {
261
+ // Include
262
+ include: function() {
298
263
  // lang
299
264
  $('head').append(
300
265
  $('<script src="' + this.opts.paths.language + '"></script>')
@@ -307,68 +272,55 @@ function detectAndroidWebKit()
307
272
  }
308
273
  },
309
274
 
310
- /*
311
- Enable
312
- */
313
- enable: function(html)
314
- {
275
+ // Enable
276
+ enable: function(html) {
315
277
  this.doc = this.contentDocumentFrame(this.frame);
316
278
 
317
279
  // flash replace
318
280
  html = html.replace(/\<object([\w\W]*?)\<\/object\>/gi, '<p class="redactor_video_box"><object$1</object></p>');
319
281
 
320
- if (html == '')
321
- {
322
- if (this.opts.autoformat === true)
323
- {
324
- if ($.browser.msie) html = "<p></p>";
325
- else html = "<p>&nbsp;</p>";
282
+ if (html == '') {
283
+ if (this.opts.autoformat === true) {
284
+ html = $.browser.msie ? "<p></p>" : "<p>&nbsp;</p>";
326
285
  }
327
286
  }
328
287
 
329
288
  this.redactorWrite(this.getRedactorDoc(html));
330
-
331
289
  if (this.opts.clearOnInit) this.clean();
332
-
333
-
334
290
  this.designMode();
335
291
  },
336
- enableAir: function()
337
- {
338
- if (this.opts.air)
339
- {
292
+
293
+ enableAir: function() {
294
+ if (this.opts.air) {
340
295
  $('#imp_redactor_air_' + this.frameID).hide();
341
296
 
342
- $(this.doc).bind('textselect', this.frameID, function(e)
343
- {
297
+ $(this.doc).bind('textselect', this.frameID, function(e) {
344
298
  var width = $('#imp_redactor_air_' + this.frameID).width();
345
299
  var width_area = $(this.frame).width();
346
-
347
300
  var diff = width_area - e.clientX;
301
+
348
302
  if (diff < width) e.clientX = e.clientX - width;
349
303
 
350
304
  $('#imp_redactor_air_' + this.frameID).css({ left: e.clientX + 'px', top: (e.clientY + 8) + 'px' }).show();
351
305
 
352
306
  }.bind2(this));
353
307
 
354
- $(this.doc).bind('textunselect', this.frameID, function()
355
- {
308
+ $(this.doc).bind('textunselect', this.frameID, function() {
356
309
  $('#imp_redactor_air_' + this.frameID).hide();
357
-
358
310
  }.bind2(this));
359
311
  }
360
312
  },
361
- redactorWrite: function(html)
362
- {
313
+
314
+ redactorWrite: function(html) {
363
315
  this.doc.open();
364
316
  this.doc.write(html);
365
317
  this.doc.close();
366
318
  },
367
- getRedactorDoc: function(html)
368
- {
319
+
320
+ getRedactorDoc: function(html) {
369
321
  css = '';
370
- for (stylesheet in this.opts.paths.stylesheets)
371
- {
322
+
323
+ for (stylesheet in this.opts.paths.stylesheets) {
372
324
  css += '<link media="all" href="' + this.opts.paths.stylesheets[stylesheet] + '" rel="stylesheet">';
373
325
  }
374
326
 
@@ -376,10 +328,11 @@ function detectAndroidWebKit()
376
328
  frameHtml += '<html><head>' + css + '</head><body>';
377
329
  frameHtml += html;
378
330
  frameHtml += '</body></html>';
331
+
379
332
  return frameHtml;
380
- },
381
- contentDocumentFrame: function(frame)
382
- {
333
+ },
334
+
335
+ contentDocumentFrame: function(frame) {
383
336
  frame = frame.get(0);
384
337
 
385
338
  if (frame.contentDocument) return frame.contentDocument;
@@ -387,34 +340,28 @@ function detectAndroidWebKit()
387
340
  else if (frame.document) return frame.document;
388
341
  else return null;
389
342
  },
390
- designMode: function()
391
- {
392
- if (this.doc)
393
- {
343
+
344
+ designMode: function() {
345
+ if (this.doc) {
394
346
  this.doc.designMode = 'on';
395
- this.frame.load(function()
396
- {
347
+ this.frame.load(function() {
397
348
  this.enableObjects();
398
349
  this.docObserve();
399
350
  this.doc.designMode = 'on';
400
351
  }.bind2(this));
401
352
  }
402
353
  },
403
- enableObjects: function()
404
- {
405
- if ($.browser.mozilla)
406
- {
354
+
355
+ enableObjects: function() {
356
+ if ($.browser.mozilla) {
407
357
  this.doc.execCommand("enableObjectResizing", false, "false");
408
358
  this.doc.execCommand("enableInlineTableEditing", false, "false");
409
359
  }
410
360
  },
411
361
 
412
362
 
413
- /*
414
- Observers
415
- */
416
- docObserve: function()
417
- {
363
+ // Observers
364
+ docObserve: function() {
418
365
  var body = $(this.doc).find('body');
419
366
 
420
367
  body.find('img').click(function(e) { this.imageEdit(e); }.bind2(this));
@@ -423,38 +370,26 @@ function detectAndroidWebKit()
423
370
 
424
371
  },
425
372
 
426
- /*
427
- Format on submit form
428
- */
429
- formSets: function()
430
- {
431
- var oldOnsubmit = null;
432
-
433
- var theForm = $(this.box).parents('form');
373
+ // Format on submit form
374
+ formSets: function() {
375
+ var oldOnsubmit = null;
376
+ var theForm = $(this.box).parents('form');
377
+
434
378
  if (theForm.length == 0) return false;
435
379
 
436
380
  oldOnsubmit = theForm.get(0).onsubmit;
437
381
 
438
- if (typeof theForm.get(0).onsubmit != "function")
439
- {
440
- theForm.get(0).onsubmit = function()
441
- {
442
- if (this.opts.visual)
443
- {
382
+ if (typeof theForm.get(0).onsubmit != "function") {
383
+ theForm.get(0).onsubmit = function() {
384
+ if (this.opts.visual) {
444
385
  this.syncCode();
445
-
446
386
  return true;
447
387
  }
448
388
  }.bind2(this)
449
- }
450
- else
451
- {
452
- theForm.get(0).onsubmit = function()
453
- {
454
- if (this.opts.visual)
455
- {
389
+ } else {
390
+ theForm.get(0).onsubmit = function() {
391
+ if (this.opts.visual) {
456
392
  this.syncCode();
457
-
458
393
  return oldOnsubmit();
459
394
  }
460
395
  }.bind2(this)
@@ -463,40 +398,29 @@ function detectAndroidWebKit()
463
398
  return true;
464
399
  },
465
400
 
466
- /*
467
- Exec
468
- */
469
- execCommand: function(cmd, param)
470
- {
471
- if (this.opts.visual && this.doc)
472
- {
473
- try
474
- {
401
+ // Exec
402
+ execCommand: function(cmd, param) {
403
+ if (this.opts.visual && this.doc) {
404
+ try {
475
405
  this.frame.get(0).contentWindow.focus();
476
406
 
477
- if (cmd == 'inserthtml' && $.browser.msie) this.doc.selection.createRange().pasteHTML(param);
478
- else
479
- {
407
+ if (cmd == 'inserthtml' && $.browser.msie) {
408
+ this.doc.selection.createRange().pasteHTML(param);
409
+ } else {
480
410
  this.doc.execCommand(cmd, false, param);
481
-
482
- if (param == "blockquote" || param == 'pre') this.doc.body.appendChild(this.doc.createElement("BR"));
411
+
412
+ if (param == "blockquote" || param == 'pre')
413
+ this.doc.body.appendChild(this.doc.createElement("BR"));
483
414
  }
484
- }
485
- catch (e) { }
415
+ } catch (e) { }
486
416
 
487
417
  this.syncCode();
488
-
489
- if (this.opts.air) $('#imp_redactor_air_' + this.frameID).hide();
490
-
418
+ if (this.opts.air) $('#imp_redactor_air_' + this.frameID).hide();
491
419
  }
492
420
  },
493
421
 
494
- /*
495
- Format and clean
496
- */
497
-
498
- clean: function()
499
- {
422
+ // Format and clean
423
+ clean: function() {
500
424
  var html = this.getHtml();
501
425
 
502
426
  if ($.browser.mozilla) html = this.convertSpan(html);
@@ -510,14 +434,12 @@ function detectAndroidWebKit()
510
434
  html = this.tidyUp(html);
511
435
 
512
436
  this.setHtml(html);
513
-
514
437
  this.paragraphise();
515
438
 
516
439
  return html;
517
440
  },
518
441
 
519
- tidyUp: function (html)
520
- {
442
+ tidyUp: function (html) {
521
443
  // lowercase
522
444
  if ($.browser.msie)
523
445
  {
@@ -1649,185 +1571,3 @@ function showRedactorTabs(el, index)
1649
1571
  $('.redactor_tabs').hide();
1650
1572
  $('#redactor_tabs' + index).show();
1651
1573
  }
1652
-
1653
-
1654
- // Define: Linkify plugin from stackoverflow
1655
- (function($){
1656
- var url2 = /(^|&lt;|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|&gt;|$)/g;
1657
-
1658
- linkifyThis = function ()
1659
- {
1660
- var childNodes = this.childNodes,
1661
- i = childNodes.length;
1662
- while(i--)
1663
- {
1664
- var n = childNodes[i];
1665
- if (n.nodeType == 3)
1666
- {
1667
- var html = n.nodeValue;
1668
- if (html)
1669
- {
1670
- html = html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(url2, '$1<a href="$2">$2</a>$5');
1671
- $(n).after(html).remove();
1672
- }
1673
- }
1674
- else if (n.nodeType == 1 && !/^(a|button|textarea)$/i.test(n.tagName)) linkifyThis.call(n);
1675
- }
1676
- };
1677
-
1678
- $.fn.linkify = function ()
1679
- {
1680
- this.each(linkifyThis);
1681
- };
1682
-
1683
- })(jQuery);
1684
-
1685
-
1686
- /* jQuery plugin textselect
1687
- * version: 0.9
1688
- * author: Josef Moravec, josef.moravec@gmail.com
1689
- * updated: Imperavi
1690
- *
1691
- */
1692
- (function($){$.event.special.textselect={setup:function(data,namespaces)
1693
- {$(this).data("textselected",false);$(this).data("ttt",data);$(this).bind('mouseup',$.event.special.textselect.handler);},teardown:function(data)
1694
- {$(this).unbind('mouseup',$.event.special.textselect.handler);},handler:function(event)
1695
- {var data=$(this).data("ttt");var text=$.event.special.textselect.getSelectedText(data).toString();if(text!='')
1696
- {$(this).data("textselected",true);event.type="textselect";event.text=text;$.event.handle.apply(this,arguments);}},getSelectedText:function(data)
1697
- {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;}}
1698
- $.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);
1699
-
1700
-
1701
- /*
1702
- Plugin Drag and drop Upload v1.0.0
1703
- http://imperavi.com/
1704
- Copyright 2011, Imperavi Ltd.
1705
- */
1706
- (function($){
1707
-
1708
- // Initialization
1709
- $.fn.dragupload = function(options)
1710
- {
1711
- return this.each(function() {
1712
- var obj = new Construct(this, options);
1713
- obj.init();
1714
- });
1715
- };
1716
-
1717
- // Options and variables
1718
- function Construct(el, options) {
1719
-
1720
- this.opts = $.extend({
1721
-
1722
- url: false,
1723
- success: false,
1724
- maxfilesize: 10485760, // 10MB
1725
- preview: false,
1726
-
1727
- text: RLANG.drop_file_here,
1728
- atext: RLANG.or_choose
1729
-
1730
- /*
1731
- success_text: 'Загрузка успешно завершена',
1732
- progress_text: 'Загрузка',
1733
- maxsize_error: 'Файл слишком большой'
1734
- */
1735
-
1736
-
1737
- }, options);
1738
-
1739
- this.$el = $(el);
1740
- };
1741
-
1742
- // Functionality
1743
- Construct.prototype = {
1744
- init: function()
1745
- {
1746
- if (!$.browser.opera && !$.browser.msie)
1747
- {
1748
- this.droparea = $('<div class="redactor_droparea"></div>');
1749
- this.dropareabox = $('<div class="redactor_dropareabox">' + this.opts.text + '</div>');
1750
- this.dropalternative = $('<div class="redactor_dropalternative">' + this.opts.atext + '</div>');
1751
-
1752
- this.droparea.append(this.dropareabox);
1753
-
1754
- this.$el.before(this.droparea);
1755
- this.$el.before(this.dropalternative);
1756
-
1757
-
1758
- // drag over
1759
- this.dropareabox.bind('dragover', function() { return this.ondrag(); }.bind2(this));
1760
-
1761
- // drag leave
1762
- this.dropareabox.bind('dragleave', function() { return this.ondragleave(); }.bind2(this));
1763
-
1764
-
1765
- // drop
1766
- this.dropareabox.get(0).ondrop = function(event) {
1767
-
1768
- event.preventDefault();
1769
-
1770
- this.dropareabox.removeClass('hover').addClass('drop');
1771
-
1772
- var file = event.dataTransfer.files[0];
1773
-
1774
-
1775
- /*
1776
- if (file.size > this.opts.maxfilesize)
1777
- {
1778
- this.dropareabox.text(this.opts.maxsize_error).addClass('error');
1779
- return false;
1780
- }
1781
-
1782
- var uploadProgress = function(e)
1783
- {
1784
- var percent = parseInt(e.loaded / e.total * 100);
1785
- this.dropareabox.text(this.opts.progress_text + ': ' + percent + '%');
1786
-
1787
- }.bind2(this);
1788
-
1789
-
1790
- var xhr = jQuery.ajaxSettings.xhr();
1791
- if (xhr.upload) xhr.upload.addEventListener('progress', uploadProgress, false);
1792
- var provider = function () { return xhr; };
1793
- */
1794
-
1795
- var fd = new FormData();
1796
- fd.append('file', file);
1797
-
1798
- $.ajax({
1799
- url: this.opts.url,
1800
- data: fd,
1801
- //xhr: provider,
1802
- cache: false,
1803
- contentType: false,
1804
- processData: false,
1805
- type: 'POST',
1806
- success: function(data)
1807
- {
1808
- if (this.opts.success !== false) this.opts.success(data);
1809
-
1810
- if (this.opts.preview === true) this.dropareabox.html(data);
1811
- //else this.dropareabox.text(this.opts.success_text);
1812
-
1813
- }.bind2(this)
1814
- });
1815
-
1816
-
1817
- }.bind2(this);
1818
- }
1819
- },
1820
- ondrag: function()
1821
- {
1822
- this.dropareabox.addClass('hover');
1823
- return false;
1824
- },
1825
- ondragleave: function()
1826
- {
1827
- this.dropareabox.removeClass('hover');
1828
- return false;
1829
- }
1830
- };
1831
-
1832
-
1833
- })(jQuery);